mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-21 07:22:05 +00:00
Fix kernel VA allocation when random allocation fails (#3755)
* Fix kernel VA allocation when random allocation fails * This was off by one
This commit is contained in:
parent
2aeb5b00e3
commit
f5a1de6ac5
1 changed files with 9 additions and 9 deletions
|
@ -2540,11 +2540,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
|
|
||||||
for (int attempt = 0; attempt < 8; attempt++)
|
for (int attempt = 0; attempt < 8; attempt++)
|
||||||
{
|
{
|
||||||
address = BitUtils.AlignDown(regionStart + GetRandomValue(0, aslrMaxOffset) * (ulong)alignment, alignment);
|
ulong aslrAddress = BitUtils.AlignDown(regionStart + GetRandomValue(0, aslrMaxOffset) * (ulong)alignment, alignment);
|
||||||
|
ulong aslrEndAddr = aslrAddress + totalNeededSize;
|
||||||
|
|
||||||
ulong endAddr = address + totalNeededSize;
|
KMemoryInfo info = _blockManager.FindBlock(aslrAddress).GetInfo();
|
||||||
|
|
||||||
KMemoryInfo info = _blockManager.FindBlock(address).GetInfo();
|
|
||||||
|
|
||||||
if (info.State != MemoryState.Unmapped)
|
if (info.State != MemoryState.Unmapped)
|
||||||
{
|
{
|
||||||
|
@ -2554,11 +2553,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
ulong currBaseAddr = info.Address + reservedPagesCount * PageSize;
|
ulong currBaseAddr = info.Address + reservedPagesCount * PageSize;
|
||||||
ulong currEndAddr = info.Address + info.Size;
|
ulong currEndAddr = info.Address + info.Size;
|
||||||
|
|
||||||
if (address >= regionStart &&
|
if (aslrAddress >= regionStart &&
|
||||||
address >= currBaseAddr &&
|
aslrAddress >= currBaseAddr &&
|
||||||
endAddr - 1 <= regionEndAddr - 1 &&
|
aslrEndAddr - 1 <= regionEndAddr - 1 &&
|
||||||
endAddr - 1 <= currEndAddr - 1)
|
aslrEndAddr - 1 <= currEndAddr - 1)
|
||||||
{
|
{
|
||||||
|
address = aslrAddress;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2603,7 +2603,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||||
|
|
||||||
ulong totalNeededSize = reservedSize + neededPagesCount * PageSize;
|
ulong totalNeededSize = reservedSize + neededPagesCount * PageSize;
|
||||||
|
|
||||||
ulong regionEndAddr = regionStart + regionPagesCount * PageSize;
|
ulong regionEndAddr = (regionStart + regionPagesCount * PageSize) - 1;
|
||||||
|
|
||||||
KMemoryBlock currBlock = _blockManager.FindBlock(regionStart);
|
KMemoryBlock currBlock = _blockManager.FindBlock(regionStart);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue