From: Andrew Cooper Date: Mon, 7 Jun 2021 12:25:09 +0000 (+0100) Subject: x86/cpuid: Fix HLE and RTM handling (again) X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~471 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=60fa12dbf1d4d2c4ffe1ef34b495b24aa7e41aa0;p=xen.git 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 element, 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. Fixes: 8fe24090d9 ("x86/cpuid: Rework HLE and RTM handling") Reported-by: Edwin Török Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index f3c8950aa3..958caf35da 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -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);