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
)) {
72 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
73 return RETURN_SUCCESS
;
77 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
80 MSR_IA32_FEATURE_CONTROL
,
81 MSR_IA32_FEATURE_CONTROL_REGISTER
,
82 Bits
.EnableVmxOutsideSmx
,
86 return RETURN_SUCCESS
;
90 Detects if Lock Feature Control Register feature supported on current processor.
92 @param[in] ProcessorNumber The index of the CPU executing this function.
93 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
94 structure for the CPU executing this function.
95 @param[in] ConfigData A pointer to the configuration buffer returned
96 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
97 CPU_FEATURE_GET_CONFIG_DATA was not provided in
100 @retval TRUE Lock Feature Control Register feature is supported.
101 @retval FALSE Lock Feature Control Register feature is not supported.
103 @note This service could be called by BSP/APs.
107 LockFeatureControlRegisterSupport (
108 IN UINTN ProcessorNumber
,
109 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
110 IN VOID
*ConfigData OPTIONAL
117 Initializes Lock Feature Control Register feature to specific state.
119 @param[in] ProcessorNumber The index of the CPU executing this function.
120 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
121 structure for the CPU executing this function.
122 @param[in] ConfigData A pointer to the configuration buffer returned
123 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
124 CPU_FEATURE_GET_CONFIG_DATA was not provided in
125 RegisterCpuFeature().
126 @param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled.
127 If FALSE, then the Lock Feature Control Register feature must be disabled.
129 @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized.
131 @note This service could be called by BSP only.
135 LockFeatureControlRegisterInitialize (
136 IN UINTN ProcessorNumber
,
137 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
138 IN VOID
*ConfigData
, OPTIONAL
143 // The scope of Lock bit in the MSR_IA32_FEATURE_CONTROL is core for
144 // below processor type, only program MSR_IA32_FEATURE_CONTROL for thread 0 in each
147 if (IS_SILVERMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
148 IS_GOLDMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
149 IS_GOLDMONT_PLUS_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
)) {
150 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
151 return RETURN_SUCCESS
;
155 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
158 MSR_IA32_FEATURE_CONTROL
,
159 MSR_IA32_FEATURE_CONTROL_REGISTER
,
164 return RETURN_SUCCESS
;
168 Detects if SMX feature supported on current processor.
170 @param[in] ProcessorNumber The index of the CPU executing this function.
171 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
172 structure for the CPU executing this function.
173 @param[in] ConfigData A pointer to the configuration buffer returned
174 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
175 CPU_FEATURE_GET_CONFIG_DATA was not provided in
176 RegisterCpuFeature().
178 @retval TRUE SMX feature is supported.
179 @retval FALSE SMX feature is not supported.
181 @note This service could be called by BSP/APs.
186 IN UINTN ProcessorNumber
,
187 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
188 IN VOID
*ConfigData OPTIONAL
191 return (CpuInfo
->CpuIdVersionInfoEcx
.Bits
.SMX
== 1);
195 Initializes SMX feature to specific state.
197 @param[in] ProcessorNumber The index of the CPU executing this function.
198 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
199 structure for the CPU executing this function.
200 @param[in] ConfigData A pointer to the configuration buffer returned
201 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
202 CPU_FEATURE_GET_CONFIG_DATA was not provided in
203 RegisterCpuFeature().
204 @param[in] State If TRUE, then SMX feature must be enabled.
205 If FALSE, then SMX feature must be disabled.
207 @retval RETURN_SUCCESS SMX feature is initialized.
208 @retval RETURN_UNSUPPORTED VMX not initialized.
210 @note This service could be called by BSP only.
215 IN UINTN ProcessorNumber
,
216 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
217 IN VOID
*ConfigData
, OPTIONAL
221 RETURN_STATUS Status
;
224 // The scope of Lock bit in the MSR_IA32_FEATURE_CONTROL is core for
225 // below processor type, only program MSR_IA32_FEATURE_CONTROL for thread 0 in each
228 if (IS_GOLDMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
229 IS_GOLDMONT_PLUS_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
)) {
230 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
231 return RETURN_SUCCESS
;
235 Status
= RETURN_SUCCESS
;
237 if (State
&& (!IsCpuFeatureInSetting (CPU_FEATURE_VMX
))) {
238 DEBUG ((DEBUG_WARN
, "Warning :: Can't enable SMX feature when VMX feature not enabled, disable it.\n"));
240 Status
= RETURN_UNSUPPORTED
;
243 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
246 MSR_IA32_FEATURE_CONTROL
,
247 MSR_IA32_FEATURE_CONTROL_REGISTER
,
248 Bits
.SenterLocalFunctionEnables
,
252 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
255 MSR_IA32_FEATURE_CONTROL
,
256 MSR_IA32_FEATURE_CONTROL_REGISTER
,
257 Bits
.SenterGlobalEnable
,
261 CPU_REGISTER_TABLE_TEST_THEN_WRITE_FIELD (
264 MSR_IA32_FEATURE_CONTROL
,
265 MSR_IA32_FEATURE_CONTROL_REGISTER
,
266 Bits
.EnableVmxInsideSmx
,