[NTOS:KE] Fix usage of KTHREAD::SwapBusy

This commit is contained in:
Timo Kreuzer 2021-06-07 13:57:32 +02:00
parent a011d19ed2
commit f4d47faeb7
3 changed files with 12 additions and 0 deletions

View file

@ -149,6 +149,14 @@ PUBLIC KiThreadStartup
.allocstack (6 * 8) .allocstack (6 * 8)
.endprolog .endprolog
/* Wait for SwapBusy */
.SwapBusySet:
cmp byte ptr [r8 + ThSwapBusy], 0
je .SwapBusyClear
pause
jmp .SwapBusySet
.SwapBusyClear:
/* Save WaitIrql as KSWITCH_FRAME::ApcBypass */ /* Save WaitIrql as KSWITCH_FRAME::ApcBypass */
mov [rsp + SwApcBypass], cl mov [rsp + SwApcBypass], cl

View file

@ -184,6 +184,9 @@ KiSwapContextResume(
0); 0);
} }
/* Old thread os no longer busy */
OldThread->SwapBusy = FALSE;
/* Kernel APCs may be pending */ /* Kernel APCs may be pending */
if (NewThread->ApcState.KernelApcPending) if (NewThread->ApcState.KernelApcPending)
{ {

View file

@ -762,6 +762,7 @@ OFFSET(ThSystemCallNumber, KTHREAD, SystemCallNumber),
OFFSET(ThTrapFrame, KTHREAD, TrapFrame), OFFSET(ThTrapFrame, KTHREAD, TrapFrame),
OFFSET(ThApcState, KTHREAD, ApcState), OFFSET(ThApcState, KTHREAD, ApcState),
OFFSET(ThPriority, KTHREAD, Priority), // obsolete OFFSET(ThPriority, KTHREAD, Priority), // obsolete
OFFSET(ThSwapBusy, KTHREAD, SwapBusy),
OFFSET(ThContextSwitches, KTHREAD, ContextSwitches), OFFSET(ThContextSwitches, KTHREAD, ContextSwitches),
OFFSET(ThState, KTHREAD, State), OFFSET(ThState, KTHREAD, State),
OFFSET(ThProcess, KTHREAD, Process), // thProcess in native headers OFFSET(ThProcess, KTHREAD, Process), // thProcess in native headers