From nobody Thu Mar 28 23:05:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61621+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61621+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592949417; cv=none; d=zohomail.com; s=zohoarc; b=UxtZ0wsrtw9DolonOnYKxS+WbJM622nd3WYjz3XoBcVXHO+YGjoc9eZrM6GH1y4UpKXkHMD/IfI7PNJKuqN7LKNQqqCw80Vcuseqi83iHMu2anGNwky3DYrsmmhOZKORDmKmpBV6BZ/1O30w5EVl0OUPVhGE6NCQjKQqNzU9sP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592949417; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=FP6MTMK1q/I1v10XcLouhDgKE5bjJF3FbRSMJQUob3s=; b=KUSfh/Dzxhj3+N0NWIzrm2OgxhfqDa4sPOkqI50pdJQJ3e5ec83h4xx3WFM1o1vDFh6ee+1Ho/bt3wXhlHIoFQL05ljmIE+LrW0djfdZOMx1m+Fja50XQHRs0gWRawUyURZAt3dGoYPtECNrKwOejW5wceojBtyHDqm1dmdA1ms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61621+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592949417540901.5449419700125; Tue, 23 Jun 2020 14:56:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id oPeZYY1788612xFo4CiZZsNL; Tue, 23 Jun 2020 14:56:57 -0700 X-Received: from atlmailgw1.ami.com (atlmailgw1.ami.com [63.147.10.40]) by mx.groups.io with SMTP id smtpd.web11.544.1592949415158553916 for ; Tue, 23 Jun 2020 14:56:55 -0700 X-AuditID: ac1060b2-ebbff70000003d78-97-5ef27aa5bc55 X-Received: from atlms1.us.megatrends.com (atlms1.us.megatrends.com [172.16.96.144]) (using TLS with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client did not present a certificate) by atlmailgw1.ami.com (Symantec Messaging Gateway) with SMTP id 83.46.15736.5AA72FE5; Tue, 23 Jun 2020 17:56:53 -0400 (EDT) X-Received: from Oleksiy77.us.megatrends.com (172.16.97.158) by atlms1.us.megatrends.com (172.16.96.144) with Microsoft SMTP Server id 14.3.468.0; Tue, 23 Jun 2020 17:55:59 -0400 From: "Oleksiy Yakovlev" To: CC: , , , , , , , Subject: [edk2-devel] [PATCH V2 1/3] MdePkg: Add New Memory Attributes Date: Tue, 23 Jun 2020 17:55:54 -0400 Message-ID: <20200623215556.80804-2-oleksiyy@ami.com> In-Reply-To: <20200623215556.80804-1-oleksiyy@ami.com> References: <20200623215556.80804-1-oleksiyy@ami.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsWyRiBhgu7Sqk9xBtOuGFls3aZu0T5hNpvF smM7WCxW3NvAbtHR8Y/JYvp2F4svq98zOrB7bP9+gdFj8Z6XTB7v911lC2COamC0SczLyy9J LElVSEktTrZVCijKLEtMrlRSyEyxVTJUUijISUxOzU3NK7FVSiwoSM1LUbLjUsAANkBlmXkK qXnJ+SmZeem2Sp7B/roWFqaWuoZKdiEZqQqZeWn5RbmJJZn5eQrJ+XklQNWpKUBRhYRuzoy2 Q5fZCg7zVDxZN4GxgXEdVxcjB4eEgInErftBXYxcHEICu5gknnzoYYdwtjBKfPy5kamLkZOD TUBT4sCxKYwgtoiAlMSUAzOZQIqYBfYwSvS8PsUKkhAWsJQ4/vEeWBGLgKrEklevwJp5BUwl lnWsAotLCGhITFtzlwlkM6eAmcTzlwEgYSGgkvbV96DKBSVOznzCAmIzC0hIHHzxghmiRlai 7fhz9gmM/LOQlM1CUraAkWkVo1BiSU5uYmZOermhXmJupl5yfu4mRkgkbtrB2HLR/BAjEwfj IUYJDmYlEd4Qt09xQrwpiZVVqUX58UWlOanFhxidgO6fyCzFDQpAYIzEGxsYSInCOIYmZibm RuaGlibmxsZK4ryT166JExJIB8ZsdmpqQWoRzBAmDk6pBsZ7W/jX+X1wnr1YmveXd/WdI8Xr tz4o7dR6aqKaUBL3ZvYdvs+HXFTWLD9mlazc4bo2QrK+dv5K965TzsVF/fzuSwqUDeymdi1f GNqi+i6g3mpi+7PzHOc+sVhEdquvTfriuUXsvInXrFfvD/eFaM0sEXj2LOjKS4ZXjKbOcrKr my6H1P76q6bEUpyRaKjFXFScCADy61z42QIAAA== Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,oleksiyy@ami.com X-Gm-Message-State: Nj1wVNWLmFHYY9xkzdO8ZfMxx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592949417; bh=7cyv6eJbHK7/xcDUA0RGiXbnRsHwWOY6fA6kBCORudA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=IhMl9SdoAs/exu0xWlLzLEVQY+ME+cT/75H1YsWdxpKTqMt70JSIxdabfJNEltU2zPt uRJaVCMd03gOk74HFSB8zgZQXQZx3K/i9odkgFAOLI9Ag9QCumyO4bvY6oDTfcc9x+mC3 fOwad0UQ2j99WsrxuobhLto5rJ3P3ic336o= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add usage of EFI_MEMORY_SP and EFI_MEMORY_CPU_CRYPTO attributes introduced in UEFI 2.8. (UEFI 2.8, mantis 1919 and 1872). Fix typos in EFI_MEMORY_CPU_CRYPTO description. Add attributes bitmasks, grouped by type. Signed-off-by: Oleksiy Yakovlev Reviewed-by: Laszlo Ersek Reviewed-by: Liming Gao Reviewed-by: Zhiguang Liu --- MdePkg/Include/Uefi/UefiSpec.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h index 558e1bc..05b82e0 100644 --- a/MdePkg/Include/Uefi/UefiSpec.h +++ b/MdePkg/Include/Uefi/UefiSpec.h @@ -96,9 +96,9 @@ typedef enum { #define EFI_MEMORY_SP 0x0000000000040000ULL // // If this flag is set, the memory region is capable of being -// protected with the CPU?s memory cryptographic +// protected with the CPU's memory cryptographic // capabilities. If this flag is clear, the memory region is not -// capable of being protected with the CPU?s memory +// capable of being protected with the CPU's memory // cryptographic capabilities or the CPU does not support CPU // memory cryptographic capabilities. // @@ -109,6 +109,12 @@ typedef enum { // #define EFI_MEMORY_RUNTIME 0x8000000000000000ULL =20 +// +// Attributes bitmasks, grouped by type +// +#define EFI_CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMO= RY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP) +#define EFI_MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEM= ORY_RO | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO) + /// /// Memory descriptor version number. /// --=20 2.9.0.windows.1 Please consider the environment before printing this email. The information contained in this message may be confidential and proprieta= ry to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephon= e at 770-246-8600, and then delete or destroy all copies of the transmissio= n. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61621): https://edk2.groups.io/g/devel/message/61621 Mute This Topic: https://groups.io/mt/75070221/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu Mar 28 23:05:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61622+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61622+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592949418; cv=none; d=zohomail.com; s=zohoarc; b=TgiCmT5itX0OJdL9h3UvLWY0ZjsiR5aR/ydA4Za4qYrwojspTc6VwVXX0C6VWssflUC6C+YygJEauv5sS0QnSJQ0vFxaUVraFZDAdJRbf62ZTyNTyEY9tJNz7ZK34zlSptBEz80qx+5Mik+eWIPtx5SF0exvt9PvuIe8mCxLXtk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592949418; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jw7hDWmOy3MCyk3BIHm8hsVCx55/aK9Ph/DkHVx8dkI=; b=OU/JEiWysKG2E7o1WOzHokC3j8XtD6nylVcxmYdwk3UrJFBldAhgsF9YyKl+Qb4ROiQVlAfhUxZh3Xl0Mbg9vjQQeOiAS9hpk/c0NWko0nmbc88vLfUQJcARbb41l3UH0McH5ZDmAXuqMY6jf+bBq5wBiLmmnWYAdn/ea/4Tca0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61622+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592949418023907.6248180875149; Tue, 23 Jun 2020 14:56:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id IHFpYY1788612xBtZ9VCq3hD; Tue, 23 Jun 2020 14:56:57 -0700 X-Received: from atlmailgw2.ami.com (atlmailgw2.ami.com []) by mx.groups.io with SMTP id smtpd.web10.563.1592949414388132273 for ; Tue, 23 Jun 2020 14:56:55 -0700 X-AuditID: ac10606f-4dbff70000003ed3-ff-5ef27aa414ea X-Received: from atlms1.us.megatrends.com (atlms1.us.megatrends.com [172.16.96.144]) (using TLS with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client did not present a certificate) by atlmailgw2.ami.com (Symantec Messaging Gateway) with SMTP id 09.45.16083.4AA72FE5; Tue, 23 Jun 2020 17:56:52 -0400 (EDT) X-Received: from Oleksiy77.us.megatrends.com (172.16.97.158) by atlms1.us.megatrends.com (172.16.96.144) with Microsoft SMTP Server id 14.3.468.0; Tue, 23 Jun 2020 17:56:00 -0400 From: "Oleksiy Yakovlev" To: CC: , , , , , , , Subject: [edk2-devel] [PATCH V2 2/3] MdeModulePkg: Add New Memory Attributes Date: Tue, 23 Jun 2020 17:55:55 -0400 Message-ID: <20200623215556.80804-3-oleksiyy@ami.com> In-Reply-To: <20200623215556.80804-1-oleksiyy@ami.com> References: <20200623215556.80804-1-oleksiyy@ami.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsWyRiBhgu6Sqk9xBqtW6Vps3aZu0T5hNpvF smM7WCxW3NvAbtHR8Y/JYvp2F4svq98zOrB7bP9+gdFj8Z6XTB7v911lC2COamC0SczLyy9J LElVSEktTrZVCijKLEtMrlRSyEyxVTJUUijISUxOzU3NK7FVSiwoSM1LUbLjUsAANkBlmXkK qXnJ+SmZeem2Sp7B/roWFqaWuoZKdiEZqQqZeWn5RbmJJZn5eQrJ+XklQNWpKUBRhYRuzozN n6cxFZyyrDg64T1TA+MenS5GTg4JAROJBUvvsnUxcnEICexikmi5P40dwtnCKNG+cycrSBWb gKbEgWNTGEFsEQEpiSkHZjKBFDEL7GGU6Hl9CqxIWMBe4ubeV2wgNouAqkTb9Y1MIDavgKnE 2mebmCDWaUhMW3MXyObg4BQwk3j+MgAkLARU0r76HlS5oMTJmU9YQGxmAQmJgy9eMEPUyEq0 HX/OPoGRfxaSsllIyhYwMq1iFEosyclNzMxJLzfSS8zN1EvOz93ECInF/B2MHz+aH2Jk4mA8 xCjBwawkwhvi9ilOiDclsbIqtSg/vqg0J7X4EKMT0P0TmaW4QSEIjJJ4YwMDKVEYx9DEzMTc yNzQ0sTc2FhJnHfS2jVxQgLpwKjNTk0tSC2CGcLEwSnVwLj6ZiyH3zmh+YzCGjsn7X7DWXp+ ZZOyUnKLrgDT2x+7S28dSOOODXz3pLIsriafe8s++f11SuWnWh+YLmr9+XvNdxNzG+nEDcm7 TrhbmlTW76rO/RcZylgtXXH1zc3nk54xtDhOtP2qsN85/wVfpAHrr1iXxXXGliXH0q90lflE i/D3Z0xaqcRSnJFoqMVcVJwIABCfZD3aAgAA Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,oleksiyy@ami.com X-Gm-Message-State: tS6rOZ5KkJAQAZLauI4Z6SgUx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592949417; bh=Ufrmygal8wwNfGkRxHO+7c54ydshE2N62PuM2Tx/sSU=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Z287mZx63bbjuLlWcqpghlhBceS4CnS8U1vbB28MI80IpkIuDCVWvIeMTpAErI0K/Th uHOpaSK5n3/gOqrsI7djN4zoNiaxIdCTUzhkY7c+quDWakrhfaqbzYpeOAj7NGZX489+I WSU4oiRaxx17ReqK7WkVvyQfi0c6Ww34o/Y= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add usage of EFI_MEMORY_SP and EFI_MEMORY_CPU_CRYPTO attributes introduced in UEFI 2.8. (UEFI 2.8, mantis 1919 and 1872). Use attributes bitmasks, defined in MdePkg. Signed-off-by: Oleksiy Yakovlev Reviewed-by: Dandan Bi Reviewed-by: Laszlo Ersek --- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 11 ++--------- MdeModulePkg/Core/Dxe/Mem/Page.c | 9 +++------ MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 7 ++----- MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 10 ++-------- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gc= d.c index 74f3b1b..2d8c076 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -35,13 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT) =20 -#define EXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_UC | EFI_MEMORY_WC | \ - EFI_MEMORY_WT | EFI_MEMORY_WB | \ - EFI_MEMORY_WP | EFI_MEMORY_UCE) - -#define NONEXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_XP | EFI_MEMORY_RP | \ - EFI_MEMORY_RO) - // // Module Variables // @@ -665,7 +658,7 @@ ConverToCpuArchAttributes ( { UINT64 CpuArchAttributes; =20 - CpuArchAttributes =3D Attributes & NONEXCLUSIVE_MEMORY_ATTRIBUTES; + CpuArchAttributes =3D Attributes & EFI_MEMORY_ATTRIBUTE_MASK; =20 if ( (Attributes & EFI_MEMORY_UC) =3D=3D EFI_MEMORY_UC) { CpuArchAttributes |=3D EFI_MEMORY_UC; @@ -951,7 +944,7 @@ CoreConvertSpace ( // Keep original CPU arch attributes when caller just calls // SetMemorySpaceAttributes() with none CPU arch attributes (for e= xample, RUNTIME). // - Attributes |=3D (Entry->Attributes & (EXCLUSIVE_MEMORY_ATTRIBUTES = | NONEXCLUSIVE_MEMORY_ATTRIBUTES)); + Attributes |=3D (Entry->Attributes & (EFI_CACHE_ATTRIBUTE_MASK | E= FI_MEMORY_ATTRIBUTE_MASK)); } Entry->Attributes =3D Attributes; break; diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index 1f0e3d9..2c2c9cd 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1857,8 +1857,7 @@ CoreGetMemoryMap ( MemoryMap->VirtualStart =3D 0; MemoryMap->NumberOfPages =3D RShiftU64 ((MergeGcdMapEntry.EndAddress= - MergeGcdMapEntry.BaseAddress + 1), EFI_PAGE_SHIFT); MemoryMap->Attribute =3D (MergeGcdMapEntry.Attributes & ~EFI_MEM= ORY_PORT_IO) | - (MergeGcdMapEntry.Capabilities & (EFI_MEMO= RY_RP | EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO | - EFI_MEMORY_UC | EFI_MEMORY_UCE | EFI_MEMOR= Y_WC | EFI_MEMORY_WT | EFI_MEMORY_WB)); + (MergeGcdMapEntry.Capabilities & (EFI_CACH= E_ATTRIBUTE_MASK | EFI_MEMORY_ATTRIBUTE_MASK)); =20 if (MergeGcdMapEntry.GcdMemoryType =3D=3D EfiGcdMemoryTypeReserved) { MemoryMap->Type =3D EfiReservedMemoryType; @@ -1892,8 +1891,7 @@ CoreGetMemoryMap ( MemoryMap->VirtualStart =3D 0; MemoryMap->NumberOfPages =3D RShiftU64 ((MergeGcdMapEntry.EndAddress= - MergeGcdMapEntry.BaseAddress + 1), EFI_PAGE_SHIFT); MemoryMap->Attribute =3D MergeGcdMapEntry.Attributes | EFI_MEMOR= Y_NV | - (MergeGcdMapEntry.Capabilities & (EFI_MEMO= RY_RP | EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO | - EFI_MEMORY_UC | EFI_MEMORY_UCE | EFI_MEMOR= Y_WC | EFI_MEMORY_WT | EFI_MEMORY_WB)); + (MergeGcdMapEntry.Capabilities & (EFI_CACH= E_ATTRIBUTE_MASK | EFI_MEMORY_ATTRIBUTE_MASK)); MemoryMap->Type =3D EfiPersistentMemory; =20 // @@ -1935,8 +1933,7 @@ CoreGetMemoryMap ( MemoryMapEnd =3D MemoryMap; MemoryMap =3D MemoryMapStart; while (MemoryMap < MemoryMapEnd) { - MemoryMap->Attribute &=3D ~(UINT64)(EFI_MEMORY_RP | EFI_MEMORY_RO | - EFI_MEMORY_XP); + MemoryMap->Attribute &=3D ~(UINT64)EFI_MEMORY_ATTRIBUTE_MASK; MemoryMap =3D NEXT_MEMORY_DESCRIPTOR (MemoryMap, Size); } MergeMemoryMap (MemoryMapStart, &BufferSize, Size); diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/C= ore/Dxe/Misc/MemoryProtection.c index 92a442f..7d1daf0 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c @@ -42,9 +42,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "DxeMain.h" #include "Mem/HeapGuard.h" =20 -#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY= _WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP) -#define MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEMORY= _RO) - // // Image type definitions // @@ -221,7 +218,7 @@ SetUefiImageMemoryAttributes ( Status =3D CoreGetMemorySpaceDescriptor(BaseAddress, &Descriptor); ASSERT_EFI_ERROR(Status); =20 - FinalAttributes =3D (Descriptor.Attributes & CACHE_ATTRIBUTE_MASK) | (At= tributes & MEMORY_ATTRIBUTE_MASK); + FinalAttributes =3D (Descriptor.Attributes & EFI_CACHE_ATTRIBUTE_MASK) |= (Attributes & EFI_MEMORY_ATTRIBUTE_MASK); =20 DEBUG ((DEBUG_INFO, "SetUefiImageMemoryAttributes - 0x%016lx - 0x%016lx = (0x%016lx)\n", BaseAddress, Length, FinalAttributes)); =20 @@ -924,7 +921,7 @@ InitializeDxeNxMemoryProtectionPolicy ( (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)) { =20 Attributes =3D GetPermissionAttributeForMemoryType (EfiConventiona= lMemory) | - (Entry->Attributes & CACHE_ATTRIBUTE_MASK); + (Entry->Attributes & EFI_CACHE_ATTRIBUTE_MASK); =20 DEBUG ((DEBUG_INFO, "Untested GCD memory space region: - 0x%016lx - 0x%016lx (0x%016= lx)\n", diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiS= mmCore/PiSmmIpl.c index 0385f1d..599a0cd 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c @@ -39,12 +39,6 @@ =20 #define SMRAM_CAPABILITIES (EFI_MEMORY_WB | EFI_MEMORY_UC) =20 -#define MEMORY_CACHE_ATTRIBUTES (EFI_MEMORY_UC | EFI_MEMORY_WC | \ - EFI_MEMORY_WT | EFI_MEMORY_WB | \ - EFI_MEMORY_WP | EFI_MEMORY_UCE) - -#define MEMORY_PAGE_ATTRIBUTES (EFI_MEMORY_XP | EFI_MEMORY_RP | EFI_MEMOR= Y_RO) - // // Function prototypes from produced protocols // @@ -1710,7 +1704,7 @@ SmmIplEntry ( CpuArch =3D NULL; Status =3D gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID = **)&CpuArch); if (!EFI_ERROR (Status)) { - MemDesc.Attributes &=3D ~(MEMORY_CACHE_ATTRIBUTES | MEMORY_PAGE_ATTR= IBUTES); + MemDesc.Attributes &=3D ~(EFI_CACHE_ATTRIBUTE_MASK | EFI_MEMORY_ATTR= IBUTE_MASK); MemDesc.Attributes |=3D EFI_MEMORY_WB; Status =3D gDS->SetMemorySpaceAttributes ( mSmramCacheBase, @@ -1727,7 +1721,7 @@ SmmIplEntry ( &MemDesc ); DEBUG ((DEBUG_INFO, "SMRAM attributes: %016lx\n", MemDesc.Attribut= es)); - ASSERT ((MemDesc.Attributes & MEMORY_PAGE_ATTRIBUTES) =3D=3D 0); + ASSERT ((MemDesc.Attributes & EFI_MEMORY_ATTRIBUTE_MASK) =3D=3D 0); ); } // --=20 2.9.0.windows.1 Please consider the environment before printing this email. The information contained in this message may be confidential and proprieta= ry to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephon= e at 770-246-8600, and then delete or destroy all copies of the transmissio= n. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61622): https://edk2.groups.io/g/devel/message/61622 Mute This Topic: https://groups.io/mt/75070222/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu Mar 28 23:05:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61623+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61623+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592949418; cv=none; d=zohomail.com; s=zohoarc; b=e2kk1lE1VHwSrNM2h6CNWoubvi2+m8RrfQCPXGMv64f4wMtOLknVbcMIlrqU319Nd2qfyYDsKAOaZRAaXNwqMY6veO9pFkLdjbO8C29jiL9MRrDTNNc9NHQmrhuMF3EVRFHSRHhb/cDlEFQR1Kk0GPtdJsQlMGN4iWK2uXszWoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592949418; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TR3otwwbqedAFF6QR/fSMXhuGm3L7PKJRjmChcSA950=; b=XlWtABgO90Fhvhfp2/43DBtC8diAuiCZmtaQov45lGBkcW/Sss1ygydUup5BaHGjROet++My9G+FJvqr2RtX1AWOK9u64bBiJo0LjEvWEQ3qlUyWEGmOMArf2ZZeJynA50Y9Ds/daKu3XSHBalBi1wP8aYk0pPloHPxaYsHtnAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61623+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592949418561253.10451644260866; Tue, 23 Jun 2020 14:56:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WXWzYY1788612xEX1fnXcJBe; Tue, 23 Jun 2020 14:56:58 -0700 X-Received: from atlmailgw1.ami.com (atlmailgw1.ami.com []) by mx.groups.io with SMTP id smtpd.web11.544.1592949415158553916 for ; Tue, 23 Jun 2020 14:56:56 -0700 X-AuditID: ac1060b2-ed1ff70000003d78-98-5ef27aa7af46 X-Received: from atlms1.us.megatrends.com (atlms1.us.megatrends.com [172.16.96.144]) (using TLS with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client did not present a certificate) by atlmailgw1.ami.com (Symantec Messaging Gateway) with SMTP id 04.46.15736.7AA72FE5; Tue, 23 Jun 2020 17:56:55 -0400 (EDT) X-Received: from Oleksiy77.us.megatrends.com (172.16.97.158) by atlms1.us.megatrends.com (172.16.96.144) with Microsoft SMTP Server id 14.3.468.0; Tue, 23 Jun 2020 17:56:01 -0400 From: "Oleksiy Yakovlev" To: CC: , , , , , , , Subject: [edk2-devel] [PATCH V2 3/3] UefiCpuPkg: Add New Memory Attributes Date: Tue, 23 Jun 2020 17:55:56 -0400 Message-ID: <20200623215556.80804-4-oleksiyy@ami.com> In-Reply-To: <20200623215556.80804-1-oleksiyy@ami.com> References: <20200623215556.80804-1-oleksiyy@ami.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsWyRiBhgu7yqk9xBhfnyVps3aZu0T5hNpvF smM7WCxW3NvAbtHR8Y/JYvp2F4svq98zOrB7bP9+gdFj8Z6XTB7v911lC2COamC0SczLyy9J LElVSEktTrZVCijKLEtMrlRSyEyxVTJUUijISUxOzU3NK7FVSiwoSM1LUbLjUsAANkBlmXkK qXnJ+SmZeem2Sp7B/roWFqaWuoZKdiEZqQqZeWn5RbmJJZn5eQrJ+XklQNWpKUBRhYRuzow1 k96xFzRrVPzdfIylgXGTbBcjJ4eEgInE5FnnmboYuTiEBHYxSeyZ1MsG4WxhlHh5/SQrSBWb gKbEgWNTGEFsEQEpiSkHZoJ1MAvsYZToeX0KqIiDQ1jAVuLdXDaQGhYBVYnf89Yxg9i8AqYS yze3skBs05CYtuYuE0g5p4CZxPOXASBhIaCS9tX3mCDKBSVOznwCVs4sICFx8MULZogaWYm2 48/ZJzDyz0JSNgtJ2QJGplWMQoklObmJmTnp5YZ6ibmZesn5uZsYIZG4aQdjy0XzQ4xMHIyH GCU4mJVEeEPcPsUJ8aYkVlalFuXHF5XmpBYfYnQCun8isxQ3KACBMRJvbGAgJQrjGJqYmZgb mRtampgbGyuJ805euyZOSCAdGLPZqakFqUUwQ5g4OKUaGFcmhH3WqjHJc1yr/jFMgOdu3HEf 5md7Fls+Nynd1HzTL8o0f3HR1MNcmy58DNA8wts4vf2qAq9g/475ycIyeqePTHjw6nzMuidz FLxeiDLOzGx7t7Htuoh8o63P+306X/IX7rVeyr/Uvzbx47ak8Khi3hd/XScYacUqf93aLMQU Vd6R99XfTomlOCPRUIu5qDgRAF/OITXZAgAA Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,oleksiyy@ami.com X-Gm-Message-State: d1ay7Hl61VMbLdHKySzxlzvOx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592949418; bh=mnbmsBmFdvHqeS0znalmYuI2Vyi0/C2NShvDPeH23sA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=YFF2W9Tm2+hdk1a/wPBvl9tLk8WZBuq3c2hQ8FGWFd4IjMqIEhfkCuFBG/foZMqNM2/ Bx66KQR6uhzb3xZfmZqhmhRlNCYyrfhiEWXYTPmNeA+mfh2rYg5gLTPUrsSiW5vX8+Oot uL5FahVmWFi40GVeGV99Q+5FHquUfFtoUhM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add usage of EFI_MEMORY_SP and EFI_MEMORY_CPU_CRYPTO attributes introduced in UEFI 2.8. (UEFI 2.8, mantis 1919 and 1872). Use attributes bitmasks, defined in MdePkg. Signed-off-by: Oleksiy Yakovlev Reviewed-by: Laszlo Ersek --- UefiCpuPkg/CpuDxe/CpuDxe.c | 11 ++++------- UefiCpuPkg/CpuDxe/CpuDxe.h | 12 ------------ UefiCpuPkg/CpuDxe/CpuPageTable.c | 6 +++--- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 2 +- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index a571fc3..52cc26e 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -10,9 +10,6 @@ #include "CpuMp.h" #include "CpuPageTable.h" =20 -#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY= _WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP) -#define MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEMORY= _RO) - // // Global Variables // @@ -417,8 +414,8 @@ CpuSetMemoryAttributes ( return EFI_SUCCESS; } =20 - CacheAttributes =3D Attributes & CACHE_ATTRIBUTE_MASK; - MemoryAttributes =3D Attributes & MEMORY_ATTRIBUTE_MASK; + CacheAttributes =3D Attributes & EFI_CACHE_ATTRIBUTE_MASK; + MemoryAttributes =3D Attributes & EFI_MEMORY_ATTRIBUTE_MASK; =20 if (Attributes !=3D (CacheAttributes | MemoryAttributes)) { return EFI_INVALID_PARAMETER; @@ -677,7 +674,7 @@ SetGcdMemorySpaceAttributes ( gDS->SetMemorySpaceAttributes ( RegionStart, RegionLength, - (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_CACHETYPE_MASK)= | (MemorySpaceMap[Index].Capabilities & Attributes) + (MemorySpaceMap[Index].Attributes & ~EFI_CACHE_ATTRIBUTE_MASK) = | (MemorySpaceMap[Index].Capabilities & Attributes) ); } =20 @@ -754,7 +751,7 @@ RefreshMemoryAttributesFromMtrr ( gDS->SetMemorySpaceAttributes ( MemorySpaceMap[Index].BaseAddress, MemorySpaceMap[Index].Length, - (MemorySpaceMap[Index].Attributes & ~EFI_MEMORY_CACHETYPE_MASK)= | + (MemorySpaceMap[Index].Attributes & ~EFI_CACHE_ATTRIBUTE_MASK) | (MemorySpaceMap[Index].Capabilities & DefaultAttributes) ); } diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h index 9299eaa..9771ec8 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.h +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h @@ -39,18 +39,6 @@ #include #include =20 -#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | \ - EFI_MEMORY_WC | \ - EFI_MEMORY_WT | \ - EFI_MEMORY_WB | \ - EFI_MEMORY_UCE \ - ) - -#define EFI_MEMORY_PAGETYPE_MASK (EFI_MEMORY_RP | \ - EFI_MEMORY_XP | \ - EFI_MEMORY_RO \ - ) - #define HEAP_GUARD_NONSTOP_MODE \ ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT4|BIT1|BIT0)) > BI= T6) =20 diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTa= ble.c index 0a02cb3..06ee1b8 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -717,7 +717,7 @@ ConvertMemoryPageAttributes ( return RETURN_INVALID_PARAMETER; } =20 - if ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) !=3D= 0) { + if ((Attributes & ~EFI_MEMORY_ATTRIBUTE_MASK) !=3D 0) { DEBUG ((DEBUG_ERROR, "Attributes(0x%lx) has unsupported bit\n", Attrib= utes)); return EFI_UNSUPPORTED; } @@ -1018,9 +1018,9 @@ RefreshGcdMemoryAttributesFromPaging ( =20 Length =3D MIN (PageLength, MemorySpaceLength); if (Attributes !=3D (MemorySpaceMap[Index].Attributes & - EFI_MEMORY_PAGETYPE_MASK)) { + EFI_MEMORY_ATTRIBUTE_MASK)) { NewAttributes =3D (MemorySpaceMap[Index].Attributes & - ~EFI_MEMORY_PAGETYPE_MASK) | Attributes; + ~EFI_MEMORY_ATTRIBUTE_MASK) | Attributes; Status =3D gDS->SetMemorySpaceAttributes ( BaseAddress, Length, diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPk= g/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 9c5a92a..ebfc46a 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -435,7 +435,7 @@ ConvertMemoryPageAttributes ( EFI_PHYSICAL_ADDRESS MaximumSupportMemAddress; =20 ASSERT (Attributes !=3D 0); - ASSERT ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) = =3D=3D 0); + ASSERT ((Attributes & ~EFI_MEMORY_ATTRIBUTE_MASK) =3D=3D 0); =20 ASSERT ((BaseAddress & (SIZE_4KB - 1)) =3D=3D 0); ASSERT ((Length & (SIZE_4KB - 1)) =3D=3D 0); --=20 2.9.0.windows.1 Please consider the environment before printing this email. The information contained in this message may be confidential and proprieta= ry to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephon= e at 770-246-8600, and then delete or destroy all copies of the transmissio= n. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61623): https://edk2.groups.io/g/devel/message/61623 Mute This Topic: https://groups.io/mt/75070223/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-