From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 10:29:54 -0700 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2884B190C004; Tue, 24 Sep 2019 17:29:54 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E56360852; Tue, 24 Sep 2019 17:29:49 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 35/35] UefiPayloadPkg/BlSupportDxe: fix ReserveResourceInGcd() calls To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , devel@edk2.groups.io Cc: Benjamin You , Guo Dong , Maurice Ma References: <20190917194935.24322-1-lersek@redhat.com> <20190917194935.24322-36-lersek@redhat.com> <91544023-5e46-83a7-c749-84bfb0a28ccb@redhat.com> From: "Laszlo Ersek" Message-ID: <823f5803-f61d-293a-cc83-2319fc5dec24@redhat.com> Date: Tue, 24 Sep 2019 19:29:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <91544023-5e46-83a7-c749-84bfb0a28ccb@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Tue, 24 Sep 2019 17:29:54 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 09/23/19 17:08, Philippe Mathieu-Daud=C3=A9 wrote: > On 9/17/19 9:49 PM, Laszlo Ersek wrote: >> The last parameter of ReserveResourceInGcd() is "ImageHandle", forward= ed >> in turn to gDS->AllocateMemorySpace() or gDS->AllocateIoSpace() as "ow= ner" >> 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. >=20 > Wow very buggy, so I assume this is mostly dead code, right? Not necessarily; as long as noone tries to use the "owner" image handle in practice, the issue may remain dormant. Thanks Laszlo >> Cc: Benjamin You >> Cc: Guo Dong >> Cc: Maurice Ma >> Signed-off-by: Laszlo Ersek >> --- >> >> Notes: >> build-tested only >> >> UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadP= kg/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, EfiGcdMemoryTypeMemoryMapped= Io, 0xFEC00000, SIZE_4KB, 0, SystemTable); // IOAPIC >> + Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMapped= Io, 0xFEC00000, SIZE_4KB, 0, ImageHandle); // IOAPIC >> ASSERT_EFI_ERROR (Status); >> =20 >> - Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMapped= Io, 0xFED00000, SIZE_1KB, 0, SystemTable); // HPET >> + Status =3D ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMapped= Io, 0xFED00000, SIZE_1KB, 0, ImageHandle); // HPET >> ASSERT_EFI_ERROR (Status); >> =20 >> // >> >=20 > Reviewed-by: Philippe Mathieu-Daude >=20