[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250314100214.683494-1-ubizjak@gmail.com>
Date: Fri, 14 Mar 2025 11:01:58 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: x86@...nel.org,
linux-kernel@...r.kernel.org
Cc: Uros Bizjak <ubizjak@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>
Subject: [PATCH] x86/asm: Use asm_inline() instead of asm() in alternative_msr_write()
Use asm_inline() to instruct the compiler that the size of asm()
is the minimum size of one instruction, ignoring how many instructions
the compiler thinks it is. ALTERNATIVE macro that expands to several
pseudo directives causes instruction length estimate to count
more than 20 instructions.
bloat-o-meter reports minimal code size increase
(x86_64 defconfig, gcc-14.2.1):
add/remove: 0/1 grow/shrink: 2/0 up/down: 338/-249 (89)
Function old new delta
-----------------------------------------------------
arch_prctl_spec_ctrl_set 339 656 +317
arch_seccomp_spec_mitigate 135 156 +21
ib_prctl_set 249 - -249
Total: Before=21423521, After=21423610, chg +0.00%
The code size increase is due to the compiler inlining
more functions that inline alternative_msr_write().
Signed-off-by: Uros Bizjak <ubizjak@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
---
arch/x86/include/asm/nospec-branch.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index e8757d7a3582..097ce28aabc5 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -510,7 +510,7 @@ enum ssb_mitigation {
static __always_inline
void alternative_msr_write(unsigned int msr, u64 val, unsigned int feature)
{
- asm volatile(ALTERNATIVE("", "wrmsr", %c[feature])
+ asm_inline volatile(ALTERNATIVE("", "wrmsr", %c[feature])
: : "c" (msr),
"a" ((u32)val),
"d" ((u32)(val >> 32)),
--
2.48.1
Powered by blists - more mailing lists