|
47 | 47 | #include <asm/pat.h>
|
48 | 48 | #include <asm/microcode.h>
|
49 | 49 | #include <asm/microcode_intel.h>
|
| 50 | +#include <asm/intel-family.h> |
| 51 | +#include <asm/cpu_device_id.h> |
50 | 52 |
|
51 | 53 | #ifdef CONFIG_X86_LOCAL_APIC
|
52 | 54 | #include <asm/uv/uv.h>
|
@@ -853,6 +855,41 @@ static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
|
853 | 855 | #endif
|
854 | 856 | }
|
855 | 857 |
|
| 858 | +static const __initdata struct x86_cpu_id cpu_no_speculation[] = { |
| 859 | + { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CEDARVIEW, X86_FEATURE_ANY }, |
| 860 | + { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CLOVERVIEW, X86_FEATURE_ANY }, |
| 861 | + { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_LINCROFT, X86_FEATURE_ANY }, |
| 862 | + { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PENWELL, X86_FEATURE_ANY }, |
| 863 | + { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PINEVIEW, X86_FEATURE_ANY }, |
| 864 | + { X86_VENDOR_CENTAUR, 5 }, |
| 865 | + { X86_VENDOR_INTEL, 5 }, |
| 866 | + { X86_VENDOR_NSC, 5 }, |
| 867 | + { X86_VENDOR_ANY, 4 }, |
| 868 | + {} |
| 869 | +}; |
| 870 | + |
| 871 | +static const __initdata struct x86_cpu_id cpu_no_meltdown[] = { |
| 872 | + { X86_VENDOR_AMD }, |
| 873 | + {} |
| 874 | +}; |
| 875 | + |
| 876 | +static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c) |
| 877 | +{ |
| 878 | + u64 ia32_cap = 0; |
| 879 | + |
| 880 | + if (x86_match_cpu(cpu_no_meltdown)) |
| 881 | + return false; |
| 882 | + |
| 883 | + if (cpu_has(c, X86_FEATURE_ARCH_CAPABILITIES)) |
| 884 | + rdmsrl(MSR_IA32_ARCH_CAPABILITIES, ia32_cap); |
| 885 | + |
| 886 | + /* Rogue Data Cache Load? No! */ |
| 887 | + if (ia32_cap & ARCH_CAP_RDCL_NO) |
| 888 | + return false; |
| 889 | + |
| 890 | + return true; |
| 891 | +} |
| 892 | + |
856 | 893 | /*
|
857 | 894 | * Do minimum CPU detection early.
|
858 | 895 | * Fields really needed: vendor, cpuid_level, family, model, mask,
|
@@ -900,11 +937,12 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
|
900 | 937 |
|
901 | 938 | setup_force_cpu_cap(X86_FEATURE_ALWAYS);
|
902 | 939 |
|
903 |
| - if (c->x86_vendor != X86_VENDOR_AMD) |
904 |
| - setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN); |
905 |
| - |
906 |
| - setup_force_cpu_bug(X86_BUG_SPECTRE_V1); |
907 |
| - setup_force_cpu_bug(X86_BUG_SPECTRE_V2); |
| 940 | + if (!x86_match_cpu(cpu_no_speculation)) { |
| 941 | + if (cpu_vulnerable_to_meltdown(c)) |
| 942 | + setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN); |
| 943 | + setup_force_cpu_bug(X86_BUG_SPECTRE_V1); |
| 944 | + setup_force_cpu_bug(X86_BUG_SPECTRE_V2); |
| 945 | + } |
908 | 946 |
|
909 | 947 | fpu__init_system(c);
|
910 | 948 |
|
|
0 commit comments