From patchwork Fri Feb 5 13:42:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8234701 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 44F329F38B for ; Fri, 5 Feb 2016 14:04:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A8F120397 for ; Fri, 5 Feb 2016 14:04:23 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4691B20389 for ; Fri, 5 Feb 2016 14:04:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aRgxd-0000Dx-1i; Fri, 05 Feb 2016 14:02:09 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aRgxb-0000Bw-LW for xen-devel@lists.xen.org; Fri, 05 Feb 2016 14:02:07 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 82/A4-25857-E5BA4B65; Fri, 05 Feb 2016 14:02:06 +0000 X-Env-Sender: prvs=8364524b4=Andrew.Cooper3@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1454680924!20279727!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57704 invoked from network); 5 Feb 2016 14:02:06 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 5 Feb 2016 14:02:06 -0000 X-IronPort-AV: E=Sophos;i="5.22,400,1449532800"; d="scan'208";a="336333895" From: Andrew Cooper To: Xen-devel Date: Fri, 5 Feb 2016 13:42:07 +0000 Message-ID: <1454679743-18133-15-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454679743-18133-1-git-send-email-andrew.cooper3@citrix.com> References: <1454679743-18133-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH v2 14/30] xen/x86: Improve disabling of features which have dependencies X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP APIC and XSAVE have dependent features, which also need disabling if Xen chooses to disable a feature. Use setup_clear_cpu_cap() rather than clear_bit(), as it takes care of dependent features as well. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- v2: Move boolean_param() adjacent to use_xsave in xstate_init() --- xen/arch/x86/apic.c | 2 +- xen/arch/x86/cpu/common.c | 12 +++--------- xen/arch/x86/xstate.c | 6 +++++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index b9601ad..8df5bd3 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -1349,7 +1349,7 @@ void pmu_apic_interrupt(struct cpu_user_regs *regs) int __init APIC_init_uniprocessor (void) { if (enable_local_apic < 0) - __clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability); + setup_clear_cpu_cap(X86_FEATURE_APIC); if (!smp_found_config && !cpu_has_apic) { skip_ioapic_setup = 1; diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index e205565..46d93a6 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -16,9 +16,6 @@ #include "cpu.h" -static bool_t use_xsave = 1; -boolean_param("xsave", use_xsave); - bool_t opt_arat = 1; boolean_param("arat", opt_arat); @@ -343,12 +340,6 @@ void identify_cpu(struct cpuinfo_x86 *c) if (this_cpu->c_init) this_cpu->c_init(c); - /* Initialize xsave/xrstor features */ - if ( !use_xsave ) - __clear_bit(X86_FEATURE_XSAVE, boot_cpu_data.x86_capability); - - if ( cpu_has_xsave ) - xstate_init(c); if ( !opt_pku ) setup_clear_cpu_cap(X86_FEATURE_PKU); @@ -374,6 +365,9 @@ void identify_cpu(struct cpuinfo_x86 *c) /* Now the feature flags better reflect actual CPU features! */ + if ( cpu_has_xsave ) + xstate_init(c); + #ifdef NOISY_CAPS printk(KERN_DEBUG "CPU: After all inits, caps:"); for (i = 0; i < NCAPINTS; i++) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index c5d17ff..56b5df2 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -505,11 +505,15 @@ unsigned int xstate_ctxt_size(u64 xcr0) /* Collect the information of processor's extended state */ void xstate_init(struct cpuinfo_x86 *c) { + static bool_t __initdata use_xsave = 1; + boolean_param("xsave", use_xsave); + bool_t bsp = c == &boot_cpu_data; u32 eax, ebx, ecx, edx; u64 feature_mask; - if ( boot_cpu_data.cpuid_level < XSTATE_CPUID ) + if ( (bsp && !use_xsave) || + boot_cpu_data.cpuid_level < XSTATE_CPUID ) { BUG_ON(!bsp); setup_clear_cpu_cap(X86_FEATURE_XSAVE);