#endif
#include <asm/processor.h>
#include <asm/percpu.h>
+#include <xen/stringify.h>
+#include <asm/cpufeature.h>
#ifndef __ASSEMBLY__
void ret_from_intr(void);
#endif
+/* "Raw" instruction opcodes */
+#define __ASM_CLAC .byte 0x0f,0x01,0xca
+#define __ASM_STAC .byte 0x0f,0x01,0xcb
+
+#ifdef __ASSEMBLY__
+#define ASM_AC(op) \
+ btl $X86_FEATURE_SMAP & 31, \
+ CPUINFO_FEATURE_OFFSET(X86_FEATURE_SMAP)+boot_cpu_data(%rip); \
+ jnc 881f; \
+ __ASM_##op; \
+881:
+
+#define ASM_STAC ASM_AC(STAC)
+#define ASM_CLAC ASM_AC(CLAC)
+#else
+static inline void clac(void)
+{
+ if ( boot_cpu_has(X86_FEATURE_SMAP) )
+ asm volatile (__stringify(__ASM_CLAC) : : : "memory");
+}
+
+static inline void stac(void)
+{
+ if ( boot_cpu_has(X86_FEATURE_SMAP) )
+ asm volatile (__stringify(__ASM_STAC) : : : "memory");
+}
+#endif
+
#ifdef __ASSEMBLY__
.macro SAVE_ALL
addq $-(UREGS_error_code-UREGS_r15), %rsp