Author: mmlr Date: 2011-05-16 15:25:45 +0200 (Mon, 16 May 2011) New Revision: 41529 Changeset: https://dev.haiku-os.org/changeset/41529 Modified: haiku/trunk/src/system/kernel/arch/x86/ioapic.cpp Log: Guard against IO-APICs with too many entries. We only support 64 entries because we use a 64 bit level triggered mask. In practice these don't exist as far as I know. If we encounter them at a later stage we need to revisit the mask. Modified: haiku/trunk/src/system/kernel/arch/x86/ioapic.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/ioapic.cpp 2011-05-16 12:57:40 UTC (rev 41528) +++ haiku/trunk/src/system/kernel/arch/x86/ioapic.cpp 2011-05-16 13:25:45 UTC (rev 41529) @@ -84,6 +84,7 @@ #define IO_APIC_INTERRUPT_VECTOR_SHIFT 0 #define IO_APIC_INTERRUPT_VECTOR_MASK 0xff +#define MAX_SUPPORTED_REDIRECTION_ENTRIES 64 #define ISA_INTERRUPT_COUNT 16 @@ -306,7 +307,7 @@ return ioapic.register_area; } - dprintf("mapped io-apic %u to %p\n", ioapic.number, ioapic.registers); + TRACE(("mapped io-apic %u to %p\n", ioapic.number, ioapic.registers)); ioapic.version = ioapic_read_32(ioapic, IO_APIC_VERSION); if (ioapic.version == 0xffffffff) { @@ -321,6 +322,12 @@ ioapic.max_redirection_entry = ((ioapic.version >> IO_APIC_MAX_REDIRECTION_ENTRY_SHIFT) & IO_APIC_MAX_REDIRECTION_ENTRY_MASK); + if (ioapic.max_redirection_entry >= MAX_SUPPORTED_REDIRECTION_ENTRIES) { + dprintf("io-apic %u entry count exceeds max supported, only using the " + "first %u entries", ioapic.number, + (uint8)MAX_SUPPORTED_REDIRECTION_ENTRIES); + ioapic.max_redirection_entry = MAX_SUPPORTED_REDIRECTION_ENTRIES - 1; + } ioapic.global_interrupt_last = ioapic.global_interrupt_base + ioapic.max_redirection_entry;