]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/spectre_v2: Add VMEXIT_FILL_RSB instead of RETPOLINE
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 2 Feb 2018 03:56:00 +0000 (22:56 -0500)
committerJack Vogel <jack.vogel@oracle.com>
Thu, 8 Feb 2018 18:15:34 +0000 (10:15 -0800)
The backport of "x86/retpoline: Fill return stack buffer on vmexit"
made the full stuffing of RSB only enabled if the kernel had
selected X86_FEATURE_RETPOLINE.

But if we are using IBRS we still want the full RSB stuffing
as it was prior to the backport.

Since we have both retpoline and ibrs wanting it we introduce
a new feature to enable the common mitigation that both of them
need.

Orabug: 27477743
CVE: CVE-2017-5715

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
arch/x86/include/asm/cpufeature.h
arch/x86/include/asm/nospec-branch.h
arch/x86/kernel/cpu/bugs_64.c

index cb6294e2b8100ae52f7b7cbf068fac859c076588..6016dbbd7be377490a67179ee1b70f0ba2ba5881 100644 (file)
 #define X86_FEATURE_IBPB                (7*32+24) /* Indirect Branch Prediction Barrier */
 
 
+#define X86_FEATURE_VMEXIT_RSB_FULL    (7*32+27) /* "" Whether to stuff the RSB on VMEXIT. */
 #define X86_FEATURE_STUFF_RSB  (7*32+28) /* "" Whether to stuff the RSB (usually dependent on !SMEP) */
 #define X86_FEATURE_RETPOLINE  ( 7*32+29) /* Generic Retpoline mitigation for Spectre variant 2 */
 #define X86_FEATURE_RETPOLINE_AMD ( 7*32+30) /* AMD Retpoline mitigation for Spectre variant 2 */
index fca2bdd8b24cd1f90f0fdb17e47c509fdf1097ad..bc4a272a315b3cd450eb568a9597185c4e067db4 100644 (file)
@@ -188,7 +188,7 @@ static inline void vmexit_fill_RSB(void)
 
        asm volatile (ALTERNATIVE("jmp 910f",
                                  __stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1)),
-                                 X86_FEATURE_RETPOLINE)
+                                 X86_FEATURE_VMEXIT_RSB_FULL)
                      "910:"
                      : "=r" (loops), ASM_CALL_CONSTRAINT
                      : : "memory" );
index 933beab407c82cca7aa89d7da8304e8bf020582e..dd4581ef6acfbf61d073e4100d999f3944ccfcbe 100644 (file)
@@ -369,6 +369,8 @@ out:
            mode == SPECTRE_V2_RETPOLINE_AMD) {
                disable_ibrs_and_friends();
        }
+       /* Future CPUs with IBRS_ATT might be able to avoid this. */
+       setup_force_cpu_cap(X86_FEATURE_VMEXIT_RSB_FULL);
 }
 
 #undef pr_fmt