]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PiSmmCore: Remove redundant functions
authorshenglei <shenglei.zhang@intel.com>
Wed, 8 Aug 2018 07:52:21 +0000 (15:52 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 21 Aug 2018 08:29:04 +0000 (16:29 +0800)
The functions that are never called have been removed.
They are IsImageInsideSmram,FindImageRecord,SmmRemoveImageRecord,
SmmMemoryAttributesTableConsistencyCheck,DumpSmmMemoryMapEntry,
SmmMemoryMapConsistencyCheckRange,SmmMemoryMapConsistencyCheck,
DumpSmmMemoryMap,ClearGuardMapBit,SetGuardMapBit,AdjustMemoryA,
AdjustMemoryS,IsHeadGuard and IsTailGuard.
FindImageRecord() is called by SmmRemoveImageRecord(); however,
nothing calls SmmRemoveImageRecord().
SmmMemoryMapConsistencyCheckRange() is called by
SmmMemoryMapConsistencyCheck(); however, nothing calls
SmmMemoryMapConsistencyCheck().
https://bugzilla.tianocore.org/show_bug.cgi?id=1062

v2:append the following to the commit message.
- FindImageRecord() is called by SmmRemoveImageRecord(); however,
nothing calls SmmRemoveImageRecord().
- SmmMemoryMapConsistencyCheckRange() is called by
SmmMemoryMapConsistencyCheck(); however, nothing calls
SmmMemoryMapConsistencyCheck().

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei <shenglei.zhang@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Core/PiSmmCore/HeapGuard.c
MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c
MdeModulePkg/Core/PiSmmCore/Page.c

index d9e54b96cb0074bc66e5bc137f72bb4844fc673d..f7ae9ae28686d1949f9e4bf9e6daba58e4fc0297 100644 (file)
@@ -455,51 +455,6 @@ GetGuardMapBit (
   return 0;\r
 }\r
 \r
   return 0;\r
 }\r
 \r
-/**\r
-  Set the bit in bitmap table for the given address.\r
-\r
-  @param[in]  Address     The address to set for.\r
-\r
-  @return VOID.\r
-**/\r
-VOID\r
-EFIAPI\r
-SetGuardMapBit (\r
-  IN EFI_PHYSICAL_ADDRESS    Address\r
-  )\r
-{\r
-  UINT64        *GuardMap;\r
-  UINT64        BitMask;\r
-\r
-  FindGuardedMemoryMap (Address, TRUE, &GuardMap);\r
-  if (GuardMap != NULL) {\r
-    BitMask = LShiftU64 (1, GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address));\r
-    *GuardMap |= BitMask;\r
-  }\r
-}\r
-\r
-/**\r
-  Clear the bit in bitmap table for the given address.\r
-\r
-  @param[in]  Address     The address to clear for.\r
-\r
-  @return VOID.\r
-**/\r
-VOID\r
-EFIAPI\r
-ClearGuardMapBit (\r
-  IN EFI_PHYSICAL_ADDRESS    Address\r
-  )\r
-{\r
-  UINT64        *GuardMap;\r
-  UINT64        BitMask;\r
-\r
-  FindGuardedMemoryMap (Address, TRUE, &GuardMap);\r
-  if (GuardMap != NULL) {\r
-    BitMask = LShiftU64 (1, GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address));\r
-    *GuardMap &= ~BitMask;\r
-  }\r
-}\r
 \r
 /**\r
   Check to see if the page at the given address is a Guard page or not.\r
 \r
 /**\r
   Check to see if the page at the given address is a Guard page or not.\r
@@ -526,39 +481,7 @@ IsGuardPage (
   return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));\r
 }\r
 \r
   return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));\r
 }\r
 \r
-/**\r
-  Check to see if the page at the given address is a head Guard page or not.\r
 \r
 \r
-  @param[in]  Address     The address to check for.\r
-\r
-  @return TRUE  The page at Address is a head Guard page.\r
-  @return FALSE The page at Address is not a head Guard page.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsHeadGuard (\r
-  IN EFI_PHYSICAL_ADDRESS    Address\r
-  )\r
-{\r
-  return (GetGuardedMemoryBits (Address, 2) == BIT1);\r
-}\r
-\r
-/**\r
-  Check to see if the page at the given address is a tail Guard page or not.\r
-\r
-  @param[in]  Address     The address to check for.\r
-\r
-  @return TRUE  The page at Address is a tail Guard page.\r
-  @return FALSE The page at Address is not a tail Guard page.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsTailGuard (\r
-  IN EFI_PHYSICAL_ADDRESS    Address\r
-  )\r
-{\r
-  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == BIT0);\r
-}\r
 \r
 /**\r
   Check to see if the page at the given address is guarded or not.\r
 \r
 /**\r
   Check to see if the page at the given address is guarded or not.\r
@@ -864,66 +787,7 @@ UnsetGuardForMemory (
   ClearGuardedMemoryBits(Memory, NumberOfPages);\r
 }\r
 \r
   ClearGuardedMemoryBits(Memory, NumberOfPages);\r
 }\r
 \r
-/**\r
-  Adjust address of free memory according to existing and/or required Guard.\r
-\r
-  This function will check if there're existing Guard pages of adjacent\r
-  memory blocks, and try to use it as the Guard page of the memory to be\r
-  allocated.\r
 \r
 \r
-  @param[in]  Start           Start address of free memory block.\r
-  @param[in]  Size            Size of free memory block.\r
-  @param[in]  SizeRequested   Size of memory to allocate.\r
-\r
-  @return The end address of memory block found.\r
-  @return 0 if no enough space for the required size of memory and its Guard.\r
-**/\r
-UINT64\r
-AdjustMemoryS (\r
-  IN UINT64                  Start,\r
-  IN UINT64                  Size,\r
-  IN UINT64                  SizeRequested\r
-  )\r
-{\r
-  UINT64  Target;\r
-\r
-  //\r
-  // UEFI spec requires that allocated pool must be 8-byte aligned. If it's\r
-  // indicated to put the pool near the Tail Guard, we need extra bytes to\r
-  // make sure alignment of the returned pool address.\r
-  //\r
-  if ((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0) {\r
-    SizeRequested = ALIGN_VALUE(SizeRequested, 8);\r
-  }\r
-\r
-  Target = Start + Size - SizeRequested;\r
-  ASSERT (Target >= Start);\r
-  if (Target == 0) {\r
-    return 0;\r
-  }\r
-\r
-  if (!IsGuardPage (Start + Size)) {\r
-    // No Guard at tail to share. One more page is needed.\r
-    Target -= EFI_PAGES_TO_SIZE (1);\r
-  }\r
-\r
-  // Out of range?\r
-  if (Target < Start) {\r
-    return 0;\r
-  }\r
-\r
-  // At the edge?\r
-  if (Target == Start) {\r
-    if (!IsGuardPage (Target - EFI_PAGES_TO_SIZE (1))) {\r
-      // No enough space for a new head Guard if no Guard at head to share.\r
-      return 0;\r
-    }\r
-  }\r
-\r
-  // OK, we have enough pages for memory and its Guards. Return the End of the\r
-  // free space.\r
-  return Target + SizeRequested - 1;\r
-}\r
 \r
 /**\r
   Adjust the start address and number of pages to free according to Guard.\r
 \r
 /**\r
   Adjust the start address and number of pages to free according to Guard.\r
@@ -1049,36 +913,6 @@ AdjustMemoryF (
   *NumberOfPages  = PagesToFree;\r
 }\r
 \r
   *NumberOfPages  = PagesToFree;\r
 }\r
 \r
-/**\r
-  Adjust the base and number of pages to really allocate according to Guard.\r
-\r
-  @param[in,out]  Memory          Base address of free memory.\r
-  @param[in,out]  NumberOfPages   Size of memory to allocate.\r
-\r
-  @return VOID.\r
-**/\r
-VOID\r
-AdjustMemoryA (\r
-  IN OUT EFI_PHYSICAL_ADDRESS    *Memory,\r
-  IN OUT UINTN                   *NumberOfPages\r
-  )\r
-{\r
-  //\r
-  // FindFreePages() has already taken the Guard into account. It's safe to\r
-  // adjust the start address and/or number of pages here, to make sure that\r
-  // the Guards are also "allocated".\r
-  //\r
-  if (!IsGuardPage (*Memory + EFI_PAGES_TO_SIZE (*NumberOfPages))) {\r
-    // No tail Guard, add one.\r
-    *NumberOfPages += 1;\r
-  }\r
-\r
-  if (!IsGuardPage (*Memory - EFI_PAGE_SIZE)) {\r
-    // No head Guard, add one.\r
-    *Memory        -= EFI_PAGE_SIZE;\r
-    *NumberOfPages += 1;\r
-  }\r
-}\r
 \r
 /**\r
   Adjust the pool head position to make sure the Guard page is adjavent to\r
 \r
 /**\r
   Adjust the pool head position to make sure the Guard page is adjavent to\r
index 36ccf65fa362a08acb2d1282408588ba35ef3d3d..1682d0f9e4042e173598578c8d46ed70a62eb6bc 100644 (file)
@@ -114,34 +114,6 @@ EfiSizeToPages (
   return RShiftU64 (Size, EFI_PAGE_SHIFT) + ((((UINTN)Size) & EFI_PAGE_MASK) ? 1 : 0);\r
 }\r
 \r
   return RShiftU64 (Size, EFI_PAGE_SHIFT) + ((((UINTN)Size) & EFI_PAGE_MASK) ? 1 : 0);\r
 }\r
 \r
-/**\r
-  Check the consistency of Smm memory attributes table.\r
-\r
-  @param[in] MemoryAttributesTable  PI SMM memory attributes table\r
-**/\r
-VOID\r
-SmmMemoryAttributesTableConsistencyCheck (\r
-  IN EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable\r
-  )\r
-{\r
-  EFI_MEMORY_DESCRIPTOR                     *MemoryMap;\r
-  UINTN                                     MemoryMapEntryCount;\r
-  UINTN                                     DescriptorSize;\r
-  UINTN                                     Index;\r
-  UINT64                                    Address;\r
-\r
-  Address = 0;\r
-  MemoryMapEntryCount = MemoryAttributesTable->NumberOfEntries;\r
-  DescriptorSize = MemoryAttributesTable->DescriptorSize;\r
-  MemoryMap = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1);\r
-  for (Index = 0; Index < MemoryMapEntryCount; Index++) {\r
-    if (Address != 0) {\r
-      ASSERT (Address == MemoryMap->PhysicalStart);\r
-    }\r
-    Address = MemoryMap->PhysicalStart + EfiPagesToSize(MemoryMap->NumberOfPages);\r
-    MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, DescriptorSize);\r
-  }\r
-}\r
 \r
 /**\r
   Sort memory map entries based upon PhysicalStart, from low to high.\r
 \r
 /**\r
   Sort memory map entries based upon PhysicalStart, from low to high.\r
@@ -1224,85 +1196,6 @@ Finish:
   return ;\r
 }\r
 \r
   return ;\r
 }\r
 \r
-/**\r
-  Find image record according to image base and size.\r
-\r
-  @param[in]  ImageBase    Base of PE image\r
-  @param[in]  ImageSize    Size of PE image\r
-\r
-  @return image record\r
-**/\r
-STATIC\r
-IMAGE_PROPERTIES_RECORD *\r
-FindImageRecord (\r
-  IN EFI_PHYSICAL_ADDRESS  ImageBase,\r
-  IN UINT64                ImageSize\r
-  )\r
-{\r
-  IMAGE_PROPERTIES_RECORD    *ImageRecord;\r
-  LIST_ENTRY                 *ImageRecordLink;\r
-  LIST_ENTRY                 *ImageRecordList;\r
-\r
-  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;\r
-\r
-  for (ImageRecordLink = ImageRecordList->ForwardLink;\r
-       ImageRecordLink != ImageRecordList;\r
-       ImageRecordLink = ImageRecordLink->ForwardLink) {\r
-    ImageRecord = CR (\r
-                    ImageRecordLink,\r
-                    IMAGE_PROPERTIES_RECORD,\r
-                    Link,\r
-                    IMAGE_PROPERTIES_RECORD_SIGNATURE\r
-                    );\r
-\r
-    if ((ImageBase == ImageRecord->ImageBase) &&\r
-        (ImageSize == ImageRecord->ImageSize)) {\r
-      return ImageRecord;\r
-    }\r
-  }\r
-\r
-  return NULL;\r
-}\r
-\r
-/**\r
-  Remove Image record.\r
-\r
-  @param[in]  DriverEntry    Driver information\r
-**/\r
-VOID\r
-SmmRemoveImageRecord (\r
-  IN EFI_SMM_DRIVER_ENTRY  *DriverEntry\r
-  )\r
-{\r
-  IMAGE_PROPERTIES_RECORD              *ImageRecord;\r
-  LIST_ENTRY                           *CodeSegmentListHead;\r
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection;\r
-\r
-  DEBUG ((DEBUG_VERBOSE, "SMM RemoveImageRecord - 0x%x\n", DriverEntry));\r
-  DEBUG ((DEBUG_VERBOSE, "SMM RemoveImageRecord - 0x%016lx - 0x%016lx\n", DriverEntry->ImageBuffer, DriverEntry->NumberOfPage));\r
-\r
-  ImageRecord = FindImageRecord (DriverEntry->ImageBuffer, EfiPagesToSize(DriverEntry->NumberOfPage));\r
-  if (ImageRecord == NULL) {\r
-    DEBUG ((DEBUG_ERROR, "SMM !!!!!!!! ImageRecord not found !!!!!!!!\n"));\r
-    return ;\r
-  }\r
-\r
-  CodeSegmentListHead = &ImageRecord->CodeSegmentList;\r
-  while (!IsListEmpty (CodeSegmentListHead)) {\r
-    ImageRecordCodeSection = CR (\r
-                               CodeSegmentListHead->ForwardLink,\r
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,\r
-                               Link,\r
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE\r
-                               );\r
-    RemoveEntryList (&ImageRecordCodeSection->Link);\r
-    FreePool (ImageRecordCodeSection);\r
-  }\r
-\r
-  RemoveEntryList (&ImageRecord->Link);\r
-  FreePool (ImageRecord);\r
-  mImagePropertiesPrivateData.ImageRecordCount--;\r
-}\r
 \r
 /**\r
   Publish MemoryAttributesTable to SMM configuration table.\r
 \r
 /**\r
   Publish MemoryAttributesTable to SMM configuration table.\r
@@ -1386,30 +1279,6 @@ PublishMemoryAttributesTable (
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
-/**\r
-  This function returns if image is inside SMRAM.\r
-\r
-  @param[in] LoadedImage LoadedImage protocol instance for an image.\r
-\r
-  @retval TRUE  the image is inside SMRAM.\r
-  @retval FALSE the image is outside SMRAM.\r
-**/\r
-BOOLEAN\r
-IsImageInsideSmram (\r
-  IN EFI_LOADED_IMAGE_PROTOCOL   *LoadedImage\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < mFullSmramRangeCount; Index++) {\r
-    if ((mFullSmramRanges[Index].PhysicalStart <= (UINTN)LoadedImage->ImageBase)&&\r
-        (mFullSmramRanges[Index].PhysicalStart + mFullSmramRanges[Index].PhysicalSize >= (UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize)) {\r
-      return TRUE;\r
-    }\r
-  }\r
-\r
-  return FALSE;\r
-}\r
 \r
 /**\r
   This function installs all SMM image record information.\r
 \r
 /**\r
   This function installs all SMM image record information.\r
index 3699af7424584c33afd383b82c72c56610a7c5ab..cd7d7ece0ceedf8cfa59b90d6f011d177dd5ab8c 100644 (file)
@@ -451,128 +451,7 @@ GetSmmMemoryMapEntryCount (
   return Count;\r
 }\r
 \r
   return Count;\r
 }\r
 \r
-/**\r
-  Dump Smm memory map entry.\r
-**/\r
-VOID\r
-DumpSmmMemoryMapEntry (\r
-  VOID\r
-  )\r
-{\r
-  LIST_ENTRY               *Link;\r
-  MEMORY_MAP               *Entry;\r
-  EFI_PHYSICAL_ADDRESS     Last;\r
-\r
-  Last = 0;\r
-  DEBUG ((DEBUG_INFO, "DumpSmmMemoryMapEntry:\n"));\r
-  Link = gMemoryMap.ForwardLink;\r
-  while (Link != &gMemoryMap) {\r
-    Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);\r
-    Link  = Link->ForwardLink;\r
-\r
-    if ((Last != 0) && (Last != (UINT64)-1)) {\r
-      if (Last + 1 != Entry->Start) {\r
-        Last = (UINT64)-1;\r
-      } else {\r
-        Last = Entry->End;\r
-      }\r
-    } else if (Last == 0) {\r
-      Last = Entry->End;\r
-    }\r
-\r
-    DEBUG ((DEBUG_INFO, "Entry (Link - 0x%x)\n", &Entry->Link));\r
-    DEBUG ((DEBUG_INFO, "  Signature         - 0x%x\n", Entry->Signature));\r
-    DEBUG ((DEBUG_INFO, "  Link.ForwardLink  - 0x%x\n", Entry->Link.ForwardLink));\r
-    DEBUG ((DEBUG_INFO, "  Link.BackLink     - 0x%x\n", Entry->Link.BackLink));\r
-    DEBUG ((DEBUG_INFO, "  Type              - 0x%x\n", Entry->Type));\r
-    DEBUG ((DEBUG_INFO, "  Start             - 0x%016lx\n", Entry->Start));\r
-    DEBUG ((DEBUG_INFO, "  End               - 0x%016lx\n", Entry->End));\r
-  }\r
-\r
-  ASSERT (Last != (UINT64)-1);\r
-}\r
-\r
-/**\r
-  Dump Smm memory map.\r
-**/\r
-VOID\r
-DumpSmmMemoryMap (\r
-  VOID\r
-  )\r
-{\r
-  LIST_ENTRY      *Node;\r
-  FREE_PAGE_LIST  *Pages;\r
-\r
-  DEBUG ((DEBUG_INFO, "DumpSmmMemoryMap\n"));\r
-\r
-  Pages = NULL;\r
-  Node = mSmmMemoryMap.ForwardLink;\r
-  while (Node != &mSmmMemoryMap) {\r
-    Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);\r
-    DEBUG ((DEBUG_INFO, "Pages - 0x%x\n", Pages));\r
-    DEBUG ((DEBUG_INFO, "Pages->NumberOfPages - 0x%x\n", Pages->NumberOfPages));\r
-    Node = Node->ForwardLink;\r
-  }\r
-}\r
 \r
 \r
-/**\r
-  Check if a Smm base~length is in Smm memory map.\r
-\r
-  @param[in] Base   The base address of Smm memory to be checked.\r
-  @param[in] Length THe length of Smm memory to be checked.\r
-\r
-  @retval TRUE  Smm base~length is in smm memory map.\r
-  @retval FALSE Smm base~length is in smm memory map.\r
-**/\r
-BOOLEAN\r
-SmmMemoryMapConsistencyCheckRange (\r
-  IN EFI_PHYSICAL_ADDRESS Base,\r
-  IN UINTN                Length\r
-  )\r
-{\r
-  LIST_ENTRY               *Link;\r
-  MEMORY_MAP               *Entry;\r
-  BOOLEAN                  Result;\r
-\r
-  Result = FALSE;\r
-  Link = gMemoryMap.ForwardLink;\r
-  while (Link != &gMemoryMap) {\r
-    Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);\r
-    Link  = Link->ForwardLink;\r
-\r
-    if (Entry->Type != EfiConventionalMemory) {\r
-      continue;\r
-    }\r
-    if (Entry->Start == Base && Entry->End == Base + Length - 1) {\r
-      Result = TRUE;\r
-      break;\r
-    }\r
-  }\r
-\r
-  return Result;\r
-}\r
-\r
-/**\r
-  Check the consistency of Smm memory map.\r
-**/\r
-VOID\r
-SmmMemoryMapConsistencyCheck (\r
-  VOID\r
-  )\r
-{\r
-  LIST_ENTRY      *Node;\r
-  FREE_PAGE_LIST  *Pages;\r
-  BOOLEAN         Result;\r
-\r
-  Pages = NULL;\r
-  Node = mSmmMemoryMap.ForwardLink;\r
-  while (Node != &mSmmMemoryMap) {\r
-    Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);\r
-    Result = SmmMemoryMapConsistencyCheckRange ((EFI_PHYSICAL_ADDRESS)(UINTN)Pages, (UINTN)EFI_PAGES_TO_SIZE(Pages->NumberOfPages));\r
-    ASSERT (Result);\r
-    Node = Node->ForwardLink;\r
-  }\r
-}\r
 \r
 /**\r
   Internal Function. Allocate n pages from given free page node.\r
 \r
 /**\r
   Internal Function. Allocate n pages from given free page node.\r