https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5ae65ab7a70aa6e627c24…
commit 5ae65ab7a70aa6e627c2462042584861258352b5
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Fri Jun 30 18:06:38 2023 +0300
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Sun Jul 2 21:00:32 2023 +0300
[NTOS:KE] Add x86 CPU features reporting to AMD64
CORE-18023 CORE-14922
---
ntoskrnl/include/internal/amd64/ke.h | 3 ++
ntoskrnl/ke/amd64/cpu.c | 54 ++++++++++++++++++++++++++++++++++++
ntoskrnl/ke/amd64/kiinit.c | 5 ++++
3 files changed, 62 insertions(+)
diff --git a/ntoskrnl/include/internal/amd64/ke.h b/ntoskrnl/include/internal/amd64/ke.h
index 318b119d513..3287e7567c2 100644
--- a/ntoskrnl/include/internal/amd64/ke.h
+++ b/ntoskrnl/include/internal/amd64/ke.h
@@ -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);
diff --git a/ntoskrnl/ke/amd64/cpu.c b/ntoskrnl/ke/amd64/cpu.c
index 0967411e644..274320c1b12 100644
--- a/ntoskrnl/ke/amd64/cpu.c
+++ b/ntoskrnl/ke/amd64/cpu.c
@@ -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)
diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c
index 65819290f46..a0dc2c5c5b8 100644
--- a/ntoskrnl/ke/amd64/kiinit.c
+++ b/ntoskrnl/ke/amd64/kiinit.c
@@ -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];