mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-25 03:52:57 +00:00
hle: kernel: k_page_table: Fix implementations of LockForCodeMemory & UnlockForCodeMemory.
This commit is contained in:
parent
0c75913bf2
commit
9408100a80
|
@ -1682,57 +1682,21 @@ ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode KPageTable::LockForCodeMemory(VAddr addr, std::size_t size) {
|
ResultCode KPageTable::LockForCodeMemory(VAddr addr, std::size_t size) {
|
||||||
KScopedLightLock lk(general_lock);
|
return this->LockMemoryAndOpen(
|
||||||
|
nullptr, nullptr, addr, size, KMemoryState::FlagCanCodeMemory,
|
||||||
KMemoryPermission new_perm = KMemoryPermission::NotMapped | KMemoryPermission::KernelReadWrite;
|
KMemoryState::FlagCanCodeMemory, KMemoryPermission::All, KMemoryPermission::UserReadWrite,
|
||||||
|
KMemoryAttribute::All, KMemoryAttribute::None,
|
||||||
KMemoryPermission old_perm{};
|
static_cast<KMemoryPermission>(KMemoryPermission::NotMapped |
|
||||||
|
KMemoryPermission::KernelReadWrite),
|
||||||
if (const ResultCode result{CheckMemoryState(
|
KMemoryAttribute::Locked);
|
||||||
nullptr, &old_perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanCodeMemory,
|
|
||||||
KMemoryState::FlagCanCodeMemory, KMemoryPermission::All,
|
|
||||||
KMemoryPermission::UserReadWrite, KMemoryAttribute::All, KMemoryAttribute::None)};
|
|
||||||
result.IsError()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_perm = (new_perm != KMemoryPermission::None) ? new_perm : old_perm;
|
|
||||||
|
|
||||||
block_manager->UpdateLock(
|
|
||||||
addr, size / PageSize,
|
|
||||||
[](KMemoryBlockManager::iterator block, KMemoryPermission permission) {
|
|
||||||
block->ShareToDevice(permission);
|
|
||||||
},
|
|
||||||
new_perm);
|
|
||||||
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size) {
|
ResultCode KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size) {
|
||||||
KScopedLightLock lk(general_lock);
|
return this->UnlockMemory(addr, size, KMemoryState::FlagCanCodeMemory,
|
||||||
|
KMemoryState::FlagCanCodeMemory, KMemoryPermission::None,
|
||||||
KMemoryPermission new_perm = KMemoryPermission::UserReadWrite;
|
KMemoryPermission::None, KMemoryAttribute::All,
|
||||||
|
KMemoryAttribute::Locked, KMemoryPermission::UserReadWrite,
|
||||||
KMemoryPermission old_perm{};
|
KMemoryAttribute::Locked, nullptr);
|
||||||
|
|
||||||
if (const ResultCode result{CheckMemoryState(
|
|
||||||
nullptr, &old_perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanCodeMemory,
|
|
||||||
KMemoryState::FlagCanCodeMemory, KMemoryPermission::None, KMemoryPermission::None,
|
|
||||||
KMemoryAttribute::All, KMemoryAttribute::Locked)};
|
|
||||||
result.IsError()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_perm = (new_perm != KMemoryPermission::None) ? new_perm : old_perm;
|
|
||||||
|
|
||||||
block_manager->UpdateLock(
|
|
||||||
addr, size / PageSize,
|
|
||||||
[](KMemoryBlockManager::iterator block, KMemoryPermission permission) {
|
|
||||||
block->UnshareToDevice(permission);
|
|
||||||
},
|
|
||||||
new_perm);
|
|
||||||
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) {
|
ResultCode KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) {
|
||||||
|
|
Loading…
Reference in a new issue