diff --git a/AK/Types.h b/AK/Types.h index 96292d8e1d3..38086047f24 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -65,14 +65,24 @@ namespace std { using nullptr_t = decltype(nullptr); } -static constexpr u32 explode_byte(u8 b) +static constexpr FlatPtr explode_byte(u8 b) { - return b << 24 | b << 16 | b << 8 | b; +#if ARCH(I386) + return (u32)b << 24 | (u32)b << 16 | (u32)b << 8 | (u32)b; +#else + return (u64)b << 56 | (u64)b << 48 | (u64)b << 40 | (u64)b << 32 | (u64)b << 24 | (u64)b << 16 | (u64)b << 8 | (u64)b; +#endif } +#if ARCH(I386) static_assert(explode_byte(0xff) == 0xffffffff); static_assert(explode_byte(0x80) == 0x80808080); static_assert(explode_byte(0x7f) == 0x7f7f7f7f); +#else +static_assert(explode_byte(0xff) == 0xffffffffffffffff); +static_assert(explode_byte(0x80) == 0x8080808080808080); +static_assert(explode_byte(0x7f) == 0x7f7f7f7f7f7f7f7f); +#endif static_assert(explode_byte(0) == 0); constexpr size_t align_up_to(const size_t value, const size_t alignment) diff --git a/Kernel/Arch/x86/common/Interrupts.cpp b/Kernel/Arch/x86/common/Interrupts.cpp index 7200f37dfa7..fc85ac4345b 100644 --- a/Kernel/Arch/x86/common/Interrupts.cpp +++ b/Kernel/Arch/x86/common/Interrupts.cpp @@ -356,12 +356,12 @@ void page_fault_handler(TrapFrame* trap) regs.exception_code & PageFaultFlags::InstructionFetch ? "instruction fetch / " : "", regs.exception_code & PageFaultFlags::Write ? "write to" : "read from", VirtualAddress(fault_address)); - u32 malloc_scrub_pattern = explode_byte(MALLOC_SCRUB_BYTE); - u32 free_scrub_pattern = explode_byte(FREE_SCRUB_BYTE); - u32 kmalloc_scrub_pattern = explode_byte(KMALLOC_SCRUB_BYTE); - u32 kfree_scrub_pattern = explode_byte(KFREE_SCRUB_BYTE); - u32 slab_alloc_scrub_pattern = explode_byte(SLAB_ALLOC_SCRUB_BYTE); - u32 slab_dealloc_scrub_pattern = explode_byte(SLAB_DEALLOC_SCRUB_BYTE); + FlatPtr malloc_scrub_pattern = explode_byte(MALLOC_SCRUB_BYTE); + FlatPtr free_scrub_pattern = explode_byte(FREE_SCRUB_BYTE); + FlatPtr kmalloc_scrub_pattern = explode_byte(KMALLOC_SCRUB_BYTE); + FlatPtr kfree_scrub_pattern = explode_byte(KFREE_SCRUB_BYTE); + FlatPtr slab_alloc_scrub_pattern = explode_byte(SLAB_ALLOC_SCRUB_BYTE); + FlatPtr slab_dealloc_scrub_pattern = explode_byte(SLAB_DEALLOC_SCRUB_BYTE); if ((fault_address & 0xffff0000) == (malloc_scrub_pattern & 0xffff0000)) { dbgln("Note: Address {} looks like it may be uninitialized malloc() memory", VirtualAddress(fault_address)); } else if ((fault_address & 0xffff0000) == (free_scrub_pattern & 0xffff0000)) {