x86/spec-ctrl: Fix default calculation of opt_srb_lock
PATCH 1/1 x86/spec-ctrl: Fix default calculation of opt_srb_lock
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.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/spec_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/spec_ctrl.c +1 -1
@@ -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 ;
Signature · 1 line
2.11.0
Quoted 7 lines · Andrew Cooper
Since this logic was introduced,
opt_tsxhas 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 thertm_disabledboolean is easier and clearer to use.Fixes 8fe24090d940 ("x86/cpuid: Rework HLE and RTM handling")Signed-off-by Andrew Cooper <[email protected]>
Quoted 6 lines · Andrew Cooper
Since this logic was introduced,
opt_tsxhas 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 thertm_disabledboolean is easier and clearer to use.Fixes 8fe24090d940 ("x86/cpuid: Rework HLE and RTM handling")
Is this accurate? Backporting the change to 4.13 locally, I notice that commit (and hence the rtm_disabled global variable) is not present on that branch, yet opt_tsx already has the "more complicated" behavior.
Jan