When re-scanning features, forced caps are taken into account but unforced
such as this are not.  This causes BTC_NO to go missing, and for the system to
appear to have lost features.

The practical consequence of this observation is that all after-the-fact
adjustments to CPUID must be forced.

Signed-off-by: Andrew Cooper <[email protected]>
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau MonnĂ© <[email protected]>
---
 xen/arch/x86/cpu/amd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 9b02e1ba675c..8f468aaf0921 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -1225,8 +1225,9 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
                 * Branch Type Confusion, but predate the allocation of the
                 * BTC_NO bit.  Fill it back in if we're not virtualised.
                 */
-               if (!cpu_has_hypervisor && !cpu_has(c, X86_FEATURE_BTC_NO))
-                       __set_bit(X86_FEATURE_BTC_NO, c->x86_capability);
+               if (c == &boot_cpu_data && !cpu_has_hypervisor &&
+                   !cpu_has(c, X86_FEATURE_BTC_NO))
+                       setup_force_cpu_cap(X86_FEATURE_BTC_NO);
                break;
        }
 
-- 
2.39.5


Reply via email to