rust-osdev/acpi

MADT parsing: processor_count is wrong for x2apic only tables

julienfreche opened this issue · 2 comments

I believe I saw an issue in this code:

        // Do a pass over the entries so we know how much space we should reserve in the vectors
        for entry in self.entries() {
            match entry {
                MadtEntry::IoApic(_) => io_apic_count += 1,
                MadtEntry::InterruptSourceOverride(_) => iso_count += 1,
                MadtEntry::NmiSource(_) => nmi_source_count += 1,
                MadtEntry::LocalApicNmi(_) => local_nmi_line_count += 1,
                MadtEntry::LocalApic(_) => processor_count += 1,
                _ => (),             <========= MadtEntry::LocalX2Apic not considered?
            }
        }

Down the road that leads to

                    if is_ap {
                        application_processors[processor_count] = processor;  <===== index out of bound
                        processor_count += 1;
                    } else {
                        boot_processor = Some(processor);
                    }

I guess the issue is only visible for platforms exposing x2apic only (no apic otherwise, some LocalApic entries would be populated)

Fixed by #204.

Thanks for filing this issue! The linked PR should have fixed the problem.

I appreciate the fix and the update!