From b4dc33efc2890bc0d60e99f715425d6af4a72b3d Mon Sep 17 00:00:00 2001 From: Mary Date: Sun, 24 Oct 2021 23:52:59 +0200 Subject: kernel: Clear pages allocated with SetHeapSize (#2776) * kernel: Clear pages allocated with SetHeapSize Before this commit, all new pages allocated by SetHeapSize were not cleared by the kernel. This would cause undefined data to be pass to the userland and possibly resulting in weird memory corruption. This commit also add support for custom fill heap and ipc value (that is also supported by the official kernel) * Remove dots at the end of KPageTableBase.MapPages new documentation * Remove unused _stackFillValue --- .../HOS/Kernel/Memory/KPageTableHostMapped.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'Ryujinx.HLE/HOS/Kernel/Memory/KPageTableHostMapped.cs') diff --git a/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableHostMapped.cs b/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableHostMapped.cs index cd51bab7..29a7b2ed 100644 --- a/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableHostMapped.cs +++ b/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableHostMapped.cs @@ -70,16 +70,30 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory } /// - protected override KernelResult MapPages(ulong dstVa, ulong pagesCount, ulong srcPa, KMemoryPermission permission) + protected override KernelResult MapPages(ulong dstVa, ulong pagesCount, ulong srcPa, KMemoryPermission permission, bool shouldFillPages, byte fillValue) { _cpuMemory.Map(dstVa, 0, pagesCount * PageSize); + + if (shouldFillPages) + { + _cpuMemory.Fill(dstVa, pagesCount * PageSize, fillValue); + } + return KernelResult.Success; } /// - protected override KernelResult MapPages(ulong address, KPageList pageList, KMemoryPermission permission) + protected override KernelResult MapPages(ulong address, KPageList pageList, KMemoryPermission permission, bool shouldFillPages, byte fillValue) { - _cpuMemory.Map(address, 0, pageList.GetPagesCount() * PageSize); + ulong pagesCount = pageList.GetPagesCount(); + + _cpuMemory.Map(address, 0, pagesCount * PageSize); + + if (shouldFillPages) + { + _cpuMemory.Fill(address, pagesCount * PageSize, fillValue); + } + return KernelResult.Success; } -- cgit v1.2.3