early-access version 2666

This commit is contained in:
pineappleEA 2022-04-11 00:44:24 +02:00
parent 7a13d2c502
commit 8bdf5dbc6c
5 changed files with 29 additions and 20 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access
=============
This is the source code for early-access 2665.
This is the source code for early-access 2666.
## Legal Notice

View File

@ -347,7 +347,7 @@ ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::
}
ResultCode KPageTable::UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size,
bool invalidate_entire_icache) {
ICacheInvalidationStrategy icache_invalidation_strategy) {
// Validate the mapping request.
R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode),
ResultInvalidMemoryRegion);
@ -397,10 +397,10 @@ ResultCode KPageTable::UnmapCodeMemory(VAddr dst_address, VAddr src_address, std
bool reprotected_pages = false;
SCOPE_EXIT({
if (reprotected_pages && any_code_pages) {
if (invalidate_entire_icache) {
system.InvalidateCpuInstructionCaches();
} else {
if (icache_invalidation_strategy == ICacheInvalidationStrategy::InvalidateRange) {
system.InvalidateCpuInstructionCacheRange(dst_address, size);
} else {
system.InvalidateCpuInstructionCaches();
}
}
});

View File

@ -26,6 +26,8 @@ class KMemoryBlockManager;
class KPageTable final {
public:
enum class ICacheInvalidationStrategy : u32 { InvalidateRange, InvalidateAll };
YUZU_NON_COPYABLE(KPageTable);
YUZU_NON_MOVEABLE(KPageTable);
@ -39,7 +41,7 @@ public:
KMemoryPermission perm);
ResultCode MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size);
ResultCode UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size,
bool invalidate_entire_icache);
ICacheInvalidationStrategy icache_invalidation_strategy);
ResultCode UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table,
VAddr src_addr);
ResultCode MapPhysicalMemory(VAddr addr, std::size_t size);

View File

@ -1713,7 +1713,8 @@ static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_ha
return ResultInvalidMemoryRegion;
}
return page_table.UnmapCodeMemory(dst_address, src_address, size, true);
return page_table.UnmapCodeMemory(dst_address, src_address, size,
KPageTable::ICacheInvalidationStrategy::InvalidateAll);
}
/// Exits the current process

View File

@ -389,8 +389,12 @@ public:
if (bss_size) {
auto block_guard = detail::ScopeExit([&] {
page_table.UnmapCodeMemory(addr + nro_size, bss_addr, bss_size, false);
page_table.UnmapCodeMemory(addr, nro_addr, nro_size, false);
page_table.UnmapCodeMemory(
addr + nro_size, bss_addr, bss_size,
Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange);
page_table.UnmapCodeMemory(
addr, nro_addr, nro_size,
Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange);
});
const ResultCode result{
@ -570,19 +574,21 @@ public:
auto& page_table{system.CurrentProcess()->PageTable()};
if (info.bss_size != 0) {
CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size +
info.ro_size + info.data_size,
info.bss_address, info.bss_size, false));
CASCADE_CODE(page_table.UnmapCodeMemory(
info.nro_address + info.text_size + info.ro_size + info.data_size, info.bss_address,
info.bss_size, Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange));
}
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, false));
CASCADE_CODE(page_table.UnmapCodeMemory(info.nro_address + info.text_size,
info.src_addr + info.text_size, info.ro_size,
false));
CASCADE_CODE(
page_table.UnmapCodeMemory(info.nro_address, info.src_addr, info.text_size, false));
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,
Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange));
CASCADE_CODE(page_table.UnmapCodeMemory(
info.nro_address + info.text_size, info.src_addr + info.text_size, info.ro_size,
Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange));
CASCADE_CODE(page_table.UnmapCodeMemory(
info.nro_address, info.src_addr, info.text_size,
Kernel::KPageTable::ICacheInvalidationStrategy::InvalidateRange));
return ResultSuccess;
}