base-hw: explicit bounds check in store_apic_id

Avoid relying on the caller regarding the CPU index argument to ease the
reasoning about the code.
This commit is contained in:
Norman Feske 2020-01-07 17:32:12 +01:00 committed by Christian Helmuth
parent 01713c74f9
commit 5635c1318c
1 changed files with 6 additions and 3 deletions

View File

@ -209,9 +209,12 @@ class Board::Pic : public Genode::Mmio
void irq_mode(unsigned irq, unsigned trigger, unsigned polarity);
void store_apic_id(unsigned const cpu_id) {
Id::access_t const lapic_id = read<Id>();
lapic_ids[cpu_id] = (lapic_id >> 24) & 0xff;
void store_apic_id(unsigned const cpu_id)
{
if (cpu_id < NR_OF_CPUS) {
Id::access_t const lapic_id = read<Id>();
lapic_ids[cpu_id] = (lapic_id >> 24) & 0xff;
}
}
void send_ipi(unsigned const);