public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Subject: [PATCH 1/6] OvmfPkg/AcpiPlatformDxe: drop double right shift in ADD/WRITE POINTER cmds
Date: Tue, 21 Feb 2017 16:38:07 +0100	[thread overview]
Message-ID: <20170221153812.1420-2-lersek@redhat.com> (raw)
In-Reply-To: <20170221153812.1420-1-lersek@redhat.com>

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 <jordan.l.justen@intel.com>
Suggested-by: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 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




  reply	other threads:[~2017-02-21 15:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 15:38 [PATCH 0/6] OvmfPkg: AcpiPlatformDxe, QemuFwCfg: small cleanups after WRITE_POINTER Laszlo Ersek
2017-02-21 15:38 ` Laszlo Ersek [this message]
2017-02-21 15:38 ` [PATCH 2/6] OvmfPkg/AcpiPlatformDxe: update PointerValue comments in "BootScript.c" Laszlo Ersek
2017-02-21 15:38 ` [PATCH 3/6] OvmfPkg/QemuFwCfgLib: move types/macros from lib class to IndustryStandard Laszlo Ersek
2017-02-21 15:38 ` [PATCH 4/6] OvmfPkg/QemuFwCfg: introduce FW_CFG_IO_SELECTOR, adapt the package Laszlo Ersek
2017-02-21 15:38 ` [PATCH 5/6] OvmfPkg/QemuFwCfg: introduce FW_CFG_IO_DATA, " Laszlo Ersek
2017-02-21 15:38 ` [PATCH 6/6] OvmfPkg/QemuFwCfg: introduce FW_CFG_IO_DMA_ADDRESS, " Laszlo Ersek
2017-02-22  1:58 ` [PATCH 0/6] OvmfPkg: AcpiPlatformDxe, QemuFwCfg: small cleanups after WRITE_POINTER Jordan Justen
2017-02-22  2:41   ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170221153812.1420-2-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox