diff options
| author | 2022-01-14 23:27:36 -0800 | |
|---|---|---|
| committer | 2022-01-22 20:51:34 -0800 | |
| commit | 07add23251880d142d0b11115d4cb239d60c57bd (patch) | |
| tree | aa0d28773b3a6636c2c4247f2803c08a069f2938 | |
| parent | core: hle: kernel: KPageTable: ReserveTransferMemory: Various cleanup. (diff) | |
| download | yuzu-07add23251880d142d0b11115d4cb239d60c57bd.tar.gz yuzu-07add23251880d142d0b11115d4cb239d60c57bd.tar.xz yuzu-07add23251880d142d0b11115d4cb239d60c57bd.zip | |
core: hle: kernel: KPageTable: MapProcessCode: Various cleanup.
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/kernel/k_page_table.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 223c0d491..d78c5e37a 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp | |||
| @@ -276,22 +276,23 @@ ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_ | |||
| 276 | 276 | ||
| 277 | ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state, | 277 | ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state, |
| 278 | KMemoryPermission perm) { | 278 | KMemoryPermission perm) { |
| 279 | std::lock_guard lock{page_table_lock}; | ||
| 280 | |||
| 281 | const u64 size{num_pages * PageSize}; | 279 | const u64 size{num_pages * PageSize}; |
| 282 | 280 | ||
| 283 | if (!CanContain(addr, size, state)) { | 281 | // Validate the mapping request. |
| 284 | return ResultInvalidCurrentMemory; | 282 | R_UNLESS(this->CanContain(addr, size, state), ResultInvalidCurrentMemory); |
| 285 | } | ||
| 286 | 283 | ||
| 287 | if (IsRegionMapped(addr, size)) { | 284 | // Lock the table. |
| 288 | return ResultInvalidCurrentMemory; | 285 | std::lock_guard lock{page_table_lock}; |
| 289 | } | 286 | |
| 287 | // Verify that the destination memory is unmapped. | ||
| 288 | R_TRY(this->CheckMemoryState(addr, size, KMemoryState::All, KMemoryState::Free, | ||
| 289 | KMemoryPermission::None, KMemoryPermission::None, | ||
| 290 | KMemoryAttribute::None, KMemoryAttribute::None)); | ||
| 290 | 291 | ||
| 291 | KPageLinkedList page_linked_list; | 292 | KPageLinkedList page_linked_list; |
| 292 | CASCADE_CODE(system.Kernel().MemoryManager().Allocate(page_linked_list, num_pages, memory_pool, | 293 | R_TRY(system.Kernel().MemoryManager().Allocate(page_linked_list, num_pages, memory_pool, |
| 293 | allocation_option)); | 294 | allocation_option)); |
| 294 | CASCADE_CODE(Operate(addr, num_pages, page_linked_list, OperationType::MapGroup)); | 295 | R_TRY(Operate(addr, num_pages, page_linked_list, OperationType::MapGroup)); |
| 295 | 296 | ||
| 296 | block_manager->Update(addr, num_pages, state, perm); | 297 | block_manager->Update(addr, num_pages, state, perm); |
| 297 | 298 | ||