Return-Path: Received: from mail.linutronix.de (193.142.43.55:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 18 Mar 2020 21:43:19 -0000 Received: from mga06.intel.com ([134.134.136.31]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jEgSo-0002AP-Ji for speck@linutronix.de; Wed, 18 Mar 2020 22:43:01 +0100 Received: from mtg-dev (mtg-dev.jf.intel.com [10.54.74.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.ostc.intel.com (Postfix) with ESMTPS id E690E6367 for ; Wed, 18 Mar 2020 21:42:54 +0000 (UTC) Received: from mgross by mtg-dev with local (Exim 4.90_1) (envelope-from ) id 1jEgSk-000TWz-OH for speck@linutronix.de; Wed, 18 Mar 2020 14:42:54 -0700 Message-Id: =?utf-8?q?=3C7a8f6bad758eedcbf9d0b3d3eccd3581dacf37b9=2E158456?= =?utf-8?q?6871=2Egit=2Emgross=40linux=2Eintel=2Ecom=3E?= In-Reply-To: References: From: mark gross Date: Mon, 16 Mar 2020 17:56:27 -0700 Subject: [MODERATED] [PATCH 1/3] v4 more sampling fun 1 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 To: speck@linutronix.de List-ID: From: mark gross Subject: [PATCH 1/3] x86/cpu: Add stepping field to x86_cpu_id structure Intel uses the same family/model for several CPUs. Sometimes the stepping must be checked to tell them apart. Note that to keep this patch simple the new field has been added at the end to avoid churn with all the pre-C99 initialized uses of this structure. Such legacy usage will result in a "0" value for the stepping field, hence X86_STEPPING_ANY is defined as "0". Signed-off-by: Mark Gross Co-developed-by: Tony Luck Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/match.c | 6 +++++- include/linux/mod_devicetable.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/match.c b/arch/x86/kernel/cpu/match.c index 6dd78d8235e4..129df1a959e9 100644 --- a/arch/x86/kernel/cpu/match.c +++ b/arch/x86/kernel/cpu/match.c @@ -34,7 +34,8 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match) const struct x86_cpu_id *m; struct cpuinfo_x86 *c = &boot_cpu_data; - for (m = match; m->vendor | m->family | m->model | m->feature; m++) { + for (m = match; m->vendor | m->family | m->model | m->feature | + m->stepping; m++) { if (m->vendor != X86_VENDOR_ANY && c->x86_vendor != m->vendor) continue; if (m->family != X86_FAMILY_ANY && c->x86 != m->family) @@ -43,6 +44,9 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match) continue; if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature)) continue; + if (m->stepping != X86_STEPPING_ANY && + !(c->x86_stepping & m->stepping)) + continue; return m; } return NULL; diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index e3596db077dc..340ad760a47a 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -665,6 +665,7 @@ struct x86_cpu_id { __u16 model; __u16 feature; /* bit index */ kernel_ulong_t driver_data; + __u16 stepping; }; #define X86_FEATURE_MATCH(x) \ @@ -674,6 +675,7 @@ struct x86_cpu_id { #define X86_FAMILY_ANY 0 #define X86_MODEL_ANY 0 #define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */ +#define X86_STEPPING_ANY 0 /* * Generic table type for matching CPU features. -- 2.17.1