https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9c1cfe058706ff31dbcd3c7b53eec879f66c8030

commit 9c1cfe058706ff31dbcd3c7b53eec879f66c8030
Author:     Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Wed Dec 20 20:04:41 2023 +0200
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Thu Jan 18 22:41:46 2024 +0100

    [NTOS:KE] Fix initialization of node block for application processors
    
    - Initialize KeNodeBlock[0] statically
    - Update Prcb->ParentNode->ProcessorMask for all processors
---
 ntoskrnl/ke/amd64/krnlinit.c |  9 ++++-----
 ntoskrnl/ke/i386/kiinit.c    | 11 +++++------
 ntoskrnl/ke/krnlinit.c       |  2 +-
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/ntoskrnl/ke/amd64/krnlinit.c b/ntoskrnl/ke/amd64/krnlinit.c
index 34d1a6621f6..d7aea4db738 100644
--- a/ntoskrnl/ke/amd64/krnlinit.c
+++ b/ntoskrnl/ke/amd64/krnlinit.c
@@ -147,6 +147,10 @@ KiSystemStartupBootStack(VOID)
     PKPROCESS Process = Thread->ApcState.Process;
     PVOID KernelStack = (PVOID)KeLoaderBlock->KernelStack;
 
+    /* Set Node Data */
+    Prcb->ParentNode = KeNodeBlock[0];
+    Prcb->ParentNode->ProcessorMask |= Prcb->SetMember;
+
     /* Initialize the Power Management Support for this PRCB */
     PoInitializePrcb(Prcb);
 
@@ -228,11 +232,6 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
     PVOID DpcStack;
     ULONG i;
 
-    /* Set Node Data */
-    KeNodeBlock[0] = &KiNode0;
-    Prcb->ParentNode = KeNodeBlock[0];
-    KeNodeBlock[0]->ProcessorMask = Prcb->SetMember;
-
     /* Set boot-level flags */
     KeFeatureBits = Prcb->FeatureBits;
 
diff --git a/ntoskrnl/ke/i386/kiinit.c b/ntoskrnl/ke/i386/kiinit.c
index 54d902add4b..2620885156a 100644
--- a/ntoskrnl/ke/i386/kiinit.c
+++ b/ntoskrnl/ke/i386/kiinit.c
@@ -413,7 +413,7 @@ KiVerifyCpuFeatures(PKPRCB Prcb)
     Cr0 &= ~(CR0_EM | CR0_MP);
     // Enable FPU exceptions.
     Cr0 |= CR0_NE;
-    
+
     __writecr0(Cr0);
 
     // Check for Pentium FPU bug.
@@ -492,14 +492,13 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
     /* Initialize spinlocks and DPC data */
     KiInitSpinLocks(Prcb, Number);
 
+    /* Set Node Data */
+    Prcb->ParentNode = KeNodeBlock[0];
+    Prcb->ParentNode->ProcessorMask |= Prcb->SetMember;
+
     /* Check if this is the Boot CPU */
     if (!Number)
     {
-        /* Set Node Data */
-        KeNodeBlock[0] = &KiNode0;
-        Prcb->ParentNode = KeNodeBlock[0];
-        KeNodeBlock[0]->ProcessorMask = Prcb->SetMember;
-
         /* Set boot-level flags */
         KeI386CpuType = Prcb->CpuType;
         KeI386CpuStep = Prcb->CpuStep;
diff --git a/ntoskrnl/ke/krnlinit.c b/ntoskrnl/ke/krnlinit.c
index cac3e1f8007..66299e3d57c 100644
--- a/ntoskrnl/ke/krnlinit.c
+++ b/ntoskrnl/ke/krnlinit.c
@@ -36,7 +36,7 @@ CCHAR KeNumberProcessors = 0;
 
 /* NUMA Node Support */
 KNODE KiNode0;
-PKNODE KeNodeBlock[1];
+PKNODE KeNodeBlock[1] = { &KiNode0 };
 UCHAR KeNumberNodes = 1;
 UCHAR KeProcessNodeSeed;
 

Reply via email to