[NTOS:KE] Add x86 CPU features reporting to AMD64

CORE-18023 CORE-14922
This commit is contained in:
Stanislav Motylkov 2023-06-30 18:06:38 +03:00
parent 6a6b383abd
commit 5ae65ab7a7
3 changed files with 62 additions and 0 deletions

View file

@ -420,6 +420,9 @@ VOID KiGetCacheInformation(VOID);
VOID KiSetProcessorType(VOID);
ULONG KiGetFeatureBits(VOID);
VOID KiInitializeCpuFeatures(VOID);
#if DBG
VOID KiReportCpuFeatures(IN PKPRCB Prcb);
#endif
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
VOID KeFreeGdtSelector(ULONG Entry);

View file

@ -234,6 +234,60 @@ KiGetFeatureBits(VOID)
return FeatureBits;
}
#if DBG
VOID
KiReportCpuFeatures(IN PKPRCB Prcb)
{
ULONG CpuFeatures = 0;
CPU_INFO CpuInfo;
if (Prcb->CpuVendor)
{
KiCpuId(&CpuInfo, 1);
CpuFeatures = CpuInfo.Edx;
}
DPRINT1("Supported CPU features: ");
#define print_kf_bit(kf_value) if (Prcb->FeatureBits & kf_value) DbgPrint(#kf_value " ")
print_kf_bit(KF_V86_VIS);
print_kf_bit(KF_RDTSC);
print_kf_bit(KF_CR4);
print_kf_bit(KF_CMOV);
print_kf_bit(KF_GLOBAL_PAGE);
print_kf_bit(KF_LARGE_PAGE);
print_kf_bit(KF_MTRR);
print_kf_bit(KF_CMPXCHG8B);
print_kf_bit(KF_CMPXCHG16B);
print_kf_bit(KF_MMX);
print_kf_bit(KF_WORKING_PTE);
print_kf_bit(KF_PAT);
print_kf_bit(KF_FXSR);
print_kf_bit(KF_FAST_SYSCALL);
print_kf_bit(KF_XMMI);
print_kf_bit(KF_3DNOW);
print_kf_bit(KF_XMMI64);
print_kf_bit(KF_DTS);
print_kf_bit(KF_NX_BIT);
print_kf_bit(KF_NX_DISABLED);
print_kf_bit(KF_NX_ENABLED);
print_kf_bit(KF_SSE3);
//print_kf_bit(KF_SSE3SUP);
//print_kf_bit(KF_SSE41);
//print_kf_bit(KF_MONITOR);
//print_kf_bit(KF_POPCNT);
print_kf_bit(KF_XSTATE);
#undef print_kf_bit
#define print_cf(cpu_flag) if (CpuFeatures & cpu_flag) DbgPrint(#cpu_flag " ")
print_cf(X86_FEATURE_PAE);
print_cf(X86_FEATURE_HT);
#undef print_cf
DbgPrint("\n");
}
#endif // DBG
VOID
NTAPI
KiGetCacheInformation(VOID)

View file

@ -341,6 +341,11 @@ KiInitializeKernelMachineDependent(
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_ALWAYSOFF;
Prcb->FeatureBits |= KF_NX_DISABLED;
}
#if DBG
/* Print applied kernel features/policies and boot CPU features */
KiReportCpuFeatures(Prcb);
#endif
}
static LDR_DATA_TABLE_ENTRY LdrCoreEntries[3];