2 Features in MSR_IA32_FEATURE_CONTROL register.
4 Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "CpuCommonFeatures.h"
12 Detects if VMX 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 VMX feature is supported.
23 @retval FALSE VMX feature is not supported.
25 @note This service could be called by BSP/APs.
30 IN UINTN ProcessorNumber
,
31 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
32 IN VOID
*ConfigData OPTIONAL
35 return (CpuInfo
->CpuIdVersionInfoEcx
.Bits
.VMX
== 1);
39 Initializes VMX feature to specific state.
41 @param[in] ProcessorNumber The index of the CPU executing this function.
42 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
43 structure for the CPU executing this function.
44 @param[in] ConfigData A pointer to the configuration buffer returned
45 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
46 CPU_FEATURE_GET_CONFIG_DATA was not provided in
48 @param[in] State If TRUE, then the VMX feature must be enabled.
49 If FALSE, then the VMX feature must be disabled.
51 @retval RETURN_SUCCESS VMX feature is initialized.
53 @note This service could be called by BSP only.
58 IN UINTN ProcessorNumber
,
59 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
60 IN VOID
*ConfigData OPTIONAL
,
65 // The scope of EnableVmxOutsideSmx bit in the MSR_IA32_FEATURE_CONTROL is core for
66 // below processor type, only program MSR_IA32_FEATURE_CONTROL for thread 0 in each
69 if (IS_SILVERMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
70 IS_GOLDMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
71 IS_GOLDMONT_PLUS_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
))
73 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
74 return RETURN_SUCCESS
;
78 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
81 MSR_IA32_FEATURE_CONTROL
,
82 MSR_IA32_FEATURE_CONTROL_REGISTER
,
83 Bits
.EnableVmxOutsideSmx
,
87 return RETURN_SUCCESS
;
91 Detects if Lock Feature Control Register feature supported on current processor.
93 @param[in] ProcessorNumber The index of the CPU executing this function.
94 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
95 structure for the CPU executing this function.
96 @param[in] ConfigData A pointer to the configuration buffer returned
97 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
98 CPU_FEATURE_GET_CONFIG_DATA was not provided in
101 @retval TRUE Lock Feature Control Register feature is supported.
102 @retval FALSE Lock Feature Control Register feature is not supported.
104 @note This service could be called by BSP/APs.
108 LockFeatureControlRegisterSupport (
109 IN UINTN ProcessorNumber
,
110 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
111 IN VOID
*ConfigData OPTIONAL
118 Initializes Lock Feature Control Register feature to specific state.
120 @param[in] ProcessorNumber The index of the CPU executing this function.
121 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
122 structure for the CPU executing this function.
123 @param[in] ConfigData A pointer to the configuration buffer returned
124 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
125 CPU_FEATURE_GET_CONFIG_DATA was not provided in
126 RegisterCpuFeature().
127 @param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled.
128 If FALSE, then the Lock Feature Control Register feature must be disabled.
130 @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized.
132 @note This service could be called by BSP only.
136 LockFeatureControlRegisterInitialize (
137 IN UINTN ProcessorNumber
,
138 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
139 IN VOID
*ConfigData OPTIONAL
,
144 // The scope of Lock bit in the MSR_IA32_FEATURE_CONTROL is core for
145 // below processor type, only program MSR_IA32_FEATURE_CONTROL for thread 0 in each
148 if (IS_SILVERMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
149 IS_GOLDMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
150 IS_GOLDMONT_PLUS_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
))
152 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
153 return RETURN_SUCCESS
;
157 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
160 MSR_IA32_FEATURE_CONTROL
,
161 MSR_IA32_FEATURE_CONTROL_REGISTER
,
166 return RETURN_SUCCESS
;
170 Detects if SMX feature supported on current processor.
172 @param[in] ProcessorNumber The index of the CPU executing this function.
173 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
174 structure for the CPU executing this function.
175 @param[in] ConfigData A pointer to the configuration buffer returned
176 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
177 CPU_FEATURE_GET_CONFIG_DATA was not provided in
178 RegisterCpuFeature().
180 @retval TRUE SMX feature is supported.
181 @retval FALSE SMX feature is not supported.
183 @note This service could be called by BSP/APs.
188 IN UINTN ProcessorNumber
,
189 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
190 IN VOID
*ConfigData OPTIONAL
193 return (CpuInfo
->CpuIdVersionInfoEcx
.Bits
.SMX
== 1);
197 Initializes SMX feature to specific state.
199 @param[in] ProcessorNumber The index of the CPU executing this function.
200 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
201 structure for the CPU executing this function.
202 @param[in] ConfigData A pointer to the configuration buffer returned
203 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
204 CPU_FEATURE_GET_CONFIG_DATA was not provided in
205 RegisterCpuFeature().
206 @param[in] State If TRUE, then SMX feature must be enabled.
207 If FALSE, then SMX feature must be disabled.
209 @retval RETURN_SUCCESS SMX feature is initialized.
210 @retval RETURN_UNSUPPORTED VMX not initialized.
212 @note This service could be called by BSP only.
217 IN UINTN ProcessorNumber
,
218 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
219 IN VOID
*ConfigData OPTIONAL
,
223 RETURN_STATUS Status
;
226 // The scope of Lock bit in the MSR_IA32_FEATURE_CONTROL is core for
227 // below processor type, only program MSR_IA32_FEATURE_CONTROL for thread 0 in each
230 if (IS_GOLDMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
231 IS_GOLDMONT_PLUS_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
))
233 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
234 return RETURN_SUCCESS
;
238 Status
= RETURN_SUCCESS
;
240 if (State
&& (!IsCpuFeatureInSetting (CPU_FEATURE_VMX
))) {
241 DEBUG ((DEBUG_WARN
, "Warning :: Can't enable SMX feature when VMX feature not enabled, disable it.\n"));
243 Status
= RETURN_UNSUPPORTED
;
246 CPU_REGISTER_TABLE_WRITE_FIELD (
255 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
258 MSR_IA32_FEATURE_CONTROL
,
259 MSR_IA32_FEATURE_CONTROL_REGISTER
,
260 Bits
.SenterLocalFunctionEnables
,
264 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
267 MSR_IA32_FEATURE_CONTROL
,
268 MSR_IA32_FEATURE_CONTROL_REGISTER
,
269 Bits
.SenterGlobalEnable
,
273 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
276 MSR_IA32_FEATURE_CONTROL
,
277 MSR_IA32_FEATURE_CONTROL_REGISTER
,
278 Bits
.EnableVmxInsideSmx
,