From nobody Thu Apr 2 09:29:02 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 228393D7D63 for ; Wed, 4 Mar 2026 18:10:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772647824; cv=none; b=fjZWi0fVpASeJNrCFEbSLjdSSZ087Dqbu/cvlOC/X7DvsHNeBxmTcINd8J6XInOtVMgSMti1jVJ5ieY4krcDKRwEMEdczGgaevc+Rc7ZFqbW2ONLeiUDMp4qu014+EJF+JHVku112pJNwBU3cgIPI84DTBspftz9KWyTkPGQ0WE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772647824; c=relaxed/simple; bh=DMvy0T8z1u6WQthJ6hqvZU/FNy6vEoEXqcgqbepEMK8=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=fVYx2rYT57ZQdqyV/TNi2R8i/In/gwYmyeM75eS++Ztxlgi+J44FjC79yUgIJ5HoTuZAIUjTKNN8oGuygFNByxhUqgvMcRLUcMVMCFF1YW0nQo6EG0e1oiFPjgVZWKwDppHdo+1DKEM3L4Yo626/Jmor5WGxGzUfzLUKdWWLXrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=U1EjHlTI; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="U1EjHlTI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772647823; x=1804183823; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=DMvy0T8z1u6WQthJ6hqvZU/FNy6vEoEXqcgqbepEMK8=; b=U1EjHlTINUOZb+NgZfWafx26aspfXdlpgHvxoOhmufBpuWG48zX9GlhZ wePTgbKLr4TOiVV5EEYTIefc82cdtzzNzUnzKAxaXjTqB1IJfnnQO21zn 31YGi850/SHEewJVkUYy+4unUMfpZmAC3WOZ+Zpr3iejzWG2iOxhQL0WK wRM3bQ55+kLyLjue5R+6InuhR7H5E+NndhFYgcCqBsizye/yfaGuSOwLr bIXCswnVTN+YzR2+D7tuzNqI+vryXzJM6W/hSDyzE6syReJCKKt5pur4M ETwDSk72dzlrvHmWI9M1DfNgZBA/nhA8ccpjyn8TwLqly/JCMcLY4ltj6 A==; X-CSE-ConnectionGUID: 5VjEti13QcmQFk1goZtlQQ== X-CSE-MsgGUID: i9W/N0WFTyCdIMVV4YX1+Q== X-IronPort-AV: E=McAfee;i="6800,10657,11719"; a="61291111" X-IronPort-AV: E=Sophos;i="6.21,324,1763452800"; d="scan'208";a="61291111" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2026 10:10:22 -0800 X-CSE-ConnectionGUID: nqwRh+63RQ212xOjNrH8iw== X-CSE-MsgGUID: p8ClIbAsRxSM7kGZzD8lgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,324,1763452800"; d="scan'208";a="215752594" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by fmviesa010.fm.intel.com with ESMTP; 04 Mar 2026 10:10:22 -0800 Subject: [PATCH v4 3/4] x86/cpu: Add platform ID to CPU matching structure To: linux-kernel@vger.kernel.org Cc: sohil.mehta@intel.com, zhao1.liu@intel.com, Dave Hansen , Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , Jon Kohler , Pawan Gupta , "Peter Zijlstra (Intel)" , Thomas Gleixner , Tony Luck , x86@kernel.org From: Dave Hansen Date: Wed, 04 Mar 2026 10:10:22 -0800 References: <20260304181016.85EC87C7@davehans-spike.ostc.intel.com> In-Reply-To: <20260304181016.85EC87C7@davehans-spike.ostc.intel.com> Message-Id: <20260304181022.058DF07C@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen The existing x86_match_cpu() infrastructure can be used to match a bunch of attributes of a CPU: vendor, family, model, steppings and CPU features. But, there's one more attribute that's missing and unable to be matched against: the platform ID, enumerated on Intel CPUs in MSR_IA32_PLATFORM_ID. It is a little more obscure and is only queried during microcode loading. This is because Intel sometimes has CPUs with identical family/model/stepping but which need different microcode. These CPUs are differentiated with the platform ID. Add a field in 'struct x86_cpu_id' for the platform ID. Similar to the stepping field, make the new field a mask of platform IDs. Some examples: 0x01: matches only platform ID 0x0 0x02: matches only platform ID 0x1 0x03: matches platform IDs 0x0 or 0x1 0x80: matches only platform ID 0x7 0xff: matches all 8 possible platform IDs Since the mask is only a byte wide, it nestles in next to another u8 and does not even increase the size of 'struct x86_cpu_id'. Reserve the all 0's value as the wildcard (X86_PLATFORM_ANY). This avoids forcing changes to existing 'struct x86_cpu_id' users. They can just continue to fill the field with 0's and their matching will work exactly as before. Note: If someone is ever looking for space in 'struct x86_cpu_id', this new field could probably get stuck over in ->driver_data for the one user that there is. Signed-off-by: Dave Hansen Reviewed-by: Sohil Mehta Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Tony Luck Cc: Pawan Gupta Cc: "Peter Zijlstra (Intel)" Cc: x86@kernel.org Cc: Jon Kohler --- b/arch/x86/kernel/cpu/match.c | 3 +++ b/include/linux/mod_devicetable.h | 2 ++ 2 files changed, 5 insertions(+) diff -puN arch/x86/kernel/cpu/match.c~platform-match arch/x86/kernel/cpu/ma= tch.c --- a/arch/x86/kernel/cpu/match.c~platform-match 2026-02-24 15:37:22.556290= 868 -0800 +++ b/arch/x86/kernel/cpu/match.c 2026-02-24 15:37:22.561291110 -0800 @@ -76,6 +76,9 @@ const struct x86_cpu_id *x86_match_cpu(c if (m->steppings !=3D X86_STEPPING_ANY && !(BIT(c->x86_stepping) & m->steppings)) continue; + if (m->platform_mask !=3D X86_PLATFORM_ANY && + !(BIT(c->intel_platform_id) & m->platform_mask)) + continue; if (m->feature !=3D X86_FEATURE_ANY && !cpu_has(c, m->feature)) continue; if (!x86_match_vendor_cpu_type(c, m)) diff -puN include/linux/mod_devicetable.h~platform-match include/linux/mod_= devicetable.h --- a/include/linux/mod_devicetable.h~platform-match 2026-02-24 15:37:22.55= 8290965 -0800 +++ b/include/linux/mod_devicetable.h 2026-02-24 15:37:22.561291110 -0800 @@ -692,6 +692,7 @@ struct x86_cpu_id { __u16 feature; /* bit index */ /* Solely for kernel-internal use: DO NOT EXPORT to userspace! */ __u16 flags; + __u8 platform_mask; __u8 type; kernel_ulong_t driver_data; }; @@ -703,6 +704,7 @@ struct x86_cpu_id { #define X86_STEPPING_ANY 0 #define X86_STEP_MIN 0 #define X86_STEP_MAX 0xf +#define X86_PLATFORM_ANY 0x0 #define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */ #define X86_CPU_TYPE_ANY 0 =20 _