KeCpuSetReportParkedProcessors
VOID __stdcall KeCpuSetReportParkedProcessors(_KAFFINITY_EX *CoreParkingMask, UINT8 OldIrql){
unsigned int v2;
UINT8 v3;
int v5;
unsigned __int16 v6;
int v7;
unsigned __int64 v8;
UINT64 v9;
unsigned __int64 v10;
unsigned __int64 v11;
unsigned __int64 v12;
unsigned __int16 i;
__int64 v14;
struct _KPRCB *CurrentPrcb;
_ETHREAD *CurrentThread;
bool v17;
unsigned __int64 v18;
__int64 v19;
__int64 v20;
__int64 v21;
__int64 v22;
UINT64 v23;
unsigned __int64 v24;
_SINGLE_LIST_ENTRY *Next;
__int64 v26;
unsigned __int64 v27;
unsigned __int64 v28;
int v29;
__int64 v30;
__int64 v31;
INT64 v32;
_ETHREAD *NextThread;
char v34;
INT64 v35;
INT64 v36;
_SINGLE_LIST_ENTRY ReadyList;
int v38;
UINT64 SpinCount[20];
v2 = (unsigned __int16)KiActiveGroups;
v3 = OldIrql;
v38 = 0;
v36 = (unsigned __int16)KiActiveGroups;
LOBYTE(v35) = OldIrql;
_m_prefetchw(KiCpuSetAffinities);
_m_prefetchw(KiCpuSetAffinitiesShadow);
if( CoreParkingMask )
KxAcquireSpinLock(&KiCpuSetLock);
v5 = 0;
HIDWORD(v35) = 0;
v6 = 0;
if( v2 )
{
v7 = 0;
while( 1 )
{
v8 = KeActiveProcessors.Bitmap[v6];
if( CoreParkingMask )
{
if( v6 >= CoreParkingMask->Count )
v18 = 0i64;
else
v18 = CoreParkingMask->Bitmap[v6];
v9 = v8 ^ v18;
*(UINT64 *)((char *)&SpinCount[v6] + 4) = v9;
if( KiNonParkedCpuSets[v6] == v9 )
goto LABEL_53;
}
else
{
v9 = KiNonParkedCpuSets[v6];
*(UINT64 *)((char *)&SpinCount[v6] + 4) = v9;
}
HIDWORD(v35) = 1;
v10 = v8 & v9;
v5 = 1;
v11 = v8 ^ v8 & v9;
if( (v8 & v9) != 0 )
{
do
{
_BitScanForward64(&v12, v10);
v38 = v12;
v10 ^= 1i64 << v12;
*((_QWORD *)KiCpuSetAffinitiesShadow + (unsigned int)((v7 << 6) + v12)) = 1i64 << v12;
}
while( v10 );
v2 = v36;
v5 = 1;
}
if( !v11 )
goto LABEL_11;
v19 = qword_140CFCA78[2 * v6];
v20 = v19 & -(__int64)((v9 & (v8 ^ v19)) != 0 && (v9 & v19) != 0);
v21 = (v8 ^ v19) & -(__int64)((v9 & (v8 ^ v19)) != 0 && (v9 & v19) != 0);
v22 = v8 ^ KiSystemAllowedCpuSets[2 * v6];
ReadyList.Next = (_SINGLE_LIST_ENTRY *)v21;
v23 = v22 & v9;
if( v22 )
{
if( v23 )
{
v24 = v11 & v22;
v11 ^= v24;
if( v24 )
{
Next = ReadyList.Next;
do
{
_BitScanForward64((unsigned __int64 *)&v26, v24);
v24 &= ~(1i64 << v26);
HIDWORD(v36) = v26;
if( _bittest64(&v20, (unsigned int)v26) )
{
v27 = v23 & v20;
if( (v23 & v20) == 0 )
v27 = v23;
}
else
{
v27 = v23;
if( (v23 & (unsigned __int64)Next) != 0 )
v27 = v23 & (unsigned __int64)Next;
}
*((_QWORD *)KiCpuSetAffinitiesShadow + (unsigned int)((v7 << 6) + v26)) = v27;
}
while( v24 );
v2 = v36;
v21 = (__int64)ReadyList.Next;
}
}
}
if( v11 )
{
v28 = v8 & ~v23;
if( (v9 & v28) == 0 )
v28 = v8;
v29 = v7 << 6;
do
{
_BitScanForward64((unsigned __int64 *)&v30, v11);
v31 = v28;
v11 &= ~(1i64 << v30);
HIDWORD(v36) = v30;
if( _bittest64(&v20, (unsigned int)v30) )
{
v31 = v20 & v28;
if( (v28 & v9 & v20) == 0 )
v31 = v28;
}
else if( (v9 & v21 & v28) != 0 )
{
v31 = v28 & v21;
}
*((_QWORD *)KiCpuSetAffinitiesShadow + (unsigned int)(v29 + v30)) = v31;
}
while( v11 );
}
LABEL_53:
v5 = HIDWORD(v35);
LABEL_11:
v7 = ++v6;
if( v6 >= v2 )
{
v3 = v35;
break;
}
}
}
ReadyList.Next = 0i64;
if( v5 )
{
RtlWriteAcquireTickLock(&KiCpuSetSequence);
for( i = 0; i < v2; KiNonParkedCpuSets[v14] = *(UINT64 *)((char *)&SpinCount[v14] + 4) )
v14 = i++;
memmove(KiCpuSetAffinities, KiCpuSetAffinitiesShadow, KiCpuSetAffinitySize);
++KiCpuSetSequence;
KiUpdateGlobalCpuSetConfiguration(&ReadyList);
}
KxReleaseSpinLock(&KiCpuSetLock);
CurrentPrcb = KeGetCurrentPrcb();
KiReadyDeferredReadyList(CurrentPrcb, &ReadyList);
if( v3 >= 2u )
{
if( CurrentPrcb->NextThread && !CurrentPrcb->DpcRoutineActive )
KiRequestSoftwareInterrupt(CurrentPrcb, 2);
}
else
{
CurrentThread = CurrentPrcb->CurrentThread;
if( CurrentPrcb->NextThread )
{
KiAbProcessContextSwitch(&CurrentPrcb->CurrentThread->Tcb, 0i64);
LODWORD(SpinCount[0]) = 0;
while( _interlockedbittestandset64((volatile signed __int32 *)&CurrentPrcb->PrcbLock, 0i64) )
{
do
KeYieldProcessorEx(SpinCount);
while( CurrentPrcb->PrcbLock );
}
NextThread = CurrentPrcb->NextThread;
CurrentPrcb->NextThread = 0i64;
_disable();
KiEndThreadCycleAccumulation((INT64)CurrentPrcb, (INT64)CurrentThread, 0i64, v32, v35, v36, (INT64)ReadyList.Next);
_enable();
CurrentPrcb->CurrentThread = NextThread;
if( NextThread->Tcb.WaitBlockFill6[68] == 1 )
NextThread->Tcb.ReadyTime = NextThread->Tcb.ReadyTime
- NextThread->Tcb.WaitBlock[2].SpareLong
+ KUSER_SHARED_DATA.TickCount.LowPart;
NextThread->Tcb.WaitBlockFill6[68] = 2;
CurrentThread->Tcb.WaitReason = 32;
CurrentThread->Tcb.WaitIrql = v3;
KiQueueReadyThread(CurrentPrcb, &CurrentThread->Tcb);
KiSwapContext();
v17 = v34 == 0;
}
else
{
v17 = (CurrentThread->Tcb._bf_0 & 0x40) == 0;
}
if( !v17 )
{
__writecr8(1ui64);
CurrentThread->Tcb._bf_0 &= ~0x40u;
KiDeliverApc(0, 0i64, 0i64);
}
__writecr8(v3);
}
}Referenced by:
KeSetSystemAllowedCpuSets
PpmParkReportMask