https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6a6b383abd2ac86746fdadb0522aadef37328caf

commit 6a6b383abd2ac86746fdadb0522aadef37328caf
Author:     Stanislav Motylkov <[email protected]>
AuthorDate: Fri Jun 30 17:16:54 2023 +0300
Commit:     Stanislav Motylkov <[email protected]>
CommitDate: Sun Jul 2 21:00:31 2023 +0300

    [NTOS:KE] Report x86 CPU features in a separate function
    
    KiGetFeatureBits() is now being called in the early boot phase 0
    when the Kernel Debugger is not yet initialized, so debug prints
    are not available here. Move the debug prints into a new function
    and call it at the right time. CORE-18023
---
 ntoskrnl/include/internal/i386/ke.h |  6 +++
 ntoskrnl/ke/i386/cpu.c              | 80 +++++++++++++++++++++++--------------
 ntoskrnl/ke/i386/kiinit.c           |  6 +++
 3 files changed, 62 insertions(+), 30 deletions(-)

diff --git a/ntoskrnl/include/internal/i386/ke.h 
b/ntoskrnl/include/internal/i386/ke.h
index cc8bca420bf..30509248a2b 100644
--- a/ntoskrnl/include/internal/i386/ke.h
+++ b/ntoskrnl/include/internal/i386/ke.h
@@ -459,6 +459,12 @@ ULONG
 NTAPI
 KiGetFeatureBits(VOID);
 
+#if DBG
+CODE_SEG("INIT")
+VOID
+KiReportCpuFeatures(VOID);
+#endif
+
 VOID
 NTAPI
 KiThreadStartup(VOID);
diff --git a/ntoskrnl/ke/i386/cpu.c b/ntoskrnl/ke/i386/cpu.c
index d4634cbe33b..a39d27a2139 100644
--- a/ntoskrnl/ke/i386/cpu.c
+++ b/ntoskrnl/ke/i386/cpu.c
@@ -380,11 +380,6 @@ KiGetFeatureBits(VOID)
     if (CpuFeatures & X86_FEATURE_SSE)     FeatureBits |= KF_XMMI;
     if (CpuFeatures & X86_FEATURE_SSE2)    FeatureBits |= KF_XMMI64;
 
-    if (CpuFeatures & X86_FEATURE_PAE)
-    {
-        DPRINT1("Support PAE\n");
-    }
-
     /* Check if the CPU has hyper-threading */
     if (CpuFeatures & X86_FEATURE_HT)
     {
@@ -430,35 +425,60 @@ KiGetFeatureBits(VOID)
         }
     }
 
-#define print_supported(kf_value) ((FeatureBits & kf_value) ? #kf_value : "")
-    DPRINT1("Supported CPU features : %s %s %s %s %s %s %s %s %s %s %s %s %s 
%s %s %s %s %s %s %s %s\n",
-    print_supported(KF_V86_VIS),
-    print_supported(KF_RDTSC),
-    print_supported(KF_CR4),
-    print_supported(KF_CMOV),
-    print_supported(KF_GLOBAL_PAGE),
-    print_supported(KF_LARGE_PAGE),
-    print_supported(KF_MTRR),
-    print_supported(KF_CMPXCHG8B),
-    print_supported(KF_MMX),
-    print_supported(KF_WORKING_PTE),
-    print_supported(KF_PAT),
-    print_supported(KF_FXSR),
-    print_supported(KF_FAST_SYSCALL),
-    print_supported(KF_XMMI),
-    print_supported(KF_3DNOW),
-    print_supported(KF_AMDK6MTRR),
-    print_supported(KF_XMMI64),
-    print_supported(KF_DTS),
-    print_supported(KF_NX_BIT),
-    print_supported(KF_NX_DISABLED),
-    print_supported(KF_NX_ENABLED));
-#undef print_supported
-
     /* Return the Feature Bits */
     return FeatureBits;
 }
 
+#if DBG
+CODE_SEG("INIT")
+VOID
+KiReportCpuFeatures(VOID)
+{
+    ULONG CpuFeatures = 0;
+    CPU_INFO CpuInfo;
+
+    if (KiGetCpuVendor())
+    {
+        KiCpuId(&CpuInfo, 1);
+        CpuFeatures = CpuInfo.Edx;
+    }
+
+    DPRINT1("Supported CPU features: ");
+
+#define print_kf_bit(kf_value) if (KeFeatureBits & 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_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_AMDK6MTRR);
+    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);
+#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_APIC);
+    print_cf(X86_FEATURE_HT);
+#undef print_cf
+
+    DbgPrint("\n");
+}
+#endif // DBG
+
 CODE_SEG("INIT")
 VOID
 NTAPI
diff --git a/ntoskrnl/ke/i386/kiinit.c b/ntoskrnl/ke/i386/kiinit.c
index a83afe72c70..9699d11b03c 100644
--- a/ntoskrnl/ke/i386/kiinit.c
+++ b/ntoskrnl/ke/i386/kiinit.c
@@ -480,6 +480,12 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
     /* Save CPU state */
     KiSaveProcessorControlState(&Prcb->ProcessorState);
 
+#if DBG
+    /* Print applied kernel features/policies and boot CPU features */
+    if (Number == 0)
+        KiReportCpuFeatures();
+#endif
+
     /* Get cache line information for this CPU */
     KiGetCacheInformation();
 

Reply via email to