diff --git a/ntoskrnl/ke/amd64/cpu.c b/ntoskrnl/ke/amd64/cpu.c index 274320c1b12..075326d91ce 100644 --- a/ntoskrnl/ke/amd64/cpu.c +++ b/ntoskrnl/ke/amd64/cpu.c @@ -151,7 +151,7 @@ KiGetFeatureBits(VOID) { PKPRCB Prcb = KeGetCurrentPrcb(); ULONG Vendor; - ULONG FeatureBits = KF_WORKING_PTE; + ULONG FeatureBits = 0; CPU_INFO CpuInfo; /* Get the Vendor ID */ @@ -167,7 +167,7 @@ KiGetFeatureBits(VOID) Prcb->InitialApicId = (UCHAR)(CpuInfo.Ebx >> 24); /* Convert all CPUID Feature bits into our format */ - if (CpuInfo.Edx & X86_FEATURE_VME) FeatureBits |= KF_V86_VIS | KF_CR4; + if (CpuInfo.Edx & X86_FEATURE_VME) FeatureBits |= KF_CR4; if (CpuInfo.Edx & X86_FEATURE_PSE) FeatureBits |= KF_LARGE_PAGE | KF_CR4; if (CpuInfo.Edx & X86_FEATURE_TSC) FeatureBits |= KF_RDTSC; if (CpuInfo.Edx & X86_FEATURE_CX8) FeatureBits |= KF_CMPXCHG8B; @@ -183,11 +183,9 @@ KiGetFeatureBits(VOID) if (CpuInfo.Edx & X86_FEATURE_SSE2) FeatureBits |= KF_XMMI64; if (CpuInfo.Ecx & X86_FEATURE_SSE3) FeatureBits |= KF_SSE3; - //if (CpuInfo.Ecx & X86_FEATURE_MONITOR) FeatureBits |= KF_MONITOR; - //if (CpuInfo.Ecx & X86_FEATURE_SSSE3) FeatureBits |= KF_SSE3SUP; + //if (CpuInfo.Ecx & X86_FEATURE_SSSE3) FeatureBits |= KF_SSSE3; if (CpuInfo.Ecx & X86_FEATURE_CX16) FeatureBits |= KF_CMPXCHG16B; - //if (CpuInfo.Ecx & X86_FEATURE_SSE41) FeatureBits |= KF_SSE41; - //if (CpuInfo.Ecx & X86_FEATURE_POPCNT) FeatureBits |= KF_POPCNT; + //if (CpuInfo.Ecx & X86_FEATURE_SSE41) FeatureBits |= KF_SSE4_1; if (CpuInfo.Ecx & X86_FEATURE_XSAVE) FeatureBits |= KF_XSTATE; /* Check if the CPU has hyper-threading */ @@ -250,7 +248,7 @@ KiReportCpuFeatures(IN PKPRCB Prcb) DPRINT1("Supported CPU features: "); #define print_kf_bit(kf_value) if (Prcb->FeatureBits & kf_value) DbgPrint(#kf_value " ") - print_kf_bit(KF_V86_VIS); + print_kf_bit(KF_SMEP); print_kf_bit(KF_RDTSC); print_kf_bit(KF_CR4); print_kf_bit(KF_CMOV); @@ -260,7 +258,6 @@ KiReportCpuFeatures(IN PKPRCB Prcb) print_kf_bit(KF_CMPXCHG8B); print_kf_bit(KF_CMPXCHG16B); 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); @@ -272,10 +269,8 @@ KiReportCpuFeatures(IN PKPRCB Prcb) print_kf_bit(KF_NX_DISABLED); print_kf_bit(KF_NX_ENABLED); print_kf_bit(KF_SSE3); - //print_kf_bit(KF_SSE3SUP); - //print_kf_bit(KF_SSE41); - //print_kf_bit(KF_MONITOR); - //print_kf_bit(KF_POPCNT); + print_kf_bit(KF_SSSE3); + print_kf_bit(KF_SSE4_1); print_kf_bit(KF_XSTATE); #undef print_kf_bit diff --git a/sdk/include/ndk/amd64/ketypes.h b/sdk/include/ndk/amd64/ketypes.h index e09c0a884ce..553c3bdb956 100644 --- a/sdk/include/ndk/amd64/ketypes.h +++ b/sdk/include/ndk/amd64/ketypes.h @@ -24,6 +24,62 @@ Author: // Dependencies // +// +// Kernel Feature Bits +// See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/structs/kprcb/featurebits.htm?tx=61&ts=0,1400 +// +#define KF_SMEP 0x00000001 // Win 6.2 +#define KF_RDTSC 0x00000002 // From ks386.inc, ksamd64.inc +#define KF_CR4 0x00000004 // From ks386.inc, ksamd64.inc +#define KF_CMOV 0x00000008 +#define KF_GLOBAL_PAGE 0x00000010 // From ks386.inc, ksamd64.inc +#define KF_LARGE_PAGE 0x00000020 // From ks386.inc, ksamd64.inc +#define KF_MTRR 0x00000040 +#define KF_CMPXCHG8B 0x00000080 // From ks386.inc, ksamd64.inc +#define KF_MMX 0x00000100 +#define KF_DTS 0x00000200 // Win 5.2-6.2 +#define KF_PAT 0x00000400 +#define KF_FXSR 0x00000800 +#define KF_FAST_SYSCALL 0x00001000 // From ks386.inc, ksamd64.inc +#define KF_XMMI 0x00002000 // SSE +#define KF_3DNOW 0x00004000 +#define KF_AMDK6MTRR 0x00008000 // Win 5.0-6.1 +#define KF_XSAVEOPT 0x00008000 // From KF_XSAVEOPT_BIT +#define KF_XMMI64 0x00010000 // SSE2 +#define KF_BRANCH 0x00020000 // From ksamd64.inc, Win 6.1-6.2 +#define KF_00040000 0x00040000 // Unclear +#define KF_SSE3 0x00080000 // Win 6.0+ +#define KF_CMPXCHG16B 0x00100000 // Win 6.0-6.2 +#define KF_AUTHENTICAMD 0x00200000 // Win 6.1+ +#define KF_ACNT2 0x00400000 // Win 6.1+ +#define KF_XSTATE 0x00800000 // From ksamd64.inc, Win 6.1+ +#define KF_GENUINE_INTEL 0x01000000 // Win 6.1+ +#define KF_02000000 0x02000000 // Unclear +#define KF_SLAT 0x04000000 // Win 6.2+, Intel: EPT supported +#define KF_VIRT_FIRMWARE_ENABLED 0x08000000 // Win 6.2+ +#define KF_RDWRFSGSBASE 0x10000000 // From ksamd64.inc KF_RDWRFSGSBASE_BIT (0x1C) +#define KF_NX_BIT 0x20000000 +#define KF_NX_DISABLED 0x40000000 +#define KF_NX_ENABLED 0x80000000 +#define KF_RDRAND 0x0000000100000000ULL // Win 10.0+ +#define KF_SMAP 0x0000000200000000ULL // From ksamd64.inc +#define KF_RDTSCP 0x0000000400000000ULL // Win 10.0+ +#define KF_HUGEPAGE 0x0000002000000000ULL // Win 10.0 1607+ +#define KF_XSAVES 0x0000004000000000ULL // From ksamd64.inc KF_XSAVES_BIT (0x26) +#define KF_FPU_LEAKAGE 0x0000020000000000ULL // From ksamd64.inc KF_FPU_LEAKAGE_BIT (0x29) +#define KF_CAT 0x0000100000000000ULL // From ksamd64.inc KF_CAT_BIT (0x02C) +#define KF_CET_SS 0x0000400000000000ULL // From ksamd64.inc +#define KF_SSSE3 0x0000800000000000ULL +#define KF_SSE4_1 0x0001000000000000ULL +#define KF_SSE4_2 0x0002000000000000ULL + +#define KF_XSAVEOPT_BIT 15 // From ksamd64.inc (0x0F -> 0x8000) +#define KF_XSTATE_BIT 23 // From ksamd64.inc (0x17 -> 0x800000) +#define KF_RDWRFSGSBASE_BIT 28 // From ksamd64.inc (0x1C -> 0x10000000) +#define KF_XSAVES_BIT 38 // From ksamd64.inc (0x26 -> 0x4000000000) +#define KF_FPU_LEAKAGE_BIT 41 // From ksamd64.inc (0x29 -> 0x20000000000) +#define KF_CAT_BIT 44 // From ksamd64.inc (0x2C -> 0x100000000000) + // // KPCR Access for non-IA64 builds // diff --git a/sdk/include/ndk/i386/ketypes.h b/sdk/include/ndk/i386/ketypes.h index 8a9ea4c2ad5..6eb97d81ba0 100644 --- a/sdk/include/ndk/i386/ketypes.h +++ b/sdk/include/ndk/i386/ketypes.h @@ -23,6 +23,52 @@ Author: // Dependencies // +// +// Kernel Feature Bits +// See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/structs/kprcb/featurebits.htm?tx=61&ts=0,1400 +// +#define KF_V86_VIS 0x00000001 // From ks386.inc +#define KF_RDTSC 0x00000002 // From ks386.inc, ksamd64.inc +#define KF_CR4 0x00000004 // From ks386.inc, ksamd64.inc +#define KF_CMOV 0x00000008 +#define KF_GLOBAL_PAGE 0x00000010 // From ks386.inc, ksamd64.inc +#define KF_LARGE_PAGE 0x00000020 // From ks386.inc, ksamd64.inc +#define KF_MTRR 0x00000040 +#define KF_CMPXCHG8B 0x00000080 // From ks386.inc, ksamd64.inc +#define KF_MMX 0x00000100 +#define KF_WORKING_PTE 0x00000200 +#define KF_PAT 0x00000400 +#define KF_FXSR 0x00000800 +#define KF_FAST_SYSCALL 0x00001000 // From ks386.inc, ksamd64.inc +#define KF_XMMI 0x00002000 // SSE +#define KF_3DNOW 0x00004000 +#define KF_AMDK6MTRR 0x00008000 // Win 5.0-6.1 +#define KF_XSAVEOPT 0x00008000 // From KF_XSAVEOPT_BIT +#define KF_XMMI64 0x00010000 // SSE2 +#define KF_DTS 0x00020000 +#define KF_CLFLUSH 0x00040000 // Win 6.0+ +#define KF_SSE3 0x00080000 // Win 6.0+ +#define KF_AUTHENTICAMD 0x00100000 // Win 6.1+ (family 5+) +#define KF_ACNT2 0x00200000 // Win 6.1+ +#define KF_XSTATE 0x00400000 // From ks386.inc, Win 6.1+ +#define KF_GENUINE_INTEL 0x00800000 // Win 6.1+ +#define KF_SMEP 0x01000000 // Win 6.2+ +#define KF_RDRAND 0x02000000 // Win 6.3+ +#define KF_SLAT 0x04000000 // Win 6.2+, Intel: EPT supported +#define KF_08000000 0x08000000 // Win 6.2+ +#define KF_NX_BIT 0x20000000 +#define KF_NX_DISABLED 0x40000000 +#define KF_NX_ENABLED 0x80000000 +#define KF_RDTSCP 0x0000000100000000ULL // Win 10.0+ +#define KF_CLFLUSHOPT 0x0000000200000000ULL // Win 10.0+ +#define KF_HDC 0x0000000400000000ULL // Win 10.0+ +#define KF_FPU_LEAKAGE 0x0000001000000000ULL // From ks386.inc KF_FPU_LEAKAGE_BIT +#define KF_SSSE3 0x0000004000000000ULL +#define KF_SSE4_1 0x0000008000000000ULL +#define KF_SSE4_2 0x0000010000000000ULL + +#define KF_FPU_LEAKAGE_BIT 36 // From ks386.inc (0x24 -> 0x1000000000) + // // KPCR Access for non-IA64 builds // diff --git a/sdk/include/ndk/ketypes.h b/sdk/include/ndk/ketypes.h index d54b9ffa131..37627fc39a4 100644 --- a/sdk/include/ndk/ketypes.h +++ b/sdk/include/ndk/ketypes.h @@ -137,39 +137,6 @@ Author: #define WAIT_QUANTUM_DECREMENT 1 #define CLOCK_QUANTUM_DECREMENT 3 -// -// Kernel Feature Bits -// -#define KF_V86_VIS 0x00000001 -#define KF_RDTSC 0x00000002 -#define KF_CR4 0x00000004 -#define KF_CMOV 0x00000008 -#define KF_GLOBAL_PAGE 0x00000010 -#define KF_LARGE_PAGE 0x00000020 -#define KF_MTRR 0x00000040 -#define KF_CMPXCHG8B 0x00000080 -#define KF_MMX 0x00000100 -#define KF_WORKING_PTE 0x00000200 -#define KF_PAT 0x00000400 -#define KF_FXSR 0x00000800 -#define KF_FAST_SYSCALL 0x00001000 -#define KF_XMMI 0x00002000 -#define KF_3DNOW 0x00004000 -#define KF_AMDK6MTRR 0x00008000 -#define KF_XMMI64 0x00010000 -#define KF_DTS 0x00020000 -#define KF_BRANCH 0x00020000 // from ksamd64.inc -#define KF_SSE3 0x00080000 -#define KF_CMPXCHG16B 0x00100000 -#define KF_XSTATE 0x00800000 // from ks386.inc, ksamd64.inc -#define KF_NX_BIT 0x20000000 -#define KF_NX_DISABLED 0x40000000 -#define KF_NX_ENABLED 0x80000000 - -#define KF_XSAVEOPT_BIT 15 -#define KF_XSTATE_BIT 23 -#define KF_RDWRFSGSBASE_BIT 28 - // // Internal Exception Codes //