From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: ami.com, ip: , mailfrom: oleksiyy@ami.com) X-AuditID: ac1060b2-ed1ff70000003d78-98-5ef27aa7af46 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) 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: [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> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20200623215556.80804-1-oleksiyy@ami.com> References: <20200623215556.80804-1-oleksiyy@ami.com> MIME-Version: 1.0 Return-Path: oleksiyy@ami.com 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 Content-Type: text/plain 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 --- 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" -#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; } - CacheAttributes = Attributes & CACHE_ATTRIBUTE_MASK; - MemoryAttributes = Attributes & MEMORY_ATTRIBUTE_MASK; + CacheAttributes = Attributes & EFI_CACHE_ATTRIBUTE_MASK; + MemoryAttributes = Attributes & EFI_MEMORY_ATTRIBUTE_MASK; if (Attributes != (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) ); } @@ -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 -#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)) > BIT6) diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c b/UefiCpuPkg/CpuDxe/CpuPageTable.c index 0a02cb3..06ee1b8 100644 --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c @@ -717,7 +717,7 @@ ConvertMemoryPageAttributes ( return RETURN_INVALID_PARAMETER; } - if ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) != 0) { + if ((Attributes & ~EFI_MEMORY_ATTRIBUTE_MASK) != 0) { DEBUG ((DEBUG_ERROR, "Attributes(0x%lx) has unsupported bit\n", Attributes)); return EFI_UNSUPPORTED; } @@ -1018,9 +1018,9 @@ RefreshGcdMemoryAttributesFromPaging ( Length = MIN (PageLength, MemorySpaceLength); if (Attributes != (MemorySpaceMap[Index].Attributes & - EFI_MEMORY_PAGETYPE_MASK)) { + EFI_MEMORY_ATTRIBUTE_MASK)) { NewAttributes = (MemorySpaceMap[Index].Attributes & - ~EFI_MEMORY_PAGETYPE_MASK) | Attributes; + ~EFI_MEMORY_ATTRIBUTE_MASK) | Attributes; Status = gDS->SetMemorySpaceAttributes ( BaseAddress, Length, diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/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; ASSERT (Attributes != 0); - ASSERT ((Attributes & ~(EFI_MEMORY_RP | EFI_MEMORY_RO | EFI_MEMORY_XP)) == 0); + ASSERT ((Attributes & ~EFI_MEMORY_ATTRIBUTE_MASK) == 0); ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); ASSERT ((Length & (SIZE_4KB - 1)) == 0); -- 2.9.0.windows.1 Please consider the environment before printing this email. The information contained in this message may be confidential and proprietary 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 designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.