aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs
diff options
context:
space:
mode:
authorMary <me@thog.eu>2021-10-24 23:52:59 +0200
committerGitHub <noreply@github.com>2021-10-24 18:52:59 -0300
commitb4dc33efc2890bc0d60e99f715425d6af4a72b3d (patch)
tree6b5a712903a20d23db5a2be70b6c1d03c8d0f019 /Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs
parent8c4e4ab3b32eb2dfe5e26fab95648b7872fe2c28 (diff)
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
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs14
1 files changed, 12 insertions, 2 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs b/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs
index 20a13f57..d7ee04e3 100644
--- a/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs
@@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
}
/// <inheritdoc/>
- 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)
{
ulong size = pagesCount * PageSize;
@@ -99,11 +99,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
Context.MemoryManager.IncrementPagesReferenceCount(srcPa, pagesCount);
}
+ if (shouldFillPages)
+ {
+ _cpuMemory.Fill(dstVa, size, fillValue);
+ }
+
return KernelResult.Success;
}
/// <inheritdoc/>
- protected override KernelResult MapPages(ulong address, KPageList pageList, KMemoryPermission permission)
+ protected override KernelResult MapPages(ulong address, KPageList pageList, KMemoryPermission permission, bool shouldFillPages, byte fillValue)
{
using var scopedPageList = new KScopedPageList(Context.MemoryManager, pageList);
@@ -118,6 +123,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
_cpuMemory.Map(currentVa, Context.Memory.GetPointer(addr, size), size);
+ if (shouldFillPages)
+ {
+ _cpuMemory.Fill(currentVa, size, fillValue);
+ }
+
currentVa += size;
}