diff options
author | bunnei <bunneidev@gmail.com> | 2021-12-23 10:10:36 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-12-23 10:10:36 +0100 |
commit | 4e7a6639d2be8c1c6a195004a1ca612a25085fea (patch) | |
tree | 3dca18bcc3afd788152bf1fbab8f1e14824c6aeb /src/core/hle/kernel/k_page_table.cpp | |
parent | Merge pull request #7616 from bunnei/fix-get-idle-ticks (diff) | |
download | yuzu-4e7a6639d2be8c1c6a195004a1ca612a25085fea.tar yuzu-4e7a6639d2be8c1c6a195004a1ca612a25085fea.tar.gz yuzu-4e7a6639d2be8c1c6a195004a1ca612a25085fea.tar.bz2 yuzu-4e7a6639d2be8c1c6a195004a1ca612a25085fea.tar.lz yuzu-4e7a6639d2be8c1c6a195004a1ca612a25085fea.tar.xz yuzu-4e7a6639d2be8c1c6a195004a1ca612a25085fea.tar.zst yuzu-4e7a6639d2be8c1c6a195004a1ca612a25085fea.zip |
Diffstat (limited to 'src/core/hle/kernel/k_page_table.cpp')
-rw-r--r-- | src/core/hle/kernel/k_page_table.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 99982e5a3..f2f88c147 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp @@ -806,6 +806,33 @@ ResultCode KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) { KMemoryAttribute::Locked, KMemoryAttribute::IpcAndDeviceMapped)); block_manager->Update(addr, size / PageSize, state, KMemoryPermission::ReadAndWrite); + return ResultSuccess; +} + +ResultCode KPageTable::SetMemoryPermission(VAddr addr, std::size_t size, + Svc::MemoryPermission svc_perm) { + const size_t num_pages = size / PageSize; + + // Lock the table. + std::lock_guard lock{page_table_lock}; + + // Verify we can change the memory permission. + KMemoryState old_state; + KMemoryPermission old_perm; + R_TRY(this->CheckMemoryState( + std::addressof(old_state), std::addressof(old_perm), nullptr, addr, size, + KMemoryState::FlagCanReprotect, KMemoryState::FlagCanReprotect, KMemoryPermission::None, + KMemoryPermission::None, KMemoryAttribute::All, KMemoryAttribute::None)); + + // Determine new perm. + const KMemoryPermission new_perm = ConvertToKMemoryPermission(svc_perm); + R_SUCCEED_IF(old_perm == new_perm); + + // Perform mapping operation. + R_TRY(Operate(addr, num_pages, new_perm, OperationType::ChangePermissions)); + + // Update the blocks. + block_manager->Update(addr, num_pages, old_state, new_perm, KMemoryAttribute::None); return ResultSuccess; } |