Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp567049yba; Wed, 3 Apr 2019 14:36:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvR5wFRz2KCkncDoUrLPqSBsrlVtNyzIrkz6trvcLGu9mcutn0Oze0cCuKSijpfj9LIlxT X-Received: by 2002:a17:902:b40a:: with SMTP id x10mr2359088plr.231.1554327368841; Wed, 03 Apr 2019 14:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554327368; cv=none; d=google.com; s=arc-20160816; b=GEurP8rl0j3HTHvh1l2E2vTJErCUwawxyY/ROlfPcuqN1v+y3c4D/Pmfsqhd+DiSZ2 B8+PqqCLl1D8doYaYDthV7F5WVxpoO20VoHZumvArY9GscABIgElD+zlGZusp7bhNwKl cqDm7PaaZyfLBsTnOWWY2EPb26Lpd0P9fMX72O+vBHFfdl9EbjPwBzRdJJl80ntSQd5T oQ2xdH8KYxbYZ4T0y41Q0k5uzPN82MoQeMMmZB+pTt9E3NquSy7Ikds3zrPisZ/oU+cx NhSGH7Pr0+qUM844wKXhpAmtmuXr5J2+5aLmVDLvfbY3tfyy/wxPO2G36vvl+kUZvAE/ cdGw== 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=7Bj2ZyiQgYanDCleVmVssPZ5XfQRXw1XPKO0P/7Dcu4=; b=wHvmY1Rl3TxELRdBFUo2MY7ehgQXTqWV2aTfcYeLVkeagtk/P4LDmCnGh7Sa46ZPKa QkDXxW7GAT7M/T69/p43Cx1vghMqCak76NxuYlTm8MBq9Ti1AkoAiJzeETFyONrcXzCh oJjBtS1Nw5TMRX7oo0OKIaAZxCd6ikda08Ihff6iwEOcl3GuiqQzN54v1iBWIUwh88sv 5HzAZDyX6Yub5zJjRPmivlpSB9RKZSrVZqs0PGJY4WFUnP6qoph7HLixoaVK1hKY2g6J pv/ivFxhtHVkxgGuF81pPHVPLKgc9jxSenhxgoUGLbk2V7Xk3SKPPXilfq3M4MWUF3aQ jszg== 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 f1si14914286pgm.373.2019.04.03.14.35.53; Wed, 03 Apr 2019 14:36:08 -0700 (PDT) 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 S1728589AbfDCVdi (ORCPT + 99 others); Wed, 3 Apr 2019 17:33:38 -0400 Received: from mga05.intel.com ([192.55.52.43]:37323 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726206AbfDCVaS (ORCPT ); Wed, 3 Apr 2019 17:30:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 14:30:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="334754281" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga005.fm.intel.com with ESMTP; 03 Apr 2019 14:30:13 -0700 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H Peter Anvin" , "Dave Hansen" , "Paolo Bonzini" , "Ashok Raj" , "Peter Zijlstra" , "Kalle Valo" , "Xiaoyao Li " , "Michael Chan" , "Ravi V Shankar" Cc: "linux-kernel" , "x86" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, Fenghua Yu Subject: [PATCH v6 18/20] x86/clearcpuid: Apply cleared feature bits that are forced set before Date: Wed, 3 Apr 2019 14:22:04 -0700 Message-Id: <1554326526-172295-19-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1554326526-172295-1-git-send-email-fenghua.yu@intel.com> References: <1554326526-172295-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 4e03f53fc079..bfa5ac6b7502 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 bbdd69dd4f5f..e1d41405c27b 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.19.1