mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-16 13:37:03 +00:00
12 GiB heap support
The heap was limited to 6 GiB no matter the memory setting, causing memory configurations above 8 GiB to not actually affect the heap size. Now when the memory config is set to [10 or] 12 GiB the heap also allocates 12 GiB. The SetHeapSize SysCall will now allow heap sizes up to 12 GiB (technically slightly less). Co-authored-by: KeatonTheBot <keaton@ryujinx.app>
This commit is contained in:
parent
fc7932ad27
commit
4f101170f0
5 changed files with 27 additions and 5 deletions
|
|
@ -29,6 +29,7 @@ namespace Ryujinx.HLE.HOS.Kernel
|
||||||
capabilities,
|
capabilities,
|
||||||
context.ResourceLimit,
|
context.ResourceLimit,
|
||||||
MemoryRegion.Service,
|
MemoryRegion.Service,
|
||||||
|
context.Device.Configuration.MemoryConfiguration,
|
||||||
null,
|
null,
|
||||||
customThreadStart);
|
customThreadStart);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
ProcessCreationFlags flags,
|
ProcessCreationFlags flags,
|
||||||
bool fromBack,
|
bool fromBack,
|
||||||
MemoryRegion memRegion,
|
MemoryRegion memRegion,
|
||||||
|
MemoryConfiguration memConfig,
|
||||||
ulong address,
|
ulong address,
|
||||||
ulong size,
|
ulong size,
|
||||||
ulong reservedSize,
|
ulong reservedSize,
|
||||||
|
|
@ -119,6 +120,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
addrSpaceBase,
|
addrSpaceBase,
|
||||||
addrSpaceSize,
|
addrSpaceSize,
|
||||||
memRegion,
|
memRegion,
|
||||||
|
memConfig,
|
||||||
address,
|
address,
|
||||||
size,
|
size,
|
||||||
reservedSize,
|
reservedSize,
|
||||||
|
|
@ -162,6 +164,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
ulong addrSpaceStart,
|
ulong addrSpaceStart,
|
||||||
ulong addrSpaceEnd,
|
ulong addrSpaceEnd,
|
||||||
MemoryRegion memRegion,
|
MemoryRegion memRegion,
|
||||||
|
MemoryConfiguration memConfig,
|
||||||
ulong address,
|
ulong address,
|
||||||
ulong size,
|
ulong size,
|
||||||
ulong reservedSize,
|
ulong reservedSize,
|
||||||
|
|
@ -197,7 +200,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
|
|
||||||
case ProcessCreationFlags.AddressSpace64BitDeprecated:
|
case ProcessCreationFlags.AddressSpace64BitDeprecated:
|
||||||
aliasRegion.Size = 0x180000000;
|
aliasRegion.Size = 0x180000000;
|
||||||
heapRegion.Size = 0x180000000;
|
heapRegion.Size = memConfig switch {
|
||||||
|
MemoryConfiguration.MemoryConfiguration10GiB
|
||||||
|
or MemoryConfiguration.MemoryConfiguration12GiB => 0x300000000u,
|
||||||
|
_ => 0x180000000u
|
||||||
|
};
|
||||||
stackRegion.Size = 0;
|
stackRegion.Size = 0;
|
||||||
tlsIoRegion.Size = 0;
|
tlsIoRegion.Size = 0;
|
||||||
CodeRegionStart = 0x8000000;
|
CodeRegionStart = 0x8000000;
|
||||||
|
|
@ -228,7 +235,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
int addressSpaceWidth = (int)ulong.Log2(reservedAddressSpaceSize);
|
int addressSpaceWidth = (int)ulong.Log2(reservedAddressSpaceSize);
|
||||||
|
|
||||||
aliasRegion.Size = reservedAddressSpaceSize >= 0x1800000000 ? 0x1000000000 : 1UL << (addressSpaceWidth - 3);
|
aliasRegion.Size = reservedAddressSpaceSize >= 0x1800000000 ? 0x1000000000 : 1UL << (addressSpaceWidth - 3);
|
||||||
heapRegion.Size = 0x180000000;
|
heapRegion.Size = memConfig switch {
|
||||||
|
MemoryConfiguration.MemoryConfiguration10GiB
|
||||||
|
or MemoryConfiguration.MemoryConfiguration12GiB => 0x300000000u,
|
||||||
|
_ => 0x180000000u
|
||||||
|
};
|
||||||
stackRegion.Size = 1UL << (addressSpaceWidth - 8);
|
stackRegion.Size = 1UL << (addressSpaceWidth - 8);
|
||||||
tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3);
|
tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3);
|
||||||
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
||||||
|
|
@ -242,7 +253,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aliasRegion.Size = 0x1000000000;
|
aliasRegion.Size = 0x1000000000;
|
||||||
heapRegion.Size = 0x180000000;
|
heapRegion.Size = memConfig switch {
|
||||||
|
MemoryConfiguration.MemoryConfiguration10GiB
|
||||||
|
or MemoryConfiguration.MemoryConfiguration12GiB => 0x300000000u,
|
||||||
|
_ => 0x180000000u
|
||||||
|
};
|
||||||
stackRegion.Size = 0x80000000;
|
stackRegion.Size = 0x80000000;
|
||||||
tlsIoRegion.Size = 0x1000000000;
|
tlsIoRegion.Size = 0x1000000000;
|
||||||
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
KPageList pageList,
|
KPageList pageList,
|
||||||
KResourceLimit resourceLimit,
|
KResourceLimit resourceLimit,
|
||||||
MemoryRegion memRegion,
|
MemoryRegion memRegion,
|
||||||
|
MemoryConfiguration memConfig,
|
||||||
IProcessContextFactory contextFactory,
|
IProcessContextFactory contextFactory,
|
||||||
ThreadStart customThreadStart = null)
|
ThreadStart customThreadStart = null)
|
||||||
{
|
{
|
||||||
|
|
@ -147,6 +148,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
creationInfo.Flags,
|
creationInfo.Flags,
|
||||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||||
memRegion,
|
memRegion,
|
||||||
|
memConfig,
|
||||||
codeAddress,
|
codeAddress,
|
||||||
codeSize,
|
codeSize,
|
||||||
Context.ReservedSize,
|
Context.ReservedSize,
|
||||||
|
|
@ -184,6 +186,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
ReadOnlySpan<uint> capabilities,
|
ReadOnlySpan<uint> capabilities,
|
||||||
KResourceLimit resourceLimit,
|
KResourceLimit resourceLimit,
|
||||||
MemoryRegion memRegion,
|
MemoryRegion memRegion,
|
||||||
|
MemoryConfiguration memConfig,
|
||||||
IProcessContextFactory contextFactory,
|
IProcessContextFactory contextFactory,
|
||||||
ThreadStart customThreadStart = null,
|
ThreadStart customThreadStart = null,
|
||||||
ulong entrypointOffset = 0UL)
|
ulong entrypointOffset = 0UL)
|
||||||
|
|
@ -248,6 +251,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||||
creationInfo.Flags,
|
creationInfo.Flags,
|
||||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||||
memRegion,
|
memRegion,
|
||||||
|
memConfig,
|
||||||
codeAddress,
|
codeAddress,
|
||||||
codeSize,
|
codeSize,
|
||||||
Context.ReservedSize,
|
Context.ReservedSize,
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||||
capabilities,
|
capabilities,
|
||||||
resourceLimit,
|
resourceLimit,
|
||||||
memRegion,
|
memRegion,
|
||||||
|
_context.Device.Configuration.MemoryConfiguration,
|
||||||
contextFactory,
|
contextFactory,
|
||||||
customThreadStart);
|
customThreadStart);
|
||||||
|
|
||||||
|
|
@ -880,7 +881,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||||
[Svc(1)]
|
[Svc(1)]
|
||||||
public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size)
|
public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size)
|
||||||
{
|
{
|
||||||
if ((size & 0xfffffffe001fffff) != 0)
|
if ((size & 0xfffffffd001fffff) != 0)
|
||||||
{
|
{
|
||||||
address = 0;
|
address = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
codeAddress,
|
codeAddress,
|
||||||
codeSize);
|
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)
|
if (result != Result.Success)
|
||||||
{
|
{
|
||||||
Logger.Error?.Print(LogClass.Loader, $"Process initialization returned error \"{result}\".");
|
Logger.Error?.Print(LogClass.Loader, $"Process initialization returned error \"{result}\".");
|
||||||
|
|
@ -401,6 +401,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
MemoryMarshal.Cast<byte, uint>(npdm.KernelCapabilityData),
|
MemoryMarshal.Cast<byte, uint>(npdm.KernelCapabilityData),
|
||||||
resourceLimit,
|
resourceLimit,
|
||||||
memoryRegion,
|
memoryRegion,
|
||||||
|
context.Device.Configuration.MemoryConfiguration,
|
||||||
processContextFactory,
|
processContextFactory,
|
||||||
entrypointOffset: nsoPatch[0]?.Size ?? 0UL);
|
entrypointOffset: nsoPatch[0]?.Size ?? 0UL);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue