public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/fpu: make WARN_ON_FPU get fully optimized out
@ 2025-01-27 22:45 Eric Biggers
  2025-02-10 16:27 ` Eric Biggers
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2025-01-27 22:45 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H . Peter Anvin, Sean Christopherson

From: Eric Biggers <ebiggers@google.com>

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: 83242c515881 ("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>
---

v2: use BUILD_BUG_ON_INVALID() as suggested by Sean Christopherson.

 arch/x86/kernel/fpu/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/internal.h b/arch/x86/kernel/fpu/internal.h
index dbdb31f55fc7f..975de070c9c98 100644
--- a/arch/x86/kernel/fpu/internal.h
+++ b/arch/x86/kernel/fpu/internal.h
@@ -16,11 +16,11 @@ static __always_inline __pure bool use_fxsr(void)
 }
 
 #ifdef CONFIG_X86_DEBUG_FPU
 # define WARN_ON_FPU(x) WARN_ON_ONCE(x)
 #else
-# define WARN_ON_FPU(x) ({ (void)(x); 0; })
+# 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);

base-commit: 805ba04cb7ccfc7d72e834ebd796e043142156ba
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86/fpu: make WARN_ON_FPU get fully optimized out
  2025-01-27 22:45 [PATCH v2] x86/fpu: make WARN_ON_FPU get fully optimized out Eric Biggers
@ 2025-02-10 16:27 ` Eric Biggers
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2025-02-10 16:27 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H . Peter Anvin, Sean Christopherson

On Mon, Jan 27, 2025 at 02:45:23PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> 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: 83242c515881 ("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>
> ---
> 
> v2: use BUILD_BUG_ON_INVALID() as suggested by Sean Christopherson.
> 
>  arch/x86/kernel/fpu/internal.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Ping.  Any interest in taking this through the x86 tree?

- Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-10 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-27 22:45 [PATCH v2] x86/fpu: make WARN_ON_FPU get fully optimized out Eric Biggers
2025-02-10 16:27 ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox