From a545f52554e954856bb0657d4bb4f2bfeb9e5fa6 Mon Sep 17 00:00:00 2001 From: "Herman S." <429230+has207@users.noreply.github.com> Date: Mon, 29 Sep 2025 16:40:58 +0900 Subject: [PATCH] Avoid alignment related assert Physical addresses need actual alignment, virtual ones just need page alignment --- src/xenia/memory.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc index 2e3e58223..bf7d94c08 100644 --- a/src/xenia/memory.cc +++ b/src/xenia/memory.cc @@ -1573,7 +1573,10 @@ bool PhysicalHeap::AllocFixed(uint32_t base_address, uint32_t size, // Shouldn't be possible for it to be allocated already. uint32_t address = heap_base_ + parent_base_address - GetPhysicalAddress(heap_base_); - if (!BaseHeap::AllocFixed(address, size, alignment, allocation_type, + // The physical memory is already aligned properly by the parent heap. + // We only need page alignment for the virtual address since the actual + // memory alignment requirement has been satisfied in physical space. + if (!BaseHeap::AllocFixed(address, size, page_size_, allocation_type, protect)) { XELOGE( "PhysicalHeap::Alloc unable to pin physical memory in physical heap"); @@ -1614,7 +1617,10 @@ bool PhysicalHeap::AllocRange(uint32_t low_address, uint32_t high_address, // Shouldn't be possible for it to be allocated already. uint32_t address = heap_base_ + parent_address - GetPhysicalAddress(heap_base_); - if (!BaseHeap::AllocFixed(address, size, alignment, allocation_type, + // The physical memory is already aligned properly by the parent heap. + // We only need page alignment for the virtual address since the actual + // memory alignment requirement has been satisfied in physical space. + if (!BaseHeap::AllocFixed(address, size, page_size_, allocation_type, protect)) { XELOGE( "PhysicalHeap::Alloc unable to pin physical memory in physical heap");