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.65]) by mx.groups.io with SMTP id smtpd.web10.1771.1596134865166080329 for ; Thu, 30 Jul 2020 11:47:45 -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=2+Di4LRl; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.220.65, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HR/801nZ0+YwrsgzH4edkbrVln7JFiCUfBSGCcgwu+J27wEAcSzhRtTmxt9Y8j6XBBt36aEQ7Hd4jyhzZGgNNM1aqa1PZRmZ7GEazcK17AWwEo7k1aV8kQd76O9qNrPfC5/BceSf5cDimXm05zmd2E89UcicK9Vi23A//jJ+nacUHmCQjlA7Z1fMzwoF6hVYp6PoQ4R74wyAFmh6ka/e4O0YcleqBK6vNCPjS4KyJOAfSo0qNGTrQCqqsxIRucdP7tx3yiPong1waNgiQQzOlqIg63Q5p2vA0ZRMjv/S80+iGmcskr9guScLv36Roftntomm8jSFf+yjEavm3nP8rA== 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=WEV0p8zXUBCrnuJY+bOrdc8XdNEw5vYlBxtBn2QRSXB6iSJtVRCVePfyU2733aKqkXILjDRBPpN2jjCTjTw/R8iOp2xBLMF16RL7X/AuFkQl5ZArzUsQ91JK8glWjpC35b2pxLKBdrproBMVCE4w1Ry2tEBDuEm51YqoaZL793KIXAvLAabUvEpmTBtU5Chnlqs/3oTP2kC6YHnylqBPFqyJ0hZU2q1q0K4CqesR2PTAv4yoYwtnaC2mJ1aJmNAQt6n54lfiyutqgJiKC4RSMwfiiQrPHCnoYwX2kMoTFPJKvKQC8aiyfVLucLG02lTGSC7JMa3SNOgKZjKpl52L7g== 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=8NTCnoZUa8l7fJRJjHTmN6rj4HEhSC81uhz1zBZyzhs=; b=2+Di4LRlr9zzqmRh9HNtQAjPtsA/yvClGZbh428AdXYJ+jpwfbPouJs+MM1WKj13QhEJA0qsrn0BEqRXtjam6XP/EmgVXKcOD7Apr3F6dTeC6SgdlXC8lODsyDkewxSV5chfzxYeeU8IyAglONcfYtgpH4TnB/QuKlgbQcYsurM= 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 DM6PR12MB4092.namprd12.prod.outlook.com (2603:10b6:5:214::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Thu, 30 Jul 2020 18:47:44 +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.3239.020; Thu, 30 Jul 2020 18:47:44 +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 v13 22/46] OvmfPkg/VmgExitLib: Add support for VMMCALL NAE events Date: Thu, 30 Jul 2020 13:43:34 -0500 Message-ID: <3875b1369073db03e6c5c82dddaf498f68505d4b.1596134638.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR21CA0024.namprd21.prod.outlook.com (2603:10b6:3:ac::34) 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 DM5PR21CA0024.namprd21.prod.outlook.com (2603:10b6:3:ac::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.1 via Frontend Transport; Thu, 30 Jul 2020 18:47:42 +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: f840f035-5931-49a5-43fc-08d834b90b4d X-MS-TrafficTypeDiagnostic: DM6PR12MB4092: 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: CVBrbgpEAvF75RUFfE53xbjz7kL2lb/XiBijmjZOI4vUDsMryJXSV07E7M96aN4jLl1TOii1gqFB3jwV98YmCBEoBmsZrIZPoLQPbpdj4pcrDTnebMEadE8JyuZGIPCUl9sKPz3L6YNKUvCGhA9kkcXcDLRntcNVDNj8SGbRt82+9YNs1H790K61j8Uc912NsxmNVYb5RPJqNIBAsZHqs3/WMBg6fnmnIhKhQ8R6LIRde970aqX5AxqswrCIjhNj6Sauh4Cie+XVdRf5RtJp4na9blCcobJj6RSr4HpHKN1D5lMZFE+X7WnKHx3ddU0gvAV/SfC+HRe/DoK6HvNQO4do0mcAIho41Lo6AglFPikE17O+MF7LiQXPp05RUWVJSdaarNkPZHaVqhN9hhhOsJkKdXH1syNTJJRV0KkKTrrWAqM52EtmseZA3rGTDpJq02nvx5qa6nVQrUcEeLyFww== 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)(366004)(346002)(39860400002)(376002)(396003)(136003)(6486002)(52116002)(7696005)(26005)(5660300002)(186003)(16526019)(54906003)(66556008)(4326008)(66476007)(66946007)(316002)(6666004)(86362001)(2906002)(2616005)(6916009)(36756003)(966005)(8676002)(83380400001)(478600001)(956004)(8936002)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AlLGpfvRF6K0+T/fcx75Xl7p343kE9dsNExnuGS3Hf7AEnI6YvJrBbNsKj2dASR+szDbqSjFHRSQflJXxVc7WnJkTjeyxH4kXCmn0E+QMRkbPTnbCw+gGHz+HDnOf/M2lYuAOZGkrl4De7J1Jbc90VskS14dZKD+WMHTSB2fDtp1sGPvjYeaZ/bAVaJemw4QB8jS2hjiaYLJx126dmbe5q9aZEaEvH505VAvqr9V2lWhwgOsRcP15iQkJkRxsudH2bGWsr9U5b9tZvCDzp6UqD4kSc8SAJHVL/lDAM5l4+J/2wskHhOyd7VWXNk5Ilfku2X/rXC/K6p2hANdjBmTQ13huA6iXgvRxUicJmwxjWmAwL8w25+kE6jseXzEv67Z43z8b4NpfOPo8h+YoDBbqeq3aYMfJGdQx3iy+/eh0F3c9s+m0QP8Nlw+4uJqGbtWGFyDVmfgHyvupNEL9CJwzRY5FJD21+QWx8hXc22mUfE3sUxAUaNOxuDPPRbZshVEWTfQsqV0M/jTUQzfS8mZ1MxcW9XY/hR7lzjSCHeivOxlaJY6DxyM2IQN853/4CmwJyrBfKdPA2p+9J3YNxKVnRxjyqf9gyWMd6fSSTBKx+NHyiwaXAMrFGTAFVWjYzh/aGmt1wT/851rz1SGZbyIeA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f840f035-5931-49a5-43fc-08d834b90b4d X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2020 18:47:43.9511 (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: ZJbCrl8VEyxgZ15uX3972B1D8AyZTpw7GOySiNqXLUuoiCeRV2zeqd7iL4W7WycUG5z4wigAC0HmKRUsCe2m6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4092 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 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