From: Jian J Wang <jian.j.wang@intel.com>
To: edk2-devel@lists.01.org
Cc: Wu Hao <hao.a.wu@intel.com>, Star Zeng <star.zeng@intel.com>,
Eric Dong <eric.dong@intel.com>
Subject: [PATCH v2 2/2] UefiCpuPkg: Fix unix style of EOL
Date: Mon, 20 Nov 2017 16:22:15 +0800 [thread overview]
Message-ID: <20171120082215.10036-3-jian.j.wang@intel.com> (raw)
In-Reply-To: <20171120082215.10036-1-jian.j.wang@intel.com>
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>
---
UefiCpuPkg/CpuDxe/CpuPageTable.c | 4 +-
UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c | 20 +-
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 40 +--
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 196 ++++++-------
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 4 +-
UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 326 ++++++++++-----------
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 28 +-
7 files changed, 309 insertions(+), 309 deletions(-)
diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c
index 309f448a83..76f44f9bd1 100644
--- a/UefiCpuPkg/CpuDxe/CpuPageTable.c
+++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c
@@ -442,8 +442,8 @@ ConvertPageEntryAttribute (
*PageEntry = NewPageEntry;
if (CurrentPageEntry != NewPageEntry) {
*IsModified = TRUE;
- DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry));
- DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry));
+ DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageEntry));
+ DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry));
} else {
*IsModified = FALSE;
}
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
index 9447a31ef5..0396f2daaa 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
@@ -196,16 +196,16 @@ SetPageTableAttributes (
BOOLEAN IsSplitted;
BOOLEAN PageTableSplitted;
- //
- // 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 ;
- }
-
+ //
+ // 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 ;
+ }
+
DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n"));
//
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index 6c6d742c95..4b66a0dfd9 100755
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -76,15 +76,15 @@ EFI_SMM_CPU_PROTOCOL mSmmCpu = {
SmmWriteSaveState
};
-///
-/// SMM Memory Attribute Protocol instance
-///
-EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL mSmmMemoryAttribute = {
- EdkiiSmmGetMemoryAttributes,
- EdkiiSmmSetMemoryAttributes,
- EdkiiSmmClearMemoryAttributes
-};
-
+///
+/// SMM Memory Attribute Protocol instance
+///
+EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL mSmmMemoryAttribute = {
+ EdkiiSmmGetMemoryAttributes,
+ EdkiiSmmSetMemoryAttributes,
+ EdkiiSmmClearMemoryAttributes
+};
+
EFI_CPU_INTERRUPT_HANDLER mExternalVectorTable[EXCEPTION_VECTOR_NUMBER];
//
@@ -902,17 +902,17 @@ PiCpuSmmEntry (
);
ASSERT_EFI_ERROR (Status);
- //
- // Install the SMM Memory Attribute Protocol into SMM protocol database
- //
- Status = gSmst->SmmInstallProtocolInterface (
- &mSmmCpuHandle,
- &gEdkiiSmmMemoryAttributeProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mSmmMemoryAttribute
- );
- ASSERT_EFI_ERROR (Status);
-
+ //
+ // Install the SMM Memory Attribute Protocol into SMM protocol database
+ //
+ Status = gSmst->SmmInstallProtocolInterface (
+ &mSmmCpuHandle,
+ &gEdkiiSmmMemoryAttributeProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mSmmMemoryAttribute
+ );
+ ASSERT_EFI_ERROR (Status);
+
//
// Expose address of CPU Hot Plug Data structure if CPU hot plug is supported.
//
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index a2d5f55045..ef32f17676 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -25,7 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SmmAccess2.h>
#include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmCpuService.h>
-#include <Protocol/SmmMemoryAttribute.h>
+#include <Protocol/SmmMemoryAttribute.h>
#include <Guid/AcpiS3Context.h>
#include <Guid/PiSmmMemoryAttributesTable.h>
@@ -1069,101 +1069,101 @@ TransferApToSafeState (
IN UINTN NumberToFinishAddress
);
-/**
- 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
- );
-
+/**
+ 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
+ );
+
#endif
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
index 9edd162feb..e37ac5f84e 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -129,7 +129,7 @@
gEfiSmmCpuProtocolGuid ## PRODUCES
gEfiSmmReadyToLockProtocolGuid ## NOTIFY
gEfiSmmCpuServiceProtocolGuid ## PRODUCES
- gEdkiiSmmMemoryAttributeProtocolGuid ## PRODUCES
+ gEdkiiSmmMemoryAttributeProtocolGuid ## PRODUCES
[Guids]
gEfiAcpiVariableGuid ## SOMETIMES_CONSUMES ## HOB # it is used for S3 boot.
@@ -161,7 +161,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ## CONSUMES
[Depex]
gEfiMpServiceProtocolGuid
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index 55c04c7aa7..2d7dba59bf 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -1120,166 +1120,166 @@ IsSmmCommBufferForbiddenAddress (
}
return FALSE;
}
-
-/**
- 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;
-}
-
+
+/**
+ 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;
+}
+
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index 1da4b5506c..79a26d7ec6 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -914,20 +914,20 @@ SetPageTableAttributes (
BOOLEAN IsSplitted;
BOOLEAN PageTableSplitted;
- //
- // 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));
+ //
+ // 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));
return ;
}
--
2.14.1.windows.1
next prev parent reply other threads:[~2017-11-20 8:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 8:22 [PATCH v2 0/2] Fix unix style of EOL Jian J Wang
2017-11-20 8:22 ` [PATCH v2 1/2] MdeModulePkg: " Jian J Wang
2017-11-20 8:22 ` Jian J Wang [this message]
2017-11-20 8:27 ` [PATCH v2 0/2] " Wu, Hao A
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171120082215.10036-3-jian.j.wang@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox