summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2017-02-21 13:30:48 +0100
committerLaszlo Ersek <lersek@redhat.com>2017-02-22 03:35:18 +0100
commita3be3b65977eec894cebddf7100429aa0e84b669 (patch)
tree551059da647ec396b458e04f90e3124c3f33eb89
parentb9d56d0b93ae4827bb447ff4a32f1f7ab46ccd94 (diff)
downloadedk2-platforms-a3be3b65977eec894cebddf7100429aa0e84b669.tar.xz
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 <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> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r--OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c8
1 files 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;