From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH RFC 17/31] xen/x86: Clear dependent features when clearing a cpu cap Date: Wed, 16 Dec 2015 21:24:19 +0000 Message-ID: <1450301073-28191-18-git-send-email-andrew.cooper3@citrix.com> References: <1450301073-28191-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1450301073-28191-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Jan Beulich List-Id: xen-devel@lists.xenproject.org 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 --- CC: Jan Beulich --- xen/arch/x86/cpu/common.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index b48ce58..ba42ac0 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -49,8 +49,24 @@ static unsigned int __cpuinitdata cleared_caps[NCAPINTS]; void __init setup_clear_cpu_cap(unsigned int cap) { + const struct tagged_featureset *dfs; + unsigned int i; + + if ( test_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 < ARRAY_SIZE(dfs->fs); ++i ) { + cleared_caps[i] |= dfs->fs[i]; + boot_cpu_data.x86_capability[i] &= ~dfs->fs[i]; + } } static void default_init(struct cpuinfo_x86 * c) -- 2.1.4