x86/spec-ctrl: Fix default calculation of opt_srb_lock
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 4 Jan 2022 14:11:55 +0000 (14:11 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 5 Jan 2022 09:44:26 +0000 (09:44 +0000)
Since this logic was introduced, opt_tsx has become more complicated and
shouldn't be compared to 0 directly.  While there are no buggy logic paths,
the correct expression is !(opt_tsx & 1) but the rtm_disabled boolean is
easier and clearer to use.

Fixes: 8fe24090d940 ("x86/cpuid: Rework HLE and RTM handling")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/spec_ctrl.c

index a5569c7f2b3fd19c904414efe300ce11500cb3b1..c18cc8aa493a978c7496e5f022de153d13bcd0f7 100644 (file)
@@ -1245,7 +1245,7 @@ void __init init_speculation_mitigations(void)
          */
         if ( opt_srb_lock == -1 &&
              (caps & (ARCH_CAPS_MDS_NO|ARCH_CAPS_TAA_NO)) == ARCH_CAPS_MDS_NO &&
-             (!cpu_has_hle || ((caps & ARCH_CAPS_TSX_CTRL) && opt_tsx == 0)) )
+             (!cpu_has_hle || ((caps & ARCH_CAPS_TSX_CTRL) && rtm_disabled)) )
             opt_srb_lock = 0;
 
         val &= ~MCU_OPT_CTRL_RNGDS_MITG_DIS;