[edk2-devel] [PATCH 2/5] MdeModulePkg/DxeCore: Align fixed-address error behaviour
Marvin Häuser
mhaeuser at posteo.de
Sat Aug 21 19:55:49 UTC 2021
Update the control flow to take the same actions for failed
fixed-address loading as if the feature was disabled. This allows
Images to still be loaded to their preferred address in the case of
a mismatch between fixed-address and preferred address, and also
ensures correct handling of stripped relocations.
Cc: Jian J Wang <jian.j.wang at intel.com>
Cc: Hao A Wu <hao.a.wu at intel.com>
Cc: Dandan Bi <dandan.bi at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Vitaly Cheptsov <vit9696 at protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser at posteo.de>
---
MdeModulePkg/Core/Dxe/Image/Image.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 641a5715b112..0a1def0572bc 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -565,6 +565,7 @@ CoreLoadPeImage (
EFI_STATUS Status;
BOOLEAN DstBufAlocated;
UINTN Size;
+ PHYSICAL_ADDRESS PreferredAddress;
ZeroMem (&Image->ImageContext, sizeof (Image->ImageContext));
@@ -642,6 +643,8 @@ CoreLoadPeImage (
// a specified address.
//
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 ) {
+ PreferredAddress = Image->ImageContext.ImageAddress;
+
Status = GetPeCoffImageFixLoadingAssignedAddress (&(Image->ImageContext));
if (EFI_ERROR (Status)) {
@@ -649,15 +652,10 @@ CoreLoadPeImage (
// If the code memory is not ready, invoke CoreAllocatePage with AllocateAnyPages to load the driver.
//
DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since specified memory is not available.\n"));
-
- Status = CoreAllocatePages (
- AllocateAnyPages,
- (EFI_MEMORY_TYPE) (Image->ImageContext.ImageCodeMemoryType),
- Image->NumberOfPages,
- &Image->ImageContext.ImageAddress
- );
+ Image->ImageContext.ImageAddress = PreferredAddress;
}
- } else {
+ }
+ if (EFI_ERROR (Status)) {
if (Image->ImageContext.ImageAddress >= 0x100000 || Image->ImageContext.RelocationsStripped) {
Status = CoreAllocatePages (
AllocateAddress,
--
2.31.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79677): https://edk2.groups.io/g/devel/message/79677
Mute This Topic: https://groups.io/mt/85048615/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list