From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=BC1kNdfM; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.74.50, mailfrom: thomas.lendacky@amd.com) Received: from NAM01-BN3-obe.outbound.protection.outlook.com (NAM01-BN3-obe.outbound.protection.outlook.com [40.107.74.50]) by groups.io with SMTP; Mon, 19 Aug 2019 14:36:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dc+o5sYYF40BYCV2hQ2oyDhUhC4aiK+iUPTUAfFalb74riC8gKX+Yi6h61vTMIk5xcidNv4yd7XkqVqz0ARm4/uafaas+jt7UuMm+QYgqrnqe/1B/tyYe7vFX5jnMiJvR29D4y0TlewBgNNyS+fGlBfilWjAW8JukDgd3CR++YKSQINl/YxPzZLqjJe22RdJnRLPQELEW4w+dsLknLEee0QsgDeavPaY/o0OgmCx8QfZu/BZkpuFvb3+y/0DGv7tAT/PPH24P/PxJAoLAksCsRzyH+kTGAosgV2AqKuFNJCWO6kV0fyE2SgW4l5aUQazY60hYyy9gIHSOFiUMnzkdw== 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=FZ8QCb4z3QBgYmBcsXS4JVgw6AvllmkHlkFhTZXi1gM=; b=nofU2ldAs4TB2fYQLqC7qZoSFyYkt15dmPdfgDxoflv1uSdCwYdBhnWDviySoLVEkp70+tmW0axx2z9GGWwh/FkREgygWv1QT92i3bJ4m4VUsjo/bgxw+7sgAqGGCelc9fiiGGfC1Pdbx2dhB8H2zZ1qts5OfDccQC7DqAniNB/y7o/68m8rd4PxQiOVj1CWp+KyQRHt1DLegX+5qgcmfnFe61auFAyUsKbuzZp4/RTShwjEStKFGeKF/3k5/+/5Bq4GqIVMM4nWZxJ4vQFl/JeDEjJhSy/SvClqnyM0roOneZFHor+4kWMz2itzWBXxbtJpbXx93x9sM94C4zJFjQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FZ8QCb4z3QBgYmBcsXS4JVgw6AvllmkHlkFhTZXi1gM=; b=BC1kNdfMQschQlGK06iuQjFPYu3XgTpPJaR6bIJvyFUJJwFrV0xa3L7tNhqpuKJxmknIAXe5Kkv1QC5aDp6PtAVGSLkfa2fGVCR7imfzkV4nmtwx9yoSUT+1fBFcfLYqA7eUKvuK5R72Z/V8NYJf//PORLUteFxmaBV7mCD0k2s= Received: from BYAPR12MB3158.namprd12.prod.outlook.com (20.179.92.19) by BYAPR12MB2965.namprd12.prod.outlook.com (20.178.52.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18; Mon, 19 Aug 2019 21:36:16 +0000 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:16 +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: [RFC PATCH 22/28] UefiCpuPkg/CpuExceptionHandler: Add support for MONITOR/MONITORX NAE events Thread-Topic: [RFC PATCH 22/28] UefiCpuPkg/CpuExceptionHandler: Add support for MONITOR/MONITORX NAE events Thread-Index: AQHVVtYhGWe9AQ4pgkCUlKlfSvg5pA== Date: Mon, 19 Aug 2019 21:36:16 +0000 Message-ID: <901593f1a8987759de1861a260f7dff2eaf755f6.1566250534.git.thomas.lendacky@amd.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: SN2PR01CA0031.prod.exchangelabs.com (2603:10b6:804:2::41) To BYAPR12MB3158.namprd12.prod.outlook.com (2603:10b6:a03:132::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 26cb4926-592a-4715-0123-08d724ed43dc x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:BYAPR12MB2965; x-ms-traffictypediagnostic: BYAPR12MB2965: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 0134AD334F x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(346002)(366004)(376002)(396003)(136003)(39860400002)(189003)(199004)(50226002)(53936002)(316002)(5660300002)(2351001)(52116002)(76176011)(36756003)(6436002)(71200400001)(19627235002)(6512007)(7736002)(256004)(86362001)(14454004)(478600001)(305945005)(2906002)(71190400001)(2501003)(64756008)(186003)(118296001)(4326008)(26005)(6486002)(99286004)(1730700003)(386003)(6506007)(66066001)(66476007)(66556008)(8676002)(102836004)(81166006)(25786009)(66446008)(6916009)(54906003)(3846002)(6116002)(486006)(5640700003)(476003)(2616005)(11346002)(446003)(81156014)(66946007)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB2965;H:BYAPR12MB3158.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: xkF5kIL55B17+r2kmZFBZGm3d917HK0GlcwWQUtFvV+PekFL1YoJHpyrg3qxVMUDNwD1lPVDovaXNQ6VJcYCxus8DoM0QipOf42nx8ESIyv+Rj96zK8CvIZBpvVCX5TLXIF5j8gD92nweKRlncEQ7uye3b68VdrfF8OPGGopRzBTy/hxWVccyUn1kgosrPuFo8wY1gkfBoVhkgN7dU1nyIAVBdP7PYX88OJf5GbhTyRciYOPBEVytnei/pQpUmRNH01Z3Md5EO5UeIOy3hYTIBmd8XNhNhIidRjgpyUbM4Nmdbx5B7nkf2Dx9d+khy9AJuUuueyzfXyX4mtMMDhMdhSIMDomFgX8kUm6JoVngtU82npd4vrZP2dF9i6tYfoZfopCr9P1TU2Z9OLT+mBRMQgbk9MN5qXzKrlk7GmbifA= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26cb4926-592a-4715-0123-08d724ed43dc X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 21:36:16.3203 (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: tqPwOP0GApF1CI7EmbUMUX6GArz8VoJrCcHDOAvCD9olPC5palucR/0FC3Eb4YrqINP/UmjFFXI22f53oQLM3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2965 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable From: Tom Lendacky Under SEV-ES, a MONITOR/MONITORX 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 | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index 8f9b742f942c..154ca091936d 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -528,6 +528,33 @@ UnsupportedExit ( return Status; } =20 +STATIC +UINTN +MonitorExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINTN Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax =3D Regs->Rax; // Identity mapped, so VA =3D PA + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Rcx =3D Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + Ghcb->SaveArea.Rdx =3D Regs->Rdx; + GhcbSetRegValid (Ghcb, GhcbRdx); + + Status =3D VmgExit (Ghcb, SvmExitMonitor, 0, 0); + if (Status) { + return Status; + } + + return 0; +} + STATIC UINTN WbinvdExit ( @@ -1043,6 +1070,10 @@ DoVcCommon ( NaeExit =3D WbinvdExit; break; =20 + case SvmExitMonitor: + NaeExit =3D MonitorExit; + break; + case SvmExitNpf: NaeExit =3D MmioExit; break; --=20 2.17.1