[Memory] Remove unnecessary 256MB carve-out from v00000000 virtual heap

The 4KB-page virtual heap (v00000000, 0x00000000-0x3FFFFFFF) had 256MB
reserved at its top end for thread stacks, but thread stacks only use
the 64KB-page heap (v40000000) at 0x70000000-0x7F000000. This wasted
256MB of allocatable address space.

Keep the carve-out only on the v40000000 heap where stacks actually reside.
This commit is contained in:
Herman S.
2026-04-08 09:07:32 +09:00
parent 658bd5db70
commit 844cc6e2ed

View File

@@ -1044,17 +1044,12 @@ bool BaseHeap::Alloc(uint32_t size, uint32_t alignment,
size = xe::round_up(size, page_size_);
alignment = xe::round_up(alignment, page_size_);
// TODO(Gliniak): Find better way to deal with this!
// Because 0x3XXXXXX and 0x7XXXXXX is used strictly as place for thread stacks
// 0x3 is probably for system threads and 0x7 for title threads
// Exclude the top 240MB of the v40000000 heap (64KB guest pages) from
// general allocation to protect the thread stack region
// (0x70000000-0x7F000000)
uint32_t heap_virtual_guest_offset = 0;
if (heap_type_ == HeapType::kGuestVirtual) {
heap_virtual_guest_offset = 0x10000000;
// Adjust for 64k pages region, to prevent having a bit too little memory
if (page_size_ == 0x10000) {
heap_virtual_guest_offset = 0x0F000000;
}
if (heap_type_ == HeapType::kGuestVirtual && page_size_ == 0x10000) {
heap_virtual_guest_offset = 0x0F000000;
}
uint32_t low_address = heap_base_;