diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 49cbffa5fc81..30d882af848f 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -116,6 +116,10 @@ ## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h gArmScmiPerformanceProtocolGuid = { 0x9b8ba84, 0x3dd3, 0x49a6, { 0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad } } + ## Arm Page Table Memory Allocation Protocol + ## ArmPkg/Include/Protocol/ArmPageTableMemoryAllocation.h + gArmPageTableMemoryAllocationProtocolGuid = { 0x623be44e, 0x506d, 0x487f, {0xa3, 0xa6, 0x92, 0xda, 0xef, 0x30, 0x2c, 0x70 } } + [Ppis] ## Include/Ppi/ArmMpCoreInfo.h gArmMpCoreInfoPpiGuid = { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d, 0xab, 0x44, 0xe7, 0x54, 0xa8, 0xfc} } @@ -135,11 +139,6 @@ # Define if the GICv3 controller should use the GICv2 legacy gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042 - # Whether to remap all unused memory NX before installing the CPU arch - # protocol driver. This is needed on platforms that map all DRAM with RWX - # attributes initially, and can be disabled otherwise. - gArmTokenSpaceGuid.PcdRemapUnusedMemoryNx|TRUE|BOOLEAN|0x00000048 - [PcdsFeatureFlag.ARM] # Whether to map normal memory as non-shareable. FALSE is the safe choice, but # TRUE may be appropriate to fix performance problems if you don't care about diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index 25d750e8ab9f..969a4bee6cbf 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -101,6 +101,7 @@ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf [Components.common] ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.c b/ArmPkg/Drivers/CpuDxe/CpuDxe.c index fc63e527846a..438971c3b325 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.c +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.c @@ -229,77 +229,6 @@ InitializeDma ( CpuArchProtocol->DmaBufferAlignment = ArmCacheWritebackGranule (); } -/** - Map all EfiConventionalMemory regions in the memory map with NX - attributes so that allocating or freeing EfiBootServicesData regions - does not result in changes to memory permission attributes. - -**/ -STATIC -VOID -RemapUnusedMemoryNx ( - VOID - ) -{ - UINT64 TestBit; - UINTN MemoryMapSize; - UINTN MapKey; - UINTN DescriptorSize; - UINT32 DescriptorVersion; - EFI_MEMORY_DESCRIPTOR *MemoryMap; - EFI_MEMORY_DESCRIPTOR *MemoryMapEntry; - EFI_MEMORY_DESCRIPTOR *MemoryMapEnd; - EFI_STATUS Status; - - TestBit = LShiftU64 (1, EfiBootServicesData); - if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & TestBit) == 0) { - return; - } - - MemoryMapSize = 0; - MemoryMap = NULL; - - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - ASSERT (Status == EFI_BUFFER_TOO_SMALL); - do { - MemoryMap = (EFI_MEMORY_DESCRIPTOR *)AllocatePool (MemoryMapSize); - ASSERT (MemoryMap != NULL); - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - if (EFI_ERROR (Status)) { - FreePool (MemoryMap); - } - } while (Status == EFI_BUFFER_TOO_SMALL); - - ASSERT_EFI_ERROR (Status); - - MemoryMapEntry = MemoryMap; - MemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)MemoryMap + MemoryMapSize); - while ((UINTN)MemoryMapEntry < (UINTN)MemoryMapEnd) { - if (MemoryMapEntry->Type == EfiConventionalMemory) { - ArmSetMemoryAttributes ( - MemoryMapEntry->PhysicalStart, - EFI_PAGES_TO_SIZE (MemoryMapEntry->NumberOfPages), - EFI_MEMORY_XP, - EFI_MEMORY_XP - ); - } - - MemoryMapEntry = NEXT_MEMORY_DESCRIPTOR (MemoryMapEntry, DescriptorSize); - } -} - EFI_STATUS CpuDxeInitialize ( IN EFI_HANDLE ImageHandle, @@ -313,19 +242,8 @@ CpuDxeInitialize ( InitializeDma (&mCpu); - // - // Once we install the CPU arch protocol, the DXE core's memory - // protection routines will invoke them to manage the permissions of page - // allocations as they are created. Given that this includes pages - // allocated for page tables by this driver, we must ensure that unused - // memory is mapped with the same permissions as boot services data - // regions. Otherwise, we may end up with unbounded recursion, due to the - // fact that updating permissions on a newly allocated page table may trigger - // a block entry split, which triggers a page table allocation, etc etc - // - if (FeaturePcdGet (PcdRemapUnusedMemoryNx)) { - RemapUnusedMemoryNx (); - } + Status = InitializePageTableMemory (ImageHandle); + ASSERT_EFI_ERROR (Status); Status = gBS->InstallMultipleProtocolInterfaces ( &mCpuHandle, @@ -333,6 +251,8 @@ CpuDxeInitialize ( &mCpu, &gEfiMemoryAttributeProtocolGuid, &mMemoryAttribute, + &gArmPageTableMemoryAllocationProtocolGuid, + &mPageTableMemAllocProtocol, NULL ); diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.h b/ArmPkg/Drivers/CpuDxe/CpuDxe.h index c6613b939a71..2786c7e095ff 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.h +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.h @@ -31,11 +31,14 @@ #include #include #include +#include extern BOOLEAN mIsFlushingGCD; extern EFI_MEMORY_ATTRIBUTE_PROTOCOL mMemoryAttribute; +extern PAGE_TABLE_MEM_ALLOC_PROTOCOL mPageTableMemAllocProtocol; + /** This function registers and enables the handler specified by InterruptHandler for a processor interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the @@ -143,4 +146,19 @@ RegionAttributeToGcdAttribute ( IN UINTN PageAttributes ); +/** + Initialize the page table memory pool and produce the page table memory allocation + protocol. + + @param[in] ImageHandle Handle on which to install the protocol. + + @retval EFI_SUCCESS The page table pool was initialized and protocol produced. + @retval Others The driver returned an error while initializing. +**/ +EFI_STATUS +EFIAPI +InitializePageTableMemory ( + IN EFI_HANDLE ImageHandle + ); + #endif // CPU_DXE_H_ diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf index 7d8132200e64..0e54fced9b9d 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf @@ -24,6 +24,7 @@ CpuMmuCommon.c Exception.c MemoryAttribute.c + PageTableMemoryAllocation.c [Sources.ARM] Arm/Mmu.c @@ -40,6 +41,7 @@ [LibraryClasses] ArmLib ArmMmuLib + BaseLib BaseMemoryLib CacheMaintenanceLib CpuLib @@ -56,6 +58,7 @@ [Protocols] gEfiCpuArchProtocolGuid gEfiMemoryAttributeProtocolGuid + gArmPageTableMemoryAllocationProtocolGuid [Guids] gEfiDebugImageInfoTableGuid @@ -69,7 +72,6 @@ [FeaturePcd.common] gArmTokenSpaceGuid.PcdDebuggerExceptionSupport - gArmTokenSpaceGuid.PcdRemapUnusedMemoryNx [Depex] gHardwareInterruptProtocolGuid OR gHardwareInterrupt2ProtocolGuid diff --git a/ArmPkg/Drivers/CpuDxe/PageTableMemoryAllocation.c b/ArmPkg/Drivers/CpuDxe/PageTableMemoryAllocation.c new file mode 100644 index 000000000000..dfd5518ddcee --- /dev/null +++ b/ArmPkg/Drivers/CpuDxe/PageTableMemoryAllocation.c @@ -0,0 +1,202 @@ +/** @file PageTableAlloc.c + +Logic facilitating the pre-allocation of page table memory. + +Copyright (c) Microsoft Corporation. +SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include + +#pragma pack(1) + +typedef struct { + UINT32 Signature; + UINTN Offset; + UINTN FreePages; + LIST_ENTRY NextPool; +} PAGE_TABLE_POOL; + +#pragma pack() + +#define MIN_PAGES_AVAILABLE 5 +#define PAGE_TABLE_POOL_SIGNATURE SIGNATURE_32 ('P','T','P','L') + +UINTN TotalFreePages = 0; +BOOLEAN mPageTablePoolLock = FALSE; +LIST_ENTRY mPageTablePoolList = INITIALIZE_LIST_HEAD_VARIABLE (mPageTablePoolList); + +/** + Allocates pages for page table memory and adds them to the pool list. + + @param[in] PoolPages The number of pages to allocate. The actual number of pages + reserved will be at least 512 - the number of pages required to describe a + fully split 2MB region. + + @retval EFI_SUCCESS More pages successfully added to the pool list + @retval EFI_INVALID_PARAMETER PoolPages is zero + @retval EFI_ABORTED Software lock is held by another call to this function + @retval EFI_OUT_OF_RESOURCES Unable to allocate pages +**/ +EFI_STATUS +GetMorePages ( + IN UINTN PoolPages + ) +{ + PAGE_TABLE_POOL *Buffer; + + if (PoolPages == 0) { + return EFI_INVALID_PARAMETER; + } + + PoolPages++; + PoolPages = ALIGN_VALUE (PoolPages, EFI_SIZE_TO_PAGES (SIZE_2MB)); // Add one page for the header + Buffer = (PAGE_TABLE_POOL *)AllocateAlignedPages (PoolPages, SIZE_2MB); + if (Buffer == NULL) { + DEBUG ((DEBUG_ERROR, "ERROR: Out of aligned pages\n")); + return EFI_OUT_OF_RESOURCES; + } + + // Reserve one page for pool header. + Buffer->FreePages = PoolPages - 1; + Buffer->Offset = EFI_PAGE_SIZE; + Buffer->Signature = PAGE_TABLE_POOL_SIGNATURE; + TotalFreePages += Buffer->FreePages; + InsertHeadList (&mPageTablePoolList, &Buffer->NextPool); + + return EFI_SUCCESS; +} + +/** + Walks the list to find a pool with enough free pages to allocate from. + + @param[in] Pages The number of pages to allocate + + @retval A pointer to the pool with enough free pages to allocate + from or NULL if no pool has enough free pages. +**/ +PAGE_TABLE_POOL * +FindPoolToAllocateFrom ( + IN UINTN Pages + ) +{ + PAGE_TABLE_POOL *PoolToAllocateFrom = NULL; + LIST_ENTRY *CurrentEntry = mPageTablePoolList.ForwardLink; + + while (CurrentEntry != &mPageTablePoolList) { + PoolToAllocateFrom = CR (CurrentEntry, PAGE_TABLE_POOL, NextPool, PAGE_TABLE_POOL_SIGNATURE); + if (Pages <= PoolToAllocateFrom->FreePages) { + break; + } + + CurrentEntry = CurrentEntry->ForwardLink; + } + + return PoolToAllocateFrom; +} + +/** + Allocate memory for the page table. + + @param[in] NumPages Number of pages to allocate. + + @retval A pointer to the allocated page table memory or NULL if the + allocation failed. +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ) +{ + VOID *Buffer; + PAGE_TABLE_POOL *PoolToAllocateFrom = NULL; + EFI_STATUS Status; + + if (Pages == 0) { + return NULL; + } + + PoolToAllocateFrom = FindPoolToAllocateFrom (Pages); + + // If we are running low on free pages, allocate more while we + // still have enough pages to accommodate a potential split. Hold + // a lock during this because the AllocatePages() call in GetMorePages() + // may call this function recursively. In that recursive call, it should + // pull from the existing pool rather than allocating more pages. + if (((PoolToAllocateFrom == NULL) || + (TotalFreePages < Pages) || + ((TotalFreePages - Pages) <= MIN_PAGES_AVAILABLE)) && + !mPageTablePoolLock) + { + DEBUG ((DEBUG_INFO, "%a - The reserve of translation table memory is being refilled!\n", __func__)); + mPageTablePoolLock = TRUE; + Status = GetMorePages (1); + mPageTablePoolLock = FALSE; + if (EFI_ERROR (Status)) { + return NULL; + } + + PoolToAllocateFrom = FindPoolToAllocateFrom (Pages); + } + + if (PoolToAllocateFrom == NULL) { + return NULL; + } + + Buffer = (UINT8 *)PoolToAllocateFrom + PoolToAllocateFrom->Offset; + PoolToAllocateFrom->Offset += EFI_PAGES_TO_SIZE (Pages); + PoolToAllocateFrom->FreePages -= Pages; + TotalFreePages -= Pages; + + return Buffer; +} + +PAGE_TABLE_MEM_ALLOC_PROTOCOL mPageTableMemAllocProtocol = { + AllocatePageTableMemory +}; + +/** + Initialize the page table memory pool and produce the page table memory allocation + protocol. + + @param[in] ImageHandle Handle on which to install the protocol. + + @retval EFI_SUCCESS The page table pool was initialized and protocol produced. + @retval Others The driver returned an error while initializing. +**/ +EFI_STATUS +EFIAPI +InitializePageTableMemory ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + PAGE_TABLE_POOL *Pages; + + Status = GetMorePages (1); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: Failed to allocate initial page table pool\n")); + return Status; + } + + Status = gBS->InstallMultipleProtocolInterfaces ( + &ImageHandle, + &gArmPageTableMemoryAllocationProtocolGuid, + &mPageTableMemAllocProtocol, + NULL + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: Failed to install ARM page table memory allocation protocol!\n")); + Pages = CR (mPageTablePoolList.ForwardLink, PAGE_TABLE_POOL, NextPool, PAGE_TABLE_POOL_SIGNATURE); + FreePages (Pages, EFI_SIZE_TO_PAGES (Pages->FreePages) + 1); + } + + return Status; +} diff --git a/ArmPkg/Include/Protocol/ArmPageTableMemoryAllocation.h b/ArmPkg/Include/Protocol/ArmPageTableMemoryAllocation.h new file mode 100644 index 000000000000..4d69e732c37f --- /dev/null +++ b/ArmPkg/Include/Protocol/ArmPageTableMemoryAllocation.h @@ -0,0 +1,40 @@ +/** @file ArmPageTableMemoryAllocation.h + +Logic facilitating the allocation of page table memory. + +Copyright (c) Microsoft Corporation. +SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef ARM_PAGE_TABLE_MEM_ALLOC_H_ +#define ARM_PAGE_TABLE_MEM_ALLOC_H_ + +#define ARM_PAGE_TABLE_MEM_ALLOC_PROTOCOL { \ + 0x623be44e, 0x506d, 0x487f, {0xa3, 0xa6, 0x92, 0xda, 0xef, 0x30, 0x2c, 0x70 } \ + } + +extern EFI_GUID gArmPageTableMemoryAllocationProtocolGuid; + +typedef struct _PAGE_TABLE_MEM_ALLOC_PROTOCOL PAGE_TABLE_MEM_ALLOC_PROTOCOL; + +// Protocol Interface functions. + +/** + Allocate memory for the page table. + + @param[in] NumPages Number of pages to allocate. + + @retval A pointer to the allocated page table memory or NULL if the + allocation failed. +**/ +typedef +VOID * +(EFIAPI *ALLOCATE_PAGE_TABLE_MEMORY)( + IN UINTN NumPages + ); + +typedef struct _PAGE_TABLE_MEM_ALLOC_PROTOCOL { + ALLOCATE_PAGE_TABLE_MEMORY AllocatePageTableMemory; +} PAGE_TABLE_MEM_ALLOC_PROTOCOL; + +#endif diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c index b83373d4b59e..bee899c96aae 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -24,6 +24,18 @@ STATIC ARM_REPLACE_LIVE_TRANSLATION_ENTRY mReplaceLiveEntryFunc = ArmReplaceLiveTranslationEntry; +/** + Allocates pages for the page table from a reserved pool. + + @param[in] Pages The number of pages to allocate + + @return A pointer to the allocated buffer or NULL if allocation fails +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ); + STATIC UINT64 ArmMemoryAttributeToPageAttribute ( @@ -272,7 +284,7 @@ UpdateRegionMappingRecursive ( // No table entry exists yet, so we need to allocate a page table // for the next level. // - TranslationTable = AllocatePages (1); + TranslationTable = AllocatePageTableMemory (1); if (TranslationTable == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -665,7 +677,7 @@ ArmConfigureMmu ( ArmSetTCR (TCR); // Allocate pages for translation table - TranslationTable = AllocatePages (1); + TranslationTable = AllocatePageTableMemory (1); if (TranslationTable == NULL) { return EFI_OUT_OF_RESOURCES; } diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibPageTableAlloc.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibPageTableAlloc.c new file mode 100644 index 000000000000..fd5053aa2743 --- /dev/null +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibPageTableAlloc.c @@ -0,0 +1,42 @@ +/** @file ArmMmuLibPageTableAlloc.c + + Logic facilitating the allocation of page table memory from a reserved pool. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include + +PAGE_TABLE_MEM_ALLOC_PROTOCOL *mPageTableMemAllocProtocol = NULL; + +/** + Allocates pages for the page table from a reserved pool. + + @param[in] Pages The number of pages to allocate + + @return A pointer to the allocated buffer or NULL if allocation fails +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ) +{ + if (mPageTableMemAllocProtocol == NULL) { + gBS->LocateProtocol ( + &gArmPageTableMemoryAllocationProtocolGuid, + NULL, + (VOID **)&mPageTableMemAllocProtocol + ); + } + + if (mPageTableMemAllocProtocol != NULL) { + return mPageTableMemAllocProtocol->AllocatePageTableMemory (Pages); + } + + return AllocatePages (Pages); +} diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibPageTableAllocPei.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibPageTableAllocPei.c new file mode 100644 index 000000000000..cc383532bf62 --- /dev/null +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibPageTableAllocPei.c @@ -0,0 +1,25 @@ +/** @file ArmMmuLibPageTableAllocPei.c + + Logic facilitating the allocation of page table memory from a reserved pool. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include + +/** + Allocates pages for the page table from a reserved pool. + + @param[in] Pages The number of pages to allocate + + @return A pointer to the allocated buffer or NULL if allocation fails +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ) +{ + return AllocatePages (Pages); +} diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf index 510511bd414f..439afe5ed5e1 100644 --- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf @@ -13,7 +13,8 @@ FILE_GUID = da8f0232-fb14-42f0-922c-63104d2c70bd MODULE_TYPE = BASE VERSION_STRING = 1.0 - LIBRARY_CLASS = ArmMmuLib + # Can't be fully BASE, because it doesn't work in MM_STANDALONE. + LIBRARY_CLASS = ArmMmuLib | DXE_DRIVER DXE_CORE DXE_RUNTIME_DRIVER [Defines.AARCH64] CONSTRUCTOR = ArmMmuBaseLibConstructor @@ -22,6 +23,7 @@ ArmMmuLibInternal.h AArch64/ArmMmuLibCore.c AArch64/ArmMmuLibReplaceEntry.S + AArch64/ArmMmuLibPageTableAlloc.c [Sources.ARM] ArmMmuLibInternal.h @@ -40,6 +42,7 @@ CacheMaintenanceLib HobLib MemoryAllocationLib + UefiBootServicesTableLib [Guids] gArmMmuReplaceLiveTranslationEntryFuncGuid diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf index 37424628aa07..fc3788282e65 100644 --- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf +++ b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf @@ -11,16 +11,25 @@ INF_VERSION = 0x00010005 BASE_NAME = ArmMmuPeiLib FILE_GUID = b50d8d53-1ad1-44ea-9e69-8c89d4a6d08b - MODULE_TYPE = PEIM + MODULE_TYPE = BASE VERSION_STRING = 1.0 - LIBRARY_CLASS = ArmMmuLib|PEIM - CONSTRUCTOR = ArmMmuPeiLibConstructor + LIBRARY_CLASS = ArmMmuLib | PEIM PEI_CORE SEC + +[Defines.AARCH64] + CONSTRUCTOR = ArmMmuBaseLibConstructor [Sources.AARCH64] ArmMmuLibInternal.h AArch64/ArmMmuLibCore.c - AArch64/ArmMmuPeiLibConstructor.c AArch64/ArmMmuLibReplaceEntry.S + AArch64/ArmMmuLibPageTableAllocPei.c + +[Sources.ARM] + ArmMmuLibInternal.h + Arm/ArmMmuLibConvert.c + Arm/ArmMmuLibCore.c + Arm/ArmMmuLibUpdate.c + Arm/ArmMmuLibV7Support.S | GCC [Packages] ArmPkg/ArmPkg.dec @@ -35,3 +44,6 @@ [Guids] gArmMmuReplaceLiveTranslationEntryFuncGuid + +[Pcd.ARM] + gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride diff --git a/ArmPlatformPkg/ArmPlatformPkg.dsc b/ArmPlatformPkg/ArmPlatformPkg.dsc index bfe1b99e8bfb..e1c12de5c78b 100644 --- a/ArmPlatformPkg/ArmPlatformPkg.dsc +++ b/ArmPlatformPkg/ArmPlatformPkg.dsc @@ -73,6 +73,9 @@ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf +[LibraryClasses.common.SEC, LibraryClasses.common.PEIM] + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf + [LibraryClasses.common.PEIM] HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf diff --git a/ArmVirtPkg/ArmVirtCloudHv.dsc b/ArmVirtPkg/ArmVirtCloudHv.dsc index 234a2b5cf0d9..c5a336957634 100644 --- a/ArmVirtPkg/ArmVirtCloudHv.dsc +++ b/ArmVirtPkg/ArmVirtCloudHv.dsc @@ -59,6 +59,9 @@ !include MdePkg/MdeLibs.dsc.inc +[LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM] + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf + [LibraryClasses.common.PEIM] ArmVirtMemInfoLib|ArmVirtPkg/Library/CloudHvVirtMemInfoLib/CloudHvVirtMemInfoPeiLib.inf diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index c5cf2a75d9f5..4ef4d54abf02 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -94,6 +94,7 @@ !if $(TARGET) != RELEASE DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf !endif + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf [LibraryClasses.common.DXE_RUNTIME_DRIVER] !if $(TARGET) != RELEASE diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 10e4541b3e01..f9f0e1ca8a44 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -100,6 +100,9 @@ [LibraryClasses.ARM] ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf +[LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses.common.PEIM] + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf + [LibraryClasses.common.PEIM] ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf ArmMonitorLib|ArmVirtPkg/Library/ArmVirtQemuMonitorPeiLib/ArmVirtQemuMonitorPeiLib.inf diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc index c5fdcfd9c72a..2ee569b32335 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -84,6 +84,9 @@ ArmMonitorLib|ArmVirtPkg/Library/ArmVirtQemuMonitorLib/ArmVirtQemuMonitorLib.inf +[LibraryClasses.common.SEC] + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf + [LibraryClasses.common.DXE_DRIVER] AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc index fd4f88725432..46df7496cc36 100644 --- a/ArmVirtPkg/ArmVirtXen.dsc +++ b/ArmVirtPkg/ArmVirtXen.dsc @@ -55,6 +55,9 @@ TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf +[LibraryClasses.common.SEC] + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf + [LibraryClasses.common.DXE_RUNTIME_DRIVER] !if $(TARGET) != RELEASE DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf