From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.10857.1675329971396725120 for ; Thu, 02 Feb 2023 01:26:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UvnOWarZ; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 97A0461A30 for ; Thu, 2 Feb 2023 09:26:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A40CC433D2 for ; Thu, 2 Feb 2023 09:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675329970; bh=Y75aRQZxqNeCZLaSDn+QpbHaM6MjlOdZyteyizDzWCU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UvnOWarZSX2HLJdSQ60SoDYyEyFWLEIyLyBvRzMzlwV7ug6ztsZ154PG+nPMFXdVX Whk3DKhCP5XtJ0YaGwtDxFYrU9AthX1zEfZycH3/sFF5EdC9iaFvmIHSsbjWD4uNXw JKVHBS5CkivcoJjyyhNCANGcab3/oMhiOGOWXt2uNiAyzhhudYo01yYSUd3sPgEg1C uJN3H1nwsiK6YTwK2giKjcD5/nJecOLAG2WGOBo1uKuexDwIU9ZDnePwHKAhBgmDgG sNdOTeHh09OPkehEUmVubZPH4qD9uuB5A874s8ieXHmBBpI0+rSWfj1IwqoIY/nDDh uoE/5k0Ba0uog== Received: by mail-lf1-f46.google.com with SMTP id v17so2056616lfd.7 for ; Thu, 02 Feb 2023 01:26:09 -0800 (PST) X-Gm-Message-State: AO0yUKW5GSiArsPPF1he2SxhFCcOeogFS8Sp0TfgYWicsA7yEDXI3fyA 8huofYi6cNmXeGbuh1jaUskjyhncwIC/3vatovw= X-Google-Smtp-Source: AK7set8RAToLjZHhNdsw6f0moDX11Fp5I/+IHlqw/pf2/dvYKv9DJ6wKB6Oeexhb2H5uGMKl7JOJhQ4ZxQJmVBH/E/k= X-Received: by 2002:ac2:4ed9:0:b0:4cb:4526:3f09 with SMTP id p25-20020ac24ed9000000b004cb45263f09mr1090397lfr.105.1675329968081; Thu, 02 Feb 2023 01:26:08 -0800 (PST) MIME-Version: 1.0 References: <20230131223550.1775834-1-ardb@kernel.org> <20230131223550.1775834-2-ardb@kernel.org> <019e01d936b5$247f4000$6d7dc000$@byosoft.com.cn> In-Reply-To: <019e01d936b5$247f4000$6d7dc000$@byosoft.com.cn> From: "Ard Biesheuvel" Date: Thu, 2 Feb 2023 10:25:57 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: =?UTF-8?B?UmU6IFtlZGsyLWRldmVsXSDlm57lpI06IFtQQVRDSCAxLzRdIE1kZVBrZzogQWRkIE1lbW9yeSBBdHRyaWJ1dGUgUHJvdG9jb2wgZGVmaW5pdGlvbg==?= To: devel@edk2.groups.io, gaoliming@byosoft.com.cn Cc: Michael Kinney , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2 Feb 2023 at 04:19, gaoliming via groups.io wrote: > > Ard: > I check this protocol definition in UEFI2.10 spec. GetMemoryAttributes a= nd > SetMemoryAttributes API return status include EFI_OUT_OF_RESOURCES and > EFI_ACCESS_DENIED. But, they are missing in this patch. Can you help > confirm? > I just took the Project Mu version without realizing this - I can fix that up in v2. > > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > > =E5=8F=91=E4=BB=B6=E4=BA=BA: Ard Biesheuvel > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B42=E6=9C=881=E6=97=A5= 6:36 > > =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io > > =E6=8A=84=E9=80=81: Ard Biesheuvel ; Michael Kinney > > ; Liming Gao ; > > Jiewen Yao ; Michael Kubacki > > ; Sean Brogan > > ; Rebecca Cran ; > > Leif Lindholm ; Sami Mujawar > > > > =E4=B8=BB=E9=A2=98: [PATCH 1/4] MdePkg: Add Memory Attribute Protocol d= efinition > > > > From: Sean Brogan > > > > Add the Memory Attribute Protocol definition, which was adopted and > > included in version 2.10 of the UEFI specification. > > > > Taken from Project Mu's mu_basecore repository. > > > > 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(+) > > > > 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 > > > > + > > > > + EFI Memory Attribute Protocol provides retrieval and update service > > > > + for memory attributes in EFI environment. > > > > + > > > > + Copyright (c) 2021, Intel Corporation. All rights reserved.
> > > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > > > + > > > > +**/ > > > > + > > > > +#ifndef __EFI_MEMORY_ATTRIBUTE_H__ > > > > +#define __EFI_MEMORY_ATTRIBUTE_H__ > > > > + > > > > +#define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \ > > > > + { \ > > > > + 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, > 0xb1, > > 0x89 } \ > > > > + } > > > > + > > > > +typedef struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL > > EFI_MEMORY_ATTRIBUTE_PROTOCOL; > > > > + > > > > +/** > > > > + This function set given attributes of the memory region specified by > > > > + BaseAddress and Length. > > > > + > > > > + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and > > EFI_MEMORY_RO. > > > > + > > > > + @param This The > > EFI_MEMORY_ATTRIBUTE_PROTOCOL instance. > > > > + @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 > > memory > > > > + region. > > > > + > > > > + @retval EFI_SUCCESS The attributes were set for the > > memory region. > > > > + @retval EFI_INVALID_PARAMETER Length is zero. > > > > + Attributes specified an illegal > > combination of > > > > + attributes that cannot be set > > together. > > > > + @retval EFI_UNSUPPORTED The processor does not support one > > or more > > > > + bytes of the memory resource range > > specified > > > > + by BaseAddress and Length. > > > > + The bit mask of attributes is not > > supported for > > > > + the memory resource range > > specified by > > > > + BaseAddress and Length. > > > > + > > > > +**/ > > > > +typedef > > > > +EFI_STATUS > > > > +(EFIAPI *EFI_SET_MEMORY_ATTRIBUTES)( > > > > + IN EFI_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. > > > > + > > > > + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and > > EFI_MEMORY_RO. > > > > + > > > > + @param This The > > EFI_MEMORY_ATTRIBUTE_PROTOCOL instance. > > > > + @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 clear for th= e > > memory > > > > + region. > > > > + > > > > + @retval EFI_SUCCESS The attributes were cleared for the > > memory region. > > > > + @retval EFI_INVALID_PARAMETER Length is zero. > > > > + Attributes specified an illegal > > combination of > > > > + attributes that cannot be cleared > > together. > > > > + @retval EFI_UNSUPPORTED The processor does not support one > > or more > > > > + bytes of the memory resource range > > specified > > > > + by BaseAddress and Length. > > > > + The bit mask of attributes is not > > supported for > > > > + the memory resource range > > specified by > > > > + BaseAddress and Length. > > > > + > > > > +**/ > > > > +typedef > > > > +EFI_STATUS > > > > +(EFIAPI *EFI_CLEAR_MEMORY_ATTRIBUTES)( > > > > + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This, > > > > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > > > > + IN UINT64 Length, > > > > + IN UINT64 Attributes > > > > + ); > > > > + > > > > +/** > > > > + This function retrieves the attributes of the memory region specifie= d > by > > > > + BaseAddress and Length. If different attributes are got from differe= nt > part > > > > + of the memory region, EFI_NO_MAPPING will be returned. > > > > + > > > > + @param This The > > EFI_MEMORY_ATTRIBUTE_PROTOCOL instance. > > > > + @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 memory > > > > + region. > > > > + @retval EFI_UNSUPPORTED The processor does not support one > > or more > > > > + bytes of the memory resource range > > specified > > > > + by BaseAddress and Length. > > > > + > > > > +**/ > > > > +typedef > > > > +EFI_STATUS > > > > +(EFIAPI *EFI_GET_MEMORY_ATTRIBUTES)( > > > > + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This, > > > > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > > > > + IN UINT64 Length, > > > > + OUT UINT64 *Attributes > > > > + ); > > > > + > > > > +/// > > > > +/// EFI Memory Attribute Protocol provides services to retrieve or upd= ate > > > > +/// attribute of memory in the EFI environment. > > > > +/// > > > > +struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL { > > > > + EFI_GET_MEMORY_ATTRIBUTES GetMemoryAttributes; > > > > + EFI_SET_MEMORY_ATTRIBUTES SetMemoryAttributes; > > > > + EFI_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes; > > > > +}; > > > > + > > > > +extern EFI_GUID gEfiMemoryAttributeProtocolGuid; > > > > + > > > > +#endif > > > > 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 > > > > gEfiRedfishDiscoverProtocolGuid =3D { 0x5db12509, 0x4550, 0x434= 7, > > { 0x96, 0xb3, 0x73, 0xc0, 0xff, 0x6e, 0x86, 0x9f }} > > > > > > > > + ## Include/Protocol/MemoryAttribute.h > > > > + gEfiMemoryAttributeProtocolGuid =3D { 0xf4560cf6, 0x40ec, 0x4b4a, { = 0xa1, > > 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 }} > > > > + > > > > # > > > > # Protocols defined in Shell2.0 > > > > # > > > > -- > > 2.39.0 > > > > > >=20 > >