[PATCH 35/35] UefiPayloadPkg/BlSupportDxe: fix ReserveResourceInGcd() calls


Laszlo Ersek
 

The last parameter of ReserveResourceInGcd() is "ImageHandle", forwarded
in turn to gDS->AllocateMemorySpace() or gDS->AllocateIoSpace() as "owner=
"
image handle.

But BlDxeEntryPoint() passes "SystemTable" as "ImageHandle".

Compilers have not flagged it because EFI_HANDLE (the type of
"ImageHandle") is unfortunately specified as (VOID*), and
(EFI_SYSTEM_TABLE*) converts to (VOID*) silently.

Hand the entry point function's "ImageHandle" parameter to
ReserveResourceInGcd(). This fixes an actual bug.

Cc: Benjamin You <benjamin.you@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
build-tested only

UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/=
BlSupportDxe/BlSupportDxe.c
index bcee4cd9bc41..28dfc8fc5545 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -106,10 +106,10 @@ BlDxeEntryPoint (
//
// Report MMIO/IO Resources
//
- Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo,=
0xFEC00000, SIZE_4KB, 0, SystemTable); // IOAPIC
+ Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo,=
0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC
ASSERT_EFI_ERROR (Status);
=20
- Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo,=
0xFED00000, SIZE_1KB, 0, SystemTable); // HPET
+ Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo,=
0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET
ASSERT_EFI_ERROR (Status);
=20
//
--=20
2.19.1.3.g30247aa5d201

Join devel@edk2.groups.io to automatically receive all group messages.