Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp910254imb; Fri, 1 Mar 2019 18:55:32 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibfni0s92Z+eE/KEel1hSO+bcrFTXTCehOCaDD9hA2mdliLmynTkLojzyEYSKeaEWARoeDn X-Received: by 2002:aa7:8117:: with SMTP id b23mr9219823pfi.2.1551495332488; Fri, 01 Mar 2019 18:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551495332; cv=none; d=google.com; s=arc-20160816; b=H01Topv92KmcKPp/9rLyViAnFIchQ/m953YFeaZqSHXOJdXMqfowLw3a9QyJWB987O H5hoa8tceM6F0Z6Ehh1S44jTMImdK3AFJ4+hKvt0QVpW4TIqX3xo/UiageOkeiohmbfG gNo6CLAvWQgqt+JK7DzKYCTR/KSwcPaG3yeyumkMA4Q7UajOu8n1CmfEFyu7Zz0B/1Cp Sh7EBILFiIXmWejCt9oJwuM/zkPRfb4ID5lNk3cnqenIMJ7F3cIlCOHqkesvj+o4Ezt8 oGnPGRXosA4ONKQ+4/p1cljgoMmgNYsurGHWzQT0ZT1kSPcJM2JaD2d8EtWf6gG7dxIx iyFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=QAGIZPS28S2dqy2QQa6cy2speXcvpJFNNngRHme/54E=; b=DVM5P/qN6+Y3uPwyKvP7LNnyUiZrsnfcjdlsJg9QKBWSw1HLH5Fji1vPOPlhpP9xBY jrPDLBelqBsdf54+GrbttgUz+vSAtt8O4McL52oOWBgW8ABrKeUVKbuYpID3H/DZSpUd rG4rggMrhdGJPy+MAtnHBC/mRBBpedPUPvjgOmcAEz3xsrOcho6wPtOS9Qx69nB3G3sn QEf02HBUI5Uz5VaHWsRi5Fk9l20+9Q6aDmydN1UlbNdAhUNpC+owPZkxGYwS6ZgswaLS GF/5lFdUr0zZdJbILv+2wwau4odGslvOWngvC0iBSJ8rvzpFbnWIlcbqfefH9gW0ApfA Ja8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e33si22099020pld.397.2019.03.01.18.55.17; Fri, 01 Mar 2019 18:55:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728371AbfCBCyX (ORCPT + 99 others); Fri, 1 Mar 2019 21:54:23 -0500 Received: from mga04.intel.com ([192.55.52.120]:49764 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbfCBCw3 (ORCPT ); Fri, 1 Mar 2019 21:52:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2019 18:52:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,430,1544515200"; d="scan'208";a="148572616" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga004.fm.intel.com with ESMTP; 01 Mar 2019 18:52:28 -0800 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H Peter Anvin" , "Paolo Bonzini" , "Dave Hansen" , "Ashok Raj" , "Peter Zijlstra" , "Ravi V Shankar" , "Xiaoyao Li " Cc: "linux-kernel" , "x86" , kvm@vger.kernel.org, Fenghua Yu Subject: [PATCH v4 10/17] x86/clearcpuid: Apply cleared feature bits that are forced set before Date: Fri, 1 Mar 2019 18:45:04 -0800 Message-Id: <1551494711-213533-11-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1551494711-213533-1-git-send-email-fenghua.yu@intel.com> References: <1551494711-213533-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some CPU feature bits are forced set and stored in cpuinfo_x86 before handling clearcpuid options. To clear those bits from cpuinfo_x86, apply_forced_cap() is called after handling the options. Please note, apply_forced_cap() is called twice on boot CPU. But this code is simple and there is no functionality issue. Signed-off-by: Fenghua Yu --- arch/x86/include/asm/cpu.h | 2 ++ arch/x86/kernel/cpu/common.c | 5 +++-- arch/x86/kernel/fpu/init.c | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index e241abce1a2a..487f32ecea0b 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -26,6 +26,8 @@ struct x86_cpu { struct cpu cpu; }; +void apply_forced_caps(struct cpuinfo_x86 *c); + #ifdef CONFIG_HOTPLUG_CPU extern int arch_register_cpu(int num); extern void arch_unregister_cpu(int); diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 79e7cc0c4c85..26723ea322fa 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -758,13 +758,14 @@ void cpu_detect(struct cpuinfo_x86 *c) } } -static void apply_forced_caps(struct cpuinfo_x86 *c) +void apply_forced_caps(struct cpuinfo_x86 *c) { int i; for (i = 0; i < NCAPINTS + NBUGINTS; i++) { - c->x86_capability[i] &= ~cpu_caps_cleared[i]; + /* Bits may be cleared after they are set. */ c->x86_capability[i] |= cpu_caps_set[i]; + c->x86_capability[i] &= ~cpu_caps_cleared[i]; } } diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c index 99b895eea166..9c2801b605e3 100644 --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -261,6 +262,7 @@ static void __init clear_cpuid(void) bit >= 0 && bit < NCAPINTS * 32) setup_clear_cpu_cap(bit); } + apply_forced_caps(&boot_cpu_data); } /* -- 2.7.4