Compare commits
1 Commits
1016_part3
...
xnetcat/ba
| Author | SHA1 | Date |
|---|---|---|
|
|
aad66f89d5 |
|
|
@ -329,16 +329,31 @@ public static partial class KernelMemoryCompatExports
|
|||
internal static int ReserveBackingRange(CpuContext ctx, ulong pointer, ulong length, ulong flags, ulong alignment)
|
||||
=> RunMappingTransaction(() => ReserveBackingRangeCore(ctx, pointer, length, flags, alignment));
|
||||
|
||||
// A batch wraps its entries in one transaction, so the entries must not hand off again.
|
||||
[ThreadStatic]
|
||||
private static bool _insideMappingTransaction;
|
||||
|
||||
private static int RunMappingTransaction(Func<int> transaction)
|
||||
{
|
||||
// GPU handoff must precede locks needed by image and buffer reads.
|
||||
if (Monitor.IsEntered(_memoryGate))
|
||||
throw new InvalidOperationException("Cannot start a mapping transaction while holding the mapping lock.");
|
||||
if (GuestGpuMemoryHook.Current is not { } memory)
|
||||
if (_insideMappingTransaction || GuestGpuMemoryHook.Current is not { } memory)
|
||||
return transaction();
|
||||
|
||||
var result = MemoryFault;
|
||||
memory.RunMappingChange(() => result = transaction());
|
||||
memory.RunMappingChange(() =>
|
||||
{
|
||||
_insideMappingTransaction = true;
|
||||
try
|
||||
{
|
||||
result = transaction();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_insideMappingTransaction = false;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5777,7 +5777,12 @@ public static partial class KernelMemoryCompatExports
|
|||
return TryWriteCompat(ctx, address, bytes);
|
||||
}
|
||||
|
||||
// One transaction for the whole batch: every entry would otherwise hand the GPU worker
|
||||
// its own mapping change and wait for the GPU to drain before it could run.
|
||||
private static int KernelBatchMapCore(CpuContext ctx, int flags)
|
||||
=> RunMappingTransaction(() => KernelBatchMapTransaction(ctx, flags));
|
||||
|
||||
private static int KernelBatchMapTransaction(CpuContext ctx, int flags)
|
||||
{
|
||||
var entriesAddress = ctx[CpuRegister.Rdi];
|
||||
var entryCount = unchecked((int)ctx[CpuRegister.Rsi]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue