yuzu-emu
/
yuzu
Archived
1
0
Fork 0

hle: kernel: k_page_table: Rename *ProcessCodeMemory -> *CodeMemory.

This commit is contained in:
bunnei 2022-01-08 23:07:07 -08:00
parent 599c0763e5
commit 081669c334
4 changed files with 19 additions and 20 deletions

View File

@ -298,7 +298,7 @@ ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemory
return ResultSuccess; 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}; std::lock_guard lock{page_table_lock};
const std::size_t num_pages{size / PageSize}; const std::size_t num_pages{size / PageSize};
@ -335,7 +335,7 @@ ResultCode KPageTable::MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std:
return ResultSuccess; 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}; std::lock_guard lock{page_table_lock};
if (!size) { if (!size) {

View File

@ -31,8 +31,8 @@ public:
KMemoryManager::Pool pool); KMemoryManager::Pool pool);
ResultCode MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state, ResultCode MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state,
KMemoryPermission perm); KMemoryPermission perm);
ResultCode MapProcessCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); ResultCode MapCodeMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
ResultCode UnmapProcessCodeMemory(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, ResultCode UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table,
VAddr src_addr); VAddr src_addr);
ResultCode MapPhysicalMemory(VAddr addr, std::size_t size); ResultCode MapPhysicalMemory(VAddr addr, std::size_t size);

View File

@ -1626,7 +1626,7 @@ static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_hand
return ResultInvalidMemoryRegion; 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, 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 ResultInvalidMemoryRegion;
} }
return page_table.UnmapProcessCodeMemory(dst_address, src_address, size); return page_table.UnmapCodeMemory(dst_address, src_address, size);
} }
/// Exits the current process /// Exits the current process

View File

@ -325,7 +325,7 @@ public:
for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) { for (std::size_t retry = 0; retry < MAXIMUM_MAP_RETRIES; retry++) {
auto& page_table{process->PageTable()}; auto& page_table{process->PageTable()};
const VAddr addr{GetRandomMapRegion(page_table, size)}; 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) { if (result == Kernel::ResultInvalidCurrentMemory) {
continue; continue;
@ -351,12 +351,12 @@ public:
if (bss_size) { if (bss_size) {
auto block_guard = detail::ScopeExit([&] { auto block_guard = detail::ScopeExit([&] {
page_table.UnmapProcessCodeMemory(addr + nro_size, bss_addr, bss_size); page_table.UnmapCodeMemory(addr + nro_size, bss_addr, bss_size);
page_table.UnmapProcessCodeMemory(addr, nro_addr, nro_size); page_table.UnmapCodeMemory(addr, nro_addr, nro_size);
}); });
const ResultCode result{ 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) { if (result == Kernel::ResultInvalidCurrentMemory) {
continue; continue;
@ -530,16 +530,15 @@ public:
ResultCode UnmapNro(const NROInfo& info) { ResultCode UnmapNro(const NROInfo& info) {
// Each region must be unmapped separately to validate memory state // Each region must be unmapped separately to validate memory state
auto& page_table{system.CurrentProcess()->PageTable()}; auto& page_table{system.CurrentProcess()->PageTable()};
CASCADE_CODE(page_table.UnmapProcessCodeMemory(info.nro_address + info.text_size + CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size + info.ro_size +
info.ro_size + info.data_size, info.data_size,
info.bss_address, info.bss_size)); info.bss_address, info.bss_size));
CASCADE_CODE(page_table.UnmapProcessCodeMemory( CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size + info.ro_size,
info.nro_address + info.text_size + info.ro_size, info.src_addr + info.text_size + info.ro_size,
info.src_addr + info.text_size + info.ro_size, info.data_size)); info.data_size));
CASCADE_CODE(page_table.UnmapProcessCodeMemory( CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size,
info.nro_address + info.text_size, info.src_addr + info.text_size, info.ro_size)); info.src_addr + info.text_size, info.ro_size));
CASCADE_CODE( CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address, info.src_addr, info.text_size));
page_table.UnmapProcessCodeMemory(info.nro_address, info.src_addr, info.text_size));
return ResultSuccess; return ResultSuccess;
} }