Signal memory tracking before/after mapping into another process (#1785)

* Signal memory tracking before/after mapping into another process

* Wording.

* Add missing method.
This commit is contained in:
riperiperi 2020-12-08 00:42:17 +00:00 committed by GitHub
parent 36f6bbf5b9
commit 4594c3b310
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 0 deletions

View file

@ -1656,6 +1656,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
}
}
// Signal a read for any resources tracking reads in the region, as the other process is likely to use their data.
_cpuMemory.SignalMemoryTracking(addressTruncated, endAddrRounded - addressTruncated, false);
lock (_blocks)
{
KernelResult result;
@ -2036,6 +2039,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
ulong endAddr = address + size;
ulong addressRounded = BitUtils.AlignUp (address, PageSize);
ulong addressTruncated = BitUtils.AlignDown(address, PageSize);
ulong endAddrRounded = BitUtils.AlignUp (endAddr, PageSize);
ulong endAddrTruncated = BitUtils.AlignDown(endAddr, PageSize);
ulong pagesCount = addressRounded < endAddrTruncated ? (endAddrTruncated - addressRounded) / PageSize : 0;
@ -2071,6 +2076,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
return KernelResult.OutOfResource;
}
// Anything on the client side should see this memory as modified.
_cpuMemory.SignalMemoryTracking(addressTruncated, endAddrRounded - addressTruncated, true);
lock (_blocks)
{
foreach (KMemoryInfo info in IterateOverRange(addressRounded, endAddrTruncated))

View file

@ -75,6 +75,11 @@ namespace Ryujinx.Memory.Tests
throw new NotImplementedException();
}
public void SignalMemoryTracking(ulong va, ulong size, bool write)
{
throw new NotImplementedException();
}
public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection)
{
}

View file

@ -545,5 +545,10 @@ namespace Ryujinx.Memory
_pageTable[l0] = null;
}
}
public void SignalMemoryTracking(ulong va, ulong size, bool write)
{
// Only the ARM Memory Manager has tracking for now.
}
}
}

View file

@ -23,6 +23,7 @@ namespace Ryujinx.Memory
bool IsRangeMapped(ulong va, ulong size);
ulong GetPhysicalAddress(ulong va);
void SignalMemoryTracking(ulong va, ulong size, bool write);
void TrackingReprotect(ulong va, ulong size, MemoryPermission protection);
}
}