From 8ec8304d74c029ddb10be2b5b07c11dc0f768446 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 23 May 2020 13:43:34 +0200 Subject: [PATCH] Kernel: Tweak some suspicious casts in InterruptManagement This code needs a closer looking-into at some point. It doesn't seem entirely safe to be casting u32's to pointers like it does. --- Kernel/Interrupts/InterruptManagement.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp index b5e4284fd0..009e229ea4 100644 --- a/Kernel/Interrupts/InterruptManagement.cpp +++ b/Kernel/Interrupts/InterruptManagement.cpp @@ -215,7 +215,8 @@ void InterruptManagement::locate_apic_data() auto* ioapic_entry = (const ACPI::Structures::MADTEntries::IOAPIC*)madt_entry; dbg() << "IOAPIC found @ MADT entry " << entry_index << ", MMIO Registers @ Px" << String::format("%x", ioapic_entry->ioapic_address); m_interrupt_controllers.resize(1 + irq_controller_count); - m_interrupt_controllers[irq_controller_count] = adopt(*new IOAPIC(*(ioapic_mmio_regs*)ioapic_entry->ioapic_address, ioapic_entry->gsi_base)); + // FIXME: Casting ioapic_entry->ioapic_address below looks suspicious! + m_interrupt_controllers[irq_controller_count] = adopt(*new IOAPIC(*(ioapic_mmio_regs*)(FlatPtr)ioapic_entry->ioapic_address, ioapic_entry->gsi_base)); irq_controller_count++; } if (madt_entry->type == (u8)ACPI::Structures::MADTEntryType::InterruptSourceOverride) { @@ -227,7 +228,7 @@ void InterruptManagement::locate_apic_data() interrupt_override_entry->flags); dbg() << "Interrupts: Overriding INT 0x" << String::format("%x", interrupt_override_entry->source) << " with GSI " << interrupt_override_entry->global_system_interrupt << ", for bus 0x" << String::format("%x", interrupt_override_entry->bus); } - madt_entry = (ACPI::Structures::MADTEntryHeader*)(VirtualAddress((u32)madt_entry).offset(entry_length).get()); + madt_entry = (ACPI::Structures::MADTEntryHeader*)(VirtualAddress(madt_entry).offset(entry_length).get()); entries_length -= entry_length; entry_index++; }