yuzu-emu
/
yuzu
Archived
1
0
Fork 0

core: hle: kernel: KPageTable: SetHeapSize: Cleanup & take physical memory lock.

This commit is contained in:
bunnei 2022-01-14 23:20:30 -08:00
parent 6d8e498f76
commit 0137f2e6e1
1 changed files with 7 additions and 4 deletions

View File

@ -885,6 +885,9 @@ ResultCode KPageTable::SetMaxHeapSize(std::size_t size) {
} }
ResultCode KPageTable::SetHeapSize(VAddr* out, std::size_t size) { ResultCode KPageTable::SetHeapSize(VAddr* out, std::size_t size) {
// Lock the physical memory lock.
std::lock_guard phys_lk(map_physical_memory_lock);
// Try to perform a reduction in heap, instead of an extension. // Try to perform a reduction in heap, instead of an extension.
VAddr cur_address{}; VAddr cur_address{};
std::size_t allocation_size{}; std::size_t allocation_size{};
@ -1014,12 +1017,12 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages,
} }
if (is_map_only) { if (is_map_only) {
CASCADE_CODE(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr)); R_TRY(Operate(addr, needed_num_pages, perm, OperationType::Map, map_addr));
} else { } else {
KPageLinkedList page_group; KPageLinkedList page_group;
CASCADE_CODE(system.Kernel().MemoryManager().Allocate(page_group, needed_num_pages, R_TRY(system.Kernel().MemoryManager().Allocate(page_group, needed_num_pages, memory_pool,
memory_pool, allocation_option)); allocation_option));
CASCADE_CODE(Operate(addr, needed_num_pages, page_group, OperationType::MapGroup)); R_TRY(Operate(addr, needed_num_pages, page_group, OperationType::MapGroup));
} }
block_manager->Update(addr, needed_num_pages, state, perm); block_manager->Update(addr, needed_num_pages, state, perm);