diff --git a/src/Ryujinx.HLE/HOS/Kernel/KernelStatic.cs b/src/Ryujinx.HLE/HOS/Kernel/KernelStatic.cs index e05fc8397..e3c5865ae 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/KernelStatic.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/KernelStatic.cs @@ -29,6 +29,7 @@ namespace Ryujinx.HLE.HOS.Kernel capabilities, context.ResourceLimit, MemoryRegion.Service, + context.Device.Configuration.MemoryConfiguration, null, customThreadStart); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs index ee1b4a7be..bc59b0b4d 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs @@ -102,6 +102,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory ProcessCreationFlags flags, bool fromBack, MemoryRegion memRegion, + MemoryConfiguration memConfig, ulong address, ulong size, KMemoryBlockSlabManager slabManager) @@ -117,6 +118,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory addrSpaceBase, addrSpaceSize, memRegion, + memConfig, address, size, slabManager); @@ -159,6 +161,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory ulong addrSpaceStart, ulong addrSpaceEnd, MemoryRegion memRegion, + MemoryConfiguration memConfig, ulong address, ulong size, KMemoryBlockSlabManager slabManager) @@ -193,7 +196,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory case ProcessCreationFlags.AddressSpace64BitDeprecated: aliasRegion.Size = 0x180000000; - heapRegion.Size = 0x180000000; + heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u; stackRegion.Size = 0; tlsIoRegion.Size = 0; CodeRegionStart = 0x8000000; @@ -223,7 +226,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory int addressSpaceWidth = (int)ulong.Log2(_reservedAddressSpaceSize); aliasRegion.Size = 1UL << (addressSpaceWidth - 3); - heapRegion.Size = 0x180000000; + heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u; stackRegion.Size = 1UL << (addressSpaceWidth - 8); tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3); CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment); @@ -237,7 +240,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory else { aliasRegion.Size = 0x1000000000; - heapRegion.Size = 0x180000000; + heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u; stackRegion.Size = 0x80000000; tlsIoRegion.Size = 0x1000000000; CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs index bea1f0ef3..b823d14f7 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs @@ -124,6 +124,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process KPageList pageList, KResourceLimit resourceLimit, MemoryRegion memRegion, + MemoryConfiguration memConfig, IProcessContextFactory contextFactory, ThreadStart customThreadStart = null) { @@ -153,6 +154,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process creationInfo.Flags, !creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr), memRegion, + memConfig, codeAddress, codeSize, slabManager); @@ -189,6 +191,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process ReadOnlySpan capabilities, KResourceLimit resourceLimit, MemoryRegion memRegion, + MemoryConfiguration memConfig, IProcessContextFactory contextFactory, ThreadStart customThreadStart = null) { @@ -252,6 +255,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process creationInfo.Flags, !creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr), memRegion, + memConfig, codeAddress, codeSize, slabManager); diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs index 005ac1452..260ff8af3 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs @@ -137,6 +137,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall capabilities, resourceLimit, memRegion, + _context.Device.Configuration.MemoryConfiguration, contextFactory, customThreadStart); @@ -888,7 +889,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall [Svc(1)] public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size) { - if ((size & 0xfffffffe001fffff) != 0) + if ((size & 0xfffffffd001fffff) != 0) { address = 0; diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs index 5729052e8..7f0c6b3f5 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs @@ -189,7 +189,7 @@ namespace Ryujinx.HLE.Loaders.Processes codeAddress, codeSize); - result = process.InitializeKip(creationInfo, kip.Capabilities, pageList, context.ResourceLimit, memoryRegion, processContextFactory); + result = process.InitializeKip(creationInfo, kip.Capabilities, pageList, context.ResourceLimit, memoryRegion, context.Device.Configuration.MemoryConfiguration, processContextFactory); if (result != Result.Success) { Logger.Error?.Print(LogClass.Loader, $"Process initialization returned error \"{result}\"."); @@ -389,6 +389,7 @@ namespace Ryujinx.HLE.Loaders.Processes MemoryMarshal.Cast(npdm.KernelCapabilityData), resourceLimit, memoryRegion, + context.Device.Configuration.MemoryConfiguration, processContextFactory); if (result != Result.Success)