diff --git a/libraries/libmesosphere/source/kern_k_page_table_base.cpp b/libraries/libmesosphere/source/kern_k_page_table_base.cpp index 1daf7c67c..75e11a70e 100644 --- a/libraries/libmesosphere/source/kern_k_page_table_base.cpp +++ b/libraries/libmesosphere/source/kern_k_page_table_base.cpp @@ -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(reinterpret_cast(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(); }