From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.57.1655262451059805627 for ; Tue, 14 Jun 2022 20:07:31 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=n6Wo1OwJ; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655262451; x=1686798451; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=jsrdoefOUsPhjUw6zxrNVU715NzgIT5/Igg/+YvdvSg=; b=n6Wo1OwJOi7crwwsK11hKpERu9BHkMP4SAM4djJkNF9gIgxzwopSpJqu q7hJLqhiJo25w0d7LYWiZjbx0gZf6LXiVpVY8wjMNuEkmwdZP0gPrayhE 7xbIBD+dPH+qg/9sST8+mHda5SY9jfO2o9YPI10Jj/ZuaBe+PnmvKrmNg yuekxZGyFGuO+EZ9qfSrgSSOWpxBIrOTuLP4rFY46w11iiOUhWPKFCrml pZisTQqY0c/KVikEKcrjpE/IU1vcsWNTZ/4h/lbsw53JzEODG1p/QwinH O4eI1/Vfck30DuP9oKjPQI0ZrPbRAPaRsDHAQNRUFKXk/FHrzECm/hoWd Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="276386891" X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="276386891" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2022 20:07:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="588846277" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga007.fm.intel.com with ESMTP; 14 Jun 2022 20:07:28 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 14 Jun 2022 20:07:28 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 14 Jun 2022 20:07:27 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 14 Jun 2022 20:07:27 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.102) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 14 Jun 2022 20:07:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R98vRAhXDomYQs4T3Gm7kHvlv7Za+sixi0oaP0W539+1XXjND+epTfcSUp1OCONRYnfvHu48dn0u2JnqfgVZATlL6YFUi6ajwJTQ+C/PvmWdZ/EFm+lU/4YEtg1el3I0aB/2Wg9doDaI8WA3o+FsYhFky84L/mnk4d05cgj9QrBjiRXOb/NsgJgDIUQdbDE7Tg5mIq6KehbIcpCTUM5Bq+HLkqmZWhVmGbI26f8gyS9qKS59la5ML5k1vxTBYGyTMnj3RajYFy2JuqBSvVQ2Q9J0HZc9jSRP+mCfxDthe/UGlea4pLrUSqjCeYxsO+bUhWXvd33w8gzhsL3Bh8lYFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vtwL386On7G+rQaYZcbJqMidStaNedUgijdWSMB1cJ4=; b=dl6F4xHs6XaxESv3/adTRIi2Fbd9TrW1GAObq5qK2ty6NWzes4ozT5f/BmOM6/JB/+52rMzL8rR4n/FE+GcUeaDfKza8IR7nW+xbWHIr6xGRZlDOVa+qyPpW7LpU/1GS7Ud/FiacYvi7eyW71ZRSGhhiRMGjY2sLWYdOEA63nWCwvW8yAxLTO2esTBby5YBHL30hK1t2K5SCAGB9W1wchP955OcQPQ9pIGwYCOeqhyarRBdAnpKe9lKMwOF4cq5HLqVULip16SymdXLg+uzu2mwJgNwjAZYx4NgtvfDqtQaOhF8+VUvIGelXUfcHjUA76ATgnuLfYmteonFS2KvK2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH0PR11MB5064.namprd11.prod.outlook.com (2603:10b6:510:3b::15) by DM5PR11MB1244.namprd11.prod.outlook.com (2603:10b6:3:13::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.15; Wed, 15 Jun 2022 03:07:25 +0000 Received: from PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::a0ea:2e53:9c0e:9148]) by PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::a0ea:2e53:9c0e:9148%4]) with mapi id 15.20.5332.022; Wed, 15 Jun 2022 03:07:24 +0000 From: "Min Xu" To: Gerd Hoffmann CC: "devel@edk2.groups.io" , "Aktas, Erdem" , James Bottomley , "Yao, Jiewen" , Tom Lendacky , Dionna Glaze , "Xu, Min M" Subject: Re: [PATCH 07/14] OvmfPkg: Add PCD and DEFINEs for Lazy Accept page. Thread-Topic: [PATCH 07/14] OvmfPkg: Add PCD and DEFINEs for Lazy Accept page. Thread-Index: AQHYeVGn1O1IU1nzYUeJHNsKK6qAgK1DxN0AgADefwCAAGkHgIAKk93w Date: Wed, 15 Jun 2022 03:07:24 +0000 Message-ID: References: <20220607104550.hz6c7etgxtksylwu@sirius.home.kraxel.org> <20220608061805.vvsjiqt55rqnl3fw@sirius.home.kraxel.org> In-Reply-To: <20220608061805.vvsjiqt55rqnl3fw@sirius.home.kraxel.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9b2686f7-7c2a-4615-b3d8-08da4e7c2c1c x-ms-traffictypediagnostic: DM5PR11MB1244:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: j7HcjiATqbADSWuHCa9zRtnomEWp/WZ1XHQOq58dbN6nV2qLN3ljIS7VoSTOLat5hpNzfRaf7IOnWZ0utDkMCpYDA7FUC4Ii5Lc3Fe12pgiCn31S/dTMPpU+jDMk9yXnc/MZpUhALqGnxE3FL0UpwYJbmsbyWycdp7Kvw4D/EjGoaz88KsZOEAOotbLsoSPMwxIu6QYF86OR0o3jtLHj461pyePMvBcGN2YukMADrfedC7qMP2i+ClCMbC9BV+T8B2xLLzSjRyCVnaLk5WceobSjtwcne2V43fq0LTNLFKJZWGpjpZ17dRAhRJviTSW6td1CEz83gY4n9Uf4TVEHvZikOro7P/vqz7DjSHiXQ7QiUopdVOEYsSQoqsn6Bur1fs1DhPiP2x23zu9y1F+8u0bc+bMUp0ZgZd9Ci/0k00YfsSpxteYAlYN5zZojdKFWxSuAUo2deWuh4XgzY0DOSPYA6hKOONWWfOKbCKm+eD/KjTKxRyKgJV54mgH/er/hfHJBfxD/rxG8T2MlZrr0rgANvwQqfB9rumDYeeEID7lGG4rty2T731NaDQNGSZyfUt8bordiFhUdwlru3ofu+9nQcizXJ4Nj0Zgi6IWzQSLbToUXmJwXLRBbmfVhJDXqKhHdwRhYZFtBUOOZCgl0yPUEWn8p/r55rieVury9rHLpHs07XKBAGVmnKmARXNiKwMJO0CnBQ1lcZnHP4A7y/d1SkD/HU5J+AGiO0xWZSku3iEkn9VIK3RyOImnUpzn5WEOVJQB9IBNEgW7HS269GMLQ0dsdcUhCst4fPAM9uiU0nr5lYhszV4LfJsmR+aS7 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB5064.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(366004)(5660300002)(83380400001)(186003)(76116006)(66946007)(64756008)(52536014)(316002)(66446008)(8676002)(38100700002)(8936002)(107886003)(55016003)(66476007)(4326008)(66556008)(7696005)(71200400001)(2906002)(82960400001)(26005)(6506007)(122000001)(86362001)(38070700005)(508600001)(9686003)(33656002)(966005)(54906003)(6916009)(134034003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?kEIO371IOngzytbqK0KozD5gKTw3zyptPNJ3gPr28aESPayXcqZrOkZS3jVQ?= =?us-ascii?Q?WzsG1wnx/n/0oXxELZnBURTf3RaXDBSImIA0lS0QYdBH9IGco7xPUKU8a4hw?= =?us-ascii?Q?OXI0KZs1uI3Yg6L9w8m0Yg5fJQYxlkMmSiztZ8gy61MHbMBSf1lhGUOd4TM4?= =?us-ascii?Q?0SIMO2eQ1AJMQ5au0NslSW2phXJ+MuwuyPkDOtI/ipz610tmn13LfyyqkE2I?= =?us-ascii?Q?3uDW6JXMGMwN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zyDUEb6qgTW6jAxyovY/DIYa2D?= =?us-ascii?Q?lRuINsKtDPWVxqB9T7WThkXgMsl7IZv3Pp8UmvRK4s+BDcyZu55sLgjwYKVo?= =?us-ascii?Q?fT0uLB6wTrayeo/TjhjQ98stp3fBKyofzdVFRbOT1ZDOg/0CJ5SVXuUpM3TX?= =?us-ascii?Q?bBPsK9cWjrE8HgAqxmEceyOe6+sEpqN2eWSp3tvm6no+20NjPxQQ3OCzAdDE?= =?us-ascii?Q?x7+D2S5bkcPy1V8O0mJ30Cc55I0GcvJ0gxLbZOs+/eSBxpEz5/Aboagew1O+?= =?us-ascii?Q?qoZTO4dW3BnrNEm7J7oCk3JWF97/LIJB0+huo4JBbWPCxKONY/C4Yrvrp4Yy?= =?us-ascii?Q?Al5p+JOMVb/VOIgLDMy/+5SX5WXiH9f3eRS0KH4n4ttXd0jpeINByCtI6MeJ?= =?us-ascii?Q?fBfvRTAx/+Voz1VuihdcAWtNuEIkiR+AqYX2Ga4wfm39HctfWZfoyWO1POAs?= =?us-ascii?Q?UO0g7FwvbqEjPK+/n/n+0Ekejfs8FvA28F83qydsxFetKv6+ZtQNxyb4yUZD?= =?us-ascii?Q?HXCSCx2EOzjzMmgJ/uiYOBqF6A3aywdtxJRj4H5hlFL2GdxIMpPkesGWEVmv?= =?us-ascii?Q?m9vmMLUQiXuf2mBZevyDDNbVyWqY3PzoUGQJy69IhpsIVtsupMk8WJR5hUmL?= =?us-ascii?Q?zsWMxs9tpg=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5064.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b2686f7-7c2a-4615-b3d8-08da4e7c2c1c X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jun 2022 03:07:24.9024 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: +UZAH53cZvAE4MBZ648keV9xe6E93c/xQ545PUhTXCbpwjtq87Ou6KKKx9p7jGCnfni5r5lFHjObFiWp7MWZuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1244 Return-Path: min.m.xu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 > > > > > > > > RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 > > > > > > > > Lazy accept page can be controlled in build time like below: > > > > -D LAZY_ACCEPT_PARTIAL_MEM=3D512 > > > > > > > > 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? >=20 > > 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. >=20 > 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 i= s used to control this feature. IntelTdxX64 is a newly added pkg and it hasn't been widely used. So it is l= ow risk to enable the lazy-accept by default. But OvmfPkgX64 is more general. So at the first stage I think it may be bet= ter to disable lazy-accept by default. If someone understand what lazy-acce= pt is and what guest os should be used, then he can enable lazy-accept in O= vmfPkgX64 by adding the compile time option. Dionna Glaze has proposed a new fw_cfg to control the lazy-accept. >=20 > With the edk2 memory management code being able to handle unaccepted > memory I just don't see the point in supporting different options in earl= y > 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 in= stall EfiMemoryAcceptProtocol TdxDxe driver. 512MB is more memories needed = by DXE.=20 That is because: Tdx guest now accepts memory in 2MB page size. Accepting 5= 12MB is not much slower than accepting 96MB. And 512MB memory can satisfy m= ost of the usage scenarios without accepting more memories later on demand. Of course other architecture CPUs can have their own implementation.=20 >=20 > > > Also what exactly does this option mean? Is this the minimum amount > > > of memory accepted by the firmware? >=20 > > 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. >=20 > 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 memo= ries later. And it has no serious performance impact. >=20 > 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 wa= y > 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/ Q= emuFwCfgItemInitrdSize/QemuFwCfgItemKernelSetupSize. So I am thinking we ca= n calculate the minimum size of accepted memory (PEI/DXE/KernelSize/InitrdS= ize/KernelSetupSize) before it jumps to OS. If we can calculate the minimu= m memory size before jumping to OS, does it mean the on-demand accept is no= t needed? Actually I am not conformable to change code of AllocatePages/All= ocatePools. What's your thought? >=20 > For guests which don't support lazy accept we could offer a (runtime) opt= ion > to simply accept all memory in ExitBootServices. What is the runtime option? Some new fw_cfg? Thanks Min