Re: [PATCH v5 3/9] x86/bugs: Decouple ALTERNATIVE usage from VERW macro definition
From: Borislav Petkov
Date: Mon Nov 17 2025 - 05:18:02 EST
On Thu, Nov 13, 2025 at 03:37:40PM -0800, Sean Christopherson wrote:
> +#define __CLEAR_CPU_BUFFERS __stringify(VERW)
Let's get rid of one indirection level pls:
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 8b4885a1b2ef..59945cb5e5f9 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -309,23 +309,21 @@
* Note: Only the memory operand variant of VERW clears the CPU buffers.
*/
#ifdef CONFIG_X86_64
-#define VERW verw x86_verw_sel(%rip)
+#define VERW __stringify(verw x86_verw_sel(%rip))
#else
/*
* In 32bit mode, the memory operand must be a %cs reference. The data segments
* may not be usable (vm86 mode), and the stack segment may not be flat (ESPFIX32).
*/
-#define VERW verw %cs:x86_verw_sel
+#define VERW __stringify(verw %cs:x86_verw_sel)
#endif
-#define __CLEAR_CPU_BUFFERS __stringify(VERW)
-
/* If necessary, emit VERW on exit-to-userspace to clear CPU buffers. */
#define CLEAR_CPU_BUFFERS \
- ALTERNATIVE "", __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF
+ ALTERNATIVE "", VERW, X86_FEATURE_CLEAR_CPU_BUF
#define VM_CLEAR_CPU_BUFFERS \
- ALTERNATIVE "", __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF_VM
+ ALTERNATIVE "", VERW, X86_FEATURE_CLEAR_CPU_BUF_VM
#ifdef CONFIG_X86_64
.macro CLEAR_BRANCH_HISTORY
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette