From nobody Tue Nov 26 00:50:30 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+63864+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+63864+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 1596829365259840.3902928497239; Fri, 7 Aug 2020 12:42:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7oXxYY1788612x2aiZqvKIe5; Fri, 07 Aug 2020 12:42:44 -0700 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.51]) by mx.groups.io with SMTP id smtpd.web12.4241.1596829364273279876 for ; Fri, 07 Aug 2020 12:42:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GgtRIigUzzlhuokqoYC/1WrTOO0jqGv7Us6TKNu2nC2Dp5++sRm8UWclQcb8SM+zm05IQ7wZzYur+d/GUkZPMXRv/vQjDNFidAYnlf6wsdm3/m+TZFXcc5u1uLdiHklahLSIPDT/g9QqaO3hkC45ERYZve+7r8LHrdgnN/nQ7epJNv16eMvWKbfIdDl/tO6YO09vyO/1BfJ4tXsAOCpEMJmFKPZTbRab93IJXwMnKLYJ0HEV57w8VAkLnL760ndomm3irOcJ+V26lBZRkWkdfGf+YAFyIctZiLvDJ6PWgMo/IQzdTTrSp1Fp7WnSOlvFD+QfIBRAFNpBTdW7qzMEtg== 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=8NTCnoZUa8l7fJRJjHTmN6rj4HEhSC81uhz1zBZyzhs=; b=WYxBZQk9Hy3roS2gczqkQCKbpK+tEBAWgVrXKjiFqNoY7k4+i4Jy4cTUWazRVkXm6dk/FXosaK6F+h0kXLvSYgEKJNP7Hui52ux9C6AcN2tNnQh6dZFt6dGwz/D7+/pKItlQVKlg4chsGV5Xj88Z2l+JkhJUgAewBFqeaeAyeRWJok7x/4kWiXWiNHoQuT+v5OtkQ9NUW+FJZsdG36QKQm/P/cT8YYP0d96nBpqe7/cd/e3ovzp+ha28EYOvDsnhOmuvlyj7qRZlDQNrDhue4xMh/DlxhES1lUd82SRPOX9iPIgKHcljOwXpFl4sivV92hmOD+eqbGykS3rg5goM0Q== 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:42 +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:42 +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 22/46] OvmfPkg/VmgExitLib: Add support for VMMCALL NAE events Date: Fri, 7 Aug 2020 14:39:07 -0500 Message-ID: In-Reply-To: References: X-ClientProxiedBy: SN4PR0501CA0084.namprd05.prod.outlook.com (2603:10b6:803:22::22) 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 SN4PR0501CA0084.namprd05.prod.outlook.com (2603:10b6:803:22::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.6 via Frontend Transport; Fri, 7 Aug 2020 19:42:41 +0000 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5beb73b4-b619-4d63-48cc-08d83b0a0ccb X-MS-TrafficTypeDiagnostic: CY4PR12MB1798: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: FuQJz3GCZDxMKmb7k7M0stWP92/ZlLTEYeutAzOxSY7gSUOC7EYsR1AFuZo9thI6biHb7EVluauzW/jSgqFi9S8zrVHkSYxiNga0CrQWmTql8leWKDP292wBb95pjFzZ7Kp1eJkGU9ibOXGCtSuli787yBcPcptK+7igmG5ddU0GxKPuNlgvcRv8w1zGuI2N5C9yRYWcIL+EZKp/3PgO2IsTaHzJTNacuac4aS21SqcvA/MnqzOog2j9o/wMPFGBzJ282zEOo1wzNb6JDbg8zc3skw28wl8Zj6Alo7IcyLrW6y18MPx4Tz/e3Zue47NvX61kQSpXmsWO4Qha5EJThU65msMNpM+3vHGj5Sm6z//M88GXj2ixSs/uG0AHgm3mGCpz+8zRnSnmZiRocPbVa98htt0vvIbWpFgmJQE09qfAGh0NufwBugJr6Td6d59rr0YblS07iMfClkLMebJiTA== X-MS-Exchange-AntiSpam-MessageData: CgncJm7AJk59bhnWePFYxoT4nPRn4tXTutPcJxNPUyXfp8TrByjv+ip4NnJoOTQ7OwhLXSGF78B5Sg3CB83YpK2BftuQxdB6XMljtXiLDjfcBuPdEp58CtnIIxxrMXY/WzyWDc+nWWu2E8i4csjoYGyABORupu50u1gvJp7VGHV53Q4rrpxYT52jc21RG+a9niURryM5tp5xnFgt6t0Ckx9+8ZOcgn2dqysSrFja+OcE/FewhnIWMzHdsdE4s/yXFTiQeYZ/YUsS7pD3Ww7d7w47LPPSKgM4EJQ+ECE8D+6l5/LGpHyNqMXDez2fHVKLiEQTKeESD2ceIpaZyxpGlydPMpg9SYGfqmEvAQpMXcAMRz+iINdIAN+BTZENKHsVTlNwVIR+xFQifT9hw8hpc9MZLWRticojKsE22vL7IHMDh288klRHWpvU5+fY0ZPUl3xQl4OIGJPHx1NUuZ8T8wGbmNivWzAGBaO1Qa+SFKC2WQA9W5nMJjvguNP9Xvdiu1D2zHPhFiVmfg35W6eokoACnHmUFURnT2rSx1bypIkZ/IZIo3PDWN4Ng8xRn8Dk5LK3o2arLt3jnse5v/Ci1Y25XdQ1cAtS0SnUo/ahGwxNdCxW2vwKW+27nNo62PyKE3ge5pheitUrZJfOn0BAtA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5beb73b4-b619-4d63-48cc-08d83b0a0ccb 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:42.5494 (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: TbBwHKvTMxqL55tH6J8oTJu/MIoDqi0SAtz2zTRqjHzior1w0bFfutLNjI/lCwwjodjmR8cVYEjrl9WhPQqUCQ== 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: 7hryzQEYGxbZtZjqg2RWvC5bx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596829364; bh=5vNQMNgQivwAAgwqqrCjOYIlPep/1vEXYa3dtaBPXas=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=FUsX/ZuenGbksfnAwpfKX1kD2WU7u47SVkp3qeTEaPh4E4ABvIserOspqmUPRaLNFju nKCN5iCQZ25Rp9XrJoYrOo+V+i+GbVUjRmK6NKholtxRNNyEFpHrErvHNzSZng83e+Qmx u5q3l0N7gSTEEr90kmuttTKU8tw7CmgHh0c= 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 VMMCALL 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 | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index af5264095b98..54134f37e614 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -881,6 +881,50 @@ WbinvdExit ( return VmgExit (Ghcb, SVM_EXIT_WBINVD, 0, 0); } =20 +/** + Handle a VMMCALL event. + + Use the VMGEXIT instruction to handle a VMMCALL 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 +VmmCallExit ( + IN OUT GHCB *Ghcb, + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, + IN SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax =3D Regs->Rax; + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Cpl =3D (UINT8) (Regs->Cs & 0x3); + GhcbSetRegValid (Ghcb, GhcbCpl); + + Status =3D VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0); + if (Status !=3D 0) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax)) { + return UnsupportedExit (Ghcb, Regs, InstructionData); + } + Regs->Rax =3D Ghcb->SaveArea.Rax; + + return 0; +} + /** Handle an MSR event. =20 @@ -1395,6 +1439,10 @@ VmgExitHandleVc ( NaeExit =3D MsrExit; break; =20 + case SVM_EXIT_VMMCALL: + NaeExit =3D VmmCallExit; + break; + case SVM_EXIT_WBINVD: NaeExit =3D WbinvdExit; 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 (#63864): https://edk2.groups.io/g/devel/message/63864 Mute This Topic: https://groups.io/mt/76056538/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-