Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2627738ybc; Wed, 20 Nov 2019 17:48:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxEiBufiNL+tbl0MrgoRyr7Ru/j1S5X/pDmWDKvz5ztsyEtSc/yPf982tk41VKyfEEFBNn3 X-Received: by 2002:a17:906:344c:: with SMTP id d12mr9359429ejb.227.1574300904264; Wed, 20 Nov 2019 17:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574300904; cv=none; d=google.com; s=arc-20160816; b=NnS3auTkyvrqvfqA1nHpBDYxQRdcOgRMn6H2u4OO6Q48NNW0PXREIOz7vhzWSKer4q e2ymucW+PmWA/cfotDyGuzhC99NFdibCH5PbFq78KhxUpQrIZY+YDsgKAG9FudzHh3Yx B3/Ve2x0RdRzXj9s4TUSPYSfGe6vKcQ9SzsfVFLTjRB09sWUF6yGvIQC7NSqL9AXOwI8 8PxFAZSSj5/NVtX/FOTyI3Rq+kYmKYlZYK0S7Rh2SEmKf7e6f8sW0fSk0+pHzUckJW6B u3UBXtGUDDCK11sG3COjROHEYotKAGdxjUtadEi8CDHC6oWqP26KijUidV0nE1nV57x4 HA9A== 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=bug1V7CV/1Ym3LWJh6SCBg67jIZgziqkR01jJ267AWA=; b=U9IdhBdSGjeOOkOr5hXG+fISHRopS9xn/gSxzslmWnTeNNOgeSm6/0D6sqT+nETD9J r7Rj85/VQ37SiGxqfuPaUlllyo/Q5SRou9JOyosXxguOEd5XPbNJsQzDyfdK+mghaKgR YMJ79M+DBq6UibOqHMSX9ruSj9BUzevxfaIUz6M754U3B/kLp1yecf1ylRkGTxCohcas +pxyy40vf9s59GeALGps1vQxN3KOB0xo5zGOsYMNbR/iXU2dBMdTspvwil0+uA3iBg/2 et97dcGx18u0GXVGQ6q62BONQyEIJZETHakjp+IA2WqiWFINYP7SdPDasBJWM7Cr7051 +yMg== 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 c53si1023767eda.396.2019.11.20.17.48.00; Wed, 20 Nov 2019 17:48:24 -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 S1726961AbfKUBqH (ORCPT + 99 others); Wed, 20 Nov 2019 20:46:07 -0500 Received: from mga05.intel.com ([192.55.52.43]:49098 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726500AbfKUBpv (ORCPT ); Wed, 20 Nov 2019 20:45:51 -0500 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; 20 Nov 2019 17:45:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,224,1571727600"; d="scan'208";a="407025907" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga005.fm.intel.com with ESMTP; 20 Nov 2019 17:45:50 -0800 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H Peter Anvin" , "Peter Zijlstra" , "Tony Luck" , "Ashok Raj" , "Ravi V Shankar" Cc: "linux-kernel" , "x86" , Fenghua Yu Subject: [PATCH v10 4/6] x86/split_lock: Enumerate split lock detection if the IA32_CORE_CAPABILITIES MSR is not supported Date: Wed, 20 Nov 2019 16:53:21 -0800 Message-Id: <1574297603-198156-5-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1574297603-198156-1-git-send-email-fenghua.yu@intel.com> References: <1574297603-198156-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 Architecturally the split lock detection feature is enumerated by IA32_CORE_CAPABILITIES MSR and future CPU models will indicate presence of the feature by setting bit 5. But the feature is present in a few older models where split lock detection is enumerated by the CPU models. Use a "x86_cpu_id" table to list the older CPU models with the feature. Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck --- arch/x86/kernel/cpu/intel.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index ce87e2c68767..2614616fb6d3 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef CONFIG_X86_64 #include @@ -1034,15 +1035,31 @@ static void __init split_lock_setup(void) setup_force_cpu_cap(X86_FEATURE_SPLIT_LOCK_DETECT); } +#define SPLIT_LOCK_CPU(model) {X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY} + +/* + * The following processors have split lock detection feature. But since they + * don't have MSR IA32_CORE_CAPABILITIES, the feature cannot be enumerated by + * the MSR. So enumerate the feature by family and model on these processors. + */ +static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = { + SPLIT_LOCK_CPU(INTEL_FAM6_ICELAKE_X), + SPLIT_LOCK_CPU(INTEL_FAM6_ICELAKE_L), + {} +}; + void __init cpu_set_core_cap_bits(struct cpuinfo_x86 *c) { u64 ia32_core_caps = 0; - if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITIES)) - return; - - /* Enumerate features reported in IA32_CORE_CAPABILITIES MSR. */ - rdmsrl(MSR_IA32_CORE_CAPABILITIES, ia32_core_caps); + if (cpu_has(c, X86_FEATURE_CORE_CAPABILITIES)) { + /* Enumerate features reported in IA32_CORE_CAPABILITIES MSR. */ + rdmsrl(MSR_IA32_CORE_CAPABILITIES, ia32_core_caps); + } else { + /* Enumerate split lock detection by family and model. */ + if (x86_match_cpu(split_lock_cpu_ids)) + ia32_core_caps |= MSR_IA32_CORE_CAPABILITIES_SPLIT_LOCK_DETECT; + } if (ia32_core_caps & MSR_IA32_CORE_CAPABILITIES_SPLIT_LOCK_DETECT) split_lock_setup(); -- 2.19.1