[edk2-devel] [Patch v2 3/6] UefiCpuPkg/PiSmmCpuDxeSmm: Supports test then write new value logic.
Laszlo Ersek
lersek at redhat.com
Mon Aug 12 14:13:46 UTC 2019
On 08/12/19 12:31, Eric Dong wrote:
> 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 at intel.com>
> Cc: Ray Ni <ray.ni at intel.com>
> Cc: Laszlo Ersek <lersek at redhat.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> index b20992d5ab..61541838e8 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> @@ -241,6 +241,7 @@ ProgramProcessorRegister (
> UINTN ValidThreadCount;
> UINT32 *ValidCoreCountPerPackage;
> EFI_STATUS Status;
> + UINT64 CurrentValue;
>
> //
> // Traverse Register Table of this logical processor
> @@ -263,6 +264,16 @@ ProgramProcessorRegister (
> if (EFI_ERROR (Status)) {
> continue;
> }
> + if (RegisterTableEntry->TestThenWrite) {
> + CurrentValue = BitFieldRead64 (
> + Value,
> + RegisterTableEntry->ValidBitStart,
> + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1
> + );
> + if (CurrentValue == RegisterTableEntry->Value) {
> + continue;
> + }
> + }
> Value = (UINTN) BitFieldWrite64 (
> Value,
> RegisterTableEntry->ValidBitStart,
> @@ -275,6 +286,24 @@ ProgramProcessorRegister (
> // The specified register is Model Specific Register
> //
> case Msr:
> + if (RegisterTableEntry->TestThenWrite) {
> + Value = (UINTN)AsmReadMsr64 (RegisterTableEntry->Index);
> + if (RegisterTableEntry->ValidBitLength >= 64) {
> + if (Value == RegisterTableEntry->Value) {
> + continue;
> + }
> + } else {
> + CurrentValue = BitFieldRead64 (
> + Value,
> + RegisterTableEntry->ValidBitStart,
> + RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1
> + );
> + if (CurrentValue == RegisterTableEntry->Value) {
> + continue;
> + }
> + }
> + }
> +
> //
> // If this function is called to restore register setting after INIT signal,
> // there is no need to restore MSRs in register table.
>
I assume that "RegisterTableEntry->Value" has all bits clear that fall
outside of the bitmask defined by ValidBitStart and ValidBitLength.
With that assumption:
Reviewed-by: Laszlo Ersek <lersek at redhat.com>
Thanks
Laszlo
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#45441): https://edk2.groups.io/g/devel/message/45441
Mute This Topic: https://groups.io/mt/32839207/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list