2017-04-05 10:33:16 +02:00
|
|
|
/** @file
|
|
|
|
This library registers CPU features defined in Intel(R) 64 and IA-32
|
|
|
|
Architectures Software Developer's Manual.
|
|
|
|
|
2019-07-02 09:15:45 +02:00
|
|
|
Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:07:22 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2017-04-05 10:33:16 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "CpuCommonFeatures.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
Register CPU features.
|
|
|
|
|
|
|
|
@retval RETURN_SUCCESS Register successfully
|
|
|
|
**/
|
|
|
|
RETURN_STATUS
|
|
|
|
EFIAPI
|
|
|
|
CpuCommonFeaturesLibConstructor (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
RETURN_STATUS Status;
|
|
|
|
|
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"AESNI",
|
|
|
|
AesniGetConfigData,
|
|
|
|
AesniSupport,
|
|
|
|
AesniInitialize,
|
|
|
|
CPU_FEATURE_AESNI,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"MWAIT",
|
|
|
|
NULL,
|
|
|
|
MonitorMwaitSupport,
|
|
|
|
MonitorMwaitInitialize,
|
|
|
|
CPU_FEATURE_MWAIT,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"ACPI",
|
2019-05-18 10:55:27 +02:00
|
|
|
ClockModulationGetConfigData,
|
2017-04-05 10:33:16 +02:00
|
|
|
ClockModulationSupport,
|
|
|
|
ClockModulationInitialize,
|
|
|
|
CPU_FEATURE_ACPI,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"EIST",
|
|
|
|
NULL,
|
|
|
|
EistSupport,
|
|
|
|
EistInitialize,
|
|
|
|
CPU_FEATURE_EIST,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"FastStrings",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FastStringsInitialize,
|
|
|
|
CPU_FEATURE_FASTSTRINGS,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"Lock Feature Control Register",
|
UefiCpuPkg/CpuCommonFeaturesLib: Use new macros.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2040
Below code is current implementation:
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber,
Msr,
MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.Lock,
1
);
}
1. In first normal boot, the Bits.Lock is 0, 1 will be added
into the register table and then will set to the MSR.
2. Trig warm reboot, MSR value preserves. After normal boot phase,
the Bits.Lock is 1, so it will not be added into the register
table during the warm reboot phase.
3. Trig S3 then resume, the Bits.Lock change to 0 and Bits.Lock is
not added in register table, so it's still 0 after resume. This
is not an expect behavior. The expect value is the value should
always 1 after booting or resuming from S3.
The root cause for this issue is
1. driver bases on current value to insert the "set value action" to
the register table.
2. Some MSRs may reserve their value during warm reboot.
The solution for this issue is using new added macros for the MSRs which
preserve value during warm reboot.
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2019-08-16 05:57:30 +02:00
|
|
|
NULL,
|
2017-04-05 10:33:16 +02:00
|
|
|
LockFeatureControlRegisterSupport,
|
|
|
|
LockFeatureControlRegisterInitialize,
|
|
|
|
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"SMX",
|
UefiCpuPkg/CpuCommonFeaturesLib: Use new macros.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2040
Below code is current implementation:
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber,
Msr,
MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.Lock,
1
);
}
1. In first normal boot, the Bits.Lock is 0, 1 will be added
into the register table and then will set to the MSR.
2. Trig warm reboot, MSR value preserves. After normal boot phase,
the Bits.Lock is 1, so it will not be added into the register
table during the warm reboot phase.
3. Trig S3 then resume, the Bits.Lock change to 0 and Bits.Lock is
not added in register table, so it's still 0 after resume. This
is not an expect behavior. The expect value is the value should
always 1 after booting or resuming from S3.
The root cause for this issue is
1. driver bases on current value to insert the "set value action" to
the register table.
2. Some MSRs may reserve their value during warm reboot.
The solution for this issue is using new added macros for the MSRs which
preserve value during warm reboot.
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2019-08-16 05:57:30 +02:00
|
|
|
NULL,
|
2017-04-05 10:33:16 +02:00
|
|
|
SmxSupport,
|
2017-07-11 04:07:36 +02:00
|
|
|
SmxInitialize,
|
2017-04-05 10:33:16 +02:00
|
|
|
CPU_FEATURE_SMX,
|
2019-07-02 09:15:45 +02:00
|
|
|
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_THREAD_BEFORE,
|
2017-04-05 10:33:16 +02:00
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"VMX",
|
UefiCpuPkg/CpuCommonFeaturesLib: Use new macros.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2040
Below code is current implementation:
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber,
Msr,
MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.Lock,
1
);
}
1. In first normal boot, the Bits.Lock is 0, 1 will be added
into the register table and then will set to the MSR.
2. Trig warm reboot, MSR value preserves. After normal boot phase,
the Bits.Lock is 1, so it will not be added into the register
table during the warm reboot phase.
3. Trig S3 then resume, the Bits.Lock change to 0 and Bits.Lock is
not added in register table, so it's still 0 after resume. This
is not an expect behavior. The expect value is the value should
always 1 after booting or resuming from S3.
The root cause for this issue is
1. driver bases on current value to insert the "set value action" to
the register table.
2. Some MSRs may reserve their value during warm reboot.
The solution for this issue is using new added macros for the MSRs which
preserve value during warm reboot.
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2019-08-16 05:57:30 +02:00
|
|
|
NULL,
|
2017-07-11 04:07:36 +02:00
|
|
|
VmxSupport,
|
|
|
|
VmxInitialize,
|
2017-04-05 10:33:16 +02:00
|
|
|
CPU_FEATURE_VMX,
|
2019-07-02 09:15:45 +02:00
|
|
|
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_THREAD_BEFORE,
|
2017-04-05 10:33:16 +02:00
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"Limit CpuId Maximum Value",
|
|
|
|
NULL,
|
|
|
|
LimitCpuidMaxvalSupport,
|
|
|
|
LimitCpuidMaxvalInitialize,
|
|
|
|
CPU_FEATURE_LIMIT_CPUID_MAX_VAL,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"Machine Check Enable",
|
|
|
|
NULL,
|
|
|
|
MceSupport,
|
|
|
|
MceInitialize,
|
|
|
|
CPU_FEATURE_MCE,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"Machine Check Architect",
|
|
|
|
NULL,
|
|
|
|
McaSupport,
|
|
|
|
McaInitialize,
|
|
|
|
CPU_FEATURE_MCA,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"MCG_CTL",
|
|
|
|
NULL,
|
|
|
|
McgCtlSupport,
|
|
|
|
McgCtlInitialize,
|
|
|
|
CPU_FEATURE_MCG_CTL,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"Pending Break",
|
|
|
|
NULL,
|
|
|
|
PendingBreakSupport,
|
|
|
|
PendingBreakInitialize,
|
|
|
|
CPU_FEATURE_PENDING_BREAK,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"C1E",
|
|
|
|
NULL,
|
|
|
|
C1eSupport,
|
|
|
|
C1eInitialize,
|
|
|
|
CPU_FEATURE_C1E,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-04-05 10:33:16 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"X2Apic",
|
2017-05-24 07:45:25 +02:00
|
|
|
X2ApicGetConfigData,
|
2017-04-05 10:33:16 +02:00
|
|
|
X2ApicSupport,
|
|
|
|
X2ApicInitialize,
|
|
|
|
CPU_FEATURE_X2APIC,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-07-14 04:22:04 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_PPIN)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"PPIN",
|
2019-07-05 07:14:33 +02:00
|
|
|
PpinGetConfigData,
|
2017-07-14 04:22:04 +02:00
|
|
|
PpinSupport,
|
|
|
|
PpinInitialize,
|
|
|
|
CPU_FEATURE_PPIN,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-08-04 02:46:41 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_LMCE)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"LMCE",
|
UefiCpuPkg/CpuCommonFeaturesLib: Use new macros.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2040
Below code is current implementation:
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber,
Msr,
MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.Lock,
1
);
}
1. In first normal boot, the Bits.Lock is 0, 1 will be added
into the register table and then will set to the MSR.
2. Trig warm reboot, MSR value preserves. After normal boot phase,
the Bits.Lock is 1, so it will not be added into the register
table during the warm reboot phase.
3. Trig S3 then resume, the Bits.Lock change to 0 and Bits.Lock is
not added in register table, so it's still 0 after resume. This
is not an expect behavior. The expect value is the value should
always 1 after booting or resuming from S3.
The root cause for this issue is
1. driver bases on current value to insert the "set value action" to
the register table.
2. Some MSRs may reserve their value during warm reboot.
The solution for this issue is using new added macros for the MSRs which
preserve value during warm reboot.
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2019-08-16 05:57:30 +02:00
|
|
|
NULL,
|
2017-08-04 02:46:41 +02:00
|
|
|
LmceSupport,
|
|
|
|
LmceInitialize,
|
|
|
|
CPU_FEATURE_LMCE,
|
2019-07-02 09:15:45 +02:00
|
|
|
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_THREAD_BEFORE,
|
2017-08-04 02:46:41 +02:00
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2021-12-05 23:54:17 +01:00
|
|
|
|
2017-08-04 03:59:08 +02:00
|
|
|
if (IsCpuFeatureSupported (CPU_FEATURE_PROC_TRACE)) {
|
|
|
|
Status = RegisterCpuFeature (
|
|
|
|
"Proc Trace",
|
|
|
|
ProcTraceGetConfigData,
|
|
|
|
ProcTraceSupport,
|
|
|
|
ProcTraceInitialize,
|
|
|
|
CPU_FEATURE_PROC_TRACE,
|
|
|
|
CPU_FEATURE_END
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
2017-04-05 10:33:16 +02:00
|
|
|
|
|
|
|
return RETURN_SUCCESS;
|
|
|
|
}
|