// If we are in EFI 1.10 compatability mode no event groups will be\r
// found and nothing will happen we we call this function. These events\r
// will get signaled but since a lock is held around the call to this\r
- // function the notificaiton events will only be called after this funciton\r
+ // function the notificaiton events will only be called after this function\r
// returns and the lock is released.\r
//\r
CoreNotifySignalList (&gEfiEventMemoryMapChangeGuid);\r
CoreFreeMemoryMapStack ();\r
CoreReleaseMemoryLock ();\r
\r
+ ApplyMemoryProtectionPolicy (EfiMaxMemoryType, Type, Start,\r
+ EFI_PAGES_TO_SIZE (NumberOfPages));\r
+\r
//\r
// If Loading Module At Fixed Address feature is enabled. try to allocate memory with Runtime code & Boot time code type\r
//\r
\r
Status = CoreInternalAllocatePages (Type, MemoryType, NumberOfPages, Memory);\r
if (!EFI_ERROR (Status)) {\r
- CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionAllocatePages, MemoryType, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) *Memory);\r
+ CoreUpdateProfile (\r
+ (EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),\r
+ MemoryProfileActionAllocatePages,\r
+ MemoryType,\r
+ EFI_PAGES_TO_SIZE (NumberOfPages),\r
+ (VOID *) (UINTN) *Memory,\r
+ NULL\r
+ );\r
+ InstallMemoryAttributesTableOnMemoryAllocation (MemoryType);\r
+ ApplyMemoryProtectionPolicy (EfiConventionalMemory, MemoryType, *Memory,\r
+ EFI_PAGES_TO_SIZE (NumberOfPages));\r
}\r
return Status;\r
}\r
\r
@param Memory Base address of memory being freed\r
@param NumberOfPages The number of pages to free\r
+ @param MemoryType Pointer to memory type\r
\r
@retval EFI_NOT_FOUND Could not find the entry that covers the range\r
@retval EFI_INVALID_PARAMETER Address not aligned\r
EFIAPI\r
CoreInternalFreePages (\r
IN EFI_PHYSICAL_ADDRESS Memory,\r
- IN UINTN NumberOfPages\r
+ IN UINTN NumberOfPages,\r
+ OUT EFI_MEMORY_TYPE *MemoryType OPTIONAL\r
)\r
{\r
EFI_STATUS Status;\r
NumberOfPages += EFI_SIZE_TO_PAGES (Alignment) - 1;\r
NumberOfPages &= ~(EFI_SIZE_TO_PAGES (Alignment) - 1);\r
\r
+ if (MemoryType != NULL) {\r
+ *MemoryType = Entry->Type;\r
+ }\r
+\r
Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);\r
\r
if (EFI_ERROR (Status)) {\r
IN UINTN NumberOfPages\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ EFI_MEMORY_TYPE MemoryType;\r
\r
- Status = CoreInternalFreePages (Memory, NumberOfPages);\r
+ Status = CoreInternalFreePages (Memory, NumberOfPages, &MemoryType);\r
if (!EFI_ERROR (Status)) {\r
- CoreUpdateProfile ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0), MemoryProfileActionFreePages, (EFI_MEMORY_TYPE) 0, EFI_PAGES_TO_SIZE (NumberOfPages), (VOID *) (UINTN) Memory);\r
+ CoreUpdateProfile (\r
+ (EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),\r
+ MemoryProfileActionFreePages,\r
+ MemoryType,\r
+ EFI_PAGES_TO_SIZE (NumberOfPages),\r
+ (VOID *) (UINTN) Memory,\r
+ NULL\r
+ );\r
+ InstallMemoryAttributesTableOnMemoryAllocation (MemoryType);\r
+ ApplyMemoryProtectionPolicy (MemoryType, EfiConventionalMemory, Memory,\r
+ EFI_PAGES_TO_SIZE (NumberOfPages));\r
}\r
return Status;\r
}\r