]> Git Repo - linux.git/commitdiff
Merge tag 'x86_microcode_for_v6.3_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <[email protected]>
Tue, 21 Feb 2023 16:47:36 +0000 (08:47 -0800)
committerLinus Torvalds <[email protected]>
Tue, 21 Feb 2023 16:47:36 +0000 (08:47 -0800)
Pull x86 microcode loader updates from Borislav Petkov:

 - Fix mixed steppings support on AMD which got broken somewhere along
   the way

 - Improve revision reporting

 - Properly check CPUID capabilities after late microcode upgrade to
   avoid false positives

 - A garden variety of other small fixes

* tag 'x86_microcode_for_v6.3_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/microcode/core: Return an error only when necessary
  x86/microcode/AMD: Fix mixed steppings support
  x86/microcode/AMD: Add a @cpu parameter to the reloading functions
  x86/microcode/amd: Remove load_microcode_amd()'s bsp parameter
  x86/microcode: Allow only "1" as a late reload trigger value
  x86/microcode/intel: Print old and new revision during early boot
  x86/microcode/intel: Pass the microcode revision to print_ucode_info() directly
  x86/microcode: Adjust late loading result reporting message
  x86/microcode: Check CPU capabilities after late microcode update correctly
  x86/microcode: Add a parameter to microcode_check() to store CPU capabilities
  x86/microcode: Use the DEVICE_ATTR_RO() macro
  x86/microcode/AMD: Handle multiple glued containers properly
  x86/microcode/AMD: Rename a couple of functions

1  2 
arch/x86/kernel/cpu/common.c

index f3cc7699e1e1b23fcd28f910e898a832b6e0ea7e,5ff73baa55839492a235f9fdad74df629193fc1f..6a25e93f2a87c9f07416c2fa59f496c3d94b842c
@@@ -1256,8 -1256,6 +1256,8 @@@ static const __initconst struct x86_cpu
  #define MMIO_SBDS     BIT(2)
  /* CPU is affected by RETbleed, speculating where you would not expect it */
  #define RETBLEED      BIT(3)
 +/* CPU is affected by SMT (cross-thread) return predictions */
 +#define SMT_RSB               BIT(4)
  
  static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
        VULNBL_INTEL_STEPPINGS(IVYBRIDGE,       X86_STEPPING_ANY,               SRBDS),
  
        VULNBL_AMD(0x15, RETBLEED),
        VULNBL_AMD(0x16, RETBLEED),
 -      VULNBL_AMD(0x17, RETBLEED),
 -      VULNBL_HYGON(0x18, RETBLEED),
 +      VULNBL_AMD(0x17, RETBLEED | SMT_RSB),
 +      VULNBL_HYGON(0x18, RETBLEED | SMT_RSB),
        {}
  };
  
@@@ -1408,9 -1406,6 +1408,9 @@@ static void __init cpu_set_bug_bits(str
            !(ia32_cap & ARCH_CAP_PBRSB_NO))
                setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB);
  
 +      if (cpu_matches(cpu_vuln_blacklist, SMT_RSB))
 +              setup_force_cpu_bug(X86_BUG_SMT_RSB);
 +
        if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
                return;
  
@@@ -2302,30 -2297,45 +2302,45 @@@ void cpu_init_secondary(void
  #endif
  
  #ifdef CONFIG_MICROCODE_LATE_LOADING
- /*
+ /**
+  * store_cpu_caps() - Store a snapshot of CPU capabilities
+  * @curr_info: Pointer where to store it
+  *
+  * Returns: None
+  */
+ void store_cpu_caps(struct cpuinfo_x86 *curr_info)
+ {
+       /* Reload CPUID max function as it might've changed. */
+       curr_info->cpuid_level = cpuid_eax(0);
+       /* Copy all capability leafs and pick up the synthetic ones. */
+       memcpy(&curr_info->x86_capability, &boot_cpu_data.x86_capability,
+              sizeof(curr_info->x86_capability));
+       /* Get the hardware CPUID leafs */
+       get_cpu_cap(curr_info);
+ }
+ /**
+  * microcode_check() - Check if any CPU capabilities changed after an update.
+  * @prev_info:        CPU capabilities stored before an update.
+  *
   * The microcode loader calls this upon late microcode load to recheck features,
   * only when microcode has been updated. Caller holds microcode_mutex and CPU
   * hotplug lock.
+  *
+  * Return: None
   */
- void microcode_check(void)
+ void microcode_check(struct cpuinfo_x86 *prev_info)
  {
-       struct cpuinfo_x86 info;
+       struct cpuinfo_x86 curr_info;
  
        perf_check_microcode();
  
-       /* Reload CPUID max function as it might've changed. */
-       info.cpuid_level = cpuid_eax(0);
-       /*
-        * Copy all capability leafs to pick up the synthetic ones so that
-        * memcmp() below doesn't fail on that. The ones coming from CPUID will
-        * get overwritten in get_cpu_cap().
-        */
-       memcpy(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability));
-       get_cpu_cap(&info);
+       store_cpu_caps(&curr_info);
  
-       if (!memcmp(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability)))
+       if (!memcmp(&prev_info->x86_capability, &curr_info.x86_capability,
+                   sizeof(prev_info->x86_capability)))
                return;
  
        pr_warn("x86/CPU: CPU features have changed after loading microcode, but might not take effect.\n");
This page took 0.074286 seconds and 4 git commands to generate.