mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 21:51:47 +00:00
[NTOS:KE] Detect CPU support for XSAVE, AVX, AVX2 and AVX512
This commit is contained in:
parent
294eb31cfd
commit
6653bb5224
3 changed files with 21 additions and 5 deletions
|
@ -210,6 +210,7 @@ KiGetFeatureBits(VOID)
|
|||
if (VersionInfo.Ecx.Bits.SSE4_2) FeatureBits |= KF_SSE4_2;
|
||||
if (VersionInfo.Ecx.Bits.XSAVE) FeatureBits |= KF_XSTATE;
|
||||
if (VersionInfo.Ecx.Bits.RDRAND) FeatureBits |= KF_RDRAND;
|
||||
if (VersionInfo.Ecx.Bits.AVX) FeatureBits |= KF_AVX;
|
||||
|
||||
/* Check if the CPU has hyper-threading */
|
||||
if (VersionInfo.Edx.Bits.HTT)
|
||||
|
@ -251,6 +252,8 @@ KiGetFeatureBits(VOID)
|
|||
if (ExtFlags.Ebx.Bits.SMEP) FeatureBits |= KF_SMEP;
|
||||
if (ExtFlags.Ebx.Bits.FSGSBASE) FeatureBits |= KF_RDWRFSGSBASE;
|
||||
if (ExtFlags.Ebx.Bits.SMAP) FeatureBits |= KF_SMAP;
|
||||
if (ExtFlags.Ebx.Bits.AVX2) FeatureBits |= KF_AVX2;
|
||||
if (ExtFlags.Ebx.Bits.AVX512F) FeatureBits |= KF_AVX512F;
|
||||
}
|
||||
|
||||
/* Check if CPUID_EXTENDED_STATE (0x0D) is supported */
|
||||
|
@ -350,6 +353,7 @@ KiGetFeatureBits(VOID)
|
|||
VOID
|
||||
KiReportCpuFeatures(IN PKPRCB Prcb)
|
||||
{
|
||||
ULONG64 FeatureBits = Prcb->FeatureBits | ((ULONG64)Prcb->FeatureBitsHigh << 32);
|
||||
ULONG CpuFeatures = 0;
|
||||
CPU_INFO CpuInfo;
|
||||
|
||||
|
@ -361,7 +365,7 @@ KiReportCpuFeatures(IN PKPRCB Prcb)
|
|||
|
||||
DPRINT1("Supported CPU features:");
|
||||
|
||||
#define print_kf_bit(kf_value) if (Prcb->FeatureBits & kf_value) DbgPrint(" " #kf_value)
|
||||
#define print_kf_bit(kf_value) if (FeatureBits & kf_value) DbgPrint(" " #kf_value)
|
||||
print_kf_bit(KF_SMEP);
|
||||
print_kf_bit(KF_RDTSC);
|
||||
print_kf_bit(KF_CR4);
|
||||
|
@ -404,6 +408,9 @@ KiReportCpuFeatures(IN PKPRCB Prcb)
|
|||
print_kf_bit(KF_SSSE3);
|
||||
print_kf_bit(KF_SSE4_1);
|
||||
print_kf_bit(KF_SSE4_2);
|
||||
print_kf_bit(KF_AVX);
|
||||
print_kf_bit(KF_AVX2);
|
||||
print_kf_bit(KF_AVX512F);
|
||||
#undef print_kf_bit
|
||||
|
||||
#define print_cf(cpu_flag) if (CpuFeatures & cpu_flag) DbgPrint(" " #cpu_flag)
|
||||
|
|
|
@ -385,7 +385,8 @@ KiInitializeKernelMachineDependent(
|
|||
(FeatureBits & KF_CMPXCHG16B) ? TRUE : FALSE;
|
||||
SharedUserData->ProcessorFeatures[PF_COMPARE64_EXCHANGE128] = FALSE; // ???
|
||||
SharedUserData->ProcessorFeatures[PF_CHANNELS_ENABLED] = FALSE; // ???
|
||||
SharedUserData->ProcessorFeatures[PF_XSAVE_ENABLED] = FALSE; // FIXME
|
||||
SharedUserData->ProcessorFeatures[PF_XSAVE_ENABLED] =
|
||||
(FeatureBits & KF_XSTATE) ? TRUE : FALSE;
|
||||
SharedUserData->ProcessorFeatures[PF_SECOND_LEVEL_ADDRESS_TRANSLATION] =
|
||||
(FeatureBits & KF_SLAT) ? TRUE : FALSE;
|
||||
SharedUserData->ProcessorFeatures[PF_VIRT_FIRMWARE_ENABLED] =
|
||||
|
@ -404,9 +405,12 @@ KiInitializeKernelMachineDependent(
|
|||
(FeatureBits & KF_SSE4_1) ? TRUE : FALSE;
|
||||
SharedUserData->ProcessorFeatures[PF_SSE4_2_INSTRUCTIONS_AVAILABLE] =
|
||||
(FeatureBits & KF_SSE4_2) ? TRUE : FALSE;
|
||||
SharedUserData->ProcessorFeatures[PF_AVX_INSTRUCTIONS_AVAILABLE] = FALSE; // FIXME
|
||||
SharedUserData->ProcessorFeatures[PF_AVX2_INSTRUCTIONS_AVAILABLE] = FALSE; // FIXME
|
||||
SharedUserData->ProcessorFeatures[PF_AVX512F_INSTRUCTIONS_AVAILABLE] = FALSE; // FIXME
|
||||
SharedUserData->ProcessorFeatures[PF_AVX_INSTRUCTIONS_AVAILABLE] =
|
||||
(FeatureBits & KF_AVX) ? TRUE : FALSE;
|
||||
SharedUserData->ProcessorFeatures[PF_AVX2_INSTRUCTIONS_AVAILABLE] =
|
||||
(FeatureBits & KF_AVX2) ? TRUE : FALSE;
|
||||
SharedUserData->ProcessorFeatures[PF_AVX512F_INSTRUCTIONS_AVAILABLE] =
|
||||
(FeatureBits & KF_AVX512F) ? TRUE : FALSE;
|
||||
|
||||
/* Set the default NX policy (opt-in) */
|
||||
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
||||
|
|
|
@ -73,6 +73,11 @@ Author:
|
|||
#define KF_SSE4_1 0x0001000000000000ULL
|
||||
#define KF_SSE4_2 0x0002000000000000ULL
|
||||
|
||||
// ReactOS specific
|
||||
#define KF_AVX 0x1000000000000000ULL
|
||||
#define KF_AVX2 0x2000000000000000ULL
|
||||
#define KF_AVX512F 0x4000000000000000ULL
|
||||
|
||||
#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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue