Skip to content

Commit be3dde7

Browse files
committed
[NTOS] Make KeFeatureBits 64 bit
1 parent 77e4217 commit be3dde7

File tree

10 files changed

+30
-10
lines changed

10 files changed

+30
-10
lines changed

ntoskrnl/ex/sysinfo.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,13 @@ QSI_DEF(SystemProcessorInformation)
664664
#else
665665
Spi->MaximumProcessors = 0;
666666
#endif
667-
Spi->ProcessorFeatureBits = KeFeatureBits;
667+
668+
/* According to Geoff Chappell, on Win 8.1 x64 / Win 10 x86, where this
669+
field is extended to 64 bits, it continues to produce only the low 32
670+
bits. For the full value, use SYSTEM_PROCESSOR_FEATURES_INFORMATION.
671+
See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/processor.htm
672+
*/
673+
Spi->ProcessorFeatureBits = (ULONG)KeFeatureBits;
668674

669675
DPRINT("Arch %u Level %u Rev 0x%x\n", Spi->ProcessorArchitecture,
670676
Spi->ProcessorLevel, Spi->ProcessorRevision);

ntoskrnl/include/internal/i386/ke.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ NTAPI
462462
KiSetProcessorType(VOID);
463463

464464
CODE_SEG("INIT")
465-
ULONG
465+
ULONG64
466466
NTAPI
467467
KiGetFeatureBits(VOID);
468468

ntoskrnl/include/internal/ke.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ extern BOOLEAN ExCmosClockIsSane;
103103
extern USHORT KeProcessorArchitecture;
104104
extern USHORT KeProcessorLevel;
105105
extern USHORT KeProcessorRevision;
106-
extern ULONG KeFeatureBits;
106+
extern ULONG64 KeFeatureBits;
107107
extern KNODE KiNode0;
108108
extern PKNODE KeNodeBlock[1];
109109
extern UCHAR KeNumberNodes;

ntoskrnl/ke/amd64/krnlinit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
233233
ULONG i;
234234

235235
/* Set boot-level flags */
236-
KeFeatureBits = Prcb->FeatureBits;
236+
KeFeatureBits = Prcb->FeatureBits | (ULONG64)Prcb->FeatureBitsHigh << 32;
237237

238238
/* Initialize 8/16 bit SList support */
239239
RtlpUse16ByteSLists = (KeFeatureBits & KF_CMPXCHG16B) ? TRUE : FALSE;

ntoskrnl/ke/i386/cpu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ KiSetProcessorType(VOID)
209209
}
210210

211211
CODE_SEG("INIT")
212-
ULONG
212+
ULONG64
213213
NTAPI
214214
KiGetFeatureBits(VOID)
215215
{
216216
PKPRCB Prcb = KeGetCurrentPrcb();
217217
ULONG Vendor;
218-
ULONG FeatureBits = KF_WORKING_PTE;
218+
ULONG64 FeatureBits = KF_WORKING_PTE;
219219
CPU_INFO CpuInfo, DummyCpuInfo;
220220
UCHAR Ccr1;
221221
BOOLEAN ExtendedCPUID = TRUE;

ntoskrnl/ke/i386/kiinit.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ KiVerifyCpuFeatures(PKPRCB Prcb)
384384
KeBugCheckEx(UNSUPPORTED_PROCESSOR, 0x386, 0, 0, 0);
385385

386386
// 3. Finally, obtain CPU features.
387-
ULONG FeatureBits = KiGetFeatureBits();
387+
ULONG64 FeatureBits = KiGetFeatureBits();
388388

389389
// 4. Verify it supports everything we need.
390390
if (!(FeatureBits & KF_RDTSC))
@@ -423,7 +423,8 @@ KiVerifyCpuFeatures(PKPRCB Prcb)
423423
}
424424

425425
// 5. Save feature bits.
426-
Prcb->FeatureBits = FeatureBits;
426+
Prcb->FeatureBits = (ULONG)FeatureBits;
427+
Prcb->FeatureBitsHigh = FeatureBits >> 32;
427428
}
428429

429430
CODE_SEG("INIT")
@@ -445,7 +446,7 @@ KiInitializeKernel(IN PKPROCESS InitProcess,
445446

446447
/* Set boot-level flags */
447448
if (Number == 0)
448-
KeFeatureBits = Prcb->FeatureBits;
449+
KeFeatureBits = Prcb->FeatureBits | (ULONG64)Prcb->FeatureBitsHigh << 32;
449450

450451
/* Set the default NX policy (opt-in) */
451452
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;

ntoskrnl/ke/krnlinit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
USHORT KeProcessorArchitecture;
2020
USHORT KeProcessorLevel;
2121
USHORT KeProcessorRevision;
22-
ULONG KeFeatureBits;
22+
ULONG64 KeFeatureBits;
2323

2424
/* System call count */
2525
ULONG KiServiceLimit = NUMBER_OF_SYSCALLS;

sdk/include/ndk/amd64/ketypes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,11 @@ typedef struct _KPRCB
939939
ULONG CacheCount;
940940
#endif
941941
#ifdef __REACTOS__
942+
#if (NTDDI_VERSION < NTDDI_WINBLUE)
943+
// On Win 8.1+ the FeatureBits field is extended to 64 bits
942944
ULONG FeatureBitsHigh;
943945
#endif
946+
#endif
944947
} KPRCB, *PKPRCB;
945948

946949
//

sdk/include/ndk/extypes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,11 @@ typedef struct _SYSTEM_PROCESSOR_INFORMATION
761761
#else
762762
USHORT MaximumProcessors;
763763
#endif
764+
#if (NTDDI_VERSION >= NTDDI_WIN10) || ((NTDDI_VERSION >= NTDDI_WINBLUE) && defined(_WIN64))
765+
ULONG64 ProcessorFeatureBits;
766+
#else
764767
ULONG ProcessorFeatureBits;
768+
#endif
765769
} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION;
766770

767771
// Class 2

sdk/include/ndk/i386/ketypes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,12 @@ typedef struct _KPRCB
781781
ULONG PackageProcessorSet;
782782
ULONG CoreProcessorSet;
783783
#endif
784+
#ifdef __REACTOS__
785+
#if (NTDDI_VERSION < NTDDI_WIN10)
786+
// On Win 10+ the FeatureBits field is extended to 64 bits
787+
ULONG FeatureBitsHigh;
788+
#endif
789+
#endif
784790
} KPRCB, *PKPRCB;
785791

786792
//

0 commit comments

Comments
 (0)