From b4dc33efc2890bc0d60e99f715425d6af4a72b3d Mon Sep 17 00:00:00 2001
From: Mary <me@thog.eu>
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
---
 Ryujinx.Memory/MemoryBlock.cs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'Ryujinx.Memory/MemoryBlock.cs')

diff --git a/Ryujinx.Memory/MemoryBlock.cs b/Ryujinx.Memory/MemoryBlock.cs
index 25c66dfe..3561b81a 100644
--- a/Ryujinx.Memory/MemoryBlock.cs
+++ b/Ryujinx.Memory/MemoryBlock.cs
@@ -216,13 +216,14 @@ namespace Ryujinx.Memory
         }
 
         /// <summary>
-        /// Fills a region of memory with zeros.
+        /// Fills a region of memory with <paramref name="value"/>.
         /// </summary>
-        /// <param name="offset">Offset of the region to fill with zeros</param>
+        /// <param name="offset">Offset of the region to fill with <paramref name="value"/></param>
         /// <param name="size">Size in bytes of the region to fill</param>
+        /// <param name="value">Value to use for the fill</param>
         /// <exception cref="ObjectDisposedException">Throw when the memory block has already been disposed</exception>
         /// <exception cref="InvalidMemoryRegionException">Throw when either <paramref name="offset"/> or <paramref name="size"/> are out of range</exception>
-        public void ZeroFill(ulong offset, ulong size)
+        public void Fill(ulong offset, ulong size, byte value)
         {
             const int MaxChunkSize = 1 << 24;
 
@@ -230,7 +231,7 @@ namespace Ryujinx.Memory
             {
                 int copySize = (int)Math.Min(MaxChunkSize, size - subOffset);
 
-                GetSpan(offset + subOffset, copySize).Fill(0);
+                GetSpan(offset + subOffset, copySize).Fill(value);
             }
         }
 
-- 
cgit v1.2.3-70-g09d2