X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmVirtPkg%2FHighMemDxe%2FHighMemDxe.c;fp=ArmVirtPkg%2FHighMemDxe%2FHighMemDxe.c;h=f70978f6414fc80c0325feb7afa42339ae4699f6;hp=22f738279b202e3256e08e8cbd7094fc71767f86;hb=413edd470932d8e542325fa205b1e4f5e163a85c;hpb=e9429e7997b8e668126d71b8030cc3a96c36a652 diff --git a/ArmVirtPkg/HighMemDxe/HighMemDxe.c b/ArmVirtPkg/HighMemDxe/HighMemDxe.c index 22f738279b..f70978f641 100644 --- a/ArmVirtPkg/HighMemDxe/HighMemDxe.c +++ b/ArmVirtPkg/HighMemDxe/HighMemDxe.c @@ -37,6 +37,7 @@ InitializeHighMemDxe ( UINTN AddressCells, SizeCells; UINT64 CurBase; UINT64 CurSize; + UINT64 Attributes; Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, (VOID **)&FdtClient); @@ -77,8 +78,21 @@ InitializeHighMemDxe ( continue; } - Status = gDS->SetMemorySpaceAttributes (CurBase, CurSize, - EFI_MEMORY_WB); + // + // Take care not to strip any permission attributes that will have been + // set by DxeCore on the region we just added if a strict permission + // policy is in effect for EfiConventionalMemory regions. + // Unfortunately, we cannot interrogate the GCD memory space map for + // those permissions, since they are not recorded there (for historical + // reasons), so check the policy directly. + // + Attributes = EFI_MEMORY_WB; + if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & + (1U << (UINT32)EfiConventionalMemory)) != 0) { + Attributes |= EFI_MEMORY_XP; + } + + Status = gDS->SetMemorySpaceAttributes (CurBase, CurSize, Attributes); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR,