]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blobdiff - arch/x86/include/asm/special_insns.h
x86/asm: Add support for the CLWB instruction
[mirror_ubuntu-eoan-kernel.git] / arch / x86 / include / asm / special_insns.h
index 2ec1a53925427049cdc867ac5bc09d16cb833de6..aeb4666e0c0a770a7fbb8432b7d133b2dd9e764d 100644 (file)
@@ -201,6 +201,20 @@ static inline void clflushopt(volatile void *__p)
                       "+m" (*(volatile char __force *)__p));
 }
 
+static inline void clwb(volatile void *__p)
+{
+       volatile struct { char x[64]; } *p = __p;
+
+       asm volatile(ALTERNATIVE_2(
+               ".byte " __stringify(NOP_DS_PREFIX) "; 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));
+}
+
 static inline void pcommit_sfence(void)
 {
        alternative(ASM_NOP7,