From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.8538.1636526812162218191 for ; Tue, 09 Nov 2021 22:46:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=hrhAKpSy; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: min.m.xu@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10163"; a="232857781" X-IronPort-AV: E=Sophos;i="5.87,223,1631602800"; d="scan'208";a="232857781" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 22:46:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,223,1631602800"; d="scan'208";a="470268536" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga002.jf.intel.com with ESMTP; 09 Nov 2021 22:46:50 -0800 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) 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.2242.12; Tue, 9 Nov 2021 22:46:49 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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.2242.12 via Frontend Transport; Tue, 9 Nov 2021 22:46:49 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.170) by edgegateway.intel.com (134.134.137.100) 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 22:46:49 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nlr8sZIy3y7dj7ymHpSFS52Gx614DDY571/Bdm6Lj8AZPxL56F8kd0fJvk5bYqVNqynKhp5g0EFqh9WnlUKv9vti1EypVpNMJpiyu+Y6E+FhNP/dTpWPjYfl25cRrtGiK+6cn8bXC9qRGhYdBsAFmU92wqUa3pCFkAN4lJt2nq7rPW+t7QM1CufFIUdToMIaYo/7Rje+wQmsvXRyrnKCGxFiXggkRb0yaYpc+ZIVLMna9gIw6TuptoQLi4KniOvtosv6uUMhNt1X6zMJ+kZiVtWk78c/phsdw/NOipEtGBYaJi5vWHIAZeE4kkuGlWEMctsMGEQIbd41tOMr880Bdg== 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=MQVxCz9tNYHUUvYNVDU/JEYOLefUMx/owaszf8N6KLI=; b=BdgPRFK85yA9Y3woLs8pctOIE/J6QyYLUOnd2P+GBWOENwVc2zMT3Y3L5RwOgL3E0nhGci5yQVipK3MlEm0tp3JwGnBFXo8EVLQWMF0YPIWwT7jOVJnV+53exks/bE+4sKHL3DLGq6FmrS1dHMsyiCkWPBguAnAmAmn4HS3FBqZ0dUgNIaPKg+ZKkLgRWyjHFVlc7SI8FsTa4cXk/BfVGuwLUyMlGFj85Apede9BokY+YDjaQdaU9sFvU5DCrzWP8XfVVfGuVKH5KyAdCRdKhWN7bFxTMWlyMGDHyg9hdEfHdRdVAsXOvP+rXGRy79KQXBhXlp9RKhoW5JQWoQ/Gsg== 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=MQVxCz9tNYHUUvYNVDU/JEYOLefUMx/owaszf8N6KLI=; b=hrhAKpSyK6pcbIgegX3YyKArRKuAMn/BAl73cq7pTnSgZfsBGSyVt5n/JSuTtlHI0aKrb8PtfZ4bIpL0942mHmN8YBeHn8LlaMZg46CEO6hdHjZFcUveY70Xblpbc16nGiNhqVu/wdXnDBQGkTFlM43Z4P/tw4fcaLzUjF3M7MA= Received: from CO1PR11MB5058.namprd11.prod.outlook.com (2603:10b6:303:99::17) by MWHPR1101MB2190.namprd11.prod.outlook.com (2603:10b6:301:5b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.16; Wed, 10 Nov 2021 06:46:47 +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 06:46:47 +0000 From: "Min Xu" To: Gerd Hoffmann CC: "devel@edk2.groups.io" , Ard Biesheuvel , "Yao, Jiewen" , "Justen, Jordan L" , Brijesh Singh , Erdem Aktas , James Bottomley , Tom Lendacky Subject: Re: [PATCH V3 04/29] OvmfPkg: Extend VmgExitLib to handle #VE exception Thread-Topic: [PATCH V3 04/29] OvmfPkg: Extend VmgExitLib to handle #VE exception Thread-Index: AQHXzyK9awvIEicReEGHASVTQY6w3avwTDoAgAwK/UA= Date: Wed, 10 Nov 2021 06:46:47 +0000 Message-ID: References: <20211102142348.wi7it5h7zgz6j2pp@sirius.home.kraxel.org> In-Reply-To: <20211102142348.wi7it5h7zgz6j2pp@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: d7280b0c-6e91-4337-a84d-08d9a415de14 x-ms-traffictypediagnostic: MWHPR1101MB2190: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WsbXdey4WjJhSqBPdm/8741GwmhwVEqzl8vLsnlmN+wgw0MD8QMg4iWnMjvl2KxdblwnVFgTBz3HlDXrz3gAuhIq2Amj4qIRbKxHf5yFxf5o0thAZbuiCWImEzBz4yqbXwsnef1Wf4k6MEmjSdv2NMc0yci6rz2ibZHCHuEE6d81f3QSjRW3ym11T5IbDiLEl39fiHrw2To7j4JtyH4UY2Q/AGuUmmKibO/LEti8+7XHRmgDPwPwqJmlbBvEuseD9N4/93p9Bfy2AR9iHMgXts5D2SNre3s0ZhH8nido6tSUQzYKZNj0gMPEX3eAOGmFSP6Nz94l65D9cYDt+nKHe1J8wSw9KwX4xVS3F7dD0rU2YnLYP6o1+uDhShsuury5MPGLsdah4nKF8VOWudoWSxLPY2tw/bEjnGzf1hGFC4ZajcmtUIYLhCEDySYEt8CwPe+buhgZD+73GrFfBYV9UpGRjUIAAQ5bu74ykU0QdtKsk0RnOyGc2mq4skJ9ZBD/IwnlcQFmwuARlGl0GtSRQKGUQWYkQJHURRBhcG9CPteLvrOToWiSFw/+4dx4J4Br4lv4d+145vNrWd2VB6ajQzCsE7X6PE7UZ3hvDmhN6AvCjqRKXiSrxNMxsFlLI2d3uGWOs4DebyJnkzfloKtgvGRPbclJOnyJsh7nqJC9OuiRe+mPHoDTOk8FJpVcgMVIpUosxm0ir1DaPHHwABPc/Q== 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)(19627235002)(186003)(38070700005)(6506007)(52536014)(71200400001)(8936002)(8676002)(122000001)(26005)(5660300002)(66946007)(54906003)(33656002)(508600001)(7696005)(82960400001)(4326008)(38100700002)(6916009)(83380400001)(66556008)(2906002)(64756008)(316002)(76116006)(66476007)(9686003)(55016002)(66446008)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9ZSdAVgeiGLAszMEiTlczQLUHJojoURhk6fRNt7LYUpKurETVuSiqFEWVYK7?= =?us-ascii?Q?GuRr1ggCWjiDFE+YcGn9PuUFwz7Htvt05HwNA9BDwkCHHwOrV99+enN5hQxl?= =?us-ascii?Q?OlueXtUyw6VvDSeFUecqmTcBejcZqLoZL2M+CGkZiy6hNPx+eVCLB+rxs3WI?= =?us-ascii?Q?pd3Bd3/GqzzoKI1FFhIVx3mcwm82JR4uZkUHq8e4X+/f5NRFId8tyey2r3Xh?= =?us-ascii?Q?6/Fmvr3spQpY/dyTgNcpvBRhCIo9bg8i73gMxjcizWod4k6cbCA7T78gvclQ?= =?us-ascii?Q?CxOZ89yKOp4gjx6V+myCLXfuVAg0DIh4PjGBWwSwQSntVaekEXacwEIchcv3?= =?us-ascii?Q?4cpfGGTaIVArYbPlBGJ+Ted6WRqqn999XAqdH8iIRcKbTt3t+PfKPkFSPloM?= =?us-ascii?Q?e9mvkOE3/fd46sQlp3Uag7UEQjQMwK8elIGtHp+zsEQkUMTpXr+ywgAGMyah?= =?us-ascii?Q?JnqrFGI7IOwVHwl7YHN6WiWXHEY5M2zb0GtayheRTEOed5pq845GKEowZSOv?= =?us-ascii?Q?fZgxDJaJOKWGqxtFf7Uc390bxOSp1+xPQkorGCpqAig/rJMUtDk0SCAbFLMC?= =?us-ascii?Q?K6iT33i5p5YACeL/l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N6?= =?us-ascii?Q?09CBX42OCaRKwDvMJEXp2oZ6IKj3XKnM6hb0SAloF7JrjlEOWwHkF1pCKfTr?= =?us-ascii?Q?QcjsNEoQXDqBp3Dvup30V1wxM/hQJOevvpovaO4AP/eHvTmulTSB7g5fD/nz?= =?us-ascii?Q?CA=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: d7280b0c-6e91-4337-a84d-08d9a415de14 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2021 06:46:47.5973 (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: 4oS52kgsjd/yxiwHQbNxy7BZbT4twfABMmMDm9INNaAeznkSU+3AsgS7AtW1bOwqcPeTM2o4g3arSdAZm4TO0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2190 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 Hi, Gerd > > +MmioExit ( > > + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, > > + IN TDCALL_VEINFO_RETURN_DATA *Veinfo > > + ) > > +{ >=20 > > + do { > > + OpCode =3D *Rip++; > > + if (OpCode =3D=3D 0x66) { > > + OpSize =3D 2; >=20 > Oh, wow. So the VE exit data doesn't provide the information which io/mm= io > access actually triggered the exception, so you have to go decode the > instruction which trapped? The VE exit data provides the information of ExitReason (ReturnData.VeInfo.= ExitReason). Based upon the ExitReason, #Ve handler knows about which opera= tion triggers this #Ve (EPT_VIOLATION maps to Mmio). SystemContext.SystemContextX64 and ReturnData.VeInfo are then passed to Mmi= oExit as the input parameters. They have the information with which MmioExi= t can emulates the MMIO instruction and then converts them to a controlled = TdVmCall(TDVMCALL_MMIO). Actually this way of handling is similar to AMD SEV. SEV has a common funct= ion (InitInstructionData) to initialize a data structure (InstructionData) = with Regs->Rip. In its MmioExit the instruction are decoded as well. >=20 > > + switch (ReturnData.VeInfo.ExitReason) { > > + case EXIT_REASON_CPUID: > > + Status =3D CpuIdExit (Regs, &ReturnData.VeInfo); >=20 > Indention is strange (switch + case should be the same). > Otherwise looks sane to me. Sure, this will be fixed in the next version. Thanks Min