}
 }
 
+static void init_speculation_control(struct cpuinfo_x86 *c)
+{
+       /*
+        * The Intel SPEC_CTRL CPUID bit implies IBRS and IBPB support,
+        * and they also have a different bit for STIBP support. Also,
+        * a hypervisor might have set the individual AMD bits even on
+        * Intel CPUs, for finer-grained selection of what's available.
+        *
+        * We use the AMD bits in 0x8000_0008 EBX as the generic hardware
+        * features, which are visible in /proc/cpuinfo and used by the
+        * kernel. So set those accordingly from the Intel bits.
+        */
+       if (cpu_has(c, X86_FEATURE_SPEC_CTRL)) {
+               set_cpu_cap(c, X86_FEATURE_IBRS);
+               set_cpu_cap(c, X86_FEATURE_IBPB);
+       }
+       if (cpu_has(c, X86_FEATURE_INTEL_STIBP))
+               set_cpu_cap(c, X86_FEATURE_STIBP);
+}
+
 void get_cpu_cap(struct cpuinfo_x86 *c)
 {
        u32 eax, ebx, ecx, edx;
                c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a);
 
        init_scattered_cpuid_features(c);
+       init_speculation_control(c);
 
        /*
         * Clear/Set all flags overridden by options, after probe.
 
        if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64))
                c->microcode = intel_get_microcode_revision();
 
-       /*
-        * The Intel SPEC_CTRL CPUID bit implies IBRS and IBPB support,
-        * and they also have a different bit for STIBP support. Also,
-        * a hypervisor might have set the individual AMD bits even on
-        * Intel CPUs, for finer-grained selection of what's available.
-        */
-       if (cpu_has(c, X86_FEATURE_SPEC_CTRL)) {
-               set_cpu_cap(c, X86_FEATURE_IBRS);
-               set_cpu_cap(c, X86_FEATURE_IBPB);
-       }
-       if (cpu_has(c, X86_FEATURE_INTEL_STIBP))
-               set_cpu_cap(c, X86_FEATURE_STIBP);
-
        /* Now if any of them are set, check the blacklist and clear the lot */
-       if ((cpu_has(c, X86_FEATURE_IBRS) || cpu_has(c, X86_FEATURE_IBPB) ||
+       if ((cpu_has(c, X86_FEATURE_SPEC_CTRL) ||
+            cpu_has(c, X86_FEATURE_INTEL_STIBP) ||
+            cpu_has(c, X86_FEATURE_IBRS) || cpu_has(c, X86_FEATURE_IBPB) ||
             cpu_has(c, X86_FEATURE_STIBP)) && bad_spectre_microcode(c)) {
                pr_warn("Intel Spectre v2 broken microcode detected; disabling Speculation Control\n");
-               clear_cpu_cap(c, X86_FEATURE_IBRS);
-               clear_cpu_cap(c, X86_FEATURE_IBPB);
-               clear_cpu_cap(c, X86_FEATURE_STIBP);
-               clear_cpu_cap(c, X86_FEATURE_SPEC_CTRL);
-               clear_cpu_cap(c, X86_FEATURE_INTEL_STIBP);
+               setup_clear_cpu_cap(X86_FEATURE_IBRS);
+               setup_clear_cpu_cap(X86_FEATURE_IBPB);
+               setup_clear_cpu_cap(X86_FEATURE_STIBP);
+               setup_clear_cpu_cap(X86_FEATURE_SPEC_CTRL);
+               setup_clear_cpu_cap(X86_FEATURE_INTEL_STIBP);
        }
 
        /*