2 Execute Disable feature.
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "CpuCommonFeatures.h"
12 Detects if Execute Disable feature supported on current processor.
14 @param[in] ProcessorNumber The index of the CPU executing this function.
15 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
16 structure for the CPU executing this function.
17 @param[in] ConfigData A pointer to the configuration buffer returned
18 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
19 CPU_FEATURE_GET_CONFIG_DATA was not provided in
22 @retval TRUE Execute Disable feature is supported.
23 @retval FALSE Execute Disable feature is not supported.
25 @note This service could be called by BSP/APs.
29 ExecuteDisableSupport (
30 IN UINTN ProcessorNumber
,
31 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
32 IN VOID
*ConfigData OPTIONAL
36 CPUID_EXTENDED_CPU_SIG_EDX Edx
;
38 AsmCpuid (CPUID_EXTENDED_FUNCTION
, &Eax
, NULL
, NULL
, NULL
);
39 if (Eax
<= CPUID_EXTENDED_FUNCTION
) {
41 // Extended CPUID functions are not supported on this processor.
46 AsmCpuid (CPUID_EXTENDED_CPU_SIG
, NULL
, NULL
, NULL
, &Edx
.Uint32
);
47 return (Edx
.Bits
.NX
!= 0);
51 Initializes Execute Disable feature to specific state.
53 @param[in] ProcessorNumber The index of the CPU executing this function.
54 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
55 structure for the CPU executing this function.
56 @param[in] ConfigData A pointer to the configuration buffer returned
57 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
58 CPU_FEATURE_GET_CONFIG_DATA was not provided in
60 @param[in] State If TRUE, then the Execute Disable feature must be enabled.
61 If FALSE, then the Execute Disable feature must be disabled.
63 @retval RETURN_SUCCESS Execute Disable feature is initialized.
65 @note This service could be called by BSP only.
69 ExecuteDisableInitialize (
70 IN UINTN ProcessorNumber
,
71 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
72 IN VOID
*ConfigData
, OPTIONAL
77 // The scope of the MSR_IA32_EFER is core for below processor type, only program
78 // MSR_IA32_EFER for thread 0 in each core.
80 if (IS_SILVERMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
)) {
81 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
82 return RETURN_SUCCESS
;
86 CPU_REGISTER_TABLE_WRITE_FIELD (
90 MSR_IA32_EFER_REGISTER
,
94 return RETURN_SUCCESS
;