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=ltmQazde; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: thomas.lendacky@amd.com) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (NAM03-DM3-obe.outbound.protection.outlook.com []) by groups.io with SMTP; Thu, 19 Sep 2019 12:53:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b2pSiHDrmoAa0rxedPNaodjXCDAc5tN6WYJaVNAuUPGp8XS7Cj5VWCmKCxEBLFn8n2LWoRP36MGQ0uvEcwtVk9dcaSjNL4EUG6BA4RveemjQ2A7OQvoV97eT/+JUsJKwC7bw09BzcjrzNNTdXHCZy4vYp0chsNF0gqPLQ5vOoCJtPqFFF4VjZOklcAxDFUl9j4zmTxlR7YRVdo4RjdAMOBGC7Sko4axUNr8lBFJI+uYB0F2rDDPb7mrhhOOnfJH2ZrNWM7kOBn7vBSDX/29rImtpzGNmvlhPKRe+Wzrt4VRVYTaGP2HsjMEgH8e7j+oRo71+aB5FKvs0zqvgm4Ilsw== 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=4I3SxFxRjRvB9PRpB/1RQ/KcnxNWWKtQnYAPfgwq+KE=; b=ib3uJNeiPjyJCoShaDzkwmDD0DlMO+0baFId4hQc+JXtDLx1NEIIi61vZzHmIjVL/gNF4vY8XmuxR/vHDhFWqUmKLxER8afcLxSQYtKj52qZYs28KrKBxTXVR/UdsE0uFwOCVhBf5KdIDkkXbL8AJme/0qnFQh9JMWt3rT2sljahcE16zPxBqlUh7S+i+Y+ANEdQp9Z8slSqr7Jd10yTMsbuSMxu+OYDzfd88Zu50fIf9DxoFOdiuCZxusbWPNbwlRaHFhsTUCK8O0N1OwKZaqRFH+Gg8LBCkOeFVDVxPKCLSe0xWbD0HoiHLy63gWLZTA+0JMQfFoVYre5B5uaBrw== 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=4I3SxFxRjRvB9PRpB/1RQ/KcnxNWWKtQnYAPfgwq+KE=; b=ltmQazde6xv9b7RxnMPY8TwmllXbIYi/bXPiZovA8L5/9PHHl6yR1ZK0FADPsWcUn7UX4rId7PBJ4rIcXPkpcqBfNmBjocVdI5xjCepehoGdr4RGGb8ic1EvQSg8Aasv1cVts4VhTfzrhc80UZBVFu7Eli3nASQwxjLX6Sf27zk= Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.104.150) by DM6PR12MB2890.namprd12.prod.outlook.com (20.179.71.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.23; Thu, 19 Sep 2019 19:53:29 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc%6]) with mapi id 15.20.2284.009; Thu, 19 Sep 2019 19:53:29 +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 v2 31/44] UefiCpuPkg/CpuExceptionHandler: Add support for MONITOR/MONITORX NAE events Thread-Topic: [RFC PATCH v2 31/44] UefiCpuPkg/CpuExceptionHandler: Add support for MONITOR/MONITORX NAE events Thread-Index: AQHVbyPWIhSqWHPdjkyT5DMv0nnupw== Date: Thu, 19 Sep 2019 19:52:59 +0000 Message-ID: <8ac82088e4bd4f97fc7d13c81866e9c1e95a8118.1568922729.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: SN4PR0501CA0146.namprd05.prod.outlook.com (2603:10b6:803:2c::24) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:182::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e4cc2f8b-00ae-44e0-4aad-08d73d3af943 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:DM6PR12MB2890; x-ms-traffictypediagnostic: DM6PR12MB2890: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(346002)(376002)(366004)(396003)(136003)(39860400002)(189003)(199004)(2501003)(99286004)(6486002)(86362001)(476003)(52116002)(11346002)(446003)(54906003)(2616005)(8936002)(19627235002)(3846002)(6436002)(64756008)(5660300002)(66556008)(66476007)(8676002)(66446008)(76176011)(66946007)(256004)(2351001)(486006)(6512007)(5640700003)(6116002)(50226002)(6916009)(6306002)(118296001)(71200400001)(71190400001)(2906002)(386003)(6506007)(966005)(14454004)(478600001)(4326008)(305945005)(6666004)(66066001)(36756003)(26005)(102836004)(316002)(7736002)(81166006)(186003)(1730700003)(25786009)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB2890;H:DM6PR12MB3163.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: C9ACymwr9+G0TgFUC/iI8EwR2RhJVSoNcaqc5h8n52t274dLhJDZINbMsjeKYVJSXrtU9gCewcManADPUK6B+PXm8ojWkRcL3QQ9Dr1/UEkX/BxSLeLPva4UUsdrwg5P+XCwIYrM/RBS3zG/8UR8t4fCtDTYjj+aY52vM7cz+jEe4H4u9qQEXVkSVYNiu6sAkvkpuksiGUloa3YX+9DUI5jlqsUOvwJTyr9hML73jEa16N7c7EBDGS1sM7V8I+36YqVaGqENNtLKxVLrJPlOwVlp1np8wHbzVqxwHydMaUGOzyeqWeaOLie4a7tsJa2Wipo0ZZBhdBsBaiodDMIqltTY9BP5RmKCW4NgKlS0yPj75SBbv2nibBTCRNwXqkjRShJCyLotNOBRk1REv60eMvAeT7KLY61Rju4jXy3eXxk= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4cc2f8b-00ae-44e0-4aad-08d73d3af943 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 19:52:59.7917 (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: Qmagyvwx1aRODaGRET9tyxfylnOVCuxI0e6IYpqtRd+Ku22DNiC777etFJU/QqXtlKd2uc8ZsSAZTbCzzoM59w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2890 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Under SEV-ES, a MONITOR/MONITORX intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek 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 c8efc5c4c106..824175a80b9b 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -555,6 +555,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 ( @@ -1051,6 +1078,10 @@ DoVcCommon ( NaeExit =3D WbinvdExit; break; =20 + case SvmExitMonitor: + NaeExit =3D MonitorExit; + break; + case SvmExitNpf: NaeExit =3D MmioExit; break; --=20 2.17.1