Merge tag 'x86_vdso_for_v6.3_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[platform/kernel/linux-rpi.git] / arch / x86 / kernel / cpu / common.c
index a26ce20..a539c8f 100644 (file)
@@ -1256,6 +1256,8 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
 #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),
@@ -1287,8 +1289,8 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
 
        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),
        {}
 };
 
@@ -1406,6 +1408,9 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
            !(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;
 
@@ -2294,30 +2299,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");