summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86/machine/biosmem.c11
-rw-r--r--arch/x86/machine/cpu.h24
-rw-r--r--arch/x86/machine/pmu_amd.c4
-rw-r--r--arch/x86/machine/pmu_intel.c4
4 files changed, 33 insertions, 10 deletions
diff --git a/arch/x86/machine/biosmem.c b/arch/x86/machine/biosmem.c
index 370c5615..8e2108c7 100644
--- a/arch/x86/machine/biosmem.c
+++ b/arch/x86/machine/biosmem.c
@@ -849,19 +849,18 @@ biosmem_load_zone(struct biosmem_zone *zone, uint64_t max_phys_end)
static int __init
biosmem_setup(void)
{
+ unsigned int phys_addr_width;
uint64_t max_phys_end;
struct biosmem_zone *zone;
- struct cpu *cpu;
- unsigned int i;
biosmem_map_show();
- cpu = cpu_current();
- max_phys_end = (cpu->phys_addr_width == 0)
+ phys_addr_width = cpu_phys_addr_width(cpu_current());
+ max_phys_end = ((phys_addr_width == 0) || (phys_addr_width == 64))
? (uint64_t)-1
- : (uint64_t)1 << cpu->phys_addr_width;
+ : (uint64_t)1 << phys_addr_width;
- for (i = 0; i < ARRAY_SIZE(biosmem_zones); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(biosmem_zones); i++) {
if (biosmem_zone_size(i) == 0) {
break;
}
diff --git a/arch/x86/machine/cpu.h b/arch/x86/machine/cpu.h
index 28308042..0c4e6e1d 100644
--- a/arch/x86/machine/cpu.h
+++ b/arch/x86/machine/cpu.h
@@ -638,6 +638,30 @@ cpu_tlb_flush_va(unsigned long va)
asm volatile("invlpg (%0)" : : "r" (va) : "memory");
}
+static inline unsigned int
+cpu_cpuid_max_basic(const struct cpu *cpu)
+{
+ return cpu->cpuid_max_basic;
+}
+
+static inline unsigned int
+cpu_vendor_id(const struct cpu *cpu)
+{
+ return cpu->vendor_id;
+}
+
+static inline unsigned int
+cpu_family(const struct cpu *cpu)
+{
+ return cpu->family;
+}
+
+static inline unsigned int
+cpu_phys_addr_width(const struct cpu *cpu)
+{
+ return cpu->phys_addr_width;
+}
+
/*
* Get CPU frequency in Hz.
*/
diff --git a/arch/x86/machine/pmu_amd.c b/arch/x86/machine/pmu_amd.c
index c3e56429..b26e3293 100644
--- a/arch/x86/machine/pmu_amd.c
+++ b/arch/x86/machine/pmu_amd.c
@@ -215,11 +215,11 @@ pmu_amd_setup(void)
cpu = cpu_current();
- if (cpu->vendor_id != CPU_VENDOR_AMD) {
+ if (cpu_vendor_id(cpu) != CPU_VENDOR_AMD) {
return ENODEV;
}
- if (cpu->family < 0x10) {
+ if (cpu_family(cpu) < 0x10) {
return ENODEV;
}
diff --git a/arch/x86/machine/pmu_intel.c b/arch/x86/machine/pmu_intel.c
index f2a26499..c1ee3885 100644
--- a/arch/x86/machine/pmu_intel.c
+++ b/arch/x86/machine/pmu_intel.c
@@ -336,11 +336,11 @@ pmu_intel_setup(void)
cpu = cpu_current();
eax = 0xa;
- if (cpu->vendor_id != CPU_VENDOR_INTEL) {
+ if (cpu_vendor_id(cpu) != CPU_VENDOR_INTEL) {
return 0;
}
- if (cpu->cpuid_max_basic < eax) {
+ if (cpu_cpuid_max_basic(cpu) < eax) {
return ENODEV;
}