Skip to content

Commit 3fa0fc9

Browse files
committed
x86/msr: Rename the WRMSRNS opcode macro to ASM_WRMSRNS (for KVM)
Rename the WRMSRNS instruction opcode macro so that it doesn't collide with X86_FEATURE_WRMSRNS when using token pasting to generate references to X86_FEATURE_WRMSRNS. KVM heavily uses token pasting to generate KVM's set of support feature bits, and adding WRMSRNS support in KVM will run will run afoul of the opcode macro. arch/x86/kvm/cpuid.c:719:37: error: pasting "X86_FEATURE_" and "" "" does not give a valid preprocessing token 719 | u32 __leaf = __feature_leaf(X86_FEATURE_##name); \ | ^~~~~~~~~~~~ KVM has worked around one such collision in the past by #undef'ing the problematic macro in order to avoid blocking a KVM rework, but such games are generally undesirable, e.g. requires bleeding macro details into KVM, risks weird behavior if what KVM is #undef'ing changes, etc. Reviewed-by: Xin Li (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 656d962 commit 3fa0fc9

File tree

1 file changed

+2
-2
lines changed
  • arch/x86/include/asm

1 file changed

+2
-2
lines changed

arch/x86/include/asm/msr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ do { \
300300
#endif /* !CONFIG_PARAVIRT_XXL */
301301

302302
/* Instruction opcode for WRMSRNS supported in binutils >= 2.40 */
303-
#define WRMSRNS _ASM_BYTES(0x0f,0x01,0xc6)
303+
#define ASM_WRMSRNS _ASM_BYTES(0x0f,0x01,0xc6)
304304

305305
/* Non-serializing WRMSR, when available. Falls back to a serializing WRMSR. */
306306
static __always_inline void wrmsrns(u32 msr, u64 val)
@@ -309,7 +309,7 @@ static __always_inline void wrmsrns(u32 msr, u64 val)
309309
* WRMSR is 2 bytes. WRMSRNS is 3 bytes. Pad WRMSR with a redundant
310310
* DS prefix to avoid a trailing NOP.
311311
*/
312-
asm volatile("1: " ALTERNATIVE("ds wrmsr", WRMSRNS, X86_FEATURE_WRMSRNS)
312+
asm volatile("1: " ALTERNATIVE("ds wrmsr", ASM_WRMSRNS, X86_FEATURE_WRMSRNS)
313313
"2: " _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_WRMSR)
314314
: : "c" (msr), "a" ((u32)val), "d" ((u32)(val >> 32)));
315315
}

0 commit comments

Comments
 (0)