public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Min Xu" <min.m.xu@intel.com>
To: Dionna Amalie Glaze <dionnaglaze@google.com>,
	"Ni, Ray" <ray.ni@intel.com>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>,
	"Gao, Zhichao" <zhichao.gao@intel.com>,
	"Aktas, Erdem" <erdemaktas@google.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	"James Bottomley" <jejb@linux.ibm.com>,
	"Yao, Jiewen" <jiewen.yao@intel.com>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Gao, Jiaqi" <jiaqi.gao@intel.com>,
	"Wang, Jian J" <jian.j.wang@intel.com>,
	"Liu, Zhiguang" <zhiguang.liu@intel.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Xu, Min M" <min.m.xu@intel.com>
Subject: Re: [edk2-devel] 回复: [PATCH V4 00/10] Introduce Lazy-accept for Tdx guest
Date: Wed, 12 Oct 2022 05:29:46 +0000	[thread overview]
Message-ID: <PH0PR11MB50641BDCEABA0F7646068D5EC5229@PH0PR11MB5064.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CAAH4kHaP29roTNSMYg12rWJNGY5yVeYzrnhZrhEEn=_NP30HhQ@mail.gmail.com>

The name of EDKII_MEMORY_ACCEPT_PROTOCOL indicates it is only used in edk2. It's not going to be included in UEFI spec, at least in current stage.
In our design of the protocol (EDKII_MEMORY_ACCEPT_PROTOCOL), it contains the function of EDKII_ACCEPT_MEMORY which is to accept the un-accepted memories based on the input address and size. We just want to make the protocol clear and straightforward.

> -----Original Message-----
> From: Dionna Amalie Glaze <dionnaglaze@google.com>
> Sent: Monday, October 10, 2022 11:51 PM
> To: Ni, Ray <ray.ni@intel.com>
> Cc: Xu, Min M <min.m.xu@intel.com>; devel@edk2.groups.io; Gao, Liming
> <gaoliming@byosoft.com.cn>; Gao, Zhichao <zhichao.gao@intel.com>; Aktas,
> Erdem <erdemaktas@google.com>; Gerd Hoffmann <kraxel@redhat.com>;
> James Bottomley <jejb@linux.ibm.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Tom Lendacky <thomas.lendacky@amd.com>; Gao,
> Jiaqi <jiaqi.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Liu,
> Zhiguang <zhiguang.liu@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] 回复: [PATCH V4 00/10] Introduce Lazy-accept for
> Tdx guest
> 
> >
> > Can OS call AcceptMemory protocol for those ranges that are not accepted?
> >
> 
> AcceptMemory is not specified to avoid accepting previously accepted
> memory. As I understand it, AcceptMemory is purely a hardware abstraction
> layer for CC technologies inside the UEFI implementation.
> It additionally is not meant to modify address spaces. Address space
> modification happens around it. Gao has a point though, that the two could
> be combined. I'm not sure if it's particularly helpful to expose AcceptMemory
> to the OS. Exposing it I think would necessitate changing its semantics to be
> safer, e.g.,
> 
> Use the insight that AcceptMemory is only used to accept full or partial
> regions of unaccepted memory spaces:
> 
> /**
>  * Accepts memory in page granularity from the beginning of a pointed-to
> memory descriptor, and changes
>  * the type of the affected memory range to EfiConventionalMemory.
>  *
>  * @param[This] This A pointer to this protocol instance
>  * @param[AddressInSpace] An address within the memory descriptor from
> which to accept pages.
>  * @param[NumPages] The amount of EFI_PAGE_SIZE blocks of memory to
> accept from the memory
>  *  descriptor's beginning and convert into EfiConventionalMemory. If pages
> remain in the memory descriptor
>  * after acceptance, the remaining memory will start at the initial memory
> descriptor's
>  * start address + NumPages * EFI_PAGE_SIZE
>  * with type EfiUnacceptedMemory.
>  * The changes to the memory map affect only the memory descriptor
> named by AddressInSpace.
>  *
>  * Returns EFI_INVALID_PARAMETER if AddressInSpace names to a memory
> descriptor that is not
>  * EfiUnacceptedMemory, or if the named memory descriptor is not at least
> NumPages in size.
>  */
> EFI_STATUS EFIAPI AcceptFromMemorySpaceBeginning (
>   IN ProtocolType *This,
>   IN EFI_VIRTUAL_ADDRESS AddressInSpace,
>   IN UINTN NumPages
>   );
> 
> /**
>  * To be called by the OS loader to indicate that it supports and accepts
> responsibility for EfiUnacceptedMemory.
>  *
>  * Without calling this function, ExitBootServices will accept all unaccepted
> memory before returning. This
>  * behavior maintains safety for OSes that do not support unaccepted
> memory or know of this protocol.
>  */
> VOID EFIAPI DisableAcceptAllOnExitBootServices (IN ProtocolType *This);
> 
> I think this could be a fine protocol to expose to the OS loader since it would
> be safer written this way, albeit AcceptFromMemorySpaceBeginning is rather
> redundant for the behavior that the OS would need to implement if it calls
> the disable function.
> 
> I'm not too pleased about the naming behavior, but I also don't really like
> requiring the interface to only accept the start address of any particular
> memory descriptor. That's a matter of taste though. The implementation of
> the memory descriptor search would not be much more complicated than a
> couple inequality checks instead of a single equality check.
> 
> I don't think it's worth the effort in this interface to allow an arbitrary range
> that could split a single memory descriptor into at most three instead of at
> most two, since it is logic I don't think would be readily exercised. Given that
> we're talking about calling this function given knowledge of the MemoryMap,
> and that the MemoryMap should be condensed to not have separate
> memory descriptors that could be coalesced, I think the limitation that
> NumPages fits within the single descriptor is reasonable.
> 
> All this being said, what's the value of combining the protocols? One fewer
> header and guid? I honestly don't know since I haven't been around long
> enough to understand how these kinds of things evolve and create possible
> warts.
> 
> If it's just two two things though, I think a header and guid are worth
> avoiding confusion by exposing AcceptMemory unnecessarily.
> 
> > > -----Original Message-----
> > > From: Xu, Min M <min.m.xu@intel.com>
> > > Sent: Monday, October 10, 2022 11:08 AM
> > > To: devel@edk2.groups.io; Dionna Amalie Glaze
> > > <dionnaglaze@google.com>; Gao, Liming <gaoliming@byosoft.com.cn>
> > > Cc: Gao, Zhichao <zhichao.gao@intel.com>; Ni, Ray
> > > <ray.ni@intel.com>; Aktas, Erdem <erdemaktas@google.com>; 'Gerd
> Hoffmann'
> > > <kraxel@redhat.com>; 'James Bottomley' <jejb@linux.ibm.com>; Yao,
> > > Jiewen <jiewen.yao@intel.com>; 'Tom Lendacky'
> > > <thomas.lendacky@amd.com>; Gao, Jiaqi <jiaqi.gao@intel.com>; Wang,
> > > Jian J <jian.j.wang@intel.com>; Liu, Zhiguang
> > > <zhiguang.liu@intel.com>; Kinney, Michael D
> > > <michael.d.kinney@intel.com>; Xu, Min M <min.m.xu@intel.com>
> > > Subject: RE: [edk2-devel] 回复: [PATCH V4 00/10] Introduce Lazy-accept
> > > for Tdx guest
> > >
> > > On October 10, 2022 10:28 AM, Gao Liming wrote:
> > > >
> > > > Min:
> > > >   I have no comments for new unaccepted resource type and
> > > > unaccepted
> > > gcd
> > > > type. In fact, they are mapping to UEFI EfiUnacceptedMemoryType.
> > > >
> > > >   For new protocol EfiMemoryAcceptProtocol, I see another patch
> > > > serial
> > > > https://edk2.groups.io/g/devel/message/94763 base on it to
> > > > introduce ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL. Can these
> two
> > > protocols
> > > > be combined into one?
> > > >
> > > EfiMemoryAcceptProtocol looks like this:
> > > typedef
> > > EFI_STATUS
> > > (EFIAPI *EDKII_ACCEPT_MEMORY)(
> > >   IN  EDKII_MEMORY_ACCEPT_PROTOCOL  *This,
> > >   IN  EFI_PHYSICAL_ADDRESS                          StartAddress,
> > >   IN  UINTN                                                         Size
> > >   );
> > > This protocol is called to accept the memory based on the input
> > > start address and size.
> > >
> > > While ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL looks like below:
> > > typedef
> > > EFI_STATUS
> > > (EFIAPI *BZ3987_DISABLE_ACCEPT_ALL_UNACCEPTED_MEMORY)(
> > >   IN  BZ3987_ACCEPT_ALL_UNACCEPTED_MEMORY_PROTOCOL  *This );
> > > According to its description
> > > (https://edk2.groups.io/g/devel/message/94768)
> > > this protocol is used to disable the behavior of accepting all
> > > unaccepted memory. And it is designed to be called by the OS loader, not
> EDK2 itself.
> > >
> > > I am afraid these 2 protocols cannot be combined into one.
> > >
> > > Dionna what's your thought?
> > >
> > > Thanks
> > > Min
> 
> 
> 
> --
> -Dionna Glaze, PhD (she/her)

  reply	other threads:[~2022-10-12  5:29 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13  0:02 [PATCH V4 00/10] Introduce Lazy-accept for Tdx guest Min Xu
2022-09-13  0:02 ` [PATCH V4 01/10] MdeModulePkg: Add PrePiHob.h Min Xu
2022-09-13  0:02 ` [PATCH V4 02/10] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Min Xu
2022-09-21  8:10   ` Gerd Hoffmann
2022-09-13  0:02 ` [PATCH V4 03/10] OvmfPkg: Use BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED defined in MdeModulePkg Min Xu
2022-09-13  0:02 ` [PATCH V4 04/10] MdePkg: Add UEFI Unaccepted memory definition Min Xu
2022-09-13  0:02 ` [PATCH V4 05/10] MdeModulePkg: Update Dxe to handle unaccepted memory type Min Xu
2022-09-13  0:02 ` [PATCH V4 06/10] ShellPkg: Update shell command memmap to show unaccepted memory Min Xu
2022-09-13  0:02 ` [PATCH V4 07/10] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Min Xu
2022-09-21  8:11   ` Gerd Hoffmann
2022-09-13  0:02 ` [PATCH V4 08/10] MdePkg: The prototype definition of EdkiiMemoryAcceptProtocol Min Xu
2022-09-13  0:02 ` [PATCH V4 09/10] OvmfPkg: Realize EdkiiMemoryAcceptProtocol in TdxDxe Min Xu
2022-09-13  0:02 ` [PATCH V4 10/10] OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages Min Xu
2022-09-22  5:25 ` [PATCH V4 00/10] Introduce Lazy-accept for Tdx guest Min Xu
2022-09-29  6:56   ` Min Xu
2022-10-10  2:27     ` 回复: " gaoliming
2022-10-10  3:08       ` [edk2-devel] " Min Xu
2022-10-10  3:18         ` Ni, Ray
2022-10-10 15:50           ` Dionna Glaze
2022-10-12  5:29             ` Min Xu [this message]
2022-10-13  5:27               ` Dionna Glaze
2022-10-18  1:13       ` Min Xu
2022-10-19  1:17         ` 回复: " gaoliming
2022-10-19  2:02           ` Min Xu
2022-10-21 15:58             ` Dionna Glaze
2022-10-25  1:07               ` Min Xu
2022-10-26  1:27                 ` 回复: " gaoliming
2022-10-26 13:35                   ` Min Xu
2022-11-01  1:18                     ` 回复: " gaoliming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH0PR11MB50641BDCEABA0F7646068D5EC5229@PH0PR11MB5064.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox