From 1fea07b6aa1ea48f88c33316f5fee9db0103de93 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 21 Oct 2013 19:26:41 -0700 Subject: [PATCH] Align physical allocations to page size. --- src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc index e12a18c88..b0929fca7 100644 --- a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc +++ b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.cc @@ -220,8 +220,9 @@ uint32_t xeMmAllocatePhysicalMemoryEx( page_size = 16 * 1024 * 1024; } - // Round up the region size to the next page. + // Round up the region size and alignment to the next page. uint32_t adjusted_size = XEROUNDUP(region_size, page_size); + uint32_t adjusted_alignment = XEROUNDUP(alignment, page_size);; // Callers can pick an address to allocate with min_addr_range/max_addr_range // and the memory must be allocated there. I haven't seen a game do this, @@ -233,7 +234,7 @@ uint32_t xeMmAllocatePhysicalMemoryEx( // Allocate. uint32_t flags = XE_MEMORY_FLAG_PHYSICAL; uint32_t base_address = xe_memory_heap_alloc( - state->memory(), 0, adjusted_size, flags, alignment); + state->memory(), 0, adjusted_size, flags, adjusted_alignment); if (!base_address) { // Failed - assume no memory available. return 0;