diff options
author | bunnei <bunneidev@gmail.com> | 2022-01-09 08:07:07 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2022-01-12 01:28:11 +0100 |
commit | 081669c3349812eb308be03107541377ac2dbc11 (patch) | |
tree | ab022caa12d1989872a2f43ebcb45f9fe1081135 /src/core | |
parent | Merge pull request #7684 from bunnei/set-mem-perm-attr (diff) | |
download | yuzu-081669c3349812eb308be03107541377ac2dbc11.tar yuzu-081669c3349812eb308be03107541377ac2dbc11.tar.gz yuzu-081669c3349812eb308be03107541377ac2dbc11.tar.bz2 yuzu-081669c3349812eb308be03107541377ac2dbc11.tar.lz yuzu-081669c3349812eb308be03107541377ac2dbc11.tar.xz yuzu-081669c3349812eb308be03107541377ac2dbc11.tar.zst yuzu-081669c3349812eb308be03107541377ac2dbc11.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/kernel/k_page_table.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/k_page_table.h | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/ldr/ldr.cpp | 27 |
4 files changed, 19 insertions, 20 deletions
diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 6077985b5..9be9f5e2b 100644 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp @@ -298,7 +298,7 @@ ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemory return ResultSuccess; } -ResultCode KPageTable::MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { +ResultCode KPageTable::MapCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { std::lock_guard lock{page_table_lock}; const std::size_t num_pages{size / PageSize}; @@ -335,7 +335,7 @@ ResultCode KPageTable::MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std: return ResultSuccess; } -ResultCode KPageTable::UnmapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { +ResultCode KPageTable::UnmapCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { std::lock_guard lock{page_table_lock}; if (!size) { diff --git a/src/core/hle/kernel/k_page_table.h b/src/core/hle/kernel/k_page_table.h index 9235b822a..a596bf381 100644 --- a/src/core/hle/kernel/k_page_table.h +++ b/src/core/hle/kernel/k_page_table.h @@ -31,8 +31,8 @@ public: KMemoryManager::Pool pool); ResultCode MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state, KMemoryPermission perm); - ResultCode MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); - ResultCode UnmapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); + ResultCode MapCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); + ResultCode UnmapCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); ResultCode UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table, VAddr src_addr); ResultCode MapPhysicalMemory(VAddr addr, std::size_t size); diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4362508a3..55ce0236f 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -1626,7 +1626,7 @@ static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_hand return ResultInvalidMemoryRegion; } - return page_table.MapProcessCodeMemory(dst_address, src_address, size); + return page_table.MapCodeMemory(dst_address, src_address, size); } static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_handle, @@ -1694,7 +1694,7 @@ static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_ha return ResultInvalidMemoryRegion; } - return page_table.UnmapProcessCodeMemory(dst_address, src_address, size); + return page_table.UnmapCodeMemory(dst_address, src_address, size); } /// Exits the current process diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index 3782703d2..f16dbc595 100644 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp @@ -325,7 +325,7 @@ public: for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) { auto& page_table{process->PageTable()}; const VAddr addr{GetRandomMapRegion(page_table, size)}; - const ResultCode result{page_table.MapProcessCodeMemory(addr, baseAddress, size)}; + const ResultCode result{page_table.MapCodeMemory(addr, baseAddress, size)}; if (result == Kernel::ResultInvalidCurrentMemory) { continue; @@ -351,12 +351,12 @@ public: if (bss_size) { auto block_guard = detail::ScopeExit([&] { - page_table.UnmapProcessCodeMemory(addr + nro_size, bss_addr, bss_size); - page_table.UnmapProcessCodeMemory(addr, nro_addr, nro_size); + page_table.UnmapCodeMemory(addr + nro_size, bss_addr, bss_size); + page_table.UnmapCodeMemory(addr, nro_addr, nro_size); }); const ResultCode result{ - page_table.MapProcessCodeMemory(addr + nro_size, bss_addr, bss_size)}; + page_table.MapCodeMemory(addr + nro_size, bss_addr, bss_size)}; if (result == Kernel::ResultInvalidCurrentMemory) { continue; @@ -530,16 +530,15 @@ public: ResultCode UnmapNro(const NROInfo& info) { // Each region must be unmapped separately to validate memory state auto& page_table{system.CurrentProcess()->PageTable()}; - CASCADE_CODE(page_table.UnmapProcessCodeMemory(info.nro_address + info.text_size + - info.ro_size + info.data_size, - info.bss_address, info.bss_size)); - CASCADE_CODE(page_table.UnmapProcessCodeMemory( - info.nro_address + info.text_size + info.ro_size, - info.src_addr + info.text_size + info.ro_size, info.data_size)); - CASCADE_CODE(page_table.UnmapProcessCodeMemory( - info.nro_address + info.text_size, info.src_addr + info.text_size, info.ro_size)); - CASCADE_CODE( - page_table.UnmapProcessCodeMemory(info.nro_address, info.src_addr, info.text_size)); + CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size + info.ro_size + + info.data_size, + info.bss_address, info.bss_size)); + CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size + info.ro_size, + info.src_addr + info.text_size + info.ro_size, + info.data_size)); + CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size, + info.src_addr + info.text_size, info.ro_size)); + CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address, info.src_addr, info.text_size)); return ResultSuccess; } |