From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E13E482218 for ; Tue, 21 Feb 2017 07:38:18 -0800 (PST) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E18C4DD55; Tue, 21 Feb 2017 15:38:19 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-47.phx2.redhat.com [10.3.116.47]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LFcGVB015879; Tue, 21 Feb 2017 10:38:18 -0500 From: Laszlo Ersek To: edk2-devel-01 Cc: Jordan Justen Date: Tue, 21 Feb 2017 16:38:07 +0100 Message-Id: <20170221153812.1420-2-lersek@redhat.com> In-Reply-To: <20170221153812.1420-1-lersek@redhat.com> References: <20170221153812.1420-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 21 Feb 2017 15:38:19 +0000 (UTC) Subject: [PATCH 1/6] OvmfPkg/AcpiPlatformDxe: drop double right shift in ADD/WRITE POINTER cmds X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Feb 2017 15:38:19 -0000 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 --- 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 eadd690bef4e..6a0ecd1ad962 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.9.3