From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web12.50.1594656855068679059 for ; Mon, 13 Jul 2020 09:14:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gf6neUTi; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594656854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HnXNVmecuQRmGHCxR37cJ1l/cjipsLBgbnFWMqA3lWw=; b=Gf6neUTiIQv+knZkfpr1VI4XU/md9xaNvl64q7c5lkxlZQmStMdDgaGnzFr6ct9j4VJL6E 37q+/tWyAuK3N5XjvmemAACdiM6Kp2+vc44YK+W7RepyZ6wCtvKHTZ1GpiPkTkElm4zpth DECh+lyXGcSTAJo4Q2P6XMA21oGmhOw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-uEKmRHRvMverijl28oZU7Q-1; Mon, 13 Jul 2020 12:14:10 -0400 X-MC-Unique: uEKmRHRvMverijl28oZU7Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B76CD107ACCA; Mon, 13 Jul 2020 16:14:06 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-183.ams2.redhat.com [10.36.114.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F03B1001281; Mon, 13 Jul 2020 16:14:04 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH V3 4/4] UefiCpuPkg: Add New Memory Attributes To: ray.ni@intel.com, Eric Dong Cc: devel@edk2.groups.io, oleksiyy@ami.com, liming.gao@intel.com, michael.d.kinney@intel.com, dandan.bi@intel.com, rahul1.kumar@intel.com, Felixp@ami.com References: <20200702205039.52400-1-oleksiyy@ami.com> <20200702205039.52400-5-oleksiyy@ami.com> From: "Laszlo Ersek" Message-ID: <2eeec9d1-1b4e-b3c6-f898-7440343e6a78@redhat.com> Date: Mon, 13 Jul 2020 18:14:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200702205039.52400-5-oleksiyy@ami.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Eric, Ray, can you please ACK this patch too? Thanks Laszlo On 07/02/20 22:50, Oleksiy Yakovlev wrote: > 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 | 13 ------------- > UefiCpuPkg/CpuDxe/CpuPageTable.c | 6 +++--- > UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 2 +- > 4 files changed, 8 insertions(+), 24 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 b30a896..9771ec8 100644 > --- a/UefiCpuPkg/CpuDxe/CpuDxe.h > +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h > @@ -39,19 +39,6 @@ > #include > #include > > -#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | \ > - EFI_MEMORY_WC | \ > - EFI_MEMORY_WT | \ > - EFI_MEMORY_WB | \ > - EFI_MEMORY_UCE | \ > - EFI_MEMORY_WP \ > - ) > - > -#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); >