From f4fd842be1abfe35b319fa89d94d93f6fc3b8413 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 4 May 2025 02:14:01 +0300 Subject: [PATCH] [NTOS:KE/X64] Move initialization of keFeatureBits --- ntoskrnl/ke/amd64/kiinit.c | 8 +++++--- ntoskrnl/ke/amd64/krnlinit.c | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/ke/amd64/kiinit.c b/ntoskrnl/ke/amd64/kiinit.c index 09a33226288..125cf852c86 100644 --- a/ntoskrnl/ke/amd64/kiinit.c +++ b/ntoskrnl/ke/amd64/kiinit.c @@ -346,7 +346,7 @@ KiInitializeKernelMachineDependent( IN PKPRCB Prcb, IN PLOADER_PARAMETER_BLOCK LoaderBlock) { - ULONG64 FeatureBits; + ULONG64 FeatureBits = KeFeatureBits; /* Set boot-level flags */ KeI386CpuType = Prcb->CpuType; @@ -356,8 +356,6 @@ KiInitializeKernelMachineDependent( if (Prcb->CpuID) KeProcessorRevision = Prcb->CpuStep; - FeatureBits = Prcb->FeatureBits | (ULONG64)Prcb->FeatureBitsHigh << 32; - /* Set basic CPU Features that user mode can read */ SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_PRECISION_ERRATA] = FALSE; SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = FALSE; @@ -522,6 +520,10 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Initial setup for the boot CPU */ if (Cpu == 0) { + /* Set global feature bits */ + KeFeatureBits = (ULONG64)Pcr->Prcb.FeatureBitsHigh << 32 | + Pcr->Prcb.FeatureBits; + /* Initialize the module list (ntos, hal, kdcom) */ KiInitModuleList(LoaderBlock); diff --git a/ntoskrnl/ke/amd64/krnlinit.c b/ntoskrnl/ke/amd64/krnlinit.c index f580cacbba9..01d5b099d9b 100644 --- a/ntoskrnl/ke/amd64/krnlinit.c +++ b/ntoskrnl/ke/amd64/krnlinit.c @@ -232,9 +232,6 @@ KiInitializeKernel(IN PKPROCESS InitProcess, PVOID DpcStack; ULONG i; - /* Set boot-level flags */ - KeFeatureBits = Prcb->FeatureBits | (ULONG64)Prcb->FeatureBitsHigh << 32; - /* Initialize 8/16 bit SList support */ RtlpUse16ByteSLists = (KeFeatureBits & KF_CMPXCHG16B) ? TRUE : FALSE;