From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.7867.1636520333271561583 for ; Tue, 09 Nov 2021 20:58:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=Aa2GAw5Y; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: min.m.xu@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10163"; a="213332096" X-IronPort-AV: E=Sophos;i="5.87,222,1631602800"; d="scan'208";a="213332096" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 20:58:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,222,1631602800"; d="scan'208";a="732301880" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga006.fm.intel.com with ESMTP; 09 Nov 2021 20:58:51 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 9 Nov 2021 20:58:51 -0800 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 9 Nov 2021 20:58:50 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) 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.2242.12 via Frontend Transport; Tue, 9 Nov 2021 20:58:50 -0800 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.47) 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.2242.12; Tue, 9 Nov 2021 20:58:50 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LalqTypWv1zEncfM0k5i8OJ2JPWgiTPmo92ow9npLYXaZ3cTXO1yhQeArfR/ObNtjLu2ykv6Qj/YZrT1wsZQmiKDd7VoBBg4ZZoFcXY/j0cG6YUiexh5ck91vMzKBr81HTtz9Axd4GsKRysGZyFbH20ElASoJhc9efJjJtzNrQs1vfGtdpoiFJTaFZMeVAExZPg+H5qHdDY451wAb0PcIiDUSpqO6s19jaGMWIuQ/dApBsh7KtnlPHPWWmvIwqTPpNvzioUP11R7oZMWi3NsRbaifMJsoF9Kxc+Sd8wJtazqSCJTy3HtNJKK2LtsYcONkScVAXXFW27Z0D+hDHlSVQ== 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=xI7mmOT8i+5SOOIqilJvtRVlLGndsmyiBqI0e4bQGyk=; b=CuWwGe2iRbSeMdlxVY3EFGhdounyNhDoyb2VWqoysDTStYKfQB1i0eZPc9NA6Hmf8d7obUHDULObrLyaaLW45JmO5lJ7GelKomSYYcOjeaFicasu0oFBcrilQTkm7IS0j2b+ORFyAVrpCgjJDIDGwIAD497Yoo4kR3Zbr3f8VnKTNy+KcxpT+NZgASK0ivQIgalj9Dgw0HprrUkHkjNFonpEDl3XzaO3SmLHRzvKlKqBIL0ovRaQBPVq/XF47jl3NDith1Vd3HK9EhBoA6AmxTDopmxbiZVC2P+ATQ+q0GQ4sgDpwws09Lv792B4Ouw4b1IW/Sr/m684BGpPhXaeow== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xI7mmOT8i+5SOOIqilJvtRVlLGndsmyiBqI0e4bQGyk=; b=Aa2GAw5YaambMeTuk3gxx3exb0dxHvJm8z9jFcQel/kjL/b8P5Ihh8J2PDOBpbnenz+U9i889jmOgkTb+OLxcy7cNmN4buAfhZsbSJa5x39wWbJJIudrTRx32MA2P97ho44vB2oRfcabma61rD5lfYCk05ZkjuH3M3lJfnFQI/Y= Received: from CO1PR11MB5058.namprd11.prod.outlook.com (2603:10b6:303:99::17) by CO1PR11MB4802.namprd11.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15; Wed, 10 Nov 2021 04:58:49 +0000 Received: from CO1PR11MB5058.namprd11.prod.outlook.com ([fe80::49d5:fe9f:6dd9:8f95]) by CO1PR11MB5058.namprd11.prod.outlook.com ([fe80::49d5:fe9f:6dd9:8f95%9]) with mapi id 15.20.4649.023; Wed, 10 Nov 2021 04:58:49 +0000 From: "Min Xu" To: "devel@edk2.groups.io" , "kraxel@redhat.com" CC: "Kinney, Michael D" , Liming Gao , "Liu, Zhiguang" , "Brijesh Singh" , Erdem Aktas , "James Bottomley" , "Yao, Jiewen" , "Tom Lendacky" Subject: Re: [edk2-devel] [PATCH V3 02/29] MdePkg: Add TdxLib to wrap Tdx operations Thread-Topic: [edk2-devel] [PATCH V3 02/29] MdePkg: Add TdxLib to wrap Tdx operations Thread-Index: AQHXzyK7o5BT5Qs88kmpsZzaPIaVJqvwR3SAgAv5EIA= Date: Wed, 10 Nov 2021 04:58:49 +0000 Message-ID: References: <232162e8ee92888f7ac9795ee9baa331ea39c613.1635769996.git.min.m.xu@intel.com> <20211102140643.7ok6qaidrau7cn6e@sirius.home.kraxel.org> In-Reply-To: <20211102140643.7ok6qaidrau7cn6e@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.200.16 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: 23dc5324-7f90-4298-a66e-08d9a406c902 x-ms-traffictypediagnostic: CO1PR11MB4802: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wMFeK/kUbDFa69gG1iaYE7lHAsamzMn/IObFMvTTIpJX2vzZ62s7NWi7ngula44TqIsH2WUhattbAW39aEHAOEXWuivtyJIgx/Scenn0f/0dp51bUsX5U16rag+L9+u8P4hoBOMnDUJQOeLESST2vaRbMDURlAvtDGr7cLGWjUXj8fRT4u2K6nMWVY8Tx2PZ3RHLtxAypDNtj95FjDyA06dHgsK4pN3HY/0qnQl/emaqzZutkK5ho8GAGiANbNbQCcylsOrNUB17c3bknHxlQfio9CxF8Yqk+1d8JuAxc9RJR4FQIjJt/OB2c1MR/XIZu6C2zSXnYNkR017KukIlh47jfpsAvDOspCTaSM3pv0BJiJYdOvBdGerf5roYqtBjyc340hhmzFFs/acXav1Qd0vkZd3obU5bS9fcVAmCnee/38dOuh858914rU6P/7Ne50M2BuWJXjz7YWVCY1JCgtIUpfOPHt6PtaHlAZpMRrBQe5+bon4h3DIhH/LfSw84h7jY9mKF4MhaPvdj6cN/Kcdcu8zh3xnPerQgK3SOxbTSOPnMJsuq681ilGm5mH8JS8RuKYA8iMzcQSLwpmMllspFL6mI+Zh6/rGQA5rIPWhVlgbsoIoHJAC4MatKFipjj42JKLgcsqFpRmpAeaYARn5PIIie8jCfL4vAcBOWm+IqgFZ2kXQ8tuR4qaZAwYdq+Z0/dRg4tDkt47HhWtaGjA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB5058.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(86362001)(26005)(71200400001)(6506007)(54906003)(110136005)(8676002)(52536014)(186003)(66476007)(64756008)(66446008)(66556008)(2906002)(508600001)(7696005)(5660300002)(76116006)(66946007)(4326008)(8936002)(9686003)(316002)(38070700005)(38100700002)(122000001)(83380400001)(33656002)(82960400001)(55016002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?T9jYHQ4nO/LjYzlMh+HBZOErdKJXWKwDSVlrhxDyi+c/zzpbFKzi5B7VHXfu?= =?us-ascii?Q?P4LRto81jj3TWT6AhUUktamfSedwBwJEaKiIBXkyugiR9bzEF3JN6BFBZg/L?= =?us-ascii?Q?yK59+5YxQMpp57dUSjBvnkeHr+QSO95Nu4WB+0oZCme49hJTOCfYHKhJl7YV?= =?us-ascii?Q?7HZoabhNu0Z5mo0ytxiPAtD/9q4VJKN9L3ioOP8tlv2wgipJHBlm7LS7ADT/?= =?us-ascii?Q?ag4zFKd5W+Ie1OfzR7UIafFXIaT0swZV2tITMsG55nVlouVO0H5z+iaMlIbn?= =?us-ascii?Q?z4llud0aWAurCysYzgDO1zdBtJ9vX/8c+XbqMaLddH3Rul4+VyJL4FzoXNFU?= =?us-ascii?Q?7M1FF7zdmSk4jMs93H2SQX+WpgINA3ne5pu8CnpcntHOLDBjcb+ZSi9Yqz1C?= =?us-ascii?Q?xMFJ2lsERIdtb37DSEWqq+OFiK6l57ogIhd4S4Oc1NfzOhjl51P/6ILCgmJa?= =?us-ascii?Q?fdO1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LLcWWJIzasM?= =?us-ascii?Q?sdPe3t1LyuoQ1PSu2YqnMAaU3Uo62L7ZzCG+sl5Qfs7LYTs86UuKWgUU80PV?= =?us-ascii?Q?pEPNxeYXpty0VcrMck6YC1coOCDR+juYY3IUiU83wqDu2GtxZ0aJoln6yb2j?= =?us-ascii?Q?dfk5O1z2HruJkfHhVoUA3alCUzz1LqHsb5TV3zeRPTS976z0PZKkzxCFlFxX?= =?us-ascii?Q?9phjFrACFsKCQ4+w0JSGefGXx3zy6une2pqnRPwfzhi4/fgUMRsWTNaoqsXZ?= =?us-ascii?Q?Ew=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5058.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23dc5324-7f90-4298-a66e-08d9a406c902 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2021 04:58:49.7982 (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: psvxCK77lqdBp0/LOG3vz+2Kn55tEvOg9y5h1MinHrF3QuEq6qFGPEa+91xd7sC+YpM0Ch72W6QV4bEleLbimw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB4802 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 November 2, 2021 10:07 PM, Gerd Hoffmann wrote: > Hi, >=20 > > +UINT64 mTdSharedPageMask =3D 0; > > +UINT32 mTdMaxVCpuNum =3D 0; > > +UINT32 mTdVCpuNum =3D 0; >=20 > > +UINT64 > > +EFIAPI > > +TdSharedPageMask ( > > + VOID > > + ) > > +{ > > + UINT64 Status; > > + UINT8 Gpaw; > > + TD_RETURN_DATA TdReturnData; > > + > > + if (mTdSharedPageMask !=3D 0) { > > + return mTdSharedPageMask; > > + } >=20 > Small possible optimization: you can cache the whole TD_RETURN_DATA struc= t > instead of the three extracted values, then ... >=20 > > + Status =3D TdCall (TDCALL_TDINFO, 0, 0, 0, &TdReturnData); ASSERT > > + (Status =3D=3D TDX_EXIT_REASON_SUCCESS); >=20 > ... you need a single TDCALL_TDINFO call only. Thanks for reminder. It will be updated in the next version. >=20 > > + tdcall > > + > > + ; Panic if TDCALL reports failure. > > + test rax, rax > > + jnz .no_return_data >=20 > > +.panic: > > + ud2 >=20 > Comment doesn't match code. jnz .panic ? Ah, good catch. It should jnz .panic. It will be fixed in the next version. Thanks Min