From cda58cde01f437d263b912c973af54355d81409e Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sun, 21 Jun 2009 15:25:36 +0800 Subject: [PATCH] ACPI MADT: Check existance of BSP in madt_check() --- sys/platform/pc32/i386/mp_madt.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sys/platform/pc32/i386/mp_madt.c b/sys/platform/pc32/i386/mp_madt.c index ba2fcb20f3..6f641effe7 100644 --- a/sys/platform/pc32/i386/mp_madt.c +++ b/sys/platform/pc32/i386/mp_madt.c @@ -37,6 +37,8 @@ #include #include +#include +#include #define ACPI_RSDP_EBDA_MAPSZ 1024 #define ACPI_RSDP_BIOS_MAPSZ 0x20000 @@ -458,6 +460,8 @@ madt_pass2(vm_paddr_t madt_paddr, int bsp_apic_id) struct madt_check_cbarg { int cpu_count; + int bsp_found; + int bsp_apic_id; }; static int @@ -470,8 +474,16 @@ madt_check_callback(void *xarg, const struct acpi_madt_ent *ent) return 0; lapic_ent = (const struct acpi_madt_lapic *)ent; - if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED) + if (lapic_ent->ml_flags & MADT_LAPIC_ENABLED) { arg->cpu_count++; + if (lapic_ent->ml_apic_id == arg->bsp_apic_id) { + if (arg->bsp_found) { + kprintf("madt_check: more than one BSP?\n"); + return EINVAL; + } + arg->bsp_found = 1; + } + } return 0; } @@ -503,10 +515,17 @@ madt_check(vm_paddr_t madt_paddr) } bzero(&arg, sizeof(arg)); + arg.bsp_apic_id = (cpu_procinfo & CPUID_LOCAL_APIC_ID) >> 24; + error = madt_iterate_entries(madt, madt_check_callback, &arg); if (!error) { - if (arg.cpu_count <= 1) + if (arg.cpu_count <= 1) { + kprintf("madt_check: less than 2 CPUs is found\n"); error = EOPNOTSUPP; + } else if (!arg.bsp_found) { + kprintf("madt_check: no BSP\n"); + error = EINVAL; + } } back: madt_sdth_unmap(&madt->madt_hdr); -- 2.11.4.GIT