From a3be3b65977eec894cebddf7100429aa0e84b669 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 21 Feb 2017 13:30:48 +0100 Subject: [PATCH] OvmfPkg/AcpiPlatformDxe: drop double right shift in ADD/WRITE POINTER cmds The Count parameter of RShiftU64() must be strictly smaller than 64. ProcessCmdAddPointer() and ProcessCmdWritePointer() currently ensure this by "cleverly" breaking the last bit of a potentially 8-byte right shift out to a separate operation. Instead, exclude the Count==64 case explicitly (in which case the preexistent outer RShiftU64() would return 0), and keep only the inner RShiftU64(), with the direct Count however. This is not a functional change, just style improvement. Cc: Jordan Justen Suggested-by: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Jordan Justen --- OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c index eadd690bef..6a0ecd1ad9 100644 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c +++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c @@ -277,8 +277,8 @@ ProcessCmdAddPointer ( ASSERT ((UINTN)Blob2->Base <= MAX_ADDRESS - Blob2->Size); PointerValue += (UINT64)(UINTN)Blob2->Base; - if (RShiftU64 ( - RShiftU64 (PointerValue, AddPointer->PointerSize * 8 - 1), 1) != 0) { + if (AddPointer->PointerSize < 8 && + RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0) { DEBUG ((EFI_D_ERROR, "%a: relocated pointer value unrepresentable in " "\"%a\"\n", __FUNCTION__, AddPointer->PointerFile)); return EFI_PROTOCOL_ERROR; @@ -438,8 +438,8 @@ ProcessCmdWritePointer ( ASSERT ((UINTN)PointeeBlob->Base <= MAX_ADDRESS - PointeeBlob->Size); PointerValue += (UINT64)(UINTN)PointeeBlob->Base; - if (RShiftU64 ( - RShiftU64 (PointerValue, WritePointer->PointerSize * 8 - 1), 1) != 0) { + if (WritePointer->PointerSize < 8 && + RShiftU64 (PointerValue, WritePointer->PointerSize * 8) != 0) { DEBUG ((DEBUG_ERROR, "%a: pointer value unrepresentable in \"%a\"\n", __FUNCTION__, WritePointer->PointerFile)); return EFI_PROTOCOL_ERROR; -- 2.39.2