From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.56]) by mx.groups.io with SMTP id smtpd.web10.4200.1596829388516195980 for ; Fri, 07 Aug 2020 12:43:08 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=cDVtBLmS; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.92.56, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IHWcI8gok+htS3gVrW0ZPy4sZhh72DOe3ZXaF928R4tdmfHafbxXksSr9AffP06Al2ZHMdzDvBDZbnv7hbeAQZfQkBtohRpnmf62KGWdvDFlgpdEv9Y+uJJxVG/+fm5VW2aGj1G9CANNpKpZO5JXz/Q7fUL1Hy3DUuyzP0f2laUqrFX26rmEva7ctf0DbHDB08tbegT8fHVkndvOLT7fooMSOcF8oGFcWjWv1dFputEonhENxt/tWG7bqKTYQo4TD0+ln2cOD07B6oLLr51MRk245TmxIKeUDWPLEuRUeOG93w8+QdkMD1DkQJroCYJV08hyQpvHl01Yik3M4hiMaw== 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=4ovVcxdgW2M+goyz4Wril5Z4GVk0Gp8R9simGO5DPIA=; b=kGZBUIFQqAd47lpOqs+fO8+pHBkBagz/oaMMu4+30EKnwTYwQclMrpa+yke2gc7oWkF2Rqca9xWnC7/kFai+pUGadcZWAJOoHtI8T7L9CFNWL8+FlmupP03CqXyphFg7woO6X3HluY7NlxxNfZzNh21VEAVYD5X53vZsbM4G4ToITe0KHMk+KtlqZ3dIJH62HPaqx7WtieDL3XySEd+233XWc686eWVQkru5mu9h8p8s6EKOqeEehCs9wLhL22X2KUdAeVRJQ9Yh4OUIbfBEZCQLjwMY59fijMTfczG23i4wPYyBludYiiFDFEibBmjxEKdeIaVU7RXA+7DO4W+s5w== 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=4ovVcxdgW2M+goyz4Wril5Z4GVk0Gp8R9simGO5DPIA=; b=cDVtBLmS/ikp4NRJOlJ5AL5R/Bz7Qy+wxpgVUYAFdV5ZFNGi+qQyvlXWV+qtLgwCQ4Pb0BT9STO6Zb4Zouc7CE2Cl+WeBTkq1+Nyq9go8/KNQvHvEz1M1dbk0Ay9sy1cH1Rbfl/uml6g8NvixxmtQXtyoJmm10PXIUjuL9JFPPw= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1798.namprd12.prod.outlook.com (2603:10b6:903:11a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Fri, 7 Aug 2020 19:43:06 +0000 Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b%5]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 19:43:06 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Ard Biesheuvel , Eric Dong , Jordan Justen , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni Subject: [PATCH v14 25/46] OvmfPkg/VmgExitLib: Add support for MWAIT/MWAITX NAE events Date: Fri, 7 Aug 2020 14:39:10 -0500 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: SN1PR12CA0113.namprd12.prod.outlook.com (2603:10b6:802:21::48) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by SN1PR12CA0113.namprd12.prod.outlook.com (2603:10b6:802:21::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.20 via Frontend Transport; Fri, 7 Aug 2020 19:43:06 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e1813f71-15a1-4121-f743-08d83b0a1b40 X-MS-TrafficTypeDiagnostic: CY4PR12MB1798: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DlIl2CCDvBCIVmSNRzpjJNDZisNiWKlyBka8x+skQevtvOK8JJou+wtun31qYHiEIhS415KSfvMQ7Ajit8pefbkGrrPhb9RxZndcZ6WgPg0wjzVPrbFHEpFADz45GGibAbwovnDzsNlVzEIJc8V8C8p0GBe9Gub+slHKt+cRxEKsuSg3+UygBr/VRq7nszVwgwYls32py44VchYNLCYUyabofYKyq0+aQ4UGexTi+Pc9e11tJiwXvv9PdwdqC86O1rRUBFIAzJF18jjApKivPRQqoLYivxRHRDpFmMq2DEfwIX7jVhGjDRrzAqa1zC01neInU+T/xiIvjkEGw+6H4gDMbuls4UAToScBjx1dnvYIj2F3yO+5/StYaOrXIBDkOqzmaVE+T4CxO/jEvOTq3BjlTyUbvwITymubFqXQ9uaMGc0Be6blvOt6M3/v68hdqkjRQE7Bo1RYU2QWCz503g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR12MB1352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(136003)(366004)(39860400002)(346002)(396003)(4326008)(66946007)(6486002)(2906002)(66556008)(66476007)(5660300002)(966005)(478600001)(8676002)(7696005)(26005)(8936002)(16526019)(186003)(86362001)(956004)(6916009)(36756003)(2616005)(6666004)(52116002)(316002)(54906003)(83380400001)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pH1UMRZSkOyNtZ7mWEzWf3x73hl2R6Vrxu7TcV+2FiQBuqnQnQpx7DuTRthm2ah+D9krTXJnkHohzsIQ926oRCxBhC1E/M2f3YZliKKAGcEB+vDzL+folX7pGWFyQrN4l2tKguNeJ+cCMgNjLMol2jrZGwpAHLvo8IGApyGmlbhKw4NoWFsid6NSBoctXoDa7zm7usBxCePvWzeYuzNF/jLoFMzQ5de3iUra5ZZbdapghlTCBd9EohhnRF2LnUUy/dFoc+dkCy0HLBzubRWjgXdEajts0RCDGKmvxt+nomXA1ktJ1LLSW4KNXVPe2W6jTLwjkLubgsk/W3COLbJYE3vM3xvCRmDr2yguyBOzAph8iK+jYsh8y59Oo5MSTENvJMAwTKjPIhEk22HukVTNo5EFuQcVzGMLrJA2BwDiNEuoFTJMJyXARYUE6C8LaF9yONDShZp7AFhSgaCjpFS9fNou16otbtd4nrZYznWhglH/gK+mZ+DR2CuvIkYNoPKe2u8IDZHDsNPVcg3xPv0/g8Xer4zplvWGYvrTEvbsyhfth2ry49nlrfvfEMMC8u0Owi9dIM3etLVlmtwTJyZ7k10eies8V0ETkM2kxKy8upo8umWlQyiwPJRUsIY0VhtlRUZO88qgFLgtTjpaaoKmEw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1813f71-15a1-4121-f743-08d83b0a1b40 X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 19:43:06.7398 (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: 1sslpqKKWJV+8DlM9u5MeTmVu6v8ywpiPqjxJTkCcPu0LmpobbPVHHLFrVnmRJbSgowScXmn4w7dJzqVnNbg2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1798 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Under SEV-ES, a MWAIT/MWAITX intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Acked-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index fe08b1e0ff49..e70e0ef82f68 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -856,6 +856,38 @@ MmioExit ( return Status; } =20 +/** + Handle a MWAIT event. + + Use the VMGEXIT instruction to handle a MWAIT event. + + @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communi= cation + Block + @param[in, out] Regs x64 processor context + @param[in] InstructionData Instruction parsing context + + @retval 0 Event handled successfully + @return New exception value to propagate + +**/ +STATIC +UINT64 +MwaitExit ( + IN OUT GHCB *Ghcb, + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, + IN SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax =3D Regs->Rax; + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Rcx =3D Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + + return VmgExit (Ghcb, SVM_EXIT_MWAIT, 0, 0); +} + /** Handle a MONITOR event. =20 @@ -1532,6 +1564,10 @@ VmgExitHandleVc ( NaeExit =3D MonitorExit; break; =20 + case SVM_EXIT_MWAIT: + NaeExit =3D MwaitExit; + break; + case SVM_EXIT_NPF: NaeExit =3D MmioExit; break; --=20 2.27.0