From 22d72c8ee12897715e08a5ec1ca105c3aa968b11 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 16 May 2011 13:25:45 +0000 Subject: [PATCH] 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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41529 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/arch/x86/ioapic.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/arch/x86/ioapic.cpp b/src/system/kernel/arch/x86/ioapic.cpp index 1bd90593ed..64b018fc53 100644 --- a/src/system/kernel/arch/x86/ioapic.cpp +++ b/src/system/kernel/arch/x86/ioapic.cpp @@ -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 @@ ioapic_map_ioapic(struct ioapic& ioapic, phys_addr_t physicalAddress) 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_map_ioapic(struct ioapic& ioapic, phys_addr_t physicalAddress) 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;