From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web10.2459.1629575786294671935 for ; Sat, 21 Aug 2021 12:56:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=S8hkmhAj; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 89B4A240026 for ; Sat, 21 Aug 2021 21:56:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1629575784; bh=AmZYTV0Bhp5iC1zi2rOluW1sjuRc+99jEtu7sqgR3Ow=; h=From:To:Cc:Subject:Date:From; b=S8hkmhAjy6sudIyaq8m1jnHjirXTqoxERODkb3YRkSqQd7EL59rPgy9uykmfAjBxO K4G90rE1TO7wvaAJIuMYi4WjVOdbHRo1NYIbwJHoBjkqjwPodYWjt5x0Xyv0BVTfpc syMzG698znGSR3X0a96OyhMBLRhj4TjEUAFHAanLaL9TijiCSZu/6nNZYmKBhtb6On cYL1QIr5OxMbnta7IV+32/n1lxcwoK2Aep+8OlJK9+nJJACd5SDfeJzK7GjW/RvW/0 KSx8FHNSR+a2QstxZJcZjdXjliugMjY4cdWGr9c5slptu0c/Syn3BZpF8Gie4DHoug l/2kak3bS5lIw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GsTlr0spWz9rxM; Sat, 21 Aug 2021 21:56:24 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Vitaly Cheptsov Subject: [PATCH 3/5] MdeModulePkg/DxeCore: Check for fixed-address Image relocations Date: Sat, 21 Aug 2021 19:55:51 +0000 Message-Id: <0255115a80c99c64628868ac5385b3c5081b0804.1629575593.git.mhaeuser@posteo.de> In-Reply-To: <6baa44c6ee3ead5e4ffdefd5fdd3961323c323d0.1629575593.git.mhaeuser@posteo.de> References: <6baa44c6ee3ead5e4ffdefd5fdd3961323c323d0.1629575593.git.mhaeuser@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Especially in the relative mode, fixed-address loading may not target the preferred Image base address. In this case, Image relocations are required to load the Image. Add the necessary check for this. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user --- MdeModulePkg/Core/Dxe/Image/Image.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index 0a1def0572bc..a19be4c2a4a9 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -647,7 +647,13 @@ CoreLoadPeImage ( =0D Status =3D GetPeCoffImageFixLoadingAssignedAddress (&(Image->ImageCo= ntext));=0D =0D - if (EFI_ERROR (Status)) {=0D + if (!EFI_ERROR (Status)) {=0D + if (PreferredAddress !=3D Image->ImageContext.ImageAddress && Im= age->ImageContext.RelocationsStripped) {=0D + Status =3D EFI_UNSUPPORTED;=0D + DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Lo= ading module at fixed address failed since relocations have been stripped.\= n"));=0D + Image->ImageContext.ImageAddress =3D PreferredAddress;=0D + }=0D + } else {=0D //=0D // If the code memory is not ready, invoke CoreAllocatePage with= AllocateAnyPages to load the driver.=0D //=0D --=20 2.31.1