[NTOS] Make KeFeatureBits 64 bit

This commit is contained in:
Timo Kreuzer 2024-09-29 21:55:20 +03:00
parent 77e4217919
commit be3dde7698
10 changed files with 30 additions and 10 deletions

View file

@ -664,7 +664,13 @@ QSI_DEF(SystemProcessorInformation)
#else
Spi->MaximumProcessors = 0;
#endif
Spi->ProcessorFeatureBits = KeFeatureBits;
/* According to Geoff Chappell, on Win 8.1 x64 / Win 10 x86, where this
field is extended to 64 bits, it continues to produce only the low 32
bits. For the full value, use SYSTEM_PROCESSOR_FEATURES_INFORMATION.
See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/processor.htm
*/
Spi->ProcessorFeatureBits = (ULONG)KeFeatureBits;
DPRINT("Arch %u Level %u Rev 0x%x\n", Spi->ProcessorArchitecture,
Spi->ProcessorLevel, Spi->ProcessorRevision);

View file

@ -462,7 +462,7 @@ NTAPI
KiSetProcessorType(VOID);
CODE_SEG("INIT")
ULONG
ULONG64
NTAPI
KiGetFeatureBits(VOID);

View file

@ -103,7 +103,7 @@ extern BOOLEAN ExCmosClockIsSane;
extern USHORT KeProcessorArchitecture;
extern USHORT KeProcessorLevel;
extern USHORT KeProcessorRevision;
extern ULONG KeFeatureBits;
extern ULONG64 KeFeatureBits;
extern KNODE KiNode0;
extern PKNODE KeNodeBlock[1];
extern UCHAR KeNumberNodes;

View file

@ -233,7 +233,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
ULONG i;
/* Set boot-level flags */
KeFeatureBits = Prcb->FeatureBits;
KeFeatureBits = Prcb->FeatureBits | (ULONG64)Prcb->FeatureBitsHigh << 32;
/* Initialize 8/16 bit SList support */
RtlpUse16ByteSLists = (KeFeatureBits & KF_CMPXCHG16B) ? TRUE : FALSE;

View file

@ -209,13 +209,13 @@ KiSetProcessorType(VOID)
}
CODE_SEG("INIT")
ULONG
ULONG64
NTAPI
KiGetFeatureBits(VOID)
{
PKPRCB Prcb = KeGetCurrentPrcb();
ULONG Vendor;
ULONG FeatureBits = KF_WORKING_PTE;
ULONG64 FeatureBits = KF_WORKING_PTE;
CPU_INFO CpuInfo, DummyCpuInfo;
UCHAR Ccr1;
BOOLEAN ExtendedCPUID = TRUE;

View file

@ -384,7 +384,7 @@ KiVerifyCpuFeatures(PKPRCB Prcb)
KeBugCheckEx(UNSUPPORTED_PROCESSOR, 0x386, 0, 0, 0);
// 3. Finally, obtain CPU features.
ULONG FeatureBits = KiGetFeatureBits();
ULONG64 FeatureBits = KiGetFeatureBits();
// 4. Verify it supports everything we need.
if (!(FeatureBits & KF_RDTSC))
@ -423,7 +423,8 @@ KiVerifyCpuFeatures(PKPRCB Prcb)
}
// 5. Save feature bits.
Prcb->FeatureBits = FeatureBits;
Prcb->FeatureBits = (ULONG)FeatureBits;
Prcb->FeatureBitsHigh = FeatureBits >> 32;
}
CODE_SEG("INIT")
@ -445,7 +446,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
/* Set boot-level flags */
if (Number == 0)
KeFeatureBits = Prcb->FeatureBits;
KeFeatureBits = Prcb->FeatureBits | (ULONG64)Prcb->FeatureBitsHigh << 32;
/* Set the default NX policy (opt-in) */
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;

View file

@ -19,7 +19,7 @@
USHORT KeProcessorArchitecture;
USHORT KeProcessorLevel;
USHORT KeProcessorRevision;
ULONG KeFeatureBits;
ULONG64 KeFeatureBits;
/* System call count */
ULONG KiServiceLimit = NUMBER_OF_SYSCALLS;

View file

@ -939,8 +939,11 @@ typedef struct _KPRCB
ULONG CacheCount;
#endif
#ifdef __REACTOS__
#if (NTDDI_VERSION < NTDDI_WINBLUE)
// On Win 8.1+ the FeatureBits field is extended to 64 bits
ULONG FeatureBitsHigh;
#endif
#endif
} KPRCB, *PKPRCB;
//

View file

@ -761,7 +761,11 @@ typedef struct _SYSTEM_PROCESSOR_INFORMATION
#else
USHORT MaximumProcessors;
#endif
#if (NTDDI_VERSION >= NTDDI_WIN10) || ((NTDDI_VERSION >= NTDDI_WINBLUE) && defined(_WIN64))
ULONG64 ProcessorFeatureBits;
#else
ULONG ProcessorFeatureBits;
#endif
} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION;
// Class 2

View file

@ -781,6 +781,12 @@ typedef struct _KPRCB
ULONG PackageProcessorSet;
ULONG CoreProcessorSet;
#endif
#ifdef __REACTOS__
#if (NTDDI_VERSION < NTDDI_WIN10)
// On Win 10+ the FeatureBits field is extended to 64 bits
ULONG FeatureBitsHigh;
#endif
#endif
} KPRCB, *PKPRCB;
//