int init_processor_name(void) { #if !CONFIG_K8_REV_F_SUPPORT u32 EightBitBrandId; #endif u32 BrandId; u32 BrandTableIndex; u32 NN; u32 ModelNumber=0; msr_t progmsr; int i; const char *processor_name_string=NULL; char program_string[48]; unsigned int *program_values = (unsigned int *)program_string; #if !CONFIG_K8_REV_F_SUPPORT /* Find out which CPU brand it is */ EightBitBrandId = cpuid_ebx(0x00000001) & 0xff; BrandId = cpuid_ebx(0x80000001) & 0xffff; if(!EightBitBrandId && !BrandId) { BrandTableIndex = 0; NN = 0xffffff; } else if(!EightBitBrandId) { BrandTableIndex = (BrandId >> 6) & 0x3f; // BrandId[11:6] NN = BrandId & 0x3f; // // BrandId[6:0] } else {
static void __init ms_hyperv_init_platform(void) { int hv_host_info_eax; int hv_host_info_ebx; int hv_host_info_ecx; int hv_host_info_edx; /* * Extract the features and hints */ ms_hyperv.features = cpuid_eax(HYPERV_CPUID_FEATURES); ms_hyperv.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES); ms_hyperv.hints = cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO); pr_info("HyperV: features 0x%x, hints 0x%x\n", ms_hyperv.features, ms_hyperv.hints); /* * Extract host information. */ if (cpuid_eax(HVCPUID_VENDOR_MAXFUNCTION) >= HVCPUID_VERSION) { hv_host_info_eax = cpuid_eax(HVCPUID_VERSION); hv_host_info_ebx = cpuid_ebx(HVCPUID_VERSION); hv_host_info_ecx = cpuid_ecx(HVCPUID_VERSION); hv_host_info_edx = cpuid_edx(HVCPUID_VERSION); pr_info("Hyper-V Host Build:%d-%d.%d-%d-%d.%d\n", hv_host_info_eax, hv_host_info_ebx >> 16, hv_host_info_ebx & 0xFFFF, hv_host_info_ecx, hv_host_info_edx >> 24, hv_host_info_edx & 0xFFFFFF); }
static void __init init_hvm_pv_info(void) { int major, minor; uint32_t eax, ebx, ecx, edx, base; base = xen_cpuid_base(); eax = cpuid_eax(base + 1); major = eax >> 16; minor = eax & 0xffff; printk(KERN_INFO "Xen version %d.%d.\n", major, minor); xen_domain_type = XEN_HVM_DOMAIN; /* PVH set up hypercall page in xen_prepare_pvh(). */ if (xen_pvh_domain()) pv_info.name = "Xen PVH"; else { u64 pfn; uint32_t msr; pv_info.name = "Xen HVM"; msr = cpuid_ebx(base + 2); pfn = __pa(hypercall_page); wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); } xen_setup_features(); cpuid(base + 4, &eax, &ebx, &ecx, &edx); if (eax & XEN_HVM_CPUID_VCPU_ID_PRESENT) this_cpu_write(xen_vcpu_id, ebx); else this_cpu_write(xen_vcpu_id, smp_processor_id()); }
static int setup_intel_arch_watchdog(void) { unsigned int evntsel; unsigned ebx; /* * Check whether the Architectural PerfMon supports * Unhalted Core Cycles Event or not. * NOTE: Corresponding bit = 0 in ebp indicates event present. */ ebx = cpuid_ebx(10); if ((ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT)) return 0; nmi_perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0; clear_msr_range(MSR_ARCH_PERFMON_EVENTSEL0, 2); clear_msr_range(MSR_ARCH_PERFMON_PERFCTR0, 2); evntsel = ARCH_PERFMON_EVENTSEL_INT | ARCH_PERFMON_EVENTSEL_OS | ARCH_PERFMON_EVENTSEL_USR | ARCH_PERFMON_NMI_EVENT_SEL | ARCH_PERFMON_NMI_EVENT_UMASK; wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, evntsel, 0); wrmsrl(MSR_ARCH_PERFMON_PERFCTR0, -((u64)cpu_khz * 1000 / nmi_hz)); apic_write(APIC_LVTPC, APIC_DM_NMI); evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE; wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, evntsel, 0); return 1; }
void svm_asid_init(struct cpuinfo_x86 *c) { int nasids = 0; /* Check for erratum #170, and leave ASIDs disabled if it's present. */ if ( !cpu_has_amd_erratum(c, AMD_ERRATUM_170) ) nasids = cpuid_ebx(0x8000000A); hvm_asid_init(nasids); }
static void disable_intel_arch_watchdog(void) { unsigned ebx; /* * Check whether the Architectural PerfMon supports * Unhalted Core Cycles Event or not. * NOTE: Corresponding bit = 0 in ebp indicates event present. */ ebx = cpuid_ebx(10); if (!(ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT)) wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, 0, 0); }
/* * This routine (and those that it might call) should not use * anything that lives in .bss since that segment will be cleared later. */ void __init xen_prepare_pvh(void) { u32 msr; u64 pfn; if (pvh_start_info.magic != XEN_HVM_START_MAGIC_VALUE) { xen_raw_printk("Error: Unexpected magic value (0x%08x)\n", pvh_start_info.magic); BUG(); } xen_pvh = 1; msr = cpuid_ebx(xen_cpuid_base() + 2); pfn = __pa(hypercall_page); wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); init_pvh_bootparams(); }
static u8 mctGetProcessorPackageType(void) { /* FIXME: I guess this belongs wherever mctGetLogicalCPUID ends up ? */ u32 BrandId = cpuid_ebx(0x80000001); return (u8)((BrandId >> 28) & 0x0F); }
int init_processor_name(void) { /* variable names taken from fam10 revision guide for clarity */ u32 BrandId; /* CPUID Fn8000_0001_EBX */ u8 String1; /* BrandID[14:11] */ u8 String2; /* BrandID[3:0] */ u8 Model; /* BrandID[10:4] */ u8 Pg; /* BrandID[15] */ u8 PkgTyp; /* BrandID[31:28] */ u8 NC; /* CPUID Fn8000_0008_ECX */ const char *processor_name_string = unknown; char program_string[48]; u32 *p_program_string = (u32 *)program_string; msr_t msr; int i, j = 0, str2_checkNC = 1; const struct str_s *str, *str2; /* Find out which CPU brand it is */ BrandId = cpuid_ebx(0x80000001); String1 = (u8)((BrandId >> 11) & 0x0F); String2 = (u8)((BrandId >> 0) & 0x0F); Model = (u8)((BrandId >> 4) & 0x7F); Pg = (u8)((BrandId >> 15) & 0x01); PkgTyp = (u8)((BrandId >> 28) & 0x0F); NC = (u8)(cpuid_ecx(0x80000008) & 0xFF); /* null the string */ memset(program_string, 0, sizeof(program_string)); if (!Model) { processor_name_string = Pg ? thermal : sample; goto done; } switch (PkgTyp) { case 0: /* F1207 */ str = String1_socket_F; str2 = String2_socket_F; str2_checkNC = 0; break; case 1: /* AM2 */ str = String1_socket_AM2; str2 = String2_socket_AM2; break; case 5: /* C32 */ str = String1_socket_C32; str2 = String2_socket_C32; break; default: goto done; } /* String1 */ for (i = 0; str[i].value; i++) { if ((str[i].Pg == Pg) && (str[i].NC == NC) && (str[i].String == String1)) { processor_name_string = str[i].value; break; } } if (!str[i].value) goto done; j = strcpymax(program_string, processor_name_string, sizeof(program_string)); /* Translate Model from 01-99 to ASCII and put it on the end. * Numbers less than 10 should include a leading zero, e.g., 09.*/ if (Model < 100 && j < sizeof(program_string) - 2) { program_string[j++] = (Model / 10) + '0'; program_string[j++] = (Model % 10) + '0'; } processor_name_string = unknown2; /* String 2 */ for(i = 0; str2[i].value; i++) { if ((str2[i].Pg == Pg) && ((str2[i].NC == NC) || !str2_checkNC) && (str2[i].String == String2)) { processor_name_string = str2[i].value; break; } } done: strcpymax(&program_string[j], processor_name_string, sizeof(program_string) - j); printk(BIOS_DEBUG, "CPU model: %s\n", program_string); for (i = 0; i < 6; i++) { msr.lo = p_program_string[(2 * i) + 0]; msr.hi = p_program_string[(2 * i) + 1]; wrmsr_amd(0xC0010030 + i, msr); } return 0; }