From nobody Tue Nov 26 00:39:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63866+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63866+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596829381684213.65029010717615; Fri, 7 Aug 2020 12:43:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ErV5YY1788612xDSdj4vFy1f; Fri, 07 Aug 2020 12:43:01 -0700 X-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 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 X-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 X-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: [edk2-devel] [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> 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) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-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-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-Message-Info: PkD8LZaGEB0fp/YliTmzw3jyUYFdIsrCpul/EF9lKV9Vw2Ko9s15y0g4fNCxKH27fzR8CY13qigNfJSzOX4vbZJQnI1LS+MdKXp5xTi5TXgbcWqS85xfgeenl/ApHMNcx+J0fP/TMBojBuLuRu6Mr7S89GD1gQ3DBWuWbawKWWrU9bXjV2FjXln76AFqTAu1/1TKXSXKlqyORvWK1B5D5agBUdYGZk5+jw28lQvy2G+qYNxXUfmSQAqEiivUImIRgLZ1PRz35kfpeIYUyPdE465ESDv4lP2pFzJA2dvrLwBmM/N0RQUQqMJwejwLLO6y1bGwc61YzrXROfVMfxeDR/0xyakRNPtvHkh4xdv3xN/EciFR8uBGtiwO3zeqY/P7g05Dyj7IJAiYch2ex5FlEDv0LK/5LyXca5W5/PJsZIZEmRrsaC41FSC96H9nxi2KkBqRmtUTZrsKLjIVA3NkCg== 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 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com X-Gm-Message-State: Aznmh1Sdas48tkUnuFd3rLo4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596829381; bh=gGXX2UwKOkr0vQnirUmGqEPjbsdT9DFG/QKV8Mkw6w0=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=fLBQN31M0Jd0XmBSEWizDsfdL3UTS5R+l6YvoliUtR3fq0xhj88Z5scUJhuHI02iwJr Bie7c3it9tQAOwraBgfR35FgEYtod6xiGltNMojHm1qF1NQJHMRzfm2bR/u+ttKCuuPTz a/v4zjpKt55e+ajTSdUAhAEsp/SNDXNYQiA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63866): https://edk2.groups.io/g/devel/message/63866 Mute This Topic: https://groups.io/mt/76056543/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-