[HLE] Write single-view guest memory without the region lock
This commit is contained in:
parent
48258b1e50
commit
8f7fa3933f
|
|
@ -2070,6 +2070,13 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||
GuestImageWriteTracker.NotifyManagedWrite(virtualAddress, (ulong)source.Length);
|
||||
GuestGpuMemoryHook.MarkCpuWrite(virtualAddress, (ulong)source.Length);
|
||||
|
||||
if (!source.IsEmpty && _backedSpace is { } backed && !_disposed &&
|
||||
backed.TryWriteSingleView(virtualAddress, source))
|
||||
{
|
||||
NotifyGuestWriteWatch(virtualAddress, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
var requiresExclusiveAccess = false;
|
||||
_gate.EnterReadLock();
|
||||
try
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ public sealed class GuestSpaceOwner : IDisposable
|
|||
// Reads through a view that covers the whole range without any lock; false otherwise.
|
||||
public bool TryReadSingleView(ulong address, Span<byte> data) => _views.TryReadSingleView(address, data);
|
||||
|
||||
public bool TryWriteSingleView(ulong address, ReadOnlySpan<byte> data) => _views.TryWriteSingleView(address, data);
|
||||
|
||||
public object AliasSnapshot => _views.AliasSnapshot;
|
||||
|
||||
public bool TryEnterAliasAccess() => _views.TryEnterAliasAccess();
|
||||
|
|
|
|||
|
|
@ -118,6 +118,24 @@ public sealed unsafe class SharedBackingViews : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
public bool TryWriteSingleView(ulong address, ReadOnlySpan<byte> data)
|
||||
{
|
||||
if (!TryAccessSingleView(address, (ulong)data.Length, out var target))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
data.CopyTo(new Span<byte>((void*)target, data.Length));
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interlocked.Decrement(ref _activeAccesses);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryReadBacking(ulong address, Span<byte> data)
|
||||
{
|
||||
if (TryAccessSingleView(address, (ulong)data.Length, out var source))
|
||||
|
|
|
|||
Loading…
Reference in New Issue