KeFlushTb

VOID __stdcall KeFlushTb(_KTBFLUSH_TYPE FlushType, _KTBFLUSH_TARGET ProcessorSet){
  int v2; 
  INT64 v4; 
  _KTBFLUSH_TYPE v5; 
  INT64 v6; 
  char v7; 
  UINT8 v8; 
  unsigned __int8 CurrentIrql; 
  char Global[8]; 
  __int64 AddressSpace[4]; 
  char v12; 

  v2 = 0;
  AddressSpace[0] = 0i64;
  v4 = (unsigned int)ProcessorSet;
  v12 = 0;
  v5 = FlushType;
  Global[0] = 0;
  v6 = (unsigned int)FlushType;
  LOBYTE(FlushType) = 1;
  v7 = 0;
  if( KiPreprocessFlushTb(*(INT64 *)&FlushType, v6, v4, &v12) )
  {
    KiFlushCurrentTbOnly((unsigned int)v5);
    __writecr8(0i64);
    v7 = 1;
  }
  if( v12 )
  {
    KiPrepareFlushParameters(v5, (UINT64 *)AddressSpace, (UINT8 *)Global);
    v8 = KiFlushAffinity((unsigned int)ProcessorSet);
    KiFlushAddressSpaceTb(AddressSpace[0], v8);
  }
  else if( !v7 )
  {
    if( KiKvaShadow )
    {
      if( v5 != FlushUser && (v5 == FlushKernel || v5 == FlushSession) )
      {
LABEL_21:
        KxFlushNonGlobalTb(ProcessorSet);
        v2 = 1;
        goto LABEL_9;
      }
    }
    else if( v5 && v5 <= FlushSession )
    {
      goto LABEL_21;
    }
    KxFlushEntireTb(ProcessorSet);
    v2 = 1;
  }
LABEL_9:
  if( v5 == FlushUser && *(_QWORD *)&KeGetCurrentThread()->ApcState.Process->Pcb.SecureState )
    VslFlushSecureAddressSpace();
  if( !v2 && v5 == 4 )
    KeFlushProcessWriteBuffers(1u);
  if( VmTbFlushEnabled )
    VmFlushTb((_MEMORY_CACHING_TYPE_ORIG)0, 0i64, (unsigned int)v5);
  if( *(&stru_140CF2E80 + 1830) )
  {
    CurrentIrql = KeGetCurrentIrql();
    __writecr8(0xFui64);
    ExFlushTb(0i64, 0i64, v5);
    __writecr8(CurrentIrql);
  }
}

Referenced by:

MiAgeWorkingSetTail
MiAttachSession
MiFlushEntireTbDueToAttributeChange
MiFlushTbList
MiGetUltraMapping
MiGetWsAndMakePageTablesNx
MiInitializeTbFlush
MiInsertCachedPte
MiSwitchToPfns