From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.11216.1635250186277415001 for ; Tue, 26 Oct 2021 05:09:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=INC90sGJ; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: min.m.xu@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10148"; a="209972279" X-IronPort-AV: E=Sophos;i="5.87,182,1631602800"; d="scan'208";a="209972279" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2021 05:09:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,182,1631602800"; d="scan'208";a="664521566" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga005.jf.intel.com with ESMTP; 26 Oct 2021 05:09:36 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 26 Oct 2021 05:09:35 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx608.amr.corp.intel.com (10.18.126.88) 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, 26 Oct 2021 05:09:35 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.170) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Tue, 26 Oct 2021 05:09:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hsIEXIfu9keMcgmx5I6ViDJ2MtKP0ZrZStW1/ZEvS195Z3QLHXuEgUNjhadFJrJqBkgXqrYSwGUfLszuu8+dEkOQlzlntqPuyOCjIcul0/qYbNrk44+pntgRwKpH6b94XoYdBXFsAmoLOOLJN1soPQHiLNE7RZ/G00YtSAcp9peuOqK6FpHaDuOP/jTJJIovReHG0DwAxTdgAiLZ23tdITxPmqbIEeqtY/cB9kHENH7IvM6eGomiUH8zSfXHrzBRUUvgbN0m8sW3sTBs0MDkrsg8gBv4NL8TflabkZTSBO8eZm3wMXCmudbu4lqr1e9dgcC3bSZlbiVUBqPndCtgnw== 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=gzrNqu8ejXbFLIA8g/q0St3I8oVFl+ov1Nh8FzafSu8=; b=j9DLV9IQLK6kYJzHbk3VnwgsjItfLqk7C6ZZtz0457IEYo3yYqTRs4cfc5xe9isa5hDk49OiB4o75DrbThbbNqDf7gG3cU4DmxctBoCYiNp2N3nemyKE6/ZDy4AMcplB8w38AwVuyz/AFFMiAGG0iF1rQesmbN6TZjiUGnLUeDuOvDg6Kq0iH+Buklks7DNyDwecNC++Kvvhh2ELoqKHt0NidtNv3bWAC22GZd67mhEtqUMjggAr32ShtELPRx1U2Qfu5pVR3SwWlf+V6iA5TNZPbywtCyjp5ltGmIsx1dfgh3ZJTnuA4JDta1H2rb+froWqes6UbWIFCj6ULuPq4g== 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=gzrNqu8ejXbFLIA8g/q0St3I8oVFl+ov1Nh8FzafSu8=; b=INC90sGJF6hRz3mgR2VFbem5NWHfyT7D3VC4ujzIpKSpkZbrVzur3licq27KNg+jfofsPrt+DZ8mCinVl4ULcdB4d5wELAB03Etjx9rE29zeLUmZjM6EFmLtH0x4wPTeZMGK+adMNq1cNrxocZ4/qrytItq8vK6gDbosw8SFo+0= Received: from PH0PR11MB5064.namprd11.prod.outlook.com (2603:10b6:510:3b::15) by PH0PR11MB5157.namprd11.prod.outlook.com (2603:10b6:510:3d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Tue, 26 Oct 2021 12:09:29 +0000 Received: from PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::7deb:6c36:73c2:f0d4]) by PH0PR11MB5064.namprd11.prod.outlook.com ([fe80::7deb:6c36:73c2:f0d4%4]) with mapi id 15.20.4649.014; Tue, 26 Oct 2021 12:09:29 +0000 From: "Min Xu" To: "kraxel@redhat.com" , Brijesh Singh , "Yao, Jiewen" CC: "devel@edk2.groups.io" , Erdem Aktas , James Bottomley , Tom Lendacky , "Dong, Eric" , "Ni, Ray" , "Kumar, Rahul1" , "Xu, Min M" Subject: Re: [edk2-devel] [PATCH V2 12/28] UefiCpuPkg/CpuExceptionHandler: Add base support for the #VE exception Thread-Topic: [edk2-devel] [PATCH V2 12/28] UefiCpuPkg/CpuExceptionHandler: Add base support for the #VE exception Thread-Index: AQHXuZrEZaTymLGmdUC5iTq/+VuJ36vPND8AgBWluZCAABOKAIAAAekggABE0wCAABjj4A== Date: Tue, 26 Oct 2021 12:09:29 +0000 Message-ID: References: <24d3a351f21bff1a4b20490313d039e403b1453c.1633401643.git.min.m.xu@intel.com> <20211012102716.wr6bao42f5hviz5z@sirius.home.kraxel.org> <20211026061148.omqerrswnpgs3jin@sirius.home.kraxel.org> <20211026102458.pvzp5nxyegq7ftuu@sirius.home.kraxel.org> In-Reply-To: <20211026102458.pvzp5nxyegq7ftuu@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: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ab998822-13d1-4513-f4a3-08d998797647 x-ms-traffictypediagnostic: PH0PR11MB5157: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: EO+ugLy2XrnTSKCSCZj9WCJS3xeLE7uUP0qExhqKHbDOoNMaYHAOKkPkcFqEr84+MG9d/eKW+nj+rJNUTIMC07TnviJ5IbJZ8mN7M1yiWhkafd7ab59X8+ce6dmuwKvWh24DzU80ZpDxFpfL0EjgAjPcp4GI63QMA819W6hbQYiY1cHItvy7z+kcYDYhhyQJKdDm4oO2rlT+LgJartJYNgnKn/A8OXGkNhJ3254a93roGGoi585kFUbWI7RcJt8hB/+WixY2c68vooQy6JCEfa4n5uTkknXrqPXvy8bTtZp++fRvuj9LRGa2ClhS92cn+xcWZ9uKYJrAvWPAvq5fXz5LbsHFyqrGviyI1BGKkuYQQnDv0H/oMf4GU8J5oG0bvmgK4LHSCtWjz/M6amItARcx0Vlmy5invV1cqBPf0gUlMWEUEa+n2ZO6WtoG6FprsXgSz/FOl5b/vXaAzr7zscu5G6NMprShdbJm9yUglym3ypdqa+ffatZ+NufaDp49sUwIZr7wY5lJYyUjrysNUQVGMs8AMRIy71x1lCgkFOYV5l1bVlJSXgVjYqrT5/MLztB7LouoUU9t6AALLUxt6E4msPQ8eKAVfTzrkFl5VeAP17VdBd3p81jT6HqbxnLWEyoZpRQlv8JyHBjFlwZr1Mwz6Qsj56l7InmHc0loLKxiL5NKNNaBqyER9LhQSag3weJ4yD0Q870NENna7EHdsoPZ8CO+0/Ztyxwu34cPnXkJVA6Z4ODH7SjaVDY3ok6TESsNAZmagIsa/47/+KEaz/42VK6IYVG0WWB6o64+b8g= 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:(366004)(66946007)(4326008)(76116006)(52536014)(26005)(5660300002)(186003)(7696005)(86362001)(6636002)(110136005)(66446008)(66476007)(107886003)(54906003)(71200400001)(33656002)(8936002)(316002)(64756008)(9686003)(2906002)(966005)(8676002)(508600001)(55016002)(83380400001)(38100700002)(122000001)(38070700005)(6506007)(82960400001)(66556008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5kMx75FIPUcKDEUaEMKD/8+5aZkJ6Jrnc+RjG8CTk1io8DBLEhkGdzdXON74?= =?us-ascii?Q?+H3TP6smEqVyrxuzGv1xE8mhwqNoTLCOnoY9Raxf3h8VaXvDkDnIXFf6JGim?= =?us-ascii?Q?8pUspB6nG66VqZ3+04PTZhYrYzwZDTCvYkLRRVVKwWuHGccyt2JHs+q37raE?= =?us-ascii?Q?DzCZ9/VvfQDTYBv3W5fy+PfKNd3cW7UvelVOFBggf1Cobc+20OUoBlO8cR8W?= =?us-ascii?Q?WfJEa7t11zHrFJ4wn9qUWqQsZgula/5UTjTETrva2ci20buyk4s5u53gCMh3?= =?us-ascii?Q?/j0RaW0pdIV+7n0+OnbGiTuYorQDQXT3m/+xuk3+iooyJPQ2UXo+28ET5JQg?= =?us-ascii?Q?ztP6LxdhaUadOFiJWnUyxTU7fj3ktHX9VdKyiB5Irpm9YBHf/QhU2k+Z7jVn?= =?us-ascii?Q?Os9JF0oeVvT6BMo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keoDtAxAAFXVBWD5OUo6d?= =?us-ascii?Q?HFVGJLanA3Jqr5lZYiglxD9ZQpAsbzAd1Kbhlz5uRxYPJgqCLkN+mqGvWDob?= =?us-ascii?Q?SAQjfPSQ81vpY5O6neuPVDct5PP+vwWOmEZEOPSy3PrKrcTF3UC9wDtKw0tM?= =?us-ascii?Q?cP2iQ2YaP7Y+V05zaRyBIAPaiyonXmgzPo0xn0v8WFezTGzbTYSKfEi2Jyg8?= =?us-ascii?Q?U8/nP2Eu8MiNBFN2hRoBis2iTUWWHdeltO0X7ulcBHDw7FqlF7mReeBFvcez?= =?us-ascii?Q?gijNq1fUUL/wqckRPQ4Bs0F/H5yHDtNv6QwMb7kuu2qE5JCdQUxPK5a0WxqF?= =?us-ascii?Q?kMaoDR3Mjy+2vpvVO21KIPY=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: ab998822-13d1-4513-f4a3-08d998797647 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2021 12:09:29.0914 (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: txL0SOxpHUrCyCGiHTjeawl/Tpj4iPKOg5HHD5zqiBqJCWaukdiOPB4zp2xH/2mv7NUBqL1hiIv5kvc3MfT3BQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5157 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 October 26, 2021 6:25 PM, Gerd Hoffmann wrote:=20 > Hi, >=20 > > > > So it has to be implemented inside the exception lib. > > > > > > Well, no, you can also change the code to avoid triggering an excepti= on. > > > > > > Adding a new lib for the exception means the lib must be added into > > > each and every *.dsc file (either the tdx impl or the null variant), > > > not only in the tianocore core itself but also all projects depending= on > tianocore. > > > > > > So IMHO it is worth checking out how much effort it would be to > > > avoid early (before component registration) exceptions. > > > > > > Which early exception do actually happen? > > > > > RegisterCpuInterfaceHandler() is not supported in SEC/PEI phase. But th= ere > are still some scenarios in SEC/PEI which will trigger #VE. > > CPUID is the sample. See below call chain in CpuMpPei. > > InitializeCpuMpWorker --> CollectBitsDataFromPpi --> > > MpInitLibGetProcessorInfo --> GetProcessorLocationByApicId() >=20 > Bad example ;) >=20 > TDX needs its own Mp implementations anyway, so that one specifically sho= uld > be quite easy to avoid. >=20 > > Actually #VE handler follows the same way as #VC handler (by SEV). See > discussions in below link. > > https://edk2.groups.io/g/devel/topic/73201885 >=20 > I guess the list of instructions which trap on tdx is quite simliar to se= v? cpuid, > msr access, io instructions? >=20 > I suspect there isn't an easy way around that then (as discussed at lengt= h in the > email thread linked, thanks for that). >=20 > How about adding the tdx exception handler to the existing library, so we= don't > have the churn of adding a new library everywhere *again*? Do you mean add the VmTdExitVeHandler.c/VmTdExitLibNull.c in CpuExceptionHa= ndlerLib, then include the corresponding source file in each *CpuExceptionH= andlerLib.inf?=20 If this is the case, then the implementation of #VE handler (TDX) will be i= n-consistent with #VC handler (SEV).=20 Shall we keep these 2 implementation consistent? Or will SEV agree to updat= e the #VC handler in the same way? Thanks Min