mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-18 17:00:26 +00:00
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:
parent
5611020f33
commit
d417d26ce8
@ -175,7 +175,10 @@ Bootstrap::Platform::Board::Board()
|
|||||||
Hw::for_each_apic_struct(*table,[&](Hw::Apic_madt const *e){
|
Hw::for_each_apic_struct(*table,[&](Hw::Apic_madt const *e){
|
||||||
if (e->type == Hw::Apic_madt::LAPIC) {
|
if (e->type == Hw::Apic_madt::LAPIC) {
|
||||||
Hw::Apic_madt::Lapic lapic(e);
|
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){
|
Hw::for_each_apic_struct(*table,[&](Hw::Apic_madt const *e){
|
||||||
if (e->type == Hw::Apic_madt::LAPIC) {
|
if (e->type == Hw::Apic_madt::LAPIC) {
|
||||||
Hw::Apic_madt::Lapic lapic(e);
|
Hw::Apic_madt::Lapic lapic(e);
|
||||||
cpus ++;
|
|
||||||
|
/* check if APIC is enabled in hardware */
|
||||||
|
if (lapic.valid())
|
||||||
|
cpus ++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -65,9 +65,11 @@ struct Hw::Apic_madt
|
|||||||
|
|
||||||
struct Lapic : Genode::Mmio {
|
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)) { }
|
Lapic(Apic_madt const * a) : Mmio(reinterpret_cast<Genode::addr_t>(a)) { }
|
||||||
|
|
||||||
|
bool valid() { return read<Flags>() & Flags::VALID; };
|
||||||
};
|
};
|
||||||
|
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user