From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.71]) by mx.groups.io with SMTP id smtpd.web11.9850.1597325198719969222 for ; Thu, 13 Aug 2020 06:26:38 -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=v7FZhXm8; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.220.71, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EYL2mMCnybh5GtNlPSdW4d1wPqZn+rsE72bHJI6suouWh1AfNF2spTI5hnPnSIJDSDzfNSiHrbwYIGXIPtLZ6K51Uo3Cu7mRQQn5uG7b2W5u6u9Li7Pk0i+fNxLHtwxlL6dIv1try+3d1ZyWm1rKGRS0b1GdSPcMan268ot5IjnpQTufgXmV2oEELaDtBEpi4mNHnRqzhQ+cJ51aE8691h4zKqB5n69v2hp9zDqCY0AmqwxTC8MP2VzlNHqP2QB29NcQoGmeW6mzYFNr6P7YVx2gpxbo+EN8O6laokdzKtee8xSCJ+NlapcwMqOPK+9LLZ7VJF3behjjb4X61nbB4g== 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=z+2p53ckXK1tC7Dz9fnwt3i6JNpVdRv+91rEgYJSxjs=; b=YuvvHJ4g2vgtTZKETBIxwMqIfi4lEr63co1xh9/+1zn2BacaMmRP+7aP8797ikmrtnBFSnJV1Lsca4T4E8jwIG7gABJ1bxCrFCMgppboFZsmlpLxFKbuwqirxPr/H0pFaFJk4psb5nOyyyxQWtr3yWQp9PHVYwK6lR5shGR2B/GaioivKT1Zwmm7SVa4CwtnLvKtgSvlf2uHLCalItaanfU26XH8JhEdrTV8RSy79DzlmYSIxwaO941MC1cujanioeqEy4rWobQlS6PB8o5YHLVxlWH/+0gWDzj0U6cKQ49DrRwFMCJCcHWHmdWIf0iTXqG3QrQVHSmLepFok7Um7A== 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=z+2p53ckXK1tC7Dz9fnwt3i6JNpVdRv+91rEgYJSxjs=; b=v7FZhXm8rtDD2MNgalpamu+WdPqu49TAv4kgQVLODYr0ZC8g0c236jTRPFMtlt0rsnYPoXoopp3ySvArlMN2J0YUszk6xSXwN8xsRakKr9Nq8gyCIN0LRi6fZUQYPJaT6SZFgaHgSFYp9ZaNXecJQM0ogFPlWgGk+RuitfojOr0= 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 DM5PR1201MB0026.namprd12.prod.outlook.com (2603:10b6:4:52::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.20; Thu, 13 Aug 2020 13:26:37 +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.3261.025; Thu, 13 Aug 2020 13:26:37 +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 v15 22/46] OvmfPkg/VmgExitLib: Add support for VMMCALL NAE events Date: Thu, 13 Aug 2020 08:23:09 -0500 Message-ID: <375c0435ce545b95e94793251dd25549350e52cf.1597325013.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR2201CA0004.namprd22.prod.outlook.com (2603:10b6:4:14::14) 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 DM5PR2201CA0004.namprd22.prod.outlook.com (2603:10b6:4:14::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Thu, 13 Aug 2020 13:26:36 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a41e34f1-90b9-4fbc-c1ec-08d83f8c8144 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0026: 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: BCL:0; X-Microsoft-Antispam-Message-Info: DaOmv9PBqEOA/A0tPXokk8xn8IXlj38xf7BLVID15lf66vqdcxRI1oHunifoI4dCN736Rdb3p9ZNrB5ZFuV9fk+x5UT7/FDImG9h8yOvtBjNBFvB4WPghXdj9/3mOwklomSz0sd0Tqu/4z2B5ee8HEKz9dhFGIDUjk5KCsvo7I8ZzSXZlyoDRaY4lr1ZWEt+SU+BNZyIYKW1ZB08ZAjy1VLjz65KB612NHb9CQkoyK38It7BpdFzIuSesn+jmTcS/dLSV71kkGY+jfn0hL01X6TpZUhuc81GXKW9lcoPG995czbmPvFPM0VJw6NoB6wWAOWa7j25C1euaCWIF4FPnL7nFe1BlolQe5RBvBfvQLRNxqi9d3fLHIFVJqK2IaqhLhOX+PD/pQzO023JRcKFrS5pXSUeLf8Gv2O+0SlwX2J13N5WOYuWzx/WKauCP5hGtCyM55i7G6A0sRtNuBODJw== 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)(376002)(136003)(346002)(396003)(366004)(39860400002)(316002)(8936002)(5660300002)(83380400001)(54906003)(8676002)(6486002)(2906002)(6666004)(6916009)(956004)(2616005)(4326008)(66476007)(26005)(52116002)(7696005)(66556008)(16526019)(36756003)(966005)(478600001)(66946007)(86362001)(186003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /9sEAsCu3dT+JohWf0dNlFWNioz5AafAqPouj1F/rynAD0C+M2JufrxcOkYlURQy4lwNgQ8KOv3YXHK7xgwFnvq/wJH15qPEzYru/R7QWJhhodtZ8RZtfI4M4V+Bx29lBF7NKFp0nxUepkOcDUA2aey+PEg/No1ihqgG4asnY+3uFkGdCjM2g3CginF27PgML1cJ45l4c4pabbmVxdRBV/CqJSLxQVZYYMc/6Cnd87zKy8VcHlPundb4Amev52TqFyJ2/k6klV3lppQXBL5o8AbSHT8b2Eoqb2EG6fUzquopCGckOLB3fhab8RGrycrnmEZVK2hoTSm8T8Z/+R3RH7HtnnTYBYR69Vm3pVSqNKN7re9mO8dfiCPPAuAgpAw0wxisKOyfEOmoeyKGBlk+maigGJpxp00pxg6wc/YT7z6L17CnjqeI8CbKO52FTPb5AZFMwM8dwRcisNSHeJUjlyCY9IM996+wsxpbRu8JCAvSb+jSdmL824dgF9hFkvwy+puxqdjhU+ftjd2V0EqTzupVuGPtwC4Lk1qEB1FluWxpBqq2PPNmNid5oX4RTkLnNWne1LvVMSQALLbegyunymcC7WgWvuY1iexwtlp/vfrkNnjh4l1B9BWneTfXple/bRtkJME8y0WG5JsUIMr31g== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a41e34f1-90b9-4fbc-c1ec-08d83f8c8144 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2020 13:26:37.2652 (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: aRqyn5huldCMamy83e0QK+X+jaZw5kOyyXILJXzWGFRPurE2MKgVOjC8Z2Dioamm46zhbuP+eZjtZV7PgXpZWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0026 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 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 ddaa19c7bcb4..dbea9c1f6aff 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -883,6 +883,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 @@ -1397,6 +1441,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.28.0