2 Features in MSR_IA32_FEATURE_CONTROL register.
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "CpuCommonFeatures.h"
18 Prepares for the data used by CPU feature detection and initialization.
20 @param[in] NumberOfProcessors The number of CPUs in the platform.
22 @return Pointer to a buffer of CPU related configuration data.
24 @note This service could be called by BSP only.
28 FeatureControlGetConfigData (
29 IN UINTN NumberOfProcessors
34 ConfigData
= AllocateZeroPool (sizeof (MSR_IA32_FEATURE_CONTROL_REGISTER
) * NumberOfProcessors
);
35 ASSERT (ConfigData
!= NULL
);
40 Detects if VMX feature supported on current processor.
42 @param[in] ProcessorNumber The index of the CPU executing this function.
43 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
44 structure for the CPU executing this function.
45 @param[in] ConfigData A pointer to the configuration buffer returned
46 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
47 CPU_FEATURE_GET_CONFIG_DATA was not provided in
50 @retval TRUE VMX feature is supported.
51 @retval FALSE VMX feature is not supported.
53 @note This service could be called by BSP/APs.
58 IN UINTN ProcessorNumber
,
59 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
60 IN VOID
*ConfigData OPTIONAL
63 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
65 ASSERT (ConfigData
!= NULL
);
66 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
67 MsrRegister
[ProcessorNumber
].Uint64
= AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL
);
68 return (CpuInfo
->CpuIdVersionInfoEcx
.Bits
.VMX
== 1);
72 Initializes VMX inside SMX feature to specific state.
74 @param[in] ProcessorNumber The index of the CPU executing this function.
75 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
76 structure for the CPU executing this function.
77 @param[in] ConfigData A pointer to the configuration buffer returned
78 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
79 CPU_FEATURE_GET_CONFIG_DATA was not provided in
81 @param[in] State If TRUE, then the VMX inside SMX feature must be enabled.
82 If FALSE, then the VMX inside SMX feature must be disabled.
84 @retval RETURN_SUCCESS VMX inside SMX feature is initialized.
86 @note This service could be called by BSP only.
90 VmxInsideSmxInitialize (
91 IN UINTN ProcessorNumber
,
92 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
93 IN VOID
*ConfigData
, OPTIONAL
97 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
99 ASSERT (ConfigData
!= NULL
);
100 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
101 if (MsrRegister
[ProcessorNumber
].Bits
.Lock
== 0) {
102 CPU_REGISTER_TABLE_WRITE_FIELD (
105 MSR_IA32_FEATURE_CONTROL
,
106 MSR_IA32_FEATURE_CONTROL_REGISTER
,
107 Bits
.EnableVmxInsideSmx
,
111 return RETURN_SUCCESS
;
115 Initializes SENTER feature to specific state.
117 @param[in] ProcessorNumber The index of the CPU executing this function.
118 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
119 structure for the CPU executing this function.
120 @param[in] ConfigData A pointer to the configuration buffer returned
121 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
122 CPU_FEATURE_GET_CONFIG_DATA was not provided in
123 RegisterCpuFeature().
124 @param[in] State If TRUE, then the SENTER feature must be enabled.
125 If FALSE, then the SENTER feature must be disabled.
127 @retval RETURN_SUCCESS SENTER feature is initialized.
129 @note This service could be called by BSP only.
134 IN UINTN ProcessorNumber
,
135 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
136 IN VOID
*ConfigData
, OPTIONAL
140 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
142 ASSERT (ConfigData
!= NULL
);
143 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
144 if (MsrRegister
[ProcessorNumber
].Bits
.Lock
== 0) {
145 CPU_REGISTER_TABLE_WRITE_FIELD (
148 MSR_IA32_FEATURE_CONTROL
,
149 MSR_IA32_FEATURE_CONTROL_REGISTER
,
150 Bits
.SenterLocalFunctionEnables
,
154 CPU_REGISTER_TABLE_WRITE_FIELD (
157 MSR_IA32_FEATURE_CONTROL
,
158 MSR_IA32_FEATURE_CONTROL_REGISTER
,
159 Bits
.SenterGlobalEnable
,
163 return RETURN_SUCCESS
;
167 Detects if Lock Feature Control Register feature supported on current processor.
169 @param[in] ProcessorNumber The index of the CPU executing this function.
170 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
171 structure for the CPU executing this function.
172 @param[in] ConfigData A pointer to the configuration buffer returned
173 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
174 CPU_FEATURE_GET_CONFIG_DATA was not provided in
175 RegisterCpuFeature().
177 @retval TRUE Lock Feature Control Register feature is supported.
178 @retval FALSE Lock Feature Control Register feature is not supported.
180 @note This service could be called by BSP/APs.
184 LockFeatureControlRegisterSupport (
185 IN UINTN ProcessorNumber
,
186 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
187 IN VOID
*ConfigData OPTIONAL
190 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
192 ASSERT (ConfigData
!= NULL
);
193 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
194 MsrRegister
[ProcessorNumber
].Uint64
= AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL
);
199 Initializes Lock Feature Control Register feature to specific state.
201 @param[in] ProcessorNumber The index of the CPU executing this function.
202 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
203 structure for the CPU executing this function.
204 @param[in] ConfigData A pointer to the configuration buffer returned
205 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
206 CPU_FEATURE_GET_CONFIG_DATA was not provided in
207 RegisterCpuFeature().
208 @param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled.
209 If FALSE, then the Lock Feature Control Register feature must be disabled.
211 @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized.
213 @note This service could be called by BSP only.
217 LockFeatureControlRegisterInitialize (
218 IN UINTN ProcessorNumber
,
219 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
220 IN VOID
*ConfigData
, OPTIONAL
224 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
226 ASSERT (ConfigData
!= NULL
);
227 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
228 if (MsrRegister
[ProcessorNumber
].Bits
.Lock
== 0) {
229 CPU_REGISTER_TABLE_WRITE_FIELD (
232 MSR_IA32_FEATURE_CONTROL
,
233 MSR_IA32_FEATURE_CONTROL_REGISTER
,
238 return RETURN_SUCCESS
;
242 Detects if SMX feature supported on current processor.
244 @param[in] ProcessorNumber The index of the CPU executing this function.
245 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
246 structure for the CPU executing this function.
247 @param[in] ConfigData A pointer to the configuration buffer returned
248 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
249 CPU_FEATURE_GET_CONFIG_DATA was not provided in
250 RegisterCpuFeature().
252 @retval TRUE SMX feature is supported.
253 @retval FALSE SMX feature is not supported.
255 @note This service could be called by BSP/APs.
260 IN UINTN ProcessorNumber
,
261 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
262 IN VOID
*ConfigData OPTIONAL
265 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
267 ASSERT (ConfigData
!= NULL
);
268 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
269 MsrRegister
[ProcessorNumber
].Uint64
= AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL
);
270 return (CpuInfo
->CpuIdVersionInfoEcx
.Bits
.SMX
== 1);
274 Initializes VMX outside SMX feature to specific state.
276 @param[in] ProcessorNumber The index of the CPU executing this function.
277 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
278 structure for the CPU executing this function.
279 @param[in] ConfigData A pointer to the configuration buffer returned
280 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
281 CPU_FEATURE_GET_CONFIG_DATA was not provided in
282 RegisterCpuFeature().
283 @param[in] State If TRUE, then the VMX outside SMX feature must be enabled.
284 If FALSE, then the VMX outside SMX feature must be disabled.
286 @retval RETURN_SUCCESS VMX outside SMX feature is initialized.
288 @note This service could be called by BSP only.
292 VmxOutsideSmxInitialize (
293 IN UINTN ProcessorNumber
,
294 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
295 IN VOID
*ConfigData
, OPTIONAL
299 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
301 ASSERT (ConfigData
!= NULL
);
302 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
303 if (MsrRegister
[ProcessorNumber
].Bits
.Lock
== 0) {
304 CPU_REGISTER_TABLE_WRITE_FIELD (
307 MSR_IA32_FEATURE_CONTROL
,
308 MSR_IA32_FEATURE_CONTROL_REGISTER
,
309 Bits
.EnableVmxOutsideSmx
,
313 return RETURN_SUCCESS
;