From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web12.4051.1667293220350665399 for ; Tue, 01 Nov 2022 02:00:20 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=d68Il0Km; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667293220; x=1698829220; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=h5QAFrM6MW9SboGRFnW5CSqAaZka9d85ren/ooLQ+Wk=; b=d68Il0KmGOM5UQoPyVByMtWPKXIXo8mFg4nWP2DTEUC3QRHwo3Brmjb+ v2ZIbob6Ea+0jT8bhl+qF4MWtUBG2fyLYpSnCnMGXM/7SA80pQPeeEYt8 hrJyJabnEk0a03es/vOKndVJYuE6P1B1ew42zS+Gn+aYlzC+vdV0tCigR WC+PlhEsVIAC1CSKmBQ9X6KTnrPr+/yHYiMzqR+mGhVWec0KWYBR6Jg8m Xf6q9axjp5/GPTaw7Y0DWMtOVvQm/+9oD08ZXWa8Z13SM+zre2WmYCN38 z9c8EOPuesPYygByCycVsr+VWGJ+ZDTp1sKEiyhZcfi40t0JvEjuEq1ez A==; X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="335760640" X-IronPort-AV: E=Sophos;i="5.95,230,1661842800"; d="scan'208";a="335760640" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2022 02:00:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="723100819" X-IronPort-AV: E=Sophos;i="5.95,230,1661842800"; d="scan'208";a="723100819" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by FMSMGA003.fm.intel.com with ESMTP; 01 Nov 2022 02:00:19 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 1 Nov 2022 02:00:19 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 1 Nov 2022 02:00:18 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 1 Nov 2022 02:00:18 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.108) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 1 Nov 2022 02:00:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nx3gjw0jyVabgXzxBZGAPBwXZICRk+1D8BU4Emhq3N89pyM1E5VqlK1MeBEQ3sMw3fGSukbOfdIdP/Jw1G1OB5xGf5Xcas18K+ymQO3zTCrszkous7iFiukOtGTYYLNIo4zZZT1BVfnj+UYAtuaF3sa3G1ph8+iwc6yIZ0ja+Qb/O1unFzoIp2VuQHoGOpmJERcszBICnT7B3hI8qgpSmX0J/HXSHlcvI8QoC2X/KdSgI+0zEpHc5mTMkgDqp5kn8leQVZw6eon0hddGzQjCXjmnYyeM51WxklTUaIQtaav5qjSQpYy07X4Sz7XzWDbYzlEIqhJ2gkBouomsf3xsVw== 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=7ethreKC5yCsnjNFdzeChJlG8CGamvRlW1N8n697d80=; b=Xgp80k1wXZy4JHyq874eXEiCIlukccmEvIO7buMtQC7d31ytxUQONOTFonkS6iBfV4nYXrHoOYoLkinEIasGLai8bHhaA4ehwzoDotMWemdEUMwlpwEniYHjyX/BJY2XMbyy6s1iwR3NLeTL1hOc4WDmryxdPG2qnOyTTsoyNTohZ3tpDtchNGX4qJ7Y5p4VOrd1GK1pLxMAwf0TyTlamgoVgsTFGhRuyMM/pjvvPLlfory/aqBEbffxc5PzuNc90QyXh8WWSK1fabOCmPU/WKkED9jeH5nR90147mOCoF0LcFxyvRmXxQffj78F1K7oG8GFUFA4jcMBUI8npchnrg== 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 MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by MW4PR11MB7053.namprd11.prod.outlook.com (2603:10b6:303:21a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Tue, 1 Nov 2022 09:00:17 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::8a27:e262:8996:473]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::8a27:e262:8996:473%9]) with mapi id 15.20.5723.033; Tue, 1 Nov 2022 09:00:17 +0000 From: "Yao, Jiewen" To: "Xu, Min M" , "devel@edk2.groups.io" CC: "Gao, Zhichao" , "Kinney, Michael D" , "Liu, Zhiguang" , "Wang, Jian J" , "Gao, Liming" , "Ni, Ray" , "Aktas, Erdem" , Gerd Hoffmann , James Bottomley , Tom Lendacky , "Gao, Jiaqi" Subject: Re: [PATCH V5 00/10] Introduce Lazy-accept for Tdx guest Thread-Topic: [PATCH V5 00/10] Introduce Lazy-accept for Tdx guest Thread-Index: AQHY7bDGRrK1pzRgiUejKQEd1QgfoK4pxTXg Date: Tue, 1 Nov 2022 09:00:16 +0000 Message-ID: References: <20221101051349.13-1-min.m.xu@intel.com> In-Reply-To: <20221101051349.13-1-min.m.xu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB5872:EE_|MW4PR11MB7053:EE_ x-ms-office365-filtering-correlation-id: 76dd7a25-11ac-45e1-9d00-08dabbe77f15 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: t/LnSvM/0PSRti2lnNzwEEUksIbrpTDcvlU2fkU7lDcJJq6qSlOPo1JKJ+rP2CzJkJD4k5uF6gpKD4BH0JACBgEXhHrRHI0RT1I6+RP0aW7kyEMqDeewoDJNfApFnAlM82Eu3GP2Bd3DTjs0hdgfohAwIKGbEfikooIeArEO943LAckNj6Bw+aei9iWYqo4ZGPQmm3y465EvlbuTFAqhlxXQMDbz8jGN2d16tB1o/4WfmzCMTnKxsMwHlX7Q7nVJ1LNh7TOw90FJGzwFdxWjBJplQJE+O/ceRPP7tTwwmuc0JtUqytijGTZBkOTo0WJJGMojSMfPQ+uwuVr8fwIhwn6CmOan4evtoJfHqiWq+AcMNWcnTA95GG4otlorlslqN27Yr80HWQJZcFZ5Rkq5fD5G14YiCYHTKfimi5Zos1WCpaG/xrs3KbfKu/aCZOTOmZ+ypTunV//J2GC0i0HzesVxnDLgy32KO7b8GFJJahHljQkC64P4x+Npq029j/kw/JrjQswsbBFE/8OcajXXpTLmLQhGU+j7q3AGn6CpSaGu/CHEpKssaUKWUQWHHveer+3bhSq1CV4PRmjgwhxzPojW/ZtUypr8S2Tf6Fk4uZbZYyKzPXintRUl7fcdtVbVAJ4yPeEk8mp6fkURVxFMLO89EjJGZaT/2ej71/XNB68LkQ9hMbbHzTnBElFE3+FutJutjdz1e91N8US5508Ru77nB2x267SrW3YctY/Lu4GRYyFWJ0CxzbpsjMxeFdxMTk90/48xBMzZKif3Kfq4a4iKrJWV28bYUz32m9RyEi9k6JAGLkTxhAiZY960JMRCWBSdWTPhNFm11g/BiKDBqw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(396003)(376002)(39860400002)(366004)(346002)(451199015)(52536014)(5660300002)(8936002)(9686003)(41300700001)(26005)(122000001)(82960400001)(38100700002)(38070700005)(86362001)(2906002)(186003)(33656002)(83380400001)(478600001)(71200400001)(55016003)(966005)(110136005)(54906003)(316002)(107886003)(19627235002)(53546011)(7696005)(6506007)(66946007)(8676002)(4326008)(64756008)(66556008)(66446008)(66476007)(76116006);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?t4UpvUmHhd5ChJ2curSm07Zw9EiIxjSODFwk9ZCoA6Grf41zeU1ll3ZxqGRX?= =?us-ascii?Q?qN1NoSPTbioGySzaq5iSycUYX4hP9D+DAz1N+UO4TdTxrCkDIpb/T+S0N/c3?= =?us-ascii?Q?t58j/+vWX1iO/xyx26grgyufGkn3AjzXiBjX1rN3hWWJA2pnBZ1bcVguP6gi?= =?us-ascii?Q?UxRisUHCOaF+3Z3y+ZdlLo1YZaOTvjU9MQmOpcMI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0SoLKcIbm3Uzx8cWWFHhPB0aNSwFQYoxy1C1O86rt9zUXCt?= =?us-ascii?Q?c9oiC+Y9HoAGf3rXWc/p8RJXGBMD9kVNjrmHhhwKB6sgOFaJlRW0RA6Gb4k9?= =?us-ascii?Q?d/n4x5CJPDPA9LQrOjLsHWKL76YBToedKByDyKQKwvM8er4sIozf7KjP7V/z?= =?us-ascii?Q?7/6iz4Vist/dJNaOq1mdwsMAeAeIKIZoGR6am4cw/dT6ttfuXyjAmyfzc3yV?= =?us-ascii?Q?/G0zY9fjuyPYj2Lmp3ZoLOaBJlzawwFdBhgtVniqSof505n9BSCJYtiHlSFp?= =?us-ascii?Q?6rREX8+9HLLNjfepcOYqtw7Q43RwnULT+akyoMSgU8c9XqZ6f3GechXA0OxX?= =?us-ascii?Q?WVn2FXnVzH9TiFoi3cbD4duY+EMLx55wfufSLcQIk0SvsQZEQmw6jyHutk5N?= =?us-ascii?Q?/WYkU3c+BrSf/euTZPh8YCA8+nS24eij/P00G+JhY+fwPCuXLtAP72Tmwdjn?= =?us-ascii?Q?caw8xGokhh1gqt/Vf/yQJlAt+bWsuwUWZjJHxJ83?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76dd7a25-11ac-45e1-9d00-08dabbe77f15 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2022 09:00:17.0152 (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: fDOtpFAaiO8v1giwx5sowDxV5BEoj5iVdDO27SXlID6xRMbQPsOHsHSmrJpIrBnzS8JcRKMTQdTpxa6TMcHpvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB7053 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable For OvmfPkg, reviewed-by: Jiewen Yao > -----Original Message----- > From: Xu, Min M > Sent: Tuesday, November 1, 2022 1:14 PM > To: devel@edk2.groups.io > Cc: Xu, Min M ; Gao, Zhichao > ; Kinney, Michael D > ; Liu, Zhiguang ; > Wang, Jian J ; Gao, Liming > ; Ni, Ray ; Aktas, Erdem > ; Gerd Hoffmann ; James > Bottomley ; Yao, Jiewen ; > Tom Lendacky ; Gao, Jiaqi > > Subject: [PATCH V5 00/10] Introduce Lazy-accept for Tdx guest >=20 > RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3937 >=20 > UnacceptedMemory is one of the four defined types of TD memory in Intel > TDX guest. TDVF must invoke TDCALL [TDG.MEM.PAGE.ACCEPT] the > unaccepted > memory before use it. See [TDVF] Section 7.1. > TDVF: https://www.intel.com/content/dam/develop/external/us/en/ > documents/tdx-virtual-firmware-design-guide-rev-1.01.pdf >=20 > It is a time-consuming task which impacts the boot performance badly. > One of the mitigation is the lazy-accept mechanism. That the whole system > memory is divided into 2 parts, one is accepted in bios phase, the other > is tagged as EfiGcdMemoryTypeUnaccepted and OS will handle these > "unaccepted" memories. > See "UEFI Spec v2.9 Table 7-5 Memory Type Usage before > ExitBootServices()" >=20 > As the first stage we accept all the memory under 4G. Please see the > discussion in https://edk2.groups.io/g/devel/message/93086 >=20 > This patch-set is related to code first, so there is a edk2-staging branc= h. > Please see https://github.com/tianocore/edk2-staging/tree/TDVF >=20 > Patch 1-4: > Introduce lazy-accept related definitions. >=20 > Patch 5-6: > Update Dxe and shell for unaccepted memory. >=20 > Patch 7: > Update OvmfPkg for unaccepted memory. >=20 > Patch 8 - 10: > Introduce EfiMemoryAcceptProtocol and realize it in TdxDxe. >=20 > Code: https://github.com/mxu9/edk2/tree/lazyaccept.v5 >=20 > v5 changes: > - Rebase the patch-set to commit df7ce74e6c75. > - Add reviewed-by in MdeModulePkg/MdePkg related patches(#1/2/4/5/8). > - Add acked-by in patch#7. >=20 > v4 changes: > - To follow the name convention of EDKII code first, the name of > EFI_RESOURCE_MEMORY_UNACCEPTED is updated to > BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED. > - Remove the definition of MaxAcceptedMemoryAddress because in > current > stage we will accept all the memory under 4G. So > MaxAcceptedMemoryAddress is not useable in this assumption. > - Because this is related to code first, there is edk2-staging branch. > The branch link is attached. > https://github.com/tianocore/edk2-staging/tree/TDVF >=20 > v3 changes: > - As the first stage we accept all the memory under 4G. See the > discussion in https://edk2.groups.io/g/devel/message/93086 > - "Pool and page functions accept memory when OOM occurs" is dropped. > See the discussion in https://edk2.groups.io/g/devel/message/93086 > - PlatformAdjustSystemMemorySizeBelow4gbForLazyAccep is deleted > because in current stage we accept all the memory under 4G. >=20 > v2 changes: > - Fix a typo that change EfiUnacceptedMemory to > EfiUnacceptedMemoryType. > - Define EFI_GCD_MEMORY_TYPE_UNACCEPTED in PrePiDxeCis.h because it > has > not been defined in PI spec. > - AllocatePages should return EFI_INVALID_PARAMETERS if input > MemoryType > is EfiUnacceptedMemoryType. > - Use EDKII_ prefix instead of EFI_ prefix in the protocol name of > EDKII_MEMORY_ACCEPT_PROTOCOL_GUID. Because this protocol is not > EFI > defined. > - Accept memory under 4G even if the PcdLazyAcceptPartialMemorySize is > bigger than 4G. So with this setting, even if the > PcdLazyAcceptPartialMemorySize is 0 (which means to accept all > memories), only the memory under 4G will be accepted. This is to > optimize the performance. >=20 > Cc: Zhichao Gao > Cc: Michael D Kinney > Cc: Zhiguang Liu > Cc: Jian J Wang > Cc: Liming Gao > Cc: Ray Ni > Cc: Erdem Aktas > Cc: Gerd Hoffmann > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Tom Lendacky > Signed-off-by: Jiaqi Gao > Signed-off-by: Min Xu >=20 > Jiaqi Gao (1): > MdePkg: The prototype definition of EdkiiMemoryAcceptProtocol >=20 > Min M Xu (9): > MdeModulePkg: Add PrePiHob.h > MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE > OvmfPkg: Use BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED defined in > MdeModulePkg > MdePkg: Add UEFI Unaccepted memory definition > MdeModulePkg: Update Dxe to handle unaccepted memory type > ShellPkg: Update shell command memmap to show unaccepted memory > OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei > OvmfPkg: Realize EdkiiMemoryAcceptProtocol in TdxDxe > OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages >=20 > MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 6 + > MdeModulePkg/Core/Dxe/Mem/Page.c | 63 ++++++++--- > MdeModulePkg/Include/Pi/PrePiDxeCis.h | 25 +++++ > MdeModulePkg/Include/Pi/PrePiHob.h | 20 ++++ > MdePkg/Include/Pi/PiDxeCis.h | 10 +- > MdePkg/Include/Pi/PiHob.h | 11 +- > MdePkg/Include/Protocol/MemoryAccept.h | 37 +++++++ > MdePkg/Include/Uefi/UefiMultiPhase.h | 5 + > MdePkg/MdePkg.dec | 3 + > .../BaseMemEncryptTdxLib.inf | 3 + > .../BaseMemEncryptTdxLib/MemoryEncryption.c | 12 +- > OvmfPkg/Library/PeilessStartupLib/Hob.c | 5 +- > OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 98 ++++++++++++++--- > OvmfPkg/Library/PlatformInitLib/MemDetect.c | 2 + > OvmfPkg/TdxDxe/TdxDxe.c | 103 ++++++++++++++++++ > OvmfPkg/TdxDxe/TdxDxe.inf | 2 + > .../UefiShellDebug1CommandsLib/MemMap.c | 13 +++ > .../UefiShellDebug1CommandsLib.uni | 3 +- > 18 files changed, 381 insertions(+), 40 deletions(-) > create mode 100644 MdeModulePkg/Include/Pi/PrePiDxeCis.h > create mode 100644 MdeModulePkg/Include/Pi/PrePiHob.h > create mode 100644 MdePkg/Include/Protocol/MemoryAccept.h >=20 > -- > 2.29.2.windows.2