mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg/PiSmmCpuDxeSmm: Supports test then write new value logic.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2040 Supports new logic which test current value before write new value. Only write new value when current value not same as new value. Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
ef21a304e0
commit
cfbcaad251
|
@ -241,6 +241,7 @@ ProgramProcessorRegister (
|
||||||
UINTN ValidThreadCount;
|
UINTN ValidThreadCount;
|
||||||
UINT32 *ValidCoreCountPerPackage;
|
UINT32 *ValidCoreCountPerPackage;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
UINT64 CurrentValue;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Traverse Register Table of this logical processor
|
// Traverse Register Table of this logical processor
|
||||||
|
@ -263,6 +264,16 @@ ProgramProcessorRegister (
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (RegisterTableEntry->TestThenWrite) {
|
||||||
|
CurrentValue = BitFieldRead64 (
|
||||||
|
Value,
|
||||||
|
RegisterTableEntry->ValidBitStart,
|
||||||
|
RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1
|
||||||
|
);
|
||||||
|
if (CurrentValue == RegisterTableEntry->Value) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Value = (UINTN) BitFieldWrite64 (
|
Value = (UINTN) BitFieldWrite64 (
|
||||||
Value,
|
Value,
|
||||||
RegisterTableEntry->ValidBitStart,
|
RegisterTableEntry->ValidBitStart,
|
||||||
|
@ -275,6 +286,24 @@ ProgramProcessorRegister (
|
||||||
// The specified register is Model Specific Register
|
// The specified register is Model Specific Register
|
||||||
//
|
//
|
||||||
case Msr:
|
case Msr:
|
||||||
|
if (RegisterTableEntry->TestThenWrite) {
|
||||||
|
Value = (UINTN)AsmReadMsr64 (RegisterTableEntry->Index);
|
||||||
|
if (RegisterTableEntry->ValidBitLength >= 64) {
|
||||||
|
if (Value == RegisterTableEntry->Value) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CurrentValue = BitFieldRead64 (
|
||||||
|
Value,
|
||||||
|
RegisterTableEntry->ValidBitStart,
|
||||||
|
RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1
|
||||||
|
);
|
||||||
|
if (CurrentValue == RegisterTableEntry->Value) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If this function is called to restore register setting after INIT signal,
|
// If this function is called to restore register setting after INIT signal,
|
||||||
// there is no need to restore MSRs in register table.
|
// there is no need to restore MSRs in register table.
|
||||||
|
|
Loading…
Reference in New Issue