From patchwork Fri Apr 8 20:31:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8785681 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 B38299F71A for ; Fri, 8 Apr 2016 20:34:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCB46202DD for ; Fri, 8 Apr 2016 20:34:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5529202BE for ; Fri, 8 Apr 2016 20:34:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aod4w-0007bF-Jx; Fri, 08 Apr 2016 20:32:30 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aod4v-0007ZT-Al for xen-devel@lists.xen.org; Fri, 08 Apr 2016 20:32:29 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 34/EE-03294-C5518075; Fri, 08 Apr 2016 20:32:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42JxWrrBXjdGlCP c4MN5PoslHxezODB6HN39mymAMYo1My8pvyKBNWPmgQa2ghuiFftWPWJqYPwr2MXIySEh4C+x dOtsVhCbTUBfYveLT0wgtoiAusTpjotAcQ4OZgFdiVU/NUDCwgIREjsnfWQHsVkEVCRmtPxnB LF5BTwlXi39wg4xUk7i/PGfzCA2p4CXxJltZ8DGCwHVXJ45nwXCVpO41n+JHaJXUOLkzCdgcW YBCYmDL14wg6yVEOCW+NttP4GRbxaSqllIqhYwMq1iVC9OLSpLLdI100sqykzPKMlNzMzRNTQ w1stNLS5OTE/NSUwq1kvOz93ECAynegYGxh2MV9qcDzFKcjApifJue8geLsSXlJ9SmZFYnBFf VJqTWnyIUYaDQ0mC11mEI1xIsCg1PbUiLTMHGNgwaQkOHiUR3skgad7igsTc4sx0iNQpRkUpc V57kIQASCKjNA+uDRZNlxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ8waBTOHJzCuBm/4KaD ET0OIL/Gwgi0sSEVJSDYxtVu1cM0z2x9X+O7N85aXsmtA+octWDPqtll+EbQ9VSXd1HhGeonx w4tzDob0b+656S07YKxARFBZjFvZLY52U6dspO+8EGG1kcWpwONZ25NzOZOe3D7KU1l+wcdK7 9vJRxhJNbtXCTMfam85n73J3KeRf/trxQsflWEHdvL39J6PmH+GcvlGJpTgj0VCLuag4EQB+M 2GeoQIAAA== X-Env-Sender: prvs=8997c7931=Andrew.Cooper3@citrix.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1460147545!7592194!2 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: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63111 invoked from network); 8 Apr 2016 20:32:28 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 8 Apr 2016 20:32:28 -0000 X-IronPort-AV: E=Sophos;i="5.24,454,1454976000"; d="scan'208";a="352596638" From: Andrew Cooper To: Xen-devel Date: Fri, 8 Apr 2016 21:31:41 +0100 Message-ID: <1460147517-11706-6-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460147517-11706-1-git-send-email-andrew.cooper3@citrix.com> References: <1460147517-11706-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH v6 05/21] xen/x86: Improve disabling of features which have dependencies X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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 Reviewed-by: Konrad Rzeszutek Wilk --- 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 0942b44..b5c023f 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); @@ -341,12 +338,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); @@ -370,6 +361,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 48c0195..8359722 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -533,11 +533,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);