From: "Min Xu" <min.m.xu@intel.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"Aktas, Erdem" <erdemaktas@google.com>,
James Bottomley <jejb@linux.ibm.com>,
"Yao, Jiewen" <jiewen.yao@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Dionna Glaze <dionnaglaze@google.com>,
"Xu, Min M" <min.m.xu@intel.com>
Subject: Re: [PATCH 07/14] OvmfPkg: Add PCD and DEFINEs for Lazy Accept page.
Date: Wed, 15 Jun 2022 03:07:24 +0000 [thread overview]
Message-ID: <PH0PR11MB5064B88B2FEFF6042175629EC5AD9@PH0PR11MB5064.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220608061805.vvsjiqt55rqnl3fw@sirius.home.kraxel.org>
On June 8, 2022 2:18 PM, Gerd Hoffmann wrote:
> On Wed, Jun 08, 2022 at 12:06:28AM +0000, Xu, Min M wrote:
> > On June 7, 2022 6:46 PM, Gerd Hoffmann wrote:
> > > On Mon, Jun 06, 2022 at 10:59:55AM +0800, Min Xu wrote:
> > > > From: Min M Xu <min.m.xu@intel.com>
> > > >
> > > > RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3937
> > > >
> > > > Lazy accept page can be controlled in build time like below:
> > > > -D LAZY_ACCEPT_PARTIAL_MEM=512
> > > >
> > > > The unit is MB. If it is 0 then it means Lazy-accept is turned off.
> > > >
> > > > Lazy-accept is turned off by default in OvmfPkgX64.
> > > > Lazy-accept is turned on with 512MB by default in IntelTdxX64.
> > >
> > > Care to explain? What is the point in not using lazy accept in
> OvmfPkgX64?
>
> > It's an Open to the community that if lazy accept should be enabled in
> > OvmfPkgX64. I would like to hear the suggestions/comments from you
> > guys. So as the first step, it is disabled.
>
> I think OvmfPkgX64 and IntelTdxX64 configuration should be identical, and
> I'm wondering whenever this should be a compile time option in the first
> place. Can we simply use lazy accept unconditionally?
Not all the guest OS support lazy accept. That's why there is a PCD which is used to control this feature.
IntelTdxX64 is a newly added pkg and it hasn't been widely used. So it is low risk to enable the lazy-accept by default.
But OvmfPkgX64 is more general. So at the first stage I think it may be better to disable lazy-accept by default. If someone understand what lazy-accept is and what guest os should be used, then he can enable lazy-accept in OvmfPkgX64 by adding the compile time option.
Dionna Glaze has proposed a new fw_cfg to control the lazy-accept.
>
> With the edk2 memory management code being able to handle unaccepted
> memory I just don't see the point in supporting different options in early
> firmware setup. I think sec/pei should accept the memory needed to run
> dxe and not more. Anything beyond that can be accepted later on demand
> via TdxDxe.
In current implementation by Tdx guest, we accept 512MB in SEC phase and install EfiMemoryAcceptProtocol TdxDxe driver. 512MB is more memories needed by DXE.
That is because: Tdx guest now accepts memory in 2MB page size. Accepting 512MB is not much slower than accepting 96MB. And 512MB memory can satisfy most of the usage scenarios without accepting more memories later on demand.
Of course other architecture CPUs can have their own implementation.
>
> > > Also what exactly does this option mean? Is this the minimum amount
> > > of memory accepted by the firmware?
>
> > Yes, this option defines the minimum amount of memory accepted by the
> > firmware. For example, if it is 512MB, then there will be such amount
> > memory accepted by the firmware before jump to OS.
>
> Where does the 512MB figure come from?
512MB is an experiment value. It includes the minimum DXE memories (~96MB) and the memories to load a normal kernel-image/initrd. In our internal test, 512MB can satisfy most of the usage scenarios without accepting more memories later. And it has no serious performance impact.
>
> Using a fixed amount of memory doesn't look very robust to me. Is it
> possible to accept memory when the guest calls ExitBootServices? That way
> we could guarantee a minimum amount of *free* accepted memory being
> available, to make sure the linux kernel has enough memory to decompress
> itself, allocate memory management data structures and get its own lazy
> accept support going.
With the help of fw_cfg, we can know the size of QemuFwCfgItemKernelSize/ QemuFwCfgItemInitrdSize/QemuFwCfgItemKernelSetupSize. So I am thinking we can calculate the minimum size of accepted memory (PEI/DXE/KernelSize/InitrdSize/KernelSetupSize) before it jumps to OS. If we can calculate the minimum memory size before jumping to OS, does it mean the on-demand accept is not needed? Actually I am not conformable to change code of AllocatePages/AllocatePools.
What's your thought?
>
> For guests which don't support lazy accept we could offer a (runtime) option
> to simply accept all memory in ExitBootServices.
What is the runtime option? Some new fw_cfg?
Thanks
Min
next prev parent reply other threads:[~2022-06-15 3:07 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 2:59 [PATCH 00/14] Introduce Lazy-accept for Tdx guest Min Xu
2022-06-06 2:59 ` [PATCH 01/14] MdeModulePkg: Add PrePiHob.h Min Xu
2022-06-06 2:59 ` [PATCH 02/14] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Min Xu
2022-06-06 3:23 ` Yao, Jiewen
2022-06-07 10:39 ` Gerd Hoffmann
2022-06-08 0:02 ` [edk2-devel] " Min Xu
2022-06-06 2:59 ` [PATCH 03/14] OvmfPkg: Use EFI_RESOURCE_MEMORY_UNACCEPTED which defined in MdeModulePkg Min Xu
2022-06-06 2:59 ` [PATCH 04/14] MdePkg: Add UEFI Unaccepted memory definition Min Xu
2022-06-06 3:23 ` Yao, Jiewen
[not found] ` <004301d87ec6$72e53d00$58afb700$@byosoft.com.cn>
2022-06-15 5:39 ` Min Xu
2022-06-06 2:59 ` [PATCH 05/14] MdeModulePkg: Update Dxe to handle unaccepted memory type Min Xu
[not found] ` <005601d87ec8$7f6f7700$7e4e6500$@byosoft.com.cn>
2022-06-15 6:18 ` [edk2-devel] " Min Xu
2022-06-06 2:59 ` [PATCH 06/14] ShellPkg: Update shell command memmap to show unaccepted memory Min Xu
2022-06-06 3:01 ` Ni, Ray
2022-06-06 3:19 ` Min Xu
2022-06-06 2:59 ` [PATCH 07/14] OvmfPkg: Add PCD and DEFINEs for Lazy Accept page Min Xu
2022-06-07 10:45 ` Gerd Hoffmann
2022-06-08 0:06 ` Min Xu
2022-06-08 6:18 ` Gerd Hoffmann
2022-06-15 3:07 ` Min Xu [this message]
2022-06-15 8:05 ` Gerd Hoffmann
2022-06-15 20:51 ` Dionna Glaze
2022-06-16 0:05 ` [edk2-devel] " Min Xu
2022-06-16 5:51 ` Gerd Hoffmann
2022-06-16 7:33 ` Min Xu
2022-06-16 13:09 ` Lendacky, Thomas
2022-06-16 16:44 ` Dionna Glaze
2022-06-16 18:33 ` Lendacky, Thomas
2022-06-16 23:47 ` Dionna Glaze
2022-06-14 16:10 ` Dionna Glaze
2022-06-15 3:08 ` Min Xu
2022-06-06 2:59 ` [PATCH 08/14] OvmfPkg: Use PcdOvmfWorkAreaBase instead of PcdSevEsWorkAreaBase Min Xu
2022-06-07 10:48 ` Gerd Hoffmann
2022-06-08 0:08 ` Min Xu
2022-06-06 2:59 ` [PATCH 09/14] OvmfPkg: Add MaxAcceptedMemoryAddress in TDX work area Min Xu
2022-06-06 2:59 ` [PATCH 10/14] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Min Xu
2022-06-06 2:59 ` [PATCH 11/14] OvmfPkg: Update ConstructFwHobList for lazy accept Min Xu
2022-06-06 3:00 ` [PATCH 12/14] MdePkg: The prototype definition of EfiMemoryAcceptProtocol Min Xu
2022-06-06 3:22 ` Yao, Jiewen
2022-06-08 0:49 ` Min Xu
2022-06-06 3:00 ` [PATCH 13/14] OvmfPkg: Realize EfiMemoryAcceptProtocol in TdxDxe Min Xu
2022-06-06 3:00 ` [PATCH 14/14] MdeModulePkg: Pool and page functions accept memory when OOM occurs Min Xu
2022-08-11 3:17 ` [PATCH 00/14] Introduce Lazy-accept for Tdx guest Min Xu
2022-08-16 6:47 ` Gerd Hoffmann
2022-09-22 20:29 ` Dionna Glaze
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=PH0PR11MB5064B88B2FEFF6042175629EC5AD9@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