hw: fix calculation of CPU count on x86_64

On x86 the CPU count is determined through ACPI's MADT by counting the
local APICs reported there. Some platforms report more APICs
than there are actual CPUs. These might be physically disabled CPUs.
Therefore, a check if the LAPIC is actually physically enabled in
hardware fixes this issue.

Thanks to Alex Boettcher

fixes #3376
This commit is contained in:
Sebastian Sumpf 2019-05-24 14:40:24 +02:00 committed by Christian Helmuth
parent 5611020f33
commit d417d26ce8
2 changed files with 11 additions and 3 deletions

View File

@ -175,7 +175,10 @@ Bootstrap::Platform::Board::Board()
Hw::for_each_apic_struct(*table,[&](Hw::Apic_madt const *e){
if (e->type == Hw::Apic_madt::LAPIC) {
Hw::Apic_madt::Lapic lapic(e);
cpus ++;
/* check if APIC is enabled in hardware */
if (lapic.valid())
cpus ++;
}
});
});
@ -190,7 +193,10 @@ Bootstrap::Platform::Board::Board()
Hw::for_each_apic_struct(*table,[&](Hw::Apic_madt const *e){
if (e->type == Hw::Apic_madt::LAPIC) {
Hw::Apic_madt::Lapic lapic(e);
cpus ++;
/* check if APIC is enabled in hardware */
if (lapic.valid())
cpus ++;
}
});
});

View File

@ -65,9 +65,11 @@ struct Hw::Apic_madt
struct Lapic : Genode::Mmio {
struct Flags : Register <0x04, 32> { enum { ENABLED = 1 }; };
struct Flags : Register <0x04, 32> { enum { VALID = 1 }; };
Lapic(Apic_madt const * a) : Mmio(reinterpret_cast<Genode::addr_t>(a)) { }
bool valid() { return read<Flags>() & Flags::VALID; };
};
} __attribute__((packed));