From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from cxsh.intel-email.com (cxsh.intel-email.com [121.46.250.151]) by mx.groups.io with SMTP id smtpd.web10.6634.1675307974386333778 for ; Wed, 01 Feb 2023 19:19:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@byosoft.com.cn header.s=cloud-union header.b=D7pyp7+k; spf=pass (domain: byosoft.com.cn, ip: 121.46.250.151, mailfrom: gaoliming@byosoft.com.cn) Received: from cxsh.intel-email.com (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id 90203DDA870 for ; Thu, 2 Feb 2023 11:19:31 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=byosoft.com.cn; s=cloud-union; t=1675307971; bh=XWdHYqxSn34i4/k0le5388nkXmfJ0Rvh1VLbgO/eD6A=; h=From:To:Cc:References:In-Reply-To:Subject:Date; b=D7pyp7+k/1XhD7Ny3aNcMqXLd/jA3zwut1SJTOou0QRTtDMie6VvIwQlXjRGdd1Jm 6K54DxY3vxe3TU4eJ6JqDF0d29EZe+9k8Rfz8fv66QyghI55tvD8dadhEls9vymsMz kmMScF/ruxdET7hWVWlVoQYGTAe9xKtk53dJsQio= Received: from localhost (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id 8B402DDA86F for ; Thu, 2 Feb 2023 11:19:31 +0800 (CST) Received: from cxsh.intel-email.com (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id 2BFDCDDA853 for ; Thu, 2 Feb 2023 11:19:31 +0800 (CST) Authentication-Results: cxsh.intel-email.com; none Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by cxsh.intel-email.com (Postfix) with SMTP id B05CCDDA85B for ; Thu, 2 Feb 2023 11:19:28 +0800 (CST) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Thu, 02 Feb 2023 11:19:19 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Ard Biesheuvel'" , Cc: "'Michael Kinney'" , "'Jiewen Yao'" , "'Michael Kubacki'" , "'Sean Brogan'" , "'Rebecca Cran'" , "'Leif Lindholm'" , "'Sami Mujawar'" References: <20230131223550.1775834-1-ardb@kernel.org> <20230131223550.1775834-2-ardb@kernel.org> In-Reply-To: <20230131223550.1775834-2-ardb@kernel.org> Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0ggMS80XSBNZGVQa2c6IEFkZCBNZW1vcnkgQXR0cmlidXRlIFByb3RvY29sIGRlZmluaXRpb24=?= Date: Thu, 2 Feb 2023 11:19:21 +0800 Message-ID: <019e01d936b5$247f4000$6d7dc000$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQEd84O0JhhFLBob2bxWVaYBF894HAIHHv5KsCFJuUA= Sender: "gaoliming" Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Ard: I check this protocol definition in UEFI2.10 spec. GetMemoryAttributes = and SetMemoryAttributes API return status include EFI_OUT_OF_RESOURCES and EFI_ACCESS_DENIED. But, they are missing in this patch. Can you help confirm? Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Ard Biesheuvel > =B7=A2=CB=CD=CA=B1=BC=E4: 2023=C4=EA2=D4=C21=C8=D5 6:36 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Ard Biesheuvel ; Michael Kinney > ; Liming Gao ; > Jiewen Yao ; Michael Kubacki > ; Sean Brogan > ; Rebecca Cran ; > Leif Lindholm ; Sami Mujawar > > =D6=F7=CC=E2: [PATCH 1/4] MdePkg: Add Memory Attribute Protocol = definition >=20 > From: Sean Brogan >=20 > Add the Memory Attribute Protocol definition, which was adopted and > included in version 2.10 of the UEFI specification. >=20 > Taken from Project Mu's mu_basecore repository. >=20 > Link: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3519 > Signed-off-by: Ard Biesheuvel > --- > MdePkg/Include/Protocol/MemoryAttribute.h | 131 > ++++++++++++++++++++ > MdePkg/MdePkg.dec | 3 + > 2 files changed, 134 insertions(+) >=20 > diff --git a/MdePkg/Include/Protocol/MemoryAttribute.h > b/MdePkg/Include/Protocol/MemoryAttribute.h > new file mode 100644 > index 000000000000..b33138732ad1 > --- /dev/null > +++ b/MdePkg/Include/Protocol/MemoryAttribute.h > @@ -0,0 +1,131 @@ > +/** @file >=20 > + >=20 > + EFI Memory Attribute Protocol provides retrieval and update service >=20 > + for memory attributes in EFI environment. >=20 > + >=20 > + Copyright (c) 2021, Intel Corporation. All rights reserved.
>=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#ifndef __EFI_MEMORY_ATTRIBUTE_H__ >=20 > +#define __EFI_MEMORY_ATTRIBUTE_H__ >=20 > + >=20 > +#define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \ >=20 > + { \ >=20 > + 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, > 0x89 } \ >=20 > + } >=20 > + >=20 > +typedef struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL > EFI_MEMORY_ATTRIBUTE_PROTOCOL; >=20 > + >=20 > +/** >=20 > + This function set given attributes of the memory region specified = by >=20 > + BaseAddress and Length. >=20 > + >=20 > + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and > EFI_MEMORY_RO. >=20 > + >=20 > + @param This The > EFI_MEMORY_ATTRIBUTE_PROTOCOL instance. >=20 > + @param BaseAddress The physical address that is the start > address of >=20 > + a memory region. >=20 > + @param Length The size in bytes of the memory region. >=20 > + @param Attributes The bit mask of attributes to set for the > memory >=20 > + region. >=20 > + >=20 > + @retval EFI_SUCCESS The attributes were set for the > memory region. >=20 > + @retval EFI_INVALID_PARAMETER Length is zero. >=20 > + Attributes specified an illegal > combination of >=20 > + attributes that cannot be set > together. >=20 > + @retval EFI_UNSUPPORTED The processor does not support one > or more >=20 > + bytes of the memory resource range > specified >=20 > + by BaseAddress and Length. >=20 > + The bit mask of attributes is not > supported for >=20 > + the memory resource range > specified by >=20 > + BaseAddress and Length. >=20 > + >=20 > +**/ >=20 > +typedef >=20 > +EFI_STATUS >=20 > +(EFIAPI *EFI_SET_MEMORY_ATTRIBUTES)( >=20 > + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This, >=20 > + IN EFI_PHYSICAL_ADDRESS BaseAddress, >=20 > + IN UINT64 Length, >=20 > + IN UINT64 Attributes >=20 > + ); >=20 > + >=20 > +/** >=20 > + This function clears given attributes of the memory region = specified by >=20 > + BaseAddress and Length. >=20 > + >=20 > + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and > EFI_MEMORY_RO. >=20 > + >=20 > + @param This The > EFI_MEMORY_ATTRIBUTE_PROTOCOL instance. >=20 > + @param BaseAddress The physical address that is the start > address of >=20 > + a memory region. >=20 > + @param Length The size in bytes of the memory region. >=20 > + @param Attributes The bit mask of attributes to clear for = the > memory >=20 > + region. >=20 > + >=20 > + @retval EFI_SUCCESS The attributes were cleared for the > memory region. >=20 > + @retval EFI_INVALID_PARAMETER Length is zero. >=20 > + Attributes specified an illegal > combination of >=20 > + attributes that cannot be cleared > together. >=20 > + @retval EFI_UNSUPPORTED The processor does not support one > or more >=20 > + bytes of the memory resource range > specified >=20 > + by BaseAddress and Length. >=20 > + The bit mask of attributes is not > supported for >=20 > + the memory resource range > specified by >=20 > + BaseAddress and Length. >=20 > + >=20 > +**/ >=20 > +typedef >=20 > +EFI_STATUS >=20 > +(EFIAPI *EFI_CLEAR_MEMORY_ATTRIBUTES)( >=20 > + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This, >=20 > + IN EFI_PHYSICAL_ADDRESS BaseAddress, >=20 > + IN UINT64 Length, >=20 > + IN UINT64 Attributes >=20 > + ); >=20 > + >=20 > +/** >=20 > + This function retrieves the attributes of the memory region = specified by >=20 > + BaseAddress and Length. If different attributes are got from = different part >=20 > + of the memory region, EFI_NO_MAPPING will be returned. >=20 > + >=20 > + @param This The > EFI_MEMORY_ATTRIBUTE_PROTOCOL instance. >=20 > + @param BaseAddress The physical address that is the start > address of >=20 > + a memory region. >=20 > + @param Length The size in bytes of the memory region. >=20 > + @param Attributes Pointer to attributes returned. >=20 > + >=20 > + @retval EFI_SUCCESS The attributes got for the memory > region. >=20 > + @retval EFI_INVALID_PARAMETER Length is zero. >=20 > + Attributes is NULL. >=20 > + @retval EFI_NO_MAPPING Attributes are not consistent cross > the memory >=20 > + region. >=20 > + @retval EFI_UNSUPPORTED The processor does not support one > or more >=20 > + bytes of the memory resource range > specified >=20 > + by BaseAddress and Length. >=20 > + >=20 > +**/ >=20 > +typedef >=20 > +EFI_STATUS >=20 > +(EFIAPI *EFI_GET_MEMORY_ATTRIBUTES)( >=20 > + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This, >=20 > + IN EFI_PHYSICAL_ADDRESS BaseAddress, >=20 > + IN UINT64 Length, >=20 > + OUT UINT64 *Attributes >=20 > + ); >=20 > + >=20 > +/// >=20 > +/// EFI Memory Attribute Protocol provides services to retrieve or = update >=20 > +/// attribute of memory in the EFI environment. >=20 > +/// >=20 > +struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL { >=20 > + EFI_GET_MEMORY_ATTRIBUTES GetMemoryAttributes; >=20 > + EFI_SET_MEMORY_ATTRIBUTES SetMemoryAttributes; >=20 > + EFI_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes; >=20 > +}; >=20 > + >=20 > +extern EFI_GUID gEfiMemoryAttributeProtocolGuid; >=20 > + >=20 > +#endif >=20 > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index 3d08f20d15b0..a8658403c8fd 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -1915,6 +1915,9 @@ [Protocols] > ## Include/Protocol/RedfishDiscover.h >=20 > gEfiRedfishDiscoverProtocolGuid =3D { 0x5db12509, 0x4550, = 0x4347, > { 0x96, 0xb3, 0x73, 0xc0, 0xff, 0x6e, 0x86, 0x9f }} >=20 >=20 >=20 > + ## Include/Protocol/MemoryAttribute.h >=20 > + gEfiMemoryAttributeProtocolGuid =3D { 0xf4560cf6, 0x40ec, 0x4b4a, { = 0xa1, > 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 }} >=20 > + >=20 > # >=20 > # Protocols defined in Shell2.0 >=20 > # >=20 > -- > 2.39.0