From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.41]) by mx.groups.io with SMTP id smtpd.web11.21252.1594737490560993734 for ; Tue, 14 Jul 2020 07:38:10 -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=zvveWmL6; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.244.41, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lX+LcTAcPuNyUkSQq0YSyp6uTsDjFaOd/hy33gum7NqzK6OBP3WSaIaEY9MJujAoX5qvv+RH+QU0twM70naABsIgtylmME08kSOjE8wsB8so3J+8H+lVHD8+81K6eeceqILwd5LT7oOrMvSlVor/HAheyV8GmeF/S6qV3j4cjdB1RdWCq3JWOpoiXpNqfLOE0XMRTdYYAUGkVvDdXniQix3u3mi27Ikd+NJCq8e2l+ertE0QBFGL7R9pnw23F0izouiBPh1EjfjEVfvpBrvZ2s0mDssZQxl3PJryUUoiITs8XeYd2gy4KLq18IUQfW2JGLxQFII+W7qEPklUY48w1A== 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=F8TjkvupE/Ud+ZsVI2VlYYedDjAsqbWb2ARs7Fy8WgK+onHQ/+KIlXUR9nwF4n0snrmgUtvHSkU1ueRoliLLCEfsBJ04Y6J9gPk/OGiAJY86dmI4GuH5bwVIIZ1NKek1LkHHEOixN4yOjiqBKddmntpsfWZGpoBYt2oNCno+9U2zI50lkLGaPTxHe66wkAevXCmWWl2O0J6qjQ2ZUUJ3lW8TE/V93WH0TQnxOa5UDsRHKejFsnW8pg7SlGBx3IqYl9AP/kDaFea7diHeRYpGzPpL1csHsO577dLZtp3Jzr3oxPSOjCAHBqc2bqo5M55jjmwTM4uh7FZjKmmCkG9OPA== 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=zvveWmL6XZZyp+KUuY/vxhJ5UNcYbGkvsP5jP9FErBBYpGMOKq6HcS3pmA54gMfFVz5QjbDZb+knGlsUo+5K5udHRegOhNBWX3BtPell7W0zf9yXculmOplYZd9BDrtt6qyOouxYKNjMgYBTlnI3cq0okwqz7l8cGELoBDv6F/A= 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 DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM6PR12MB4219.namprd12.prod.outlook.com (2603:10b6:5:217::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17; Tue, 14 Jul 2020 14:38:07 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0%8]) with mapi id 15.20.3174.026; Tue, 14 Jul 2020 14:38:07 +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 v10 25/46] OvmfPkg/VmgExitLib: Add support for MWAIT/MWAITX NAE events Date: Tue, 14 Jul 2020 09:37:32 -0500 Message-ID: <7daa9f497e0ef2da547d71404f20c02be6123381.1594736896.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR20CA0032.namprd20.prod.outlook.com (2603:10b6:3:13d::18) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) 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 DM5PR20CA0032.namprd20.prod.outlook.com (2603:10b6:3:13d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 14:38: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: 275a66a9-f397-4384-2426-08d828038620 X-MS-TrafficTypeDiagnostic: DM6PR12MB4219: 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: YuO85O9m1PmVblX3jYw6u9eLQ9kQaiKCFZs+OxZ4XIfaUxp0vJGqRcsItqm2WOwDJxH427f7u7rm2pdiacE77zZSK0hlztdth3UR5rd5dIS8FvhiVGCHXTMD7LoF7pAQ5778WUVnluYWQ6U9votVNhTr5zi9nsBTp+CTxr2bxbz1pGJ1dEuceVTrEUd3FfBw3Mdxt3MgreW+xQFRSoP6hC1Il/jyrEq6xMK2KzXcggcKbWI7zT6dG/823CUpQi82CYf5lzoLDUvPuZqsgiwA4FTdr7NVS+VmI2a/Whk7zNfN4sTq6dVbq7tt4M9rixptmSj38GhWVF4EdpK6zCXjFrLiKsQX6kg4m/8238xa/duUQuEOZq5iaeyVvwCRakSx7WLzMpbu+S7Q9zp6nUCUqszfaKM20UWlMwd1X1e9Sh4kCOSglmowGhmLZXENSpPEDTZ49vME7NesFU7gw2aEmg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(136003)(39860400002)(366004)(376002)(396003)(4326008)(316002)(66476007)(2616005)(6916009)(36756003)(2906002)(66556008)(66946007)(54906003)(52116002)(7696005)(6486002)(956004)(8676002)(86362001)(5660300002)(6666004)(186003)(966005)(16526019)(26005)(83380400001)(478600001)(8936002)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 8tI1hjEOq9I+McKCmrzS6uXw21yETBs8tmb0PusYC/n+bpz6AeWCQgEBpUyPg2RUKYwUOlJiltMXuu+94G1QZHDSqNAaV6Hnd3JNKV3MNoTIGNLu4Baa+6aAwZ1NtZjb+j2L8po/Q6DuqBAv9kyOJiQH1CfqDJdotu7JZ1A6HNgI0Uhij4d+/rSBr5nyXexOMXP3rLEacRnea15D+7Nc+mtb2ylUiSfOqnd6YYYbAVAsgcglCrFDjSfsMOcXRayXGYPMwm7o7+p7JDAZ0yIV65LHMDqfcaWpeN39dGQqbOzFHc1Se/hzGA+1DnDBJsylIgttHneyWnlK/8DDVlsCUCEF8coyMBWTkZbzMSJR3XJYFZoXz5+hcjlPFQehs9SyZclmoGBpynRc56/LpCvlKZXPeyfOpraZ/yqoe/HKNz5PfsGeUzG+vk1IOAFlqLvKXRnIxMI8t7vTvOijoaKS/CE7tfq6kARC6pdZEhCaMFY= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 275a66a9-f397-4384-2426-08d828038620 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 14:38:07.5711 (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: OCvkB3ccfMNd0cfldV84Jek5pF4uZZEXLhiWqVmn2JFQCXPUv+T8fq4IQeA989Z+PSB2cixrfeWWOjMI1nLAuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4219 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