xen/x86: Clear dependent features when clearing a cpu cap
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 Nov 2015 12:51:20 +0000 (12:51 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 8 Apr 2016 20:54:04 +0000 (21:54 +0100)
When clearing a cpu cap, clear all dependent features.  This avoids having a
featureset with intermediate features disabled, but leaf features enabled.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <JBeulich@suse.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
xen/arch/x86/cpu/common.c

index d302272a4e8c533c86939ef9d7fcea912c0c6601..0942b44bfdf3628522f2852adf3981ec3ea1261c 100644 (file)
@@ -53,8 +53,22 @@ static unsigned int cleared_caps[NCAPINTS];
 
 void __init setup_clear_cpu_cap(unsigned int cap)
 {
+       const uint32_t *dfs;
+       unsigned int i;
+
+       if (__test_and_set_bit(cap, cleared_caps))
+               return;
+
        __clear_bit(cap, boot_cpu_data.x86_capability);
-       __set_bit(cap, cleared_caps);
+       dfs = lookup_deep_deps(cap);
+
+       if (!dfs)
+               return;
+
+       for (i = 0; i < FSCAPINTS; ++i) {
+               cleared_caps[i] |= dfs[i];
+               boot_cpu_data.x86_capability[i] &= ~dfs[i];
+       }
 }
 
 static void default_init(struct cpuinfo_x86 * c)