X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPkg%2FLibrary%2FUncachedMemoryAllocationLib%2FUncachedMemoryAllocationLib.c;fp=ArmPkg%2FLibrary%2FUncachedMemoryAllocationLib%2FUncachedMemoryAllocationLib.c;h=cd13a7da92e0468f2ec81caf2ba0cd62b7a7b61b;hp=f6c692f9a4034bdcaf199dc4e1bc5fa3da7c71b7;hb=bb52ec2d6b76b043cd70f277887519f09f36b55a;hpb=29e9bf10dcd23da8e8068e22ee133eac29cdda9d diff --git a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c index f6c692f9a4..cd13a7da92 100644 --- a/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c +++ b/ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.c @@ -42,11 +42,6 @@ UncachedInternalAllocateAlignedPages ( -// -// Assume all of memory has the same cache attributes, unless we do our magic -// -UINT64 gAttributes; - typedef struct { EFI_PHYSICAL_ADDRESS Base; VOID *Allocation; @@ -54,6 +49,7 @@ typedef struct { EFI_MEMORY_TYPE MemoryType; BOOLEAN Allocated; LIST_ENTRY Link; + UINT64 Attributes; } FREE_PAGE_NODE; STATIC LIST_ENTRY mPageList = INITIALIZE_LIST_HEAD_VARIABLE (mPageList); @@ -153,10 +149,7 @@ AllocatePagesFromList ( } Status = gDS->GetMemorySpaceDescriptor (Memory, &Descriptor); - if (!EFI_ERROR (Status)) { - // We are making an assumption that all of memory has the same default attributes - gAttributes = Descriptor.Attributes; - } else { + if (EFI_ERROR (Status)) { gBS->FreePages (Memory, Pages); return Status; } @@ -181,6 +174,7 @@ AllocatePagesFromList ( NewNode->Pages = Pages; NewNode->Allocated = TRUE; NewNode->MemoryType = MemoryType; + NewNode->Attributes = Descriptor.Attributes; InsertTailList (&mPageList, &NewNode->Link); @@ -266,6 +260,10 @@ UncachedMemoryAllocationLibDestructor ( // We only free the non-allocated buffer if (OldNode->Allocated == FALSE) { gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)OldNode->Base, OldNode->Pages); + + gDS->SetMemorySpaceAttributes ((EFI_PHYSICAL_ADDRESS)(UINTN)OldNode->Base, + EFI_PAGES_TO_SIZE (OldNode->Pages), OldNode->Attributes); + RemoveEntryList (&OldNode->Link); FreePool (OldNode); }