mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Currently WARN_ON_FPU evaluates its argument even if
CONFIG_X86_DEBUG_FPU is disabled, which adds unnecessary instructions to
several functions, for example kernel_fpu_begin(). Fix this by using
BUILD_BUG_ON_INVALID(x) in the no-debug case rather than (void)(x).
Fixes: 83242c5158
("x86/fpu: Make WARN_ON_FPU() more robust in the !CONFIG_X86_DEBUG_FPU case")
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/all/20250127224523.94300-1-ebiggers%40kernel.org
28 lines
657 B
C
28 lines
657 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __X86_KERNEL_FPU_INTERNAL_H
|
|
#define __X86_KERNEL_FPU_INTERNAL_H
|
|
|
|
extern struct fpstate init_fpstate;
|
|
|
|
/* CPU feature check wrappers */
|
|
static __always_inline __pure bool use_xsave(void)
|
|
{
|
|
return cpu_feature_enabled(X86_FEATURE_XSAVE);
|
|
}
|
|
|
|
static __always_inline __pure bool use_fxsr(void)
|
|
{
|
|
return cpu_feature_enabled(X86_FEATURE_FXSR);
|
|
}
|
|
|
|
#ifdef CONFIG_X86_DEBUG_FPU
|
|
# define WARN_ON_FPU(x) WARN_ON_ONCE(x)
|
|
#else
|
|
# define WARN_ON_FPU(x) ({ BUILD_BUG_ON_INVALID(x); 0; })
|
|
#endif
|
|
|
|
/* Used in init.c */
|
|
extern void fpstate_init_user(struct fpstate *fpstate);
|
|
extern void fpstate_reset(struct fpu *fpu);
|
|
|
|
#endif
|