x86/cpuid: Fix HLE and RTM handling (again)
PATCH 1/1 x86/cpuid: Fix HLE and RTM handling (again)
For reasons which are my fault, but I don't recall why, the FDP_EXCP_ONLY/NO_FPU_SEL adjustment uses the whole special_features[] array, not the two relevant bits.
HLE and RTM were recently added to the list of special features, causing them to be always set in guest view, irrespective of the toolstacks choice on the matter.
Rewrite the logic to refer to the features specifically, rather than relying on the contents of the special_features[] array.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/cpuid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/cpuid.c +4 -2
@@ -672,9 +672,11 @@ void recalculate_cpuid_policy(struct domain *d)sanitise_featureset (fs);/* Fold host's FDP_EXCP_ONLY and NO_FPU_SEL into guest's view. */ - fs[FEATURESET_7b0] &= ~special_features[FEATURESET_7b0]; + fs[FEATURESET_7b0] &= ~(cpufeat_mask (X86_FEATURE_FDP_EXCP_ONLY ) | +cpufeat_mask (X86_FEATURE_NO_FPU_SEL )); fs[FEATURESET_7b0] |= (host_cpuid_policy.feat._7b0 & - special_features[FEATURESET_7b0]); + (cpufeat_mask (X86_FEATURE_FDP_EXCP_ONLY ) | +cpufeat_mask (X86_FEATURE_NO_FPU_SEL )));cpuid_featureset_to_policy (fs, p);
Signature · 1 line
2.11.0
Quoted 8 lines · Andrew Cooper
For reasons which are my fault, but I don't recall why, the FDP_EXCP_ONLY/NO_FPU_SEL adjustment uses the whole special_features[] array, not the two relevant bits.
HLE and RTM were recently added to the list of special features, causing them to be always set in guest view, irrespective of the toolstacks choice on the matter.
Quoted 6 lines
Rewrite the logic to refer to the features specifically, rather than relying on the contents of the special_features[] array.
Fixes 8fe24090d9 ("x86/cpuid: Rework HLE and RTM handling")Signed-off-by Andrew Cooper <[email protected]>Reported-by Edwin Török <[email protected]>