]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Fix unix style of EOL
authorJian J Wang <jian.j.wang@intel.com>
Mon, 20 Nov 2017 08:14:10 +0000 (16:14 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 21 Nov 2017 12:24:37 +0000 (20:24 +0800)
Cc: Wu Hao <hao.a.wu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
UefiCpuPkg/CpuDxe/CpuPageTable.c
UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c

index 309f448a835763dcae70fe32977701a5802e4910..76f44f9bd1b4c5bc8de1720e27c130a631bea333 100644 (file)
@@ -442,8 +442,8 @@ ConvertPageEntryAttribute (
   *PageEntry = NewPageEntry;\r
   if (CurrentPageEntry != NewPageEntry) {\r
     *IsModified = TRUE;\r
   *PageEntry = NewPageEntry;\r
   if (CurrentPageEntry != NewPageEntry) {\r
     *IsModified = TRUE;\r
-    DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry));
-    DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry));
+    DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry));\r
+    DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry));\r
   } else {\r
     *IsModified = FALSE;\r
   }\r
   } else {\r
     *IsModified = FALSE;\r
   }\r
index 9447a31ef5691b4fe0d1bcf792a9419151195ad2..0396f2daaaed1aaa570acdb72970a697baae498c 100644 (file)
@@ -196,16 +196,16 @@ SetPageTableAttributes (
   BOOLEAN               IsSplitted;\r
   BOOLEAN               PageTableSplitted;\r
 \r
   BOOLEAN               IsSplitted;\r
   BOOLEAN               PageTableSplitted;\r
 \r
-  //
-  // Don't mark page table as read-only if heap guard is enabled.
-  //
-  //      BIT2: SMM page guard enabled
-  //      BIT3: SMM pool guard enabled
-  //
-  if ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) {
-    return ;
-  }
-
+  //\r
+  // Don't mark page table as read-only if heap guard is enabled.\r
+  //\r
+  //      BIT2: SMM page guard enabled\r
+  //      BIT3: SMM pool guard enabled\r
+  //\r
+  if ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) {\r
+    return ;\r
+  }\r
+\r
   DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n"));\r
 \r
   //\r
   DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n"));\r
 \r
   //\r
index 6c6d742c95383e3e064b974176837b17e75a8985..4b66a0dfd931eef8083e4f33054c24c53ff02af3 100755 (executable)
@@ -76,15 +76,15 @@ EFI_SMM_CPU_PROTOCOL  mSmmCpu  = {
   SmmWriteSaveState\r
 };\r
 \r
   SmmWriteSaveState\r
 };\r
 \r
-///
-/// SMM Memory Attribute Protocol instance
-///
-EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL  mSmmMemoryAttribute  = {
-  EdkiiSmmGetMemoryAttributes,
-  EdkiiSmmSetMemoryAttributes,
-  EdkiiSmmClearMemoryAttributes
-};
-
+///\r
+/// SMM Memory Attribute Protocol instance\r
+///\r
+EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL  mSmmMemoryAttribute  = {\r
+  EdkiiSmmGetMemoryAttributes,\r
+  EdkiiSmmSetMemoryAttributes,\r
+  EdkiiSmmClearMemoryAttributes\r
+};\r
+\r
 EFI_CPU_INTERRUPT_HANDLER   mExternalVectorTable[EXCEPTION_VECTOR_NUMBER];\r
 \r
 //\r
 EFI_CPU_INTERRUPT_HANDLER   mExternalVectorTable[EXCEPTION_VECTOR_NUMBER];\r
 \r
 //\r
@@ -902,17 +902,17 @@ PiCpuSmmEntry (
                     );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
                     );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //
-  // Install the SMM Memory Attribute Protocol into SMM protocol database
-  //
-  Status = gSmst->SmmInstallProtocolInterface (
-                    &mSmmCpuHandle,
-                    &gEdkiiSmmMemoryAttributeProtocolGuid,
-                    EFI_NATIVE_INTERFACE,
-                    &mSmmMemoryAttribute
-                    );
-  ASSERT_EFI_ERROR (Status);
-
+  //\r
+  // Install the SMM Memory Attribute Protocol into SMM protocol database\r
+  //\r
+  Status = gSmst->SmmInstallProtocolInterface (\r
+                    &mSmmCpuHandle,\r
+                    &gEdkiiSmmMemoryAttributeProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    &mSmmMemoryAttribute\r
+                    );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   //\r
   // Expose address of CPU Hot Plug Data structure if CPU hot plug is supported.\r
   //\r
   //\r
   // Expose address of CPU Hot Plug Data structure if CPU hot plug is supported.\r
   //\r
index a2d5f55045b19d7eb143e892c33bd645c525f7bb..ef32f17676658ecae614bf6c03743e69626c0336 100644 (file)
@@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/SmmAccess2.h>\r
 #include <Protocol/SmmReadyToLock.h>\r
 #include <Protocol/SmmCpuService.h>\r
 #include <Protocol/SmmAccess2.h>\r
 #include <Protocol/SmmReadyToLock.h>\r
 #include <Protocol/SmmCpuService.h>\r
-#include <Protocol/SmmMemoryAttribute.h>
+#include <Protocol/SmmMemoryAttribute.h>\r
 \r
 #include <Guid/AcpiS3Context.h>\r
 #include <Guid/PiSmmMemoryAttributesTable.h>\r
 \r
 #include <Guid/AcpiS3Context.h>\r
 #include <Guid/PiSmmMemoryAttributesTable.h>\r
@@ -1069,101 +1069,101 @@ TransferApToSafeState (
   IN UINTN  NumberToFinishAddress\r
   );\r
 \r
   IN UINTN  NumberToFinishAddress\r
   );\r
 \r
-/**
-  This function set given attributes of the memory region specified by
-  BaseAddress and Length.
-
-  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
-  @param  BaseAddress       The physical address that is the start address of
-                            a memory region.
-  @param  Length            The size in bytes of the memory region.
-  @param  Attributes        The bit mask of attributes to set for the memory
-                            region.
-
-  @retval EFI_SUCCESS           The attributes were set for the memory region.
-  @retval EFI_INVALID_PARAMETER Length is zero.
-                                Attributes specified an illegal combination of
-                                attributes that cannot be set together.
-  @retval EFI_UNSUPPORTED       The processor does not support one or more
-                                bytes of the memory resource range specified
-                                by BaseAddress and Length.
-                                The bit mask of attributes is not support for
-                                the memory resource range specified by
-                                BaseAddress and Length.
-
-**/
-EFI_STATUS
-EFIAPI
-EdkiiSmmSetMemoryAttributes (
-  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
-  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
-  IN  UINT64                                Length,
-  IN  UINT64                                Attributes
-  );
-
-/**
-  This function clears given attributes of the memory region specified by
-  BaseAddress and Length.
-
-  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
-  @param  BaseAddress       The physical address that is the start address of
-                            a memory region.
-  @param  Length            The size in bytes of the memory region.
-  @param  Attributes        The bit mask of attributes to set for the memory
-                            region.
-
-  @retval EFI_SUCCESS           The attributes were set for the memory region.
-  @retval EFI_INVALID_PARAMETER Length is zero.
-                                Attributes specified an illegal combination of
-                                attributes that cannot be set together.
-  @retval EFI_UNSUPPORTED       The processor does not support one or more
-                                bytes of the memory resource range specified
-                                by BaseAddress and Length.
-                                The bit mask of attributes is not support for
-                                the memory resource range specified by
-                                BaseAddress and Length.
-
-**/
-EFI_STATUS
-EFIAPI
-EdkiiSmmClearMemoryAttributes (
-  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
-  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
-  IN  UINT64                                Length,
-  IN  UINT64                                Attributes
-  );
-
-/**
-  This function retrieve the attributes of the memory region specified by
-  BaseAddress and Length. If different attributes are got from different part
-  of the memory region, EFI_NO_MAPPING will be returned.
-
-  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
-  @param  BaseAddress       The physical address that is the start address of
-                            a memory region.
-  @param  Length            The size in bytes of the memory region.
-  @param  Attributes        Pointer to attributes returned.
-
-  @retval EFI_SUCCESS           The attributes got for the memory region.
-  @retval EFI_INVALID_PARAMETER Length is zero.
-                                Attributes is NULL.
-  @retval EFI_NO_MAPPING        Attributes are not consistent cross the memory
-                                region.
-  @retval EFI_UNSUPPORTED       The processor does not support one or more
-                                bytes of the memory resource range specified
-                                by BaseAddress and Length.
-                                The bit mask of attributes is not support for
-                                the memory resource range specified by
-                                BaseAddress and Length.
-
-**/
-EFI_STATUS
-EFIAPI
-EdkiiSmmGetMemoryAttributes (
-  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
-  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
-  IN  UINT64                                Length,
-  IN  UINT64                                *Attributes
-  );
-
+/**\r
+  This function set given attributes of the memory region specified by\r
+  BaseAddress and Length.\r
+\r
+  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        The bit mask of attributes to set for the memory\r
+                            region.\r
+\r
+  @retval EFI_SUCCESS           The attributes were set for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes specified an illegal combination of\r
+                                attributes that cannot be set together.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not support for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EdkiiSmmSetMemoryAttributes (\r
+  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,\r
+  IN  UINT64                                Length,\r
+  IN  UINT64                                Attributes\r
+  );\r
+\r
+/**\r
+  This function clears given attributes of the memory region specified by\r
+  BaseAddress and Length.\r
+\r
+  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        The bit mask of attributes to set for the memory\r
+                            region.\r
+\r
+  @retval EFI_SUCCESS           The attributes were set for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes specified an illegal combination of\r
+                                attributes that cannot be set together.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not support for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EdkiiSmmClearMemoryAttributes (\r
+  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,\r
+  IN  UINT64                                Length,\r
+  IN  UINT64                                Attributes\r
+  );\r
+\r
+/**\r
+  This function retrieve the attributes of the memory region specified by\r
+  BaseAddress and Length. If different attributes are got from different part\r
+  of the memory region, EFI_NO_MAPPING will be returned.\r
+\r
+  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        Pointer to attributes returned.\r
+\r
+  @retval EFI_SUCCESS           The attributes got for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes is NULL.\r
+  @retval EFI_NO_MAPPING        Attributes are not consistent cross the memory\r
+                                region.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not support for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EdkiiSmmGetMemoryAttributes (\r
+  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,\r
+  IN  UINT64                                Length,\r
+  IN  UINT64                                *Attributes\r
+  );\r
+\r
 #endif\r
 #endif\r
index 9edd162feb1b6c71a13c1d60bedba604774edc9d..e37ac5f84ee1c13f44e24b7ea5a79b0e85a4bc7d 100644 (file)
   gEfiSmmCpuProtocolGuid                   ## PRODUCES\r
   gEfiSmmReadyToLockProtocolGuid           ## NOTIFY\r
   gEfiSmmCpuServiceProtocolGuid            ## PRODUCES\r
   gEfiSmmCpuProtocolGuid                   ## PRODUCES\r
   gEfiSmmReadyToLockProtocolGuid           ## NOTIFY\r
   gEfiSmmCpuServiceProtocolGuid            ## PRODUCES\r
-  gEdkiiSmmMemoryAttributeProtocolGuid     ## PRODUCES
+  gEdkiiSmmMemoryAttributeProtocolGuid     ## PRODUCES\r
 \r
 [Guids]\r
   gEfiAcpiVariableGuid                     ## SOMETIMES_CONSUMES ## HOB # it is used for S3 boot.\r
 \r
 [Guids]\r
   gEfiAcpiVariableGuid                     ## SOMETIMES_CONSUMES ## HOB # it is used for S3 boot.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                   ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask    ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask    ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                   ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask    ## CONSUMES\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask    ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask               ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask               ## CONSUMES\r
 \r
 [Depex]\r
   gEfiMpServiceProtocolGuid\r
 \r
 [Depex]\r
   gEfiMpServiceProtocolGuid\r
index 55c04c7aa79b6bdcdaeac55fa7bdf25f2f04f685..2d7dba59bf30370241c06f22bb4e690a9533846d 100644 (file)
@@ -1120,166 +1120,166 @@ IsSmmCommBufferForbiddenAddress (
   }\r
   return FALSE;\r
 }\r
   }\r
   return FALSE;\r
 }\r
-
-/**
-  This function set given attributes of the memory region specified by
-  BaseAddress and Length.
-
-  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
-  @param  BaseAddress       The physical address that is the start address of
-                            a memory region.
-  @param  Length            The size in bytes of the memory region.
-  @param  Attributes        The bit mask of attributes to set for the memory
-                            region.
-
-  @retval EFI_SUCCESS           The attributes were set for the memory region.
-  @retval EFI_INVALID_PARAMETER Length is zero.
-                                Attributes specified an illegal combination of
-                                attributes that cannot be set together.
-  @retval EFI_UNSUPPORTED       The processor does not support one or more
-                                bytes of the memory resource range specified
-                                by BaseAddress and Length.
-                                The bit mask of attributes is not support for
-                                the memory resource range specified by
-                                BaseAddress and Length.
-
-**/
-EFI_STATUS
-EFIAPI
-EdkiiSmmSetMemoryAttributes (
-  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
-  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
-  IN  UINT64                                Length,
-  IN  UINT64                                Attributes
-  )
-{
-  return SmmSetMemoryAttributes (BaseAddress, Length, Attributes);
-}
-
-/**
-  This function clears given attributes of the memory region specified by
-  BaseAddress and Length.
-
-  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
-  @param  BaseAddress       The physical address that is the start address of
-                            a memory region.
-  @param  Length            The size in bytes of the memory region.
-  @param  Attributes        The bit mask of attributes to set for the memory
-                            region.
-
-  @retval EFI_SUCCESS           The attributes were set for the memory region.
-  @retval EFI_INVALID_PARAMETER Length is zero.
-                                Attributes specified an illegal combination of
-                                attributes that cannot be set together.
-  @retval EFI_UNSUPPORTED       The processor does not support one or more
-                                bytes of the memory resource range specified
-                                by BaseAddress and Length.
-                                The bit mask of attributes is not support for
-                                the memory resource range specified by
-                                BaseAddress and Length.
-
-**/
-EFI_STATUS
-EFIAPI
-EdkiiSmmClearMemoryAttributes (
-  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
-  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
-  IN  UINT64                                Length,
-  IN  UINT64                                Attributes
-  )
-{
-  return SmmClearMemoryAttributes (BaseAddress, Length, Attributes);
-}
-
-/**
-  This function retrieve the attributes of the memory region specified by
-  BaseAddress and Length. If different attributes are got from different part
-  of the memory region, EFI_NO_MAPPING will be returned.
-
-  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
-  @param  BaseAddress       The physical address that is the start address of
-                            a memory region.
-  @param  Length            The size in bytes of the memory region.
-  @param  Attributes        Pointer to attributes returned.
-
-  @retval EFI_SUCCESS           The attributes got for the memory region.
-  @retval EFI_INVALID_PARAMETER Length is zero.
-                                Attributes is NULL.
-  @retval EFI_NO_MAPPING        Attributes are not consistent cross the memory
-                                region.
-  @retval EFI_UNSUPPORTED       The processor does not support one or more
-                                bytes of the memory resource range specified
-                                by BaseAddress and Length.
-                                The bit mask of attributes is not support for
-                                the memory resource range specified by
-                                BaseAddress and Length.
-
-**/
-EFI_STATUS
-EFIAPI
-EdkiiSmmGetMemoryAttributes (
-  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,
-  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,
-  IN  UINT64                                Length,
-  OUT UINT64                                *Attributes
-  )
-{
-  EFI_PHYSICAL_ADDRESS  Address;
-  UINT64                *PageEntry;
-  UINT64                MemAttr;
-  PAGE_ATTRIBUTE        PageAttr;
-  INT64                 Size;
-
-  if (Length < SIZE_4KB || Attributes == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  Size = (INT64)Length;
-  MemAttr = (UINT64)-1;
-
-  do {
-
-    PageEntry = GetPageTableEntry (BaseAddress, &PageAttr);
-    if (PageEntry == NULL || PageAttr == PageNone) {
-      return EFI_UNSUPPORTED;
-    }
-
-    //
-    // If the memory range is cross page table boundary, make sure they
-    // share the same attribute. Return EFI_NO_MAPPING if not.
-    //
-    *Attributes = GetAttributesFromPageEntry (PageEntry);
-    if (MemAttr != (UINT64)-1 && *Attributes != MemAttr) {
-      return EFI_NO_MAPPING;
-    }
-
-    switch (PageAttr) {
-    case Page4K:
-      Address     = *PageEntry & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64;
-      Size        -= (SIZE_4KB - (BaseAddress - Address));
-      BaseAddress += (SIZE_4KB - (BaseAddress - Address));
-      break;
-
-    case Page2M:
-      Address     = *PageEntry & ~mAddressEncMask & PAGING_2M_ADDRESS_MASK_64;
-      Size        -= SIZE_2MB - (BaseAddress - Address);
-      BaseAddress += SIZE_2MB - (BaseAddress - Address);
-      break;
-
-    case Page1G:
-      Address     = *PageEntry & ~mAddressEncMask & PAGING_1G_ADDRESS_MASK_64;
-      Size        -= SIZE_1GB - (BaseAddress - Address);
-      BaseAddress += SIZE_1GB - (BaseAddress - Address);
-      break;
-
-    default:
-      return EFI_UNSUPPORTED;
-    }
-
-    MemAttr = *Attributes;
-
-  } while (Size > 0);
-
-  return EFI_SUCCESS;
-}
-
+\r
+/**\r
+  This function set given attributes of the memory region specified by\r
+  BaseAddress and Length.\r
+\r
+  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        The bit mask of attributes to set for the memory\r
+                            region.\r
+\r
+  @retval EFI_SUCCESS           The attributes were set for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes specified an illegal combination of\r
+                                attributes that cannot be set together.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not support for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EdkiiSmmSetMemoryAttributes (\r
+  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,\r
+  IN  UINT64                                Length,\r
+  IN  UINT64                                Attributes\r
+  )\r
+{\r
+  return SmmSetMemoryAttributes (BaseAddress, Length, Attributes);\r
+}\r
+\r
+/**\r
+  This function clears given attributes of the memory region specified by\r
+  BaseAddress and Length.\r
+\r
+  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        The bit mask of attributes to set for the memory\r
+                            region.\r
+\r
+  @retval EFI_SUCCESS           The attributes were set for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes specified an illegal combination of\r
+                                attributes that cannot be set together.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not support for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EdkiiSmmClearMemoryAttributes (\r
+  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,\r
+  IN  UINT64                                Length,\r
+  IN  UINT64                                Attributes\r
+  )\r
+{\r
+  return SmmClearMemoryAttributes (BaseAddress, Length, Attributes);\r
+}\r
+\r
+/**\r
+  This function retrieve the attributes of the memory region specified by\r
+  BaseAddress and Length. If different attributes are got from different part\r
+  of the memory region, EFI_NO_MAPPING will be returned.\r
+\r
+  @param  This              The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.\r
+  @param  BaseAddress       The physical address that is the start address of\r
+                            a memory region.\r
+  @param  Length            The size in bytes of the memory region.\r
+  @param  Attributes        Pointer to attributes returned.\r
+\r
+  @retval EFI_SUCCESS           The attributes got for the memory region.\r
+  @retval EFI_INVALID_PARAMETER Length is zero.\r
+                                Attributes is NULL.\r
+  @retval EFI_NO_MAPPING        Attributes are not consistent cross the memory\r
+                                region.\r
+  @retval EFI_UNSUPPORTED       The processor does not support one or more\r
+                                bytes of the memory resource range specified\r
+                                by BaseAddress and Length.\r
+                                The bit mask of attributes is not support for\r
+                                the memory resource range specified by\r
+                                BaseAddress and Length.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EdkiiSmmGetMemoryAttributes (\r
+  IN  EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL   *This,\r
+  IN  EFI_PHYSICAL_ADDRESS                  BaseAddress,\r
+  IN  UINT64                                Length,\r
+  OUT UINT64                                *Attributes\r
+  )\r
+{\r
+  EFI_PHYSICAL_ADDRESS  Address;\r
+  UINT64                *PageEntry;\r
+  UINT64                MemAttr;\r
+  PAGE_ATTRIBUTE        PageAttr;\r
+  INT64                 Size;\r
+\r
+  if (Length < SIZE_4KB || Attributes == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Size = (INT64)Length;\r
+  MemAttr = (UINT64)-1;\r
+\r
+  do {\r
+\r
+    PageEntry = GetPageTableEntry (BaseAddress, &PageAttr);\r
+    if (PageEntry == NULL || PageAttr == PageNone) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+\r
+    //\r
+    // If the memory range is cross page table boundary, make sure they\r
+    // share the same attribute. Return EFI_NO_MAPPING if not.\r
+    //\r
+    *Attributes = GetAttributesFromPageEntry (PageEntry);\r
+    if (MemAttr != (UINT64)-1 && *Attributes != MemAttr) {\r
+      return EFI_NO_MAPPING;\r
+    }\r
+\r
+    switch (PageAttr) {\r
+    case Page4K:\r
+      Address     = *PageEntry & ~mAddressEncMask & PAGING_4K_ADDRESS_MASK_64;\r
+      Size        -= (SIZE_4KB - (BaseAddress - Address));\r
+      BaseAddress += (SIZE_4KB - (BaseAddress - Address));\r
+      break;\r
+\r
+    case Page2M:\r
+      Address     = *PageEntry & ~mAddressEncMask & PAGING_2M_ADDRESS_MASK_64;\r
+      Size        -= SIZE_2MB - (BaseAddress - Address);\r
+      BaseAddress += SIZE_2MB - (BaseAddress - Address);\r
+      break;\r
+\r
+    case Page1G:\r
+      Address     = *PageEntry & ~mAddressEncMask & PAGING_1G_ADDRESS_MASK_64;\r
+      Size        -= SIZE_1GB - (BaseAddress - Address);\r
+      BaseAddress += SIZE_1GB - (BaseAddress - Address);\r
+      break;\r
+\r
+    default:\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+\r
+    MemAttr = *Attributes;\r
+\r
+  } while (Size > 0);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
index 1da4b5506c965c58ce68326e48b11062042f09c7..79a26d7ec6a3eef8015a14431110b1a8dbc9bf8f 100644 (file)
@@ -914,20 +914,20 @@ SetPageTableAttributes (
   BOOLEAN               IsSplitted;\r
   BOOLEAN               PageTableSplitted;\r
 \r
   BOOLEAN               IsSplitted;\r
   BOOLEAN               PageTableSplitted;\r
 \r
-  //
-  // Don't do this if
-  //  - no static page table; or
-  //  - SMM heap guard feature enabled
-  //      BIT2: SMM page guard enabled
-  //      BIT3: SMM pool guard enabled
-  //
-  if (!mCpuSmmStaticPageTable ||
-      (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) {
-    //
-    // Static paging and heap guard should not be enabled at the same time.
-    //
-    ASSERT (!(mCpuSmmStaticPageTable &&
-              (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0));
+  //\r
+  // Don't do this if\r
+  //  - no static page table; or\r
+  //  - SMM heap guard feature enabled\r
+  //      BIT2: SMM page guard enabled\r
+  //      BIT3: SMM pool guard enabled\r
+  //\r
+  if (!mCpuSmmStaticPageTable ||\r
+      (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) {\r
+    //\r
+    // Static paging and heap guard should not be enabled at the same time.\r
+    //\r
+    ASSERT (!(mCpuSmmStaticPageTable &&\r
+              (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0));\r
     return ;\r
   }\r
 \r
     return ;\r
   }\r
 \r