Lines Matching refs:c

136 static void ppin_init(struct cpuinfo_x86 *c)  in ppin_init()  argument
168 c->ppin = native_rdmsrq(info->msr_ppin); in ppin_init()
169 set_cpu_cap(c, info->feature); in ppin_init()
177 static void default_init(struct cpuinfo_x86 *c) in default_init() argument
180 cpu_detect_cache_sizes(c); in default_init()
184 if (c->cpuid_level == -1) { in default_init()
186 if (c->x86 == 4) in default_init()
187 strcpy(c->x86_model_id, "486"); in default_init()
188 else if (c->x86 == 3) in default_init()
189 strcpy(c->x86_model_id, "386"); in default_init()
331 static void squash_the_stupid_serial_number(struct cpuinfo_x86 *c) in squash_the_stupid_serial_number() argument
335 if (!cpu_has(c, X86_FEATURE_PN) || !disable_x86_serial_nr) in squash_the_stupid_serial_number()
345 clear_cpu_cap(c, X86_FEATURE_PN); in squash_the_stupid_serial_number()
348 c->cpuid_level = cpuid_eax(0); in squash_the_stupid_serial_number()
358 static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c) in squash_the_stupid_serial_number() argument
363 static __always_inline void setup_smep(struct cpuinfo_x86 *c) in setup_smep() argument
365 if (cpu_has(c, X86_FEATURE_SMEP)) in setup_smep()
369 static __always_inline void setup_smap(struct cpuinfo_x86 *c) in setup_smap() argument
376 if (cpu_has(c, X86_FEATURE_SMAP)) in setup_smap()
380 static __always_inline void setup_umip(struct cpuinfo_x86 *c) in setup_umip() argument
387 if (!cpu_has(c, X86_FEATURE_UMIP)) in setup_umip()
519 static __always_inline void setup_pku(struct cpuinfo_x86 *c) in setup_pku() argument
521 if (c == &boot_cpu_data) { in setup_pku()
589 static __always_inline void setup_cet(struct cpuinfo_x86 *c) in setup_cet() argument
604 set_cpu_cap(c, X86_FEATURE_USER_SHSTK); in setup_cet()
648 static void filter_cpuid_features(struct cpuinfo_x86 *c, bool warn) in filter_cpuid_features() argument
654 if (!cpu_has(c, df->feature)) in filter_cpuid_features()
664 (u32)df->level > (u32)c->extended_cpuid_level : in filter_cpuid_features()
665 (s32)df->level > (s32)c->cpuid_level)) in filter_cpuid_features()
668 clear_cpu_cap(c, df->feature); in filter_cpuid_features()
685 static const char *table_lookup_model(struct cpuinfo_x86 *c) in table_lookup_model() argument
690 if (c->x86_model >= 16) in table_lookup_model()
699 if (info->family == c->x86) in table_lookup_model()
700 return info->model_names[c->x86_model]; in table_lookup_model()
781 static void get_model_name(struct cpuinfo_x86 *c) in get_model_name() argument
786 if (c->extended_cpuid_level < 0x80000004) in get_model_name()
789 v = (unsigned int *)c->x86_model_id; in get_model_name()
793 c->x86_model_id[48] = 0; in get_model_name()
796 p = q = s = &c->x86_model_id[0]; in get_model_name()
812 void cpu_detect_cache_sizes(struct cpuinfo_x86 *c) in cpu_detect_cache_sizes() argument
816 n = c->extended_cpuid_level; in cpu_detect_cache_sizes()
820 c->x86_cache_size = (ecx>>24) + (edx>>24); in cpu_detect_cache_sizes()
823 c->x86_tlbsize = 0; in cpu_detect_cache_sizes()
834 c->x86_tlbsize += ((ebx >> 16) & 0xfff) + (ebx & 0xfff); in cpu_detect_cache_sizes()
838 l2size = this_cpu->legacy_cache_size(c, l2size); in cpu_detect_cache_sizes()
848 c->x86_cache_size = l2size; in cpu_detect_cache_sizes()
859 static void cpu_detect_tlb(struct cpuinfo_x86 *c) in cpu_detect_tlb() argument
862 this_cpu->c_detect_tlb(c); in cpu_detect_tlb()
871 void get_cpu_vendor(struct cpuinfo_x86 *c) in get_cpu_vendor() argument
873 char *v = c->x86_vendor_id; in get_cpu_vendor()
885 c->x86_vendor = this_cpu->c_x86_vendor; in get_cpu_vendor()
893 c->x86_vendor = X86_VENDOR_UNKNOWN; in get_cpu_vendor()
897 void cpu_detect(struct cpuinfo_x86 *c) in cpu_detect() argument
900 cpuid(0x00000000, (unsigned int *)&c->cpuid_level, in cpu_detect()
901 (unsigned int *)&c->x86_vendor_id[0], in cpu_detect()
902 (unsigned int *)&c->x86_vendor_id[8], in cpu_detect()
903 (unsigned int *)&c->x86_vendor_id[4]); in cpu_detect()
905 c->x86 = 4; in cpu_detect()
907 if (c->cpuid_level >= 0x00000001) { in cpu_detect()
911 c->x86 = x86_family(tfms); in cpu_detect()
912 c->x86_model = x86_model(tfms); in cpu_detect()
913 c->x86_stepping = x86_stepping(tfms); in cpu_detect()
916 c->x86_clflush_size = ((misc >> 8) & 0xff) * 8; in cpu_detect()
917 c->x86_cache_alignment = c->x86_clflush_size; in cpu_detect()
922 static void apply_forced_caps(struct cpuinfo_x86 *c) in apply_forced_caps() argument
927 c->x86_capability[i] &= ~cpu_caps_cleared[i]; in apply_forced_caps()
928 c->x86_capability[i] |= cpu_caps_set[i]; in apply_forced_caps()
932 static void init_speculation_control(struct cpuinfo_x86 *c) in init_speculation_control() argument
940 if (cpu_has(c, X86_FEATURE_SPEC_CTRL)) { in init_speculation_control()
941 set_cpu_cap(c, X86_FEATURE_IBRS); in init_speculation_control()
942 set_cpu_cap(c, X86_FEATURE_IBPB); in init_speculation_control()
943 set_cpu_cap(c, X86_FEATURE_MSR_SPEC_CTRL); in init_speculation_control()
946 if (cpu_has(c, X86_FEATURE_INTEL_STIBP)) in init_speculation_control()
947 set_cpu_cap(c, X86_FEATURE_STIBP); in init_speculation_control()
949 if (cpu_has(c, X86_FEATURE_SPEC_CTRL_SSBD) || in init_speculation_control()
950 cpu_has(c, X86_FEATURE_VIRT_SSBD)) in init_speculation_control()
951 set_cpu_cap(c, X86_FEATURE_SSBD); in init_speculation_control()
953 if (cpu_has(c, X86_FEATURE_AMD_IBRS)) { in init_speculation_control()
954 set_cpu_cap(c, X86_FEATURE_IBRS); in init_speculation_control()
955 set_cpu_cap(c, X86_FEATURE_MSR_SPEC_CTRL); in init_speculation_control()
958 if (cpu_has(c, X86_FEATURE_AMD_IBPB)) in init_speculation_control()
959 set_cpu_cap(c, X86_FEATURE_IBPB); in init_speculation_control()
961 if (cpu_has(c, X86_FEATURE_AMD_STIBP)) { in init_speculation_control()
962 set_cpu_cap(c, X86_FEATURE_STIBP); in init_speculation_control()
963 set_cpu_cap(c, X86_FEATURE_MSR_SPEC_CTRL); in init_speculation_control()
966 if (cpu_has(c, X86_FEATURE_AMD_SSBD)) { in init_speculation_control()
967 set_cpu_cap(c, X86_FEATURE_SSBD); in init_speculation_control()
968 set_cpu_cap(c, X86_FEATURE_MSR_SPEC_CTRL); in init_speculation_control()
969 clear_cpu_cap(c, X86_FEATURE_VIRT_SSBD); in init_speculation_control()
973 void get_cpu_cap(struct cpuinfo_x86 *c) in get_cpu_cap() argument
978 if (c->cpuid_level >= 0x00000001) { in get_cpu_cap()
981 c->x86_capability[CPUID_1_ECX] = ecx; in get_cpu_cap()
982 c->x86_capability[CPUID_1_EDX] = edx; in get_cpu_cap()
986 if (c->cpuid_level >= 0x00000006) in get_cpu_cap()
987 c->x86_capability[CPUID_6_EAX] = cpuid_eax(0x00000006); in get_cpu_cap()
990 if (c->cpuid_level >= 0x00000007) { in get_cpu_cap()
992 c->x86_capability[CPUID_7_0_EBX] = ebx; in get_cpu_cap()
993 c->x86_capability[CPUID_7_ECX] = ecx; in get_cpu_cap()
994 c->x86_capability[CPUID_7_EDX] = edx; in get_cpu_cap()
999 c->x86_capability[CPUID_7_1_EAX] = eax; in get_cpu_cap()
1004 if (c->cpuid_level >= 0x0000000d) { in get_cpu_cap()
1007 c->x86_capability[CPUID_D_1_EAX] = eax; in get_cpu_cap()
1015 c->extended_cpuid_level = ((eax & 0xffff0000) == 0x80000000) ? eax : 0; in get_cpu_cap()
1017 if (c->extended_cpuid_level >= 0x80000001) { in get_cpu_cap()
1020 c->x86_capability[CPUID_8000_0001_ECX] = ecx; in get_cpu_cap()
1021 c->x86_capability[CPUID_8000_0001_EDX] = edx; in get_cpu_cap()
1024 if (c->extended_cpuid_level >= 0x80000007) { in get_cpu_cap()
1027 c->x86_capability[CPUID_8000_0007_EBX] = ebx; in get_cpu_cap()
1028 c->x86_power = edx; in get_cpu_cap()
1031 if (c->extended_cpuid_level >= 0x80000008) { in get_cpu_cap()
1033 c->x86_capability[CPUID_8000_0008_EBX] = ebx; in get_cpu_cap()
1036 if (c->extended_cpuid_level >= 0x8000000a) in get_cpu_cap()
1037 c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a); in get_cpu_cap()
1039 if (c->extended_cpuid_level >= 0x8000001f) in get_cpu_cap()
1040 c->x86_capability[CPUID_8000_001F_EAX] = cpuid_eax(0x8000001f); in get_cpu_cap()
1042 if (c->extended_cpuid_level >= 0x80000021) in get_cpu_cap()
1043 c->x86_capability[CPUID_8000_0021_EAX] = cpuid_eax(0x80000021); in get_cpu_cap()
1045 init_scattered_cpuid_features(c); in get_cpu_cap()
1046 init_speculation_control(c); in get_cpu_cap()
1053 apply_forced_caps(c); in get_cpu_cap()
1056 void get_cpu_address_sizes(struct cpuinfo_x86 *c) in get_cpu_address_sizes() argument
1060 if (!cpu_has(c, X86_FEATURE_CPUID) || in get_cpu_address_sizes()
1061 (c->extended_cpuid_level < 0x80000008)) { in get_cpu_address_sizes()
1063 c->x86_clflush_size = 64; in get_cpu_address_sizes()
1064 c->x86_phys_bits = 36; in get_cpu_address_sizes()
1065 c->x86_virt_bits = 48; in get_cpu_address_sizes()
1067 c->x86_clflush_size = 32; in get_cpu_address_sizes()
1068 c->x86_virt_bits = 32; in get_cpu_address_sizes()
1069 c->x86_phys_bits = 32; in get_cpu_address_sizes()
1071 if (cpu_has(c, X86_FEATURE_PAE) || in get_cpu_address_sizes()
1072 cpu_has(c, X86_FEATURE_PSE36)) in get_cpu_address_sizes()
1073 c->x86_phys_bits = 36; in get_cpu_address_sizes()
1078 c->x86_virt_bits = (eax >> 8) & 0xff; in get_cpu_address_sizes()
1079 c->x86_phys_bits = eax & 0xff; in get_cpu_address_sizes()
1082 if (!c->x86_clflush_size) in get_cpu_address_sizes()
1083 c->x86_clflush_size = 32; in get_cpu_address_sizes()
1086 c->x86_cache_bits = c->x86_phys_bits; in get_cpu_address_sizes()
1087 c->x86_cache_alignment = c->x86_clflush_size; in get_cpu_address_sizes()
1090 static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c) in identify_cpu_without_cpuid() argument
1099 c->x86 = 4; in identify_cpu_without_cpuid()
1101 c->x86 = 3; in identify_cpu_without_cpuid()
1105 c->x86_vendor_id[0] = 0; in identify_cpu_without_cpuid()
1106 cpu_devs[i]->c_identify(c); in identify_cpu_without_cpuid()
1107 if (c->x86_vendor_id[0]) { in identify_cpu_without_cpuid()
1108 get_cpu_vendor(c); in identify_cpu_without_cpuid()
1395 static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c) in cpu_set_bug_bits() argument
1422 !cpu_has(c, X86_FEATURE_AMD_SSB_NO)) in cpu_set_bug_bits()
1433 (cpu_has(c, X86_FEATURE_AUTOIBRS) && in cpu_set_bug_bits()
1462 (cpu_has(c, X86_FEATURE_RTM) || in cpu_set_bug_bits()
1474 if ((cpu_has(c, X86_FEATURE_RDRAND) || in cpu_set_bug_bits()
1475 cpu_has(c, X86_FEATURE_RDSEED)) && in cpu_set_bug_bits()
1491 if (!cpu_has(c, X86_FEATURE_BTC_NO)) { in cpu_set_bug_bits()
1499 if (!cpu_has(c, X86_FEATURE_SRSO_NO)) { in cpu_set_bug_bits()
1527 if (cpu_has(c, X86_FEATURE_AMD_IBPB) && !cpu_has(c, X86_FEATURE_AMD_IBPB_RET)) in cpu_set_bug_bits()
1536 if (c->x86_vendor == X86_VENDOR_AMD) { in cpu_set_bug_bits()
1537 if (!cpu_has(c, X86_FEATURE_TSA_SQ_NO) || in cpu_set_bug_bits()
1538 !cpu_has(c, X86_FEATURE_TSA_L1_NO)) { in cpu_set_bug_bits()
1541 (cpu_has(c, X86_FEATURE_HYPERVISOR) && cpu_has(c, X86_FEATURE_ZEN))) in cpu_set_bug_bits()
1722 static void __init early_identify_cpu(struct cpuinfo_x86 *c) in early_identify_cpu() argument
1724 memset(&c->x86_capability, 0, sizeof(c->x86_capability)); in early_identify_cpu()
1725 c->extended_cpuid_level = 0; in early_identify_cpu()
1728 identify_cpu_without_cpuid(c); in early_identify_cpu()
1732 cpu_detect(c); in early_identify_cpu()
1733 get_cpu_vendor(c); in early_identify_cpu()
1734 intel_unlock_cpuid_leafs(c); in early_identify_cpu()
1735 get_cpu_cap(c); in early_identify_cpu()
1737 get_cpu_address_sizes(c); in early_identify_cpu()
1740 cpu_init_topology(c); in early_identify_cpu()
1743 this_cpu->c_early_init(c); in early_identify_cpu()
1745 c->cpu_index = 0; in early_identify_cpu()
1746 filter_cpuid_features(c, false); in early_identify_cpu()
1747 check_cpufeature_deps(c); in early_identify_cpu()
1750 this_cpu->c_bsp_init(c); in early_identify_cpu()
1753 get_cpu_address_sizes(c); in early_identify_cpu()
1754 cpu_init_topology(c); in early_identify_cpu()
1759 cpu_set_bug_bits(c); in early_identify_cpu()
1761 sld_setup(c); in early_identify_cpu()
1854 void check_null_seg_clears_base(struct cpuinfo_x86 *c) in check_null_seg_clears_base() argument
1860 if (cpu_has(c, X86_FEATURE_NULL_SEL_CLR_BASE)) in check_null_seg_clears_base()
1870 if (cpu_has(c, X86_FEATURE_HYPERVISOR)) { in check_null_seg_clears_base()
1871 set_cpu_bug(c, X86_BUG_NULL_SEG); in check_null_seg_clears_base()
1879 if ((c->x86 == 0x17 || c->x86 == 0x18) && in check_null_seg_clears_base()
1884 set_cpu_bug(c, X86_BUG_NULL_SEG); in check_null_seg_clears_base()
1887 static void generic_identify(struct cpuinfo_x86 *c) in generic_identify() argument
1889 c->extended_cpuid_level = 0; in generic_identify()
1892 identify_cpu_without_cpuid(c); in generic_identify()
1898 cpu_detect(c); in generic_identify()
1900 get_cpu_vendor(c); in generic_identify()
1901 intel_unlock_cpuid_leafs(c); in generic_identify()
1902 get_cpu_cap(c); in generic_identify()
1904 get_cpu_address_sizes(c); in generic_identify()
1906 get_model_name(c); /* Default name */ in generic_identify()
1922 set_cpu_bug(c, X86_BUG_ESPFIX); in generic_identify()
1929 static void identify_cpu(struct cpuinfo_x86 *c) in identify_cpu() argument
1933 c->loops_per_jiffy = loops_per_jiffy; in identify_cpu()
1934 c->x86_cache_size = 0; in identify_cpu()
1935 c->x86_vendor = X86_VENDOR_UNKNOWN; in identify_cpu()
1936 c->x86_model = c->x86_stepping = 0; /* So far unknown... */ in identify_cpu()
1937 c->x86_vendor_id[0] = '\0'; /* Unset */ in identify_cpu()
1938 c->x86_model_id[0] = '\0'; /* Unset */ in identify_cpu()
1940 c->x86_clflush_size = 64; in identify_cpu()
1941 c->x86_phys_bits = 36; in identify_cpu()
1942 c->x86_virt_bits = 48; in identify_cpu()
1944 c->cpuid_level = -1; /* CPUID not detected */ in identify_cpu()
1945 c->x86_clflush_size = 32; in identify_cpu()
1946 c->x86_phys_bits = 32; in identify_cpu()
1947 c->x86_virt_bits = 32; in identify_cpu()
1949 c->x86_cache_alignment = c->x86_clflush_size; in identify_cpu()
1950 memset(&c->x86_capability, 0, sizeof(c->x86_capability)); in identify_cpu()
1952 memset(&c->vmx_capability, 0, sizeof(c->vmx_capability)); in identify_cpu()
1955 generic_identify(c); in identify_cpu()
1957 cpu_parse_topology(c); in identify_cpu()
1960 this_cpu->c_identify(c); in identify_cpu()
1963 apply_forced_caps(c); in identify_cpu()
1969 set_cpu_cap(c, X86_FEATURE_APIC_MSRS_FENCE); in identify_cpu()
1982 this_cpu->c_init(c); in identify_cpu()
1987 squash_the_stupid_serial_number(c); in identify_cpu()
1990 setup_smep(c); in identify_cpu()
1991 setup_smap(c); in identify_cpu()
1992 setup_umip(c); in identify_cpu()
1995 if (cpu_has(c, X86_FEATURE_FSGSBASE)) { in identify_cpu()
2006 filter_cpuid_features(c, true); in identify_cpu()
2009 check_cpufeature_deps(c); in identify_cpu()
2012 if (!c->x86_model_id[0]) { in identify_cpu()
2014 p = table_lookup_model(c); in identify_cpu()
2016 strcpy(c->x86_model_id, p); in identify_cpu()
2019 sprintf(c->x86_model_id, "%02x/%02x", in identify_cpu()
2020 c->x86, c->x86_model); in identify_cpu()
2023 x86_init_rdrand(c); in identify_cpu()
2024 setup_pku(c); in identify_cpu()
2025 setup_cet(c); in identify_cpu()
2031 apply_forced_caps(c); in identify_cpu()
2039 if (c != &boot_cpu_data) { in identify_cpu()
2042 boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; in identify_cpu()
2046 c->x86_capability[i] |= boot_cpu_data.x86_capability[i]; in identify_cpu()
2049 ppin_init(c); in identify_cpu()
2052 mcheck_cpu_init(c); in identify_cpu()
2105 struct cpuinfo_x86 *c = &cpu_data(cpu); in identify_secondary_cpu() local
2108 if (!c->initialized) in identify_secondary_cpu()
2109 *c = boot_cpu_data; in identify_secondary_cpu()
2110 c->cpu_index = cpu; in identify_secondary_cpu()
2112 identify_cpu(c); in identify_secondary_cpu()
2122 c->initialized = true; in identify_secondary_cpu()
2125 void print_cpu_info(struct cpuinfo_x86 *c) in print_cpu_info() argument
2129 if (c->x86_vendor < X86_VENDOR_NUM) { in print_cpu_info()
2132 if (c->cpuid_level >= 0) in print_cpu_info()
2133 vendor = c->x86_vendor_id; in print_cpu_info()
2136 if (vendor && !strstr(c->x86_model_id, vendor)) in print_cpu_info()
2139 if (c->x86_model_id[0]) in print_cpu_info()
2140 pr_cont("%s", c->x86_model_id); in print_cpu_info()
2142 pr_cont("%d86", c->x86); in print_cpu_info()
2144 pr_cont(" (family: 0x%x, model: 0x%x", c->x86, c->x86_model); in print_cpu_info()
2146 if (c->x86_stepping || c->cpuid_level >= 0) in print_cpu_info()
2147 pr_cont(", stepping: 0x%x)\n", c->x86_stepping); in print_cpu_info()
2501 struct cpuinfo_x86 *c = this_cpu_ptr(&cpu_info); in arch_cpu_finalize_init() local
2551 *c = boot_cpu_data; in arch_cpu_finalize_init()
2552 c->initialized = true; in arch_cpu_finalize_init()