x86, cpu, amd: Add workaround for family 16h, erratum 793
[pandora-kernel.git] / arch / x86 / kernel / cpu / amd.c
index f07becc..60d4c33 100644 (file)
@@ -408,6 +408,16 @@ static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
 
        c->x86_coreid_bits = bits;
 #endif
+
+       /* F16h erratum 793, CVE-2013-6885 */
+       if (c->x86 == 0x16 && c->x86_model <= 0xf) {
+               u64 val;
+
+               if (!rdmsrl_amd_safe(MSR_AMD64_LS_CFG, &val) &&
+                   !(val & BIT(15)))
+                       wrmsrl_amd_safe(MSR_AMD64_LS_CFG, val | BIT(15));
+       }
+
 }
 
 static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c)
@@ -469,6 +479,13 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
                        set_cpu_cap(c, X86_FEATURE_EXTD_APICID);
        }
 #endif
+
+       /*
+        * This is only needed to tell the kernel whether to use VMCALL
+        * and VMMCALL.  VMMCALL is never executed except under virt, so
+        * we can set it unconditionally.
+        */
+       set_cpu_cap(c, X86_FEATURE_VMMCALL);
 }
 
 static void __cpuinit init_amd(struct cpuinfo_x86 *c)