From 8671f61ca4192a9dedfe8344605d8a318fcf681b Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Thu, 30 Jan 2025 18:36:01 +0300 Subject: [PATCH] Ring3: Prevented loading of DxeRing3 driver, when UserSpace is disabled. --- ArmVirtPkg/Library/DebugLibFdtPL011Uart/User.c | 3 +-- MdeModulePkg/Core/Dxe/Image/Image.c | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/User.c b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/User.c index 2229cffde0..6e012ee85b 100644 --- a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/User.c +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/User.c @@ -29,11 +29,10 @@ DebugLibFdtPL011UartUserConstructor ( for (Index = 0; Index < SystemTable->NumberOfTableEntries; ++Index) { if (CompareGuid (&gEarlyPL011BaseAddressGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) { mDebugLibFdtPL011UartAddress = (UINTN)SystemTable->ConfigurationTable[Index].VendorTable; - return EFI_SUCCESS; } } - return EFI_NOT_FOUND; + return EFI_SUCCESS; } /** diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 417b6c9c58..533dad8b6e 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -23,6 +23,7 @@ typedef struct { STATIC LIST_ENTRY mAvailableEmulators; STATIC EFI_EVENT mPeCoffEmuProtocolRegistrationEvent; STATIC VOID *mPeCoffEmuProtocolNotifyRegistration; +STATIC BOOLEAN mDxeRing3 = TRUE; extern BOOLEAN gBdsStarted; @@ -1348,6 +1349,12 @@ CoreLoadImageCommon ( Image->Info.ParentHandle = ParentImageHandle; Image->IsUserImage = (FileAttributes & EFI_FV_FILE_ATTRIB_USER) != 0; + if ((!PcdGetBool (PcdEnableUserSpace)) && Image->IsUserImage && mDxeRing3) { + mDxeRing3 = FALSE; + Status = EFI_NOT_STARTED; + goto Done; + } + if (NumberOfPages != NULL) { Image->NumberOfPages = *NumberOfPages; } else { @@ -1444,7 +1451,7 @@ CoreLoadImageCommon ( Status = EFI_SUCCESS; ProtectUefiImage (&Image->Info, ImageOrigin, &ImageContext, Image->IsUserImage); - if ((gRing3Data != NULL) && Image->IsUserImage) { + if (PcdGetBool (PcdEnableUserSpace) && (gRing3Data != NULL) && Image->IsUserImage) { Image->UserPageTable = InitializeUserPageTable (Image); }