From e61287a9141c09531e15c95bdc1a50214753a572 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 18 Nov 2015 12:51:20 +0000 Subject: [PATCH] xen/x86: Clear dependent features when clearing a cpu cap 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 Reviewed-by: Jan Beulich Reviewed-by: Konrad Rzeszutek Wilk --- xen/arch/x86/cpu/common.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index d302272a4e..0942b44bfd 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -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) -- 2.30.2