Kernel: FIX ubsan complaining about unaligned addresses for STDHeaders

This commit is contained in:
Bananymous 2023-03-08 22:55:44 +02:00
parent 371dfe8ef3
commit 2e6e0d0ef5
1 changed files with 4 additions and 2 deletions

View File

@ -185,11 +185,13 @@ uintptr_t locate_madt(uintptr_t rsdp_addr)
uintptr_t entry_addr_ptr = entry_address_base + i * entry_pointer_size;
MMU::get().allocate_page(entry_addr_ptr, MMU::Flags::ReadWrite | MMU::Flags::Present);
union dummy { uint32_t addr32; uint64_t addr64; } __attribute__((aligned(1), packed));
uintptr_t entry_addr;
if (entry_pointer_size == 4)
entry_addr = *(uint32_t*)entry_addr_ptr;
entry_addr = ((dummy*)entry_addr_ptr)->addr32;
else
entry_addr = *(uint64_t*)entry_addr_ptr;
entry_addr = ((dummy*)entry_addr_ptr)->addr64;
MMU::get().allocate_page(entry_addr, MMU::Flags::ReadWrite | MMU::Flags::Present);