[RFC PATCH 00/15] Prepare for new Intel family models

Sohil Mehta posted 15 patches 18 hours ago
arch/x86/events/intel/p4.c            |  7 ++--
arch/x86/events/intel/p6.c            | 28 ++++---------
arch/x86/include/asm/intel-family.h   | 16 ++++++++
arch/x86/kernel/acpi/cstate.c         |  8 ++--
arch/x86/kernel/apic/apic.c           |  4 +-
arch/x86/kernel/cpu/intel.c           | 58 ++++++++++++---------------
arch/x86/kernel/cpu/microcode/intel.c |  3 +-
arch/x86/kernel/cpu/mtrr/generic.c    |  4 +-
arch/x86/kernel/smpboot.c             |  8 ++--
arch/x86/mm/pat/memtype.c             |  7 ++--
drivers/cpufreq/cpufreq_ondemand.c    | 13 +++---
drivers/hwmon/coretemp.c              | 26 ++++++++----
12 files changed, 96 insertions(+), 86 deletions(-)
[RFC PATCH 00/15] Prepare for new Intel family models
Posted by Sohil Mehta 18 hours ago
---Tl;Dr---
Audit all the Intel family model checks to get ready for the upcoming family 18
and 19 models.
Patches 1-5: Fixes in arch/x86 and drivers
Patches 6-15: Cleanups in arch/x86 to convert x86_model checks to VFM ones.

This series does not include cleanups in drivers/

---Background---
Mainstream Intel processors have been using family number 6 for a couple of
decades. The last deviation from this were the Netburst architecture based
Pentium 4s that had a family number of 15. Intel has recently started to
introduce extended family numbers greater than 15 [1]. Though newer CPUs can
have any family number, the currently planned CPUs lie in families 18 and 19.

Some kernel code assumes that the family number would always remain 6.  There
are checks that apply to recent family 6 models such as Lunar Lake and
Clearwater Forest but don't automatically extend to family 19 models such as
Diamond Rapids. This series aims to fix and cleanup all of such Intel specific
checks (mainly in arch/x86) to avoid such issues in the future. It also
converts almost all of the x86_model checks in arch/x86 to the new VFM ones.

OTOH, x86_model usage in drivers/ is a huge mess. Some drivers might need to be
completely rewritten to make them future proof. I have attempted a couple of
fixes in cpufreq and hwmon but I am uncertain of their efficacy.  A more
thorough clean up of drivers is needed to replace all x86_model usage with
the new VFM checks.

---Assumptions and Trade-offs---
Newer CPUs will have model numbers only in family 6 or after family 15.  No new
processors would be added between family 6 and 15. There are a couple of
related quirks that have been described below.

As a convention, Intel family numbers are referenced using decimals (family 15,
19, etc.) even though the AMD specific code might prefer hexadecimals in
similar situations.

It would be preferable to have simpler and more maintainable checks that might
in a rare situation change the behavior on really old platforms. If someone
pops up with an issue, the code would be fixed later.
For example, the check,
	c->x86_vfm >= INTEL_PENTIUM_PRO
is preferred over,
	c->x86 == 6 || c->x86 > 15
if the likelihood of adversely affecting family 15 is low.

Also, the CPU defines in intel-family.h have been added as and when needed to
make reviewing and applying patches out of order easier. Please let me know if
it would be preferable to add all the defines in a single patch at the
beginning.

---Noteworthy quirks---
Pentium II Overdrive - A unique family number:
  Wikipedia says[2], In Intel's "Family/Model/Stepping" scheme, the Pentium II
  OverDrive CPU identifies itself as family 6, model 3, though this is 
  misleading, as it is not based on the family 6/model 3 Klamath core. As 
  mentioned in the Pentium II Processor update documentation from Intel, 
  "although this processor has a CPUID of 163xh, it uses a Pentium II processor 
  CPUID 065xh processor core."

  A dump of the microcode file 06-03-02 shows:
    001/001: sig 0x00001632, pf_mask 0x00, 1998-06-10, rev 0x0002, size 2048
  An archived CPUID dump [3] also says:
    CPUID 00000001: 00001632-00000000-00000000-0183FBFF

  That would translate to a family number of 22 (0x16). This aberration is 
  not explicitly handled anywhere in the kernel so the platform might already 
  be broken. This series might make it worse for the platform if the latest 
  kernel works on it by chance.

Xeon Phi coprocessors:
  The first couple of Knights line of products (Knights Ferry and Knights
  Corner) have a family number of 11. But they were released purely as
  coprocessors and would not directly boot mainline Linux. The later
  versions Knights Landing and Knights Mill could act as a host processor
  but they used family number 6. So, the changes in this series should not
  affect any of these platforms.

---Links---
[1]: commit d1fb034b75a8 ("x86/cpu: Add two Intel CPU model numbers")
[2]: https://en.wikipedia.org/wiki/Pentium_II#Pentium_II_OverDrive
[3]: https://github.com/InstLatx64/InstLatx64/blob/master/GenuineIntel/GenuineIntel0000632_P2OD_CPUID.txt

The series has only been lightly tested on a couple of family 6 systems.
Planning to test it on more systems in the future. Any testing on legacy
platforms would be greatly helpful.

Many thanks to Tony and Dave for guiding me through this historical maze.

Sohil Mehta (15):
  x86/apic: Fix 32-bit APIC initialization for extended Intel families
  x86/apic: Fix smp init delay for extended Intel families
  x86/cpu/intel: Fix init_intel() checks for extended family numbers
  cpufreq: Fix the efficient idle check for Intel extended families
  hwmon: Fix Intel family checks to include extended family numbers
  x86/microcode: Update the Intel processor flag scan check
  x86/mtrr: Modify a x86_model check to an Intel VFM check
  x86/cpu/intel: Replace early family 6 checks with VFM ones
  x86/cpu/intel: Replace family 15 checks with VFM ones
  x86/cpu/intel: Replace family 5 model checks with VFM ones
  x86/pat: Replace Intel model checks with VFM ones
  x86/acpi/cstate: Improve Intel family model checks
  x86/cpu/intel: Bound the non-architectural constant_tsc model checks
  perf/x86: Simplify p6_pmu_init()
  perf/x86/p4: Replace Pentium 4 model checks with VFM ones

 arch/x86/events/intel/p4.c            |  7 ++--
 arch/x86/events/intel/p6.c            | 28 ++++---------
 arch/x86/include/asm/intel-family.h   | 16 ++++++++
 arch/x86/kernel/acpi/cstate.c         |  8 ++--
 arch/x86/kernel/apic/apic.c           |  4 +-
 arch/x86/kernel/cpu/intel.c           | 58 ++++++++++++---------------
 arch/x86/kernel/cpu/microcode/intel.c |  3 +-
 arch/x86/kernel/cpu/mtrr/generic.c    |  4 +-
 arch/x86/kernel/smpboot.c             |  8 ++--
 arch/x86/mm/pat/memtype.c             |  7 ++--
 drivers/cpufreq/cpufreq_ondemand.c    | 13 +++---
 drivers/hwmon/coretemp.c              | 26 ++++++++----
 12 files changed, 96 insertions(+), 86 deletions(-)


base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8
-- 
2.43.0
Re: [RFC PATCH 00/15] Prepare for new Intel family models
Posted by Andrew Cooper 15 hours ago
> ---Noteworthy quirks---
> Pentium II Overdrive - A unique family number:
>   Wikipedia says[2], In Intel's "Family/Model/Stepping" scheme, the Pentium II
>   OverDrive CPU identifies itself as family 6, model 3, though this is 
>   misleading, as it is not based on the family 6/model 3 Klamath core. As 
>   mentioned in the Pentium II Processor update documentation from Intel, 
>   "although this processor has a CPUID of 163xh, it uses a Pentium II processor 
>   CPUID 065xh processor core."
>
>   A dump of the microcode file 06-03-02 shows:
>     001/001: sig 0x00001632, pf_mask 0x00, 1998-06-10, rev 0x0002, size 2048
>   An archived CPUID dump [3] also says:
>     CPUID 00000001: 00001632-00000000-00000000-0183FBFF
>
>   That would translate to a family number of 22 (0x16). This aberration is 
>   not explicitly handled anywhere in the kernel so the platform might already 
>   be broken. This series might make it worse for the platform if the latest 
>   kernel works on it by chance.

Are you sure?  Bits 13:12 are the type field, and the 0x1 you've got is
for an OverDrive processor.

x86_family() will consider this to be family 6 as far as I can see.

~Andrew