+++ /dev/null
-/** @file\r
- Execute Disable feature.\r
-\r
- Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "CpuCommonFeatures.h"\r
-\r
-/**\r
- Detects if Execute Disable feature supported on current processor.\r
-\r
- @param[in] ProcessorNumber The index of the CPU executing this function.\r
- @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
- structure for the CPU executing this function.\r
- @param[in] ConfigData A pointer to the configuration buffer returned\r
- by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r
- CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
- RegisterCpuFeature().\r
-\r
- @retval TRUE Execute Disable feature is supported.\r
- @retval FALSE Execute Disable feature is not supported.\r
-\r
- @note This service could be called by BSP/APs.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-ExecuteDisableSupport (\r
- IN UINTN ProcessorNumber,\r
- IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r
- IN VOID *ConfigData OPTIONAL\r
- )\r
-{\r
- UINT32 Eax;\r
- CPUID_EXTENDED_CPU_SIG_EDX Edx;\r
-\r
- AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL);\r
- if (Eax <= CPUID_EXTENDED_FUNCTION) {\r
- //\r
- // Extended CPUID functions are not supported on this processor.\r
- //\r
- return FALSE;\r
- }\r
-\r
- AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32);\r
- return (Edx.Bits.NX != 0);\r
-}\r
-\r
-/**\r
- Initializes Execute Disable feature to specific state.\r
-\r
- @param[in] ProcessorNumber The index of the CPU executing this function.\r
- @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
- structure for the CPU executing this function.\r
- @param[in] ConfigData A pointer to the configuration buffer returned\r
- by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r
- CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
- RegisterCpuFeature().\r
- @param[in] State If TRUE, then the Execute Disable feature must be enabled.\r
- If FALSE, then the Execute Disable feature must be disabled.\r
-\r
- @retval RETURN_SUCCESS Execute Disable feature is initialized.\r
-\r
- @note This service could be called by BSP only.\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-ExecuteDisableInitialize (\r
- IN UINTN ProcessorNumber,\r
- IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r
- IN VOID *ConfigData, OPTIONAL\r
- IN BOOLEAN State\r
- )\r
-{\r
- //\r
- // The scope of the MSR_IA32_EFER is core for below processor type, only program\r
- // MSR_IA32_EFER for thread 0 in each core.\r
- //\r
- if (IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {\r
- if (CpuInfo->ProcessorInfo.Location.Thread != 0) {\r
- return RETURN_SUCCESS;\r
- }\r
- }\r
-\r
- CPU_REGISTER_TABLE_WRITE_FIELD (\r
- ProcessorNumber,\r
- Msr,\r
- MSR_IA32_EFER,\r
- MSR_IA32_EFER_REGISTER,\r
- Bits.NXE,\r
- (State) ? 1 : 0\r
- );\r
- return RETURN_SUCCESS;\r
-}\r