Skip to content

Commit

Permalink
x86/asm: Use CLFLUSHOPT and CLWB mnemonics in <asm/special_insns.h>
Browse files Browse the repository at this point in the history
Current minimum required version of binutils is 2.25,
which supports CLFLUSHOPT and CLWB instruction mnemonics.

Replace the byte-wise specification of CLFLUSHOPT and
CLWB with these proper mnemonics.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250313102715.333142-1-ubizjak@gmail.com
  • Loading branch information
Uros Bizjak authored and Ingo Molnar committed Mar 19, 2025
1 parent 21fe251 commit 5328663
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions arch/x86/include/asm/special_insns.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,8 @@ static __always_inline void clflush(volatile void *__p)

static inline void clflushopt(volatile void *__p)
{
alternative_io(".byte 0x3e; clflush %0",
".byte 0x66; clflush %0",
X86_FEATURE_CLFLUSHOPT,
alternative_io("ds clflush %0",
"clflushopt %0", X86_FEATURE_CLFLUSHOPT,
"+m" (*(volatile char __force *)__p));
}

Expand All @@ -187,13 +186,10 @@ static inline void clwb(volatile void *__p)
volatile struct { char x[64]; } *p = __p;

asm volatile(ALTERNATIVE_2(
".byte 0x3e; clflush (%[pax])",
".byte 0x66; clflush (%[pax])", /* clflushopt (%%rax) */
X86_FEATURE_CLFLUSHOPT,
".byte 0x66, 0x0f, 0xae, 0x30", /* clwb (%%rax) */
X86_FEATURE_CLWB)
: [p] "+m" (*p)
: [pax] "a" (p));
"ds clflush %0",
"clflushopt %0", X86_FEATURE_CLFLUSHOPT,
"clwb %0", X86_FEATURE_CLWB)
: "+m" (*p));
}

#ifdef CONFIG_X86_USER_SHADOW_STACK
Expand Down

0 comments on commit 5328663

Please sign in to comment.