x86/cpu/vfm: Add/initialize x86_vfm field to struct cpuinfo_x86
authorTony Luck <tony.luck@intel.com>
Tue, 16 Apr 2024 21:19:03 +0000 (14:19 -0700)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 22 Apr 2024 09:43:48 +0000 (11:43 +0200)
Refactor struct cpuinfo_x86 so that the vendor, family, and model
fields are overlaid in a union with a 32-bit field that combines
all three (together with a one byte reserved field in the upper
byte).

This will make it easy, cheap, and reliable to check all three
values at once.

See

  https://lore.kernel.org/r/Zgr6kT8oULbnmEXx@agluck-desk3

for why the ordering is (low-to-high bits):

  (vendor, family, model)

  [ bp: Move comments over the line, add the backstory about the
    particular order of the fields. ]

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240416211941.9369-2-tony.luck@intel.com
arch/x86/include/asm/processor.h

index 811548f131f4e30418bedfdf98f1f302fc06723d..e0f9251e105b36981356b2f94974be73a126ba3e 100644 (file)
@@ -108,9 +108,23 @@ struct cpuinfo_topology {
 };
 
 struct cpuinfo_x86 {
-       __u8                    x86;            /* CPU family */
-       __u8                    x86_vendor;     /* CPU vendor */
-       __u8                    x86_model;
+       union {
+               /*
+                * The particular ordering (low-to-high) of (vendor,
+                * family, model) is done in case range of models, like
+                * it is usually done on AMD, need to be compared.
+                */
+               struct {
+                       __u8    x86_model;
+                       /* CPU family */
+                       __u8    x86;
+                       /* CPU vendor */
+                       __u8    x86_vendor;
+                       __u8    x86_reserved;
+               };
+               /* combined vendor, family, model */
+               __u32           x86_vfm;
+       };
        __u8                    x86_stepping;
 #ifdef CONFIG_X86_64
        /* Number of 4K pages in DTLB/ITLB combined(in pages): */