From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E5D54941442 for ; Fri, 4 Aug 2023 06:29:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=0WVxmVGLTR9vDtnQ2AO1u22JMANQJuOBEAD2Ohpe58c=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1691130566; v=1; b=vB8/CkcZ/4I0IIMfA2/dKF81Uduav5bw7zvjsrlOzufJCZCm5p5FbpAKNvTZWCjedSeYQZmz loT8DNokbmyokgxyqE1t3rjrudNAhakeNSy9vj+BOS8Q9uOwE1N3eZLYy5v2Txf7lIVhAo2xB9J OqhtCFXnmQ2fu+HHGidPeqeg= X-Received: by 127.0.0.2 with SMTP id heDCYY7687511xaGI29ngSil; Thu, 03 Aug 2023 23:29:26 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.5967.1691130566029745557 for ; Thu, 03 Aug 2023 23:29:26 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="368983634" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="368983634" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2023 23:29:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="843933213" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="843933213" X-Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga002.fm.intel.com with ESMTP; 03 Aug 2023 23:29:25 -0700 X-Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.2507.27; Thu, 3 Aug 2023 23:29:25 -0700 X-Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 3 Aug 2023 23:29:24 -0700 X-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.2507.27 via Frontend Transport; Thu, 3 Aug 2023 23:29:24 -0700 X-Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.48) 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.2507.27; Thu, 3 Aug 2023 23:29:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lykiJVCbSF0P/zTISIeXdK/1Xs68DZOJ+GYL6dp/0w7euUOHaDejtdUNusyr/sLPSJRlnZbsHBPxjzgTCA9KpduQJvzMpCU5OWl18pZS4o+4dc6A1Z9iEre1o66KUuZAqTbEVzRbNM5gddDW5ZFAmM83Epy/YNq05O950QOS7N2dEDouGR3DPaU4haMblcUhiZXyHJ1S3UZ5L1ZB513cOtH1FVz41zsievOKHBRG39XYmXI8ELWfCg8x1IWmD1duJjiwWdGGY0Frj+38VXYW65FLAcWh0NCgsInhWx/Fkvz3Sl/D+cB/1VFTspWrjejIILZZrqtXd0jKUN3Xq3oeuw== 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=6U+3ciO4WrFEWOuG3NmQrCumuhtDkZSlwrhq6yZIhmg=; b=iRiWvkPD5IwE0SwJiDgfr5MKQiFkoU1VIOaAIzuHFqQSPdRhpKkxSZFvXciDUW9tZ7WhIO0nxtq9kt1zVMTDQCeatGyh4GiFBKwR+P+kL1G8AvGfCrSqjZqT13K/kKkLwRB6Ad3AArjLqkcVmGUDJlaiyufETKprFcoPOaETcTGKUFrT1YoXcOt/FqPnen1XC66ZcjUac8EpA7EywuB2itDmhqZ59bfo6qMVuHebgVq8WtxOZfms6EeZv++skh1GNY6dR3AgFl567Zzm8A0KwTLX+h7IGR/BJ2DOCuh/GG/Wv2ShRk7ERl4LMYbBC5/X4UpbIsLYpekoHZS32Wtw4Q== 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 X-Received: from PH0PR11MB5064.namprd11.prod.outlook.com (2603:10b6:510:3b::15) by SJ0PR11MB5215.namprd11.prod.outlook.com (2603:10b6:a03:2d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.20; Fri, 4 Aug 2023 06:29:22 +0000 X-Received: from PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::b032:35db:18c3:d7ab]) by PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::b032:35db:18c3:d7ab%6]) with mapi id 15.20.6652.020; Fri, 4 Aug 2023 06:29:22 +0000 From: "Min Xu" To: "Yamahata, Isaku" , "devel@edk2.groups.io" CC: "isaku.yamahata@gmail.com" , "Yao, Jiewen" Subject: Re: [edk2-devel] [PATCH] OvmfPkg/BaseMemEncryptTdxLib: Make SetOrClearSharedBit() handle retry error Thread-Topic: [PATCH] OvmfPkg/BaseMemEncryptTdxLib: Make SetOrClearSharedBit() handle retry error Thread-Index: AQHZxYWhwXOAc6LZGEiCdCFMAIntOq/Zrtgw Date: Fri, 4 Aug 2023 06:29:22 +0000 Message-ID: References: <448dd0fdd1ae9faa938e9b3649570ad2d30952a9.1691010366.git.isaku.yamahata@intel.com> In-Reply-To: <448dd0fdd1ae9faa938e9b3649570ad2d30952a9.1691010366.git.isaku.yamahata@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR11MB5064:EE_|SJ0PR11MB5215:EE_ x-ms-office365-filtering-correlation-id: 645b7553-1633-471f-789a-08db94b4242d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: LiHemQcubO76wnfOVT/lIva+9a5H8xhwb4cW65ybYaWTLs5sPfYSmxiqQd/YQp0y70707SygaGpZGplQUTblXXEltog3p5VqWFSAmexl8rMRfzw8V9qcZEz0oDdSDF2A7XSflD52KVdqV1YDO2FpaIsv8FNDMxq3SZWDrLq+27hPpkANNbeEamHy0bHeFaCQBZaFHTKg8tVWCWAJJdEy2CWTebjxFUDreKNuUleWncGlvVqoFPz2V+a+nfjgq9CIs0cOlHtBboc0dAwUTgAFrsxtjryFPZlVR6MVWNXrHdmtyeDmMQaIIQAYlUuSFc0OmN2NnFxBIl1qa9XxckjRThLSQYw1LeGAxc0OT6OQj4ecHQ2uKfchqGexEb00YwZ4W9mU3urqPuG2COOVvDZtadnjWz4kgDqeUOOQurzGZudoh0NkdXyi4aTq5s1eZ8h4t5FfrofajStgC5cA5Q8xEghfqeolf3HznMS8qer3i4obqIWPXtFwaKB7PNk6joMHpCOk9IaYeJC1fn9q93glFPCKyZknQ90tGtT4KYqEN+dIE11CbCJbwlGWY/powTtIXK/CEsfyxeHCMO/5b0vDMbNM1xkrWhnWRO/EkUkOJjsUv06W/yeUuIpWIkh31Xs4g8YNIbatAdtbggm52RsDWw== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?j/s7OJwC4cYWA2Wnt8SzD0Lk+JKXmPnjC1yf6Qt80V51r9RuOj5zDwMckWdr?= =?us-ascii?Q?p6BDqFi1+rq3O0PhgNRswq8viyPKZutJBj5/Ft00lC7CY6aNksMwuvyBoGXJ?= =?us-ascii?Q?1iRPbTehvGQOqmlOdYj0BJIck8WZa1ILHokrODHcIqjLlMizBD5ymP2WDcT2?= =?us-ascii?Q?0VgyL3hmuqXR5LKr8n33P/z6AvDJl+tXZJOfTPFlOP8tK/Y9VKzw9tWRZPJ4?= =?us-ascii?Q?jC7XEE3q5wN37MA/s97lY8FSvQgAlRhgnuowgRt4t52ZC6JUoJQt+SyRkZ30?= =?us-ascii?Q?pGNrBvHfZ7sqDYeVgmugsLHUEyuCK5DZS3sPrQUA9T58eYKJsRdF33W+eiYy?= =?us-ascii?Q?4y7d7V0vptEw8fqf057z3uoTidyxpZSGmxI9gKzQM/a3FGnl2X9i4jFR35eD?= =?us-ascii?Q?tFNjETK47I2O6dhHIW1u+yS+d6bSJA/imrkGoIb0BL+SoSqXSxP+GsvDWYGk?= =?us-ascii?Q?u5FGmUGi4qofpB+Umlz3pVErPpieAwed8l1CAnh+GnjcNRBqnK8R+FOR59uU?= =?us-ascii?Q?NrwQa58VEJvQqebvh4VUWXk39GXb2LifSLHgqC3efaJ4ruF6CqZqgfd6OK2w?= =?us-ascii?Q?2cQ+mgzkO9q91L209cv2vZ2GP9Uk2vyZojmJA3B0E4yxlDiaMijXeG3J5zCc?= =?us-ascii?Q?IU1WJQ9VopS7+DUv8NRqvJL5BR/4Q3VpmggydZQc1OYB6gMNG0u8CtVTQHrM?= =?us-ascii?Q?lPEUaupVhDV/VgJkq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uthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5064.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 645b7553-1633-471f-789a-08db94b4242d X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Aug 2023 06:29:22.4983 (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: 7vc8EWPS3Qz6uxnXEgAkPPGV3PdGxwE0L23Nnp711o+LGMgDcruCeNIBR6D0UGhq5ayFqkRU/EulNvDNj7HKeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5215 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7YigW4otMSXhMQWao3VKxI3zx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="vB8/CkcZ"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Min Xu > -----Original Message----- > From: Yamahata, Isaku > Sent: Thursday, August 3, 2023 5:09 AM > To: devel@edk2.groups.io > Cc: isaku.yamahata@gmail.com; Yamahata, Isaku > ; Yao, Jiewen ; Xu, Min > M > Subject: [PATCH] OvmfPkg/BaseMemEncryptTdxLib: Make > SetOrClearSharedBit() handle retry error >=20 > From: Isaku Yamahata >=20 > TDG.VP.VMCALL can return TDG.VP.VMCALL_RETRY when the > length is too large so that VMM can avoid too long processing time. The > caller should retry with the updated starting GPA on the error. Add chec= k > TDG.VP.VMCALL_RETRY check. >=20 > Signed-off-by: Isaku Yamahata > --- > MdePkg/Include/IndustryStandard/Tdx.h | 4 ++++ > MdePkg/Library/BaseLib/X64/TdVmcall.nasm | 4 +--- > .../Library/BaseMemEncryptTdxLib/MemoryEncryption.c | 10 ++++++++-- > 3 files changed, 13 insertions(+), 5 deletions(-) >=20 > diff --git a/MdePkg/Include/IndustryStandard/Tdx.h > b/MdePkg/Include/IndustryStandard/Tdx.h > index 81df1361842b..4ea2960a70f9 100644 > --- a/MdePkg/Include/IndustryStandard/Tdx.h > +++ b/MdePkg/Include/IndustryStandard/Tdx.h > @@ -103,6 +103,10 @@ > #define TDVMCALL_REPORT_FATAL_ERR 0x10003 #define > TDVMCALL_SETUP_EVENT_NOTIFY 0x10004 +// TDVMCALL API sub-function > Completion Status Codes+#define TDG_VP_VMCALL_SUCCESS > 0x0000000000000000+#define TDG_VP_VMCALL_RETRY > 0x0000000000000001+ #pragma pack(1) typedef struct { UINT64 > Data[6];diff --git a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm > b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm > index 5ecc10b17193..8dd9bfcbfa14 100644 > --- a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm > +++ b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm > @@ -133,9 +133,7 @@ ASM_PFX(TdVmCall): > test r9, r9 jz .no_return_data - ; On success, propa= gate > TDVMCALL output value to output param- test rax, rax- > jnz .no_return_data+ ; Propagate TDVMCALL output value to output > param mov [r9], r11 .no_return_data: tdcall_regs_postambled= iff --git > a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c > b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c > index a01dc98852b8..d55c2a34a44e 100644 > --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c > +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c > @@ -526,6 +526,8 @@ SetOrClearSharedBit ( > UINT64 TdStatus; EFI_STATUS = Status; > EDKII_MEMORY_ACCEPT_PROTOCOL *MemoryAcceptProtocol;+ > PHYSICAL_ADDRESS TmpPhysicalAddress;+ UINT64 > TmpLength; AddressEncMask =3D GetMemEncryptionAddressMask (); @@ - > 540,8 +542,12 @@ SetOrClearSharedBit ( > PhysicalAddress &=3D ~AddressEncMask; } - TdStatus =3D TdVmCall > (TDVMCALL_MAPGPA, PhysicalAddress, Length, 0, 0, NULL);- if (TdStatus != =3D > 0) {+ TmpPhysicalAddress =3D PhysicalAddress;+ do {+ TmpLength =3D > PhysicalAddress + Length - TmpPhysicalAddress;+ TdStatus =3D TdVmCall > (TDVMCALL_MAPGPA, TmpPhysicalAddress, TmpLength, 0, 0, > &TmpPhysicalAddress);+ } while (TdStatus =3D=3D TDG_VP_VMCALL_RETRY);+ = if > (TdStatus !=3D TDG_VP_VMCALL_SUCCESS) { DEBUG ((DEBUG_ERROR, "%a: > TdVmcall(MAPGPA) failed with %llx\n", __func__, TdStatus)); ASSERT > (FALSE); return EFI_DEVICE_ERROR; > base-commit: 677f2c6f1509da21258e02957b869b71b008fc61 > -- > 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107562): https://edk2.groups.io/g/devel/message/107562 Mute This Topic: https://groups.io/mt/100514591/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-