From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.47]) by mx.groups.io with SMTP id smtpd.web11.4260.1596829380488888821 for ; Fri, 07 Aug 2020 12:43:00 -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=ZEmT7hUo; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.94.47, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kVctTK0YINaPpGr0RlRkO2yAoVNfIFE8dWD5kK222hJAAAoFODSjxB+JS0KVX1F+aWRVQnlt162N2MXNz87pE2vy/yiPriLThbRkfhfrvJWTGKT0LIItaIdO6UjsQ71/o4PYwKxoevI22Jg8NRgtrR7Zt64NwZmamsY19AwS0hzmhwFImyu5dncuXTqRwc7kBSNV4rN+Zew4ON6xuvKCLq3+amYvHXS+NVDBqehnPNI2UwBKkvIhWebjmoRb1l1o2yEvLVHwNFvTDjWeJE4xwY31aW1aidv6+kunqLkGhZmXwc4dO03JtOtKPL5X8t7ELsy8zzZqYutkM1PFThPUeQ== 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=8ngCipJpXdBRXheijMbZLSMbkg66Y4aDLYNKKgZfARY=; b=QfGgMJglK1bS+EHDdNg7lIURDyc+9HCjQIFQsCUYhikfPbO2tR3xvFJOEiN7UlfSMu0IEL1kd7y94kbcgq5XFjpcX5rorsRbhwEA9GLlAVES5mSJUlED/Pg8o5/pASv71/wOacJVHh9xzLLfEU3+5XHAf4TK4/ljvzIKEK7ZaEhIi6MtMjX56D8YjfZRnxjsD/ptXZ/P4cBA50gE0LyD8qth9npLB4QCdGeHdRWYYMA3tH9x6a3WFWEmvmE2psGG+cUazsedRzbUeE58X4y5qKFEhionZh8LQKK/pLgVDrnPk8wRdS6Pp9WEiPIHXyfrlINoF3ZeoN3JiypSwaOGjQ== 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=8ngCipJpXdBRXheijMbZLSMbkg66Y4aDLYNKKgZfARY=; b=ZEmT7hUoK5sEW232E60ID3D5ZIGOz4E/BPoYg51kEM+aAQIJwHWN3qjjE/AmepaNnkEsV916LJCOsOqetAwU2L4CiYwbAwxH3O3sqps45OyU6xJhsQ+OTuXoaRkD2mHq87Qi75kp9WbHnenZeKQcLFiPE2IhZkDnS6rgaTGTQ6o= 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:42:58 +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:42:58 +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 24/46] OvmfPkg/VmgExitLib: Add support for MONITOR/MONITORX NAE events Date: Fri, 7 Aug 2020 14:39:09 -0500 Message-ID: <7a56a78a07635c124f27e7c4ac1a9c3eb6877e55.1596829170.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: SN6PR01CA0028.prod.exchangelabs.com (2603:10b6:805:b6::41) 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 SN6PR01CA0028.prod.exchangelabs.com (2603:10b6:805:b6::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19 via Frontend Transport; Fri, 7 Aug 2020 19:42:57 +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: 6585d997-caf8-470b-305a-08d83b0a1679 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: PkD8LZaGEB0fp/YliTmzw3jyUYFdIsrCpul/EF9lKV9Vw2Ko9s15y0g4fNCxKH27fzR8CY13qigNfJSzOX4vbZJQnI1LS+MdKXp5xTi5TXgbcWqS85xfgeenl/ApHMNcx+J0fP/TMBojBuLuRu6Mr7S89GD1gQ3DBWuWbawKWWrU9bXjV2FjXln76AFqTAu1/1TKXSXKlqyORvWK1B5D5agBUdYGZk5+jw28lQvy2G+qYNxXUfmSQAqEiivUImIRgLZ1PRz35kfpeIYUyPdE465ESDv4lP2pFzJA2dvrLwBmM/N0RQUQqMJwejwLLO6y1bGwc61YzrXROfVMfxeDR/0xyakRNPtvHkh4xdv3xN/EciFR8uBGtiwO3zeqY/P7g05Dyj7IJAiYch2ex5FlEDv0LK/5LyXca5W5/PJsZIZEmRrsaC41FSC96H9nxi2KkBqRmtUTZrsKLjIVA3NkCg== 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: 8mWlRlJjOevA4pscpXODKcqzz+o/V+yvToNMC7asBMf4A3iGo3G9CD25bqIWJBydBEw0JdEgjJ8K5P36lpU95/p6jnIAT6U4lx30tcVQr8xNm2ub5+8QI+7ZDstn2VdivHhJqPOLmuOWLM8LV3Ga/omGT4C5e9S0bCmTmFYssCiT9IE2XSA9p3NyCRkgifYjWu2L+PPBSab0ZShi9hoKozfg+tCXAPYx4IEHkfVTbCZPwVBM6EwcYH+xi0IkwvqonHP0UyF20oifzBsGbHaJ7TVi/3Qv1FIiDGb5Ntn4Ke1Gwka4n3SvXvHolGr0M1ugMNC58pkp3t63uDftzWUfMjfQjlu2xCEVz2YAbeTUxKImS17QK7jHhGg0wpxmFG9N1e4faB67kzJ1weyT9KPUkm8wwzEvIgpl1HaOVDhB0U0buwUAYDwRzpe85YwPgLYGAQ4wYnB0AHfYF77w9k0cbK+0Kt2TzoYvoF45kqTl/LMcO1mXPBp3NRQf6llIRr09MlvZS4eS1IHfaeOZYzbAst1A9y7UuwjAXltd7Dm2j/MxCnDD7umv6J+bCTvtIGFQE5pO1x2z0Ovp9GcB38qKiFoW7egD4Hnj8s04NrszHygKH3wTOA5ujlpQSz7WxGLgDLsFzk5KSnOwItWNOiC4Fw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6585d997-caf8-470b-305a-08d83b0a1679 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:42:58.7876 (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: tcNfidmDLZl51gjFc4463cXwXIgr+sLz/qzBGqjImVYH7sKOvi6elzfI6JinxlG/m0M33KUlieN/EuLzi1dFBg== 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 MONITOR/MONITORX 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 | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index a1cf792d4d0b..fe08b1e0ff49 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -856,6 +856,40 @@ MmioExit ( return Status; } =20 +/** + Handle a MONITOR event. + + Use the VMGEXIT instruction to handle a MONITOR 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 +MonitorExit ( + 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; // 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); + + return VmgExit (Ghcb, SVM_EXIT_MONITOR, 0, 0); +} + /** Handle a WBINVD event. =20 @@ -1494,6 +1528,10 @@ VmgExitHandleVc ( NaeExit =3D WbinvdExit; break; =20 + case SVM_EXIT_MONITOR: + NaeExit =3D MonitorExit; + break; + case SVM_EXIT_NPF: NaeExit =3D MmioExit; break; --=20 2.27.0