From nobody Wed Dec 25 01:19:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1511166146190828.9001163539693; Mon, 20 Nov 2017 00:22:26 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6CB0220347128; Mon, 20 Nov 2017 00:18:11 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7080D20347119 for ; Mon, 20 Nov 2017 00:18:08 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2017 00:22:22 -0800 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.35]) by fmsmga001.fm.intel.com with ESMTP; 20 Nov 2017 00:22:21 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,425,1505804400"; d="scan'208";a="4821607" From: Jian J Wang To: edk2-devel@lists.01.org Date: Mon, 20 Nov 2017 16:22:15 +0800 Message-Id: <20171120082215.10036-3-jian.j.wang@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20171120082215.10036-1-jian.j.wang@intel.com> References: <20171120082215.10036-1-jian.j.wang@intel.com> Subject: [edk2] [PATCH v2 2/2] UefiCpuPkg: Fix unix style of EOL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wu Hao , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Wu Hao Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- 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/CpuPageTa= ble.c index 309f448a83..76f44f9bd1 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -442,8 +442,8 @@ ConvertPageEntryAttribute ( *PageEntry =3D NewPageEntry; if (CurrentPageEntry !=3D NewPageEntry) { *IsModified =3D TRUE; - DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageE= ntry)); - DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry)); + DEBUG ((DEBUG_VERBOSE, "ConvertPageEntryAttribute 0x%lx", CurrentPageE= ntry)); + DEBUG ((DEBUG_VERBOSE, "->0x%lx\n", NewPageEntry)); } else { *IsModified =3D FALSE; } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c b/UefiCpuPkg/PiSmmCpu= DxeSmm/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; =20 - // - // 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)) !=3D 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)) !=3D 0) { + return ; + } + DEBUG ((DEBUG_INFO, "SetPageTableAttributes\n")); =20 // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmC= puDxeSmm/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 =3D { SmmWriteSaveState }; =20 -/// -/// SMM Memory Attribute Protocol instance -/// -EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL mSmmMemoryAttribute =3D { - EdkiiSmmGetMemoryAttributes, - EdkiiSmmSetMemoryAttributes, - EdkiiSmmClearMemoryAttributes -}; - +/// +/// SMM Memory Attribute Protocol instance +/// +EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL mSmmMemoryAttribute =3D { + EdkiiSmmGetMemoryAttributes, + EdkiiSmmSetMemoryAttributes, + EdkiiSmmClearMemoryAttributes +}; + EFI_CPU_INTERRUPT_HANDLER mExternalVectorTable[EXCEPTION_VECTOR_NUMBER]; =20 // @@ -902,17 +902,17 @@ PiCpuSmmEntry ( ); ASSERT_EFI_ERROR (Status); =20 - // - // Install the SMM Memory Attribute Protocol into SMM protocol database - // - Status =3D gSmst->SmmInstallProtocolInterface ( - &mSmmCpuHandle, - &gEdkiiSmmMemoryAttributeProtocolGuid, - EFI_NATIVE_INTERFACE, - &mSmmMemoryAttribute - ); - ASSERT_EFI_ERROR (Status); - + // + // Install the SMM Memory Attribute Protocol into SMM protocol database + // + Status =3D 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 supp= orted. // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmC= puDxeSmm/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 #include #include -#include +#include =20 #include #include @@ -1069,101 +1069,101 @@ TransferApToSafeState ( IN UINTN NumberToFinishAddress ); =20 -/** - This function set given attributes of the memory region specified by - BaseAddress and Length. - - @param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instan= ce. - @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 memo= ry - region. - - @retval EFI_SUCCESS The attributes were set for the memory reg= ion. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combinatio= n of - attributes that cannot be set together. - @retval EFI_UNSUPPORTED The processor does not support one or more - bytes of the memory resource range specifi= ed - 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 instan= ce. - @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 memo= ry - region. - - @retval EFI_SUCCESS The attributes were set for the memory reg= ion. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combinatio= n of - attributes that cannot be set together. - @retval EFI_UNSUPPORTED The processor does not support one or more - bytes of the memory resource range specifi= ed - 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 p= art - of the memory region, EFI_NO_MAPPING will be returned. - - @param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instan= ce. - @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 me= mory - region. - @retval EFI_UNSUPPORTED The processor does not support one or more - bytes of the memory resource range specifi= ed - 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 instan= ce. + @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 memo= ry + region. + + @retval EFI_SUCCESS The attributes were set for the memory reg= ion. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combinatio= n of + attributes that cannot be set together. + @retval EFI_UNSUPPORTED The processor does not support one or more + bytes of the memory resource range specifi= ed + 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 instan= ce. + @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 memo= ry + region. + + @retval EFI_SUCCESS The attributes were set for the memory reg= ion. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combinatio= n of + attributes that cannot be set together. + @retval EFI_UNSUPPORTED The processor does not support one or more + bytes of the memory resource range specifi= ed + 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 p= art + of the memory region, EFI_NO_MAPPING will be returned. + + @param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instan= ce. + @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 me= mory + region. + @retval EFI_UNSUPPORTED The processor does not support one or more + bytes of the memory resource range specifi= ed + 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/PiSm= mCpuDxeSmm/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 =20 [Guids] gEfiAcpiVariableGuid ## SOMETIMES_CONSUMES ## HOB # = it is used for S3 boot. @@ -161,7 +161,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONS= UMES gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ##= CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ##= CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ##= CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask ##= CONSUMES =20 [Depex] gEfiMpServiceProtocolGuid diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPk= g/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 instan= ce. - @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 memo= ry - region. - - @retval EFI_SUCCESS The attributes were set for the memory reg= ion. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combinatio= n of - attributes that cannot be set together. - @retval EFI_UNSUPPORTED The processor does not support one or more - bytes of the memory resource range specifi= ed - 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 instan= ce. - @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 memo= ry - region. - - @retval EFI_SUCCESS The attributes were set for the memory reg= ion. - @retval EFI_INVALID_PARAMETER Length is zero. - Attributes specified an illegal combinatio= n of - attributes that cannot be set together. - @retval EFI_UNSUPPORTED The processor does not support one or more - bytes of the memory resource range specifi= ed - 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 p= art - of the memory region, EFI_NO_MAPPING will be returned. - - @param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instan= ce. - @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 me= mory - region. - @retval EFI_UNSUPPORTED The processor does not support one or more - bytes of the memory resource range specifi= ed - 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 =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - Size =3D (INT64)Length; - MemAttr =3D (UINT64)-1; - - do { - - PageEntry =3D GetPageTableEntry (BaseAddress, &PageAttr); - if (PageEntry =3D=3D NULL || PageAttr =3D=3D 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 =3D GetAttributesFromPageEntry (PageEntry); - if (MemAttr !=3D (UINT64)-1 && *Attributes !=3D MemAttr) { - return EFI_NO_MAPPING; - } - - switch (PageAttr) { - case Page4K: - Address =3D *PageEntry & ~mAddressEncMask & PAGING_4K_ADDRESS_MA= SK_64; - Size -=3D (SIZE_4KB - (BaseAddress - Address)); - BaseAddress +=3D (SIZE_4KB - (BaseAddress - Address)); - break; - - case Page2M: - Address =3D *PageEntry & ~mAddressEncMask & PAGING_2M_ADDRESS_MA= SK_64; - Size -=3D SIZE_2MB - (BaseAddress - Address); - BaseAddress +=3D SIZE_2MB - (BaseAddress - Address); - break; - - case Page1G: - Address =3D *PageEntry & ~mAddressEncMask & PAGING_1G_ADDRESS_MA= SK_64; - Size -=3D SIZE_1GB - (BaseAddress - Address); - BaseAddress +=3D SIZE_1GB - (BaseAddress - Address); - break; - - default: - return EFI_UNSUPPORTED; - } - - MemAttr =3D *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 instan= ce. + @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 memo= ry + region. + + @retval EFI_SUCCESS The attributes were set for the memory reg= ion. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combinatio= n of + attributes that cannot be set together. + @retval EFI_UNSUPPORTED The processor does not support one or more + bytes of the memory resource range specifi= ed + 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 instan= ce. + @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 memo= ry + region. + + @retval EFI_SUCCESS The attributes were set for the memory reg= ion. + @retval EFI_INVALID_PARAMETER Length is zero. + Attributes specified an illegal combinatio= n of + attributes that cannot be set together. + @retval EFI_UNSUPPORTED The processor does not support one or more + bytes of the memory resource range specifi= ed + 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 p= art + of the memory region, EFI_NO_MAPPING will be returned. + + @param This The EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instan= ce. + @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 me= mory + region. + @retval EFI_UNSUPPORTED The processor does not support one or more + bytes of the memory resource range specifi= ed + 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Size =3D (INT64)Length; + MemAttr =3D (UINT64)-1; + + do { + + PageEntry =3D GetPageTableEntry (BaseAddress, &PageAttr); + if (PageEntry =3D=3D NULL || PageAttr =3D=3D 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 =3D GetAttributesFromPageEntry (PageEntry); + if (MemAttr !=3D (UINT64)-1 && *Attributes !=3D MemAttr) { + return EFI_NO_MAPPING; + } + + switch (PageAttr) { + case Page4K: + Address =3D *PageEntry & ~mAddressEncMask & PAGING_4K_ADDRESS_MA= SK_64; + Size -=3D (SIZE_4KB - (BaseAddress - Address)); + BaseAddress +=3D (SIZE_4KB - (BaseAddress - Address)); + break; + + case Page2M: + Address =3D *PageEntry & ~mAddressEncMask & PAGING_2M_ADDRESS_MA= SK_64; + Size -=3D SIZE_2MB - (BaseAddress - Address); + BaseAddress +=3D SIZE_2MB - (BaseAddress - Address); + break; + + case Page1G: + Address =3D *PageEntry & ~mAddressEncMask & PAGING_1G_ADDRESS_MA= SK_64; + Size -=3D SIZE_1GB - (BaseAddress - Address); + BaseAddress +=3D SIZE_1GB - (BaseAddress - Address); + break; + + default: + return EFI_UNSUPPORTED; + } + + MemAttr =3D *Attributes; + + } while (Size > 0); + + return EFI_SUCCESS; +} + diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuD= xeSmm/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; =20 - // - // 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)) !=3D 0) { - // - // Static paging and heap guard should not be enabled at the same time. - // - ASSERT (!(mCpuSmmStaticPageTable && - (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) !=3D 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)) !=3D 0) { + // + // Static paging and heap guard should not be enabled at the same time. + // + ASSERT (!(mCpuSmmStaticPageTable && + (PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) !=3D 0)= ); return ; } =20 --=20 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel