kern: KPageTableBase::WriteDebugMemory stores/invalidates cache

This commit is contained in:
Michael Scire 2020-08-03 18:43:38 -07:00 committed by SciresM
parent b5f2698bf0
commit 595c6dbe8f

View file

@ -2157,6 +2157,8 @@ namespace ams::kern {
if (cur_size >= sizeof(u32)) {
const size_t copy_size = util::AlignDown(cur_size, sizeof(u32));
R_UNLESS(UserspaceAccess::CopyMemoryFromUserAligned32Bit(GetVoidPointer(GetLinearMappedVirtualAddress(cur_addr)), buffer, copy_size), svc::ResultInvalidCurrentMemory());
cpu::StoreDataCache(GetVoidPointer(GetLinearMappedVirtualAddress(cur_addr)), copy_size);
buffer = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(buffer) + copy_size);
cur_addr += copy_size;
cur_size -= copy_size;
@ -2165,6 +2167,7 @@ namespace ams::kern {
/* Copy remaining data. */
if (cur_size > 0) {
R_UNLESS(UserspaceAccess::CopyMemoryFromUser(GetVoidPointer(GetLinearMappedVirtualAddress(cur_addr)), buffer, cur_size), svc::ResultInvalidCurrentMemory());
cpu::StoreDataCache(GetVoidPointer(GetLinearMappedVirtualAddress(cur_addr)), copy_size);
}
return ResultSuccess();
@ -2200,6 +2203,9 @@ namespace ams::kern {
/* Perform copy for the last block. */
R_TRY(PerformCopy());
/* Invalidate the entire instruction cache, as this svc allows modifying executable pages. */
cpu::InvalidateEntireInstructionCache();
return ResultSuccess();
}