]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86: Instead of 0x2, 0x4, and 0x1 use #defines.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 5 Jan 2018 02:33:07 +0000 (21:33 -0500)
committerKirtikar Kashyap <kirtikar.kashyap@oracle.com>
Fri, 12 Jan 2018 18:20:12 +0000 (10:20 -0800)
This mirrors what the posted upstream patches are doing.

Orabug: 27344012
CVE: CVE-2017-5715

Reviewed-by: Todd Vierling <todd.vierling@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Kirtikar Kashyap <kirtikar.kashyap@oracle.com>
arch/x86/include/asm/spec_ctrl.h
include/linux/smp.h

index ba1c51058b62ce2969af995fad1f7161d3ae7421..5204336841a173c2713639032919543c2d930a39 100644 (file)
@@ -6,6 +6,10 @@
 #include <asm/cpufeature.h>
 #include <asm/alternative-asm.h>
 
+#define SPEC_CTRL_IBRS_INUSE           (1<<0)  /* OS enables IBRS usage */
+#define SPEC_CTRL_IBRS_SUPPORTED       (1<<1)  /* System supports IBRS */
+#define SPEC_CTRL_IBRS_ADMIN_DISABLED  (1<<2)  /* Admin disables IBRS */
+
 #ifdef __ASSEMBLY__
 
 .extern use_ibrs
@@ -128,14 +132,14 @@ ALTERNATIVE "", __stringify(__ASM_ENABLE_IBRS), X86_FEATURE_SPEC_CTRL
 .endm
 
 .macro ENABLE_IBRS_CLOBBER
-       testl   $1, use_ibrs
+       testl   $SPEC_CTRL_IBRS_INUSE, use_ibrs
        jz      11f
        __ASM_ENABLE_IBRS_CLOBBER
 11:
 .endm
 
 .macro ENABLE_IBRS_SAVE_AND_CLOBBER save_reg:req
-       testl   $1, use_ibrs
+       testl   $SPEC_CTRL_IBRS_INUSE, use_ibrs
        jz      12f
 
        movl    $MSR_IA32_SPEC_CTRL, %ecx
@@ -152,7 +156,7 @@ ALTERNATIVE "", __stringify(__ASM_ENABLE_IBRS), X86_FEATURE_SPEC_CTRL
 .endm
 
 .macro RESTORE_IBRS_CLOBBER save_reg:req
-       testl   $1, use_ibrs
+       testl   $SPEC_CTRL_IBRS_INUSE, use_ibrs
        jz      13f
 
        cmpl    $FEATURE_ENABLE_IBRS, \save_reg
@@ -169,7 +173,7 @@ ALTERNATIVE "", __stringify(__ASM_ENABLE_IBRS), X86_FEATURE_SPEC_CTRL
 .endm
 
 .macro DISABLE_IBRS
-       testl   $1, use_ibrs
+       testl   $SPEC_CTRL_IBRS_INUSE, use_ibrs
        jz      9f
        __ASM_DISABLE_IBRS
 9:
index 3689de249d0ce0202dc245175e0303fa0bba9a72..3701f451f12a67226d253f49f9c043612d34b0e2 100644 (file)
@@ -55,20 +55,20 @@ int smp_call_function_single_async(int cpu, struct call_single_data *csd);
 extern int use_ibrs;
 extern u32 sysctl_ibrs_enabled;
 extern struct mutex spec_ctrl_mutex;
-#define ibrs_supported         (use_ibrs & 0x2)
-#define ibrs_disabled          (use_ibrs & 0x4)
+#define ibrs_supported         (use_ibrs & SPEC_CTRL_IBRS_SUPPORTED)
+#define ibrs_disabled          (use_ibrs & SPEC_CTRL_IBRS_ADMIN_DISABLED)
 static inline void set_ibrs_inuse(void)
 {
        if (ibrs_supported)
-               use_ibrs |= 0x1;
+               use_ibrs |= SPEC_CTRL_IBRS_INUSE;
 }
 static inline void clear_ibrs_inuse(void)
 {
-       use_ibrs &= ~0x1;
+       use_ibrs &= ~SPEC_CTRL_IBRS_INUSE;
 }
 static inline int check_ibrs_inuse(void)
 {
-       if (use_ibrs & 0x1)
+       if (use_ibrs & SPEC_CTRL_IBRS_INUSE)
                return 1;
        else
                /* rmb to prevent wrong speculation for security */
@@ -77,19 +77,19 @@ static inline int check_ibrs_inuse(void)
 }
 static inline void set_ibrs_supported(void)
 {
-       use_ibrs |= 0x2;
+       use_ibrs |= SPEC_CTRL_IBRS_SUPPORTED;
        if (!ibrs_disabled)
                set_ibrs_inuse();
 }
 static inline void set_ibrs_disabled(void)
 {
-       use_ibrs |= 0x4;
+       use_ibrs |= SPEC_CTRL_IBRS_ADMIN_DISABLED;
        if (check_ibrs_inuse())
                clear_ibrs_inuse();
 }
 static inline void clear_ibrs_disabled(void)
 {
-       use_ibrs &= ~0x4;
+       use_ibrs &= ~SPEC_CTRL_IBRS_ADMIN_DISABLED;
        set_ibrs_inuse();
 }
 #define ibrs_inuse             (check_ibrs_inuse())