From nobody Tue Nov 26 22:28:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46087+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1566301157697573.0072385291683; Tue, 20 Aug 2019 04:39:17 -0700 (PDT) Return-Path: X-Received: from NAM05-CO1-obe.outbound.protection.outlook.com (NAM05-CO1-obe.outbound.protection.outlook.com [40.107.72.58]) by groups.io with SMTP; Mon, 19 Aug 2019 14:36:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jcWbwle6aLthDwqvc5hd9ei3J1/2V61Hnw/DGfbVYgLc+4CQAauOfiHvUuJozQXj5NOzdLA1QJHp8SCEei+xD3LCtShYzFG0VeMCPc87SqfOBD5hk0iNN7nTbHQiTS9yGFvdIMqgcjwOPkeCcEcZzfFCu2cWKtOVWDJEgfSAsZph9LxqEt1FX+gMb6rN9/wQY9QOZsWUMTmD2Z4ZZSZyPU3HGiA9Ku+vm6YnxvIdpbk94rOQqwL7/IeJS4ApB+t8dNBycvH1RsQic5gbJjqRFRx+3o/Lowa+lQWpAAcKnirnKANkUYUJlBKopiuieo+3QpjGSWbKcUhmpovgu0X+Pg== 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-SenderADCheck; bh=0gPthfGgRD+kPl65kSibTsQXpwNMCyiHGiZn64xRacs=; b=V+fAgDMipjT3eAZfuZUJk+JOOhtOBURjlMX3pthsZSY56SBGohvqxdXLgDnsBI6LicV30U+oBk9ed7kTfNTkHx209IJR+nxh25A4oroyx018dmrWqvD6PFYIOfrVc6LiLfTQAkikD9vyoFE6WO2XCYBLG2rxe08DQmMuHBRSRE0naofLDgcFI63Hh3/W1vZU+ji04DOILliUUDdRs9dGX4FAB05sNWd083Pfokm3kxnIXDtFU95+0dPGvpeJnlBr8HX8Q1ywNvTTzHh6hEoyieoYrsSAUZpcy6j4EeQIE+1WZhcSVSF2ymoQKR9wt+zPH8ScxzycTYgFEKBCbuxzKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from BYAPR12MB3158.namprd12.prod.outlook.com (20.179.92.19) by BYAPR12MB3112.namprd12.prod.outlook.com (20.178.54.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.20; Mon, 19 Aug 2019 21:36:17 +0000 X-Received: from BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27]) by BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27%6]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 21:36:17 +0000 From: "Lendacky, Thomas" To: "devel@edk2.groups.io" CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , "Singh, Brijesh" Subject: [edk2-devel] [RFC PATCH 23/28] UefiCpuPkg/CpuExceptionHandler: Add support for MWAIT/MWAITX NAE events Thread-Topic: [RFC PATCH 23/28] UefiCpuPkg/CpuExceptionHandler: Add support for MWAIT/MWAITX NAE events Thread-Index: AQHVVtYiiqWARbmny0CW2InOhvCZCQ== Date: Mon, 19 Aug 2019 21:36:17 +0000 Message-ID: <5b34d3a3c9c83d44818893f6ace5716b4c202f4d.1566250534.git.thomas.lendacky@amd.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN2PR01CA0031.prod.exchangelabs.com (2603:10b6:804:2::41) To BYAPR12MB3158.namprd12.prod.outlook.com (2603:10b6:a03:132::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1a884520-3911-4def-c848-08d724ed449a x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: BYAPR12MB3112: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+46087+1787277+3901457@groups.io; helo=web01.groups.io; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 3X7ub+AgKmf7cWkAdpXEEMgtT6x4+BSLNlXGtJg6Z2bY13Dna0/2+XskTZkuqPzPay2vYtVi1FROb5UPDDoQCMnPzjWtnughvwC6ZsioA66ghi6y0pJSo+ZnxdQEsXgVfDBxX8UZQOmjPpChV9eU7jmt+KtQWwINxh3zen3PmZHsv+eWtUccZYNYBDJfdi7wVjr/DW+XhcBTpinbTmuqgwgTE9fa6kS/7w4z4ixwXL5vXzDaRgcxuemo3tKhawYjLpoLkbmOJ/3rwZqrJkQTuUvDQyK9qAn4Tvhqogp+KKYVYHMFjOZww2gLwbtlGyT3Xh/GYXk5G//S0tjs37QhAUaA/YIpEmF4QGi84+OZlNXPYNGVHqcRbL+AcwBWd89ClbAKwNdMPdFwkSvkQGiAFw3qTpxK9VMZr3T+tE9gYPg= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a884520-3911-4def-c848-08d724ed449a X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 21:36:17.5436 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: B08N2li0R11UVpL3/vcNX6DG0ffZ0Mw5XPUvWlIs/8PU+PeXl7kty4to8niJR0XfSgiusOEUzFa26yntjQywEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3112 Precedence: Bulk List-Unsubscribe: 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,thomas.lendacky@amd.com Content-Language: en-US Content-ID: Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1566301157; bh=a8678KoAFUaUQINRZUQRVfPa1kvHOBVgS4i3cmpCSac=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=jEpPMbVFCCZQb0qPH8hcKriJy5l5kayNz+9aBnQ13ZzhsDHzp/qdqYPS56Fea6jFADQ ovi//xtOOymW2wfkiAmq6vv4CeShNW4ZEFCrnqX24sedhUGME4jkwQfDHHwt4sYD7LEUR 1xQbd0Sr3J7d01pxfYP7BFEzExEL0BIH4Vo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky Under SEV-ES, a MWAIT/MWAITX intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Signed-off-by: Tom Lendacky --- .../X64/AMDSevVcCommon.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index 154ca091936d..43a3a116af5d 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -528,6 +528,31 @@ UnsupportedExit ( return Status; } =20 +STATIC +UINTN +MwaitExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINTN Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax =3D Regs->Rax; + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Rcx =3D Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + + Status =3D VmgExit (Ghcb, SvmExitMwait, 0, 0); + if (Status) { + return Status; + } + + return 0; +} + STATIC UINTN MonitorExit ( @@ -1074,6 +1099,10 @@ DoVcCommon ( NaeExit =3D MonitorExit; break; =20 + case SvmExitMwait: + NaeExit =3D MwaitExit; + break; + case SvmExitNpf: NaeExit =3D MmioExit; break; --=20 2.17.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 (#46087): https://edk2.groups.io/g/devel/message/46087 Mute This Topic: https://groups.io/mt/32966260/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-