From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.86]) by mx.groups.io with SMTP id smtpd.web11.21137.1594737218070746006 for ; Tue, 14 Jul 2020 07:33: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=XESXt02D; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.244.86, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=goHOVTVpAeFJskowtqIEk+c8GRUalT9fKrXmIIPfXcoaGZuXMWjjB1s2ytuA1Fkq53ZXB9Le+ljQ2uzEWs6BzMW50DuPPqRdKqrYWFhwOqOxxjWJXXGJnHVt+trLEMwcVV+xR9wY5f7YIGEe9vxb4tkZ/0596ZRRr6uswx7Av6WT4QzlvaweTGJpLzbayYUXmbpa3Rol5sckGY8e9Yxzx6v64bTLXRYbeBd1I9UDOXN2cGvZrNNrDyjhfb7TRWo/9SEeTvOoLXVsQ5svfpBSITMLEEiIrZwOCKUbXXZC7jLW1s3rPDrX5PzZ5umL5k28aNo9h/UcHE5QCGszInmbBA== 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=hYocCpCTduTZGrJEsxXhrPWj/Df3OJTf3lnoMQRwVrtCx07G6hVbDL3Ls1ViFbEforuFUfTvlV0ZHSclFkM8gz54Zu7QmCvsq5ijGS+EBs7qE4jS3elVS1l6s7xt0xM/SEdVmi8pdFBkHHUpIIPim1EfqDqtFEtWLOjlcOm5STysN+lNCafHf64IZzZTTcTgZ37gJMfEuLsv41/k8A2ESddq32kbAwsuGrdOUYeMCCvEphx/Ggs9R6cyw3y+Mlk2jGOgfIyF4xAX+bqsWDQgEQvTb5kZhZuxrLzBaeShgRsWiZCDpHnqofDDk8LXAcrRDPNcrY+IplUaQHdAbBxONg== 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=XESXt02DtwaXR668LurRB2t8/4G87zk0qBxivxqNSd7WOqul/6qNgGS5MoSkcwbB1VuTkijGHeoRX3PnhrPKXk/Xa3jZmXhWBuuJHcww0p78CgLRp3z3t+YCgTQF5oHsbXidvWL5EtCWhsa0TJksQB0zQK2jMBgl3X8mvm0Y6ys= 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 DM6PR12MB4219.namprd12.prod.outlook.com (2603:10b6:5:217::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17; Tue, 14 Jul 2020 14:33:35 +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.3174.026; Tue, 14 Jul 2020 14:33:35 +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 v10 24/46] OvmfPkg/VmgExitLib: Add support for MONITOR/MONITORX NAE events Date: Tue, 14 Jul 2020 09:27:55 -0500 Message-ID: <39ba43a83dee27d8ac1650d2bf0a58d11c110855.1594736896.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM6PR06CA0037.namprd06.prod.outlook.com (2603:10b6:5:54::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 DM6PR06CA0037.namprd06.prod.outlook.com (2603:10b6:5:54::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 14:33:34 +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: ba175775-b619-4101-098b-08d82802e3c4 X-MS-TrafficTypeDiagnostic: DM6PR12MB4219: 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: 1N4QvfNv0czW+eam4atkFs7vZgLeyf5e7UpWEm+uaWxicz7udNyzXKommgQPdmJ1r+Qq1k7eInkYI8yGp938aFR+YpW5eh6tvJnYogeRXqqmFEhFVxZCJWBhfAdzKFPc4IuNgzLP6TehxMnuYMgqa45Hr+yq/xCcS+JkgZTykKUuqXVT2gWZn3yn61fdwlMWHND0yuzsNujLcah3mC7JTnJN9XGa6yHZ5bFZMDnQ640fD/c+76GKcJNZytqwDhkMpslH94Y0ZPVS80vHcRODh1FAiLXA7oCLvAOHBkpGIw4Qv3vz6cvg9poxZH/dF7N/kIvJ+1XZ+hb1pfpElRyJHq92cWk9jMWdQSYSGlqccAdZd3bGdWgAgIzrZoE2HHDPC/6l4Kjq1CGUPhf3tb0qD0dTU30D6ySjEdbCssCYThlbMXh4auDG8iE5n5Q782HvAtsTeKGcI6p5u9oxIE6d1Q== 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)(346002)(136003)(39860400002)(366004)(376002)(396003)(4326008)(316002)(66476007)(2616005)(6916009)(36756003)(2906002)(66556008)(66946007)(54906003)(52116002)(7696005)(6486002)(956004)(8676002)(86362001)(5660300002)(6666004)(186003)(966005)(16526019)(26005)(83380400001)(478600001)(8936002)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hDAXcMaZbpYsuDaO9lv1FCPa5e+f6zH8yMzQ/1zNj9mT80vLcauFBLhdFeEGQwhDbpMVKB0pR4vDn8yNFjXQUgr35JUeu5Wa66ZlReqNly3FHyrF0Ku5QzbrYN2Y5CdKSHxDDycpsVWgUzptX6aBUUBpgIfMsB8gw9po8byWXVnjih4qGd5NHC6sRcFRlEUdLAQkq0rzam6h9eZaQAmfvp4eTusVieG1QdJQHrTBEPx7NGnMUBDfAgkU87O+yZgPzKboIP0gdSaZZRNBW+WcOmW8XygRzB7VP3ZHtE7uypKfJ7r20mvrk49Yd/qoD6SeKgkKFOhuUkDkq+f6YERyl9gX/ad39wdQKMRM792cJzBPEvyahLkaw4LnHIB7ShkH0Qv34APYY0IWYJNqoEwrDlHg2dsVzmbuBLnnDjZTX+vtXZQldBGPQPdI/TVaMmCSDQ40HDsKP2lkKgLbNbGxYuojlF8NWv5DuEim+vvUvWk= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba175775-b619-4101-098b-08d82802e3c4 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 14:33:35.2804 (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: NwNShIIgSJ6P5WiBMMNKx1wjAcVDQe9ZYBSmKj/HI4yCaaRuhbVz72XCS5pLw6TY81iCtJO5Ii73Nh5BaBlvQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4219 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