From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (NAM04-SN1-obe.outbound.protection.outlook.com [40.107.70.84]) by mx.groups.io with SMTP id smtpd.web11.58135.1595863790552577121 for ; Mon, 27 Jul 2020 08:29:50 -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=a93NPYlm; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.70.84, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EWHUUAtwXLJAsLc3/0oUR4DPa2A8CweB8nY810oUiuYbVXM6zogOxsEe5bssRNz7s+GTUVLoxfKqfDv25Kd8CWO/2LHM1JvjfijzlSrGLKXIhABYkyWz+C0oh29WmbsOIV13Rbt+jq+WYFr6P9jnWwG2vGSaat0OyJKrgQY95R1YnVpT7wEWs/olzT6MYtidO9FzSvRSXGJQK8ejU8QugZlsYwi51tOozu993lV+W2dTScNtNJhCkPGac5FrG+GqcmI4NMjoueooiraFOl0gM601EixaTeE/RcXk6LfC+AhmbURApuZH5b4q1xnTExylUuW0TSgE9kUIEINe/nhHWA== 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=BfynjQ5B8a5I1s4lemQ61H5pO7KCIKi/r2VwHDBnd+HKM4iHkHHrSPwvhcFROuLlldbjurDMpqR33/8odM7Ab+jWk4ggyvJSjFqMzbHuXdD0u5h7MWsYHp+yAP4XbsDVjq+ypdW1S2Rv9itvER7Phpd2ocwxEqVoUr5pxYXA9yqwWwLK+JyAcQOw25c2dWMxeQKDh/ccuEVtM9NSKpYuj6MSq2BNZqwnuNmgmyQ0cXEqGKmkXYH+hMAwTTVGWZegib3iNgcEsVLWUkcFL1x6JQ16NI3rt/6RGKK2wN8sUJe4yyTmmKivVLUPRx3lS9XZa6u/zZL48+oy5sGt8GWLpA== 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=a93NPYlmY2pG0mR75gpyZFLx0hOWncG1kI3EjFfXIBWOUgVs3uY/wWu8wttSf/F4rB//VfQ52O5PUjVFLJI05ZkTbWBgtqqIeh8gJQO/Ma55Zk8ebyVIjbLXR91Qk/76fEC+IE6mJ0uWo5fGz01HrS1SWzc+Fp8vU9l31Y44e9I= 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 DM5PR12MB1163.namprd12.prod.outlook.com (2603:10b6:3:7a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.25; Mon, 27 Jul 2020 15:29:49 +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.3216.031; Mon, 27 Jul 2020 15:29:49 +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 v12 24/46] OvmfPkg/VmgExitLib: Add support for MONITOR/MONITORX NAE events Date: Mon, 27 Jul 2020 10:26:05 -0500 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR08CA0054.namprd08.prod.outlook.com (2603:10b6:4:60::43) 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 DM5PR08CA0054.namprd08.prod.outlook.com (2603:10b6:4:60::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21 via Frontend Transport; Mon, 27 Jul 2020 15:29:48 +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: ef457342-077d-41f7-58f0-08d83241e626 X-MS-TrafficTypeDiagnostic: DM5PR12MB1163: 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: +TrYObIEewsJv5/6kyJgGS/a8NYiGXUkhtbvCg/M9Cg2dnooG3qdHbXJ28it9xxoq1S6+LMN9HUEnFKUHXoHGz0kl9MLSbi2wEZLOkS154BK/tDkTLmhJuhf0CVBKqfcVIMcZOz5Luj7/q48QaFIAQAjAQ7FJFcG8FFg4hdDXiWwzBCsT5xVSFG2n9CPwBEqorVMNrBOK9sW/72Bp9l87nxe03LaIYYeQd7AcvP1WjOeiE1QTwHCn+CDR04jgXxuRPxq6MScz5NY2DliEYqrFaVAdGBzMCojuDJ7aUW4dfb7YsIs2fco8lQ1pe/PfNLOlVEbsBJA64RVweqF0KNU6QV4QgnM5bWb4Q2PY6P/ckUzfBidgxw3/ixIESD4uSExvWpPSHGAJbzFdPysNhGBQsq+j+2cnMqn6QAq507w/PGSuPQ8mRPK0HmCbYgdJFTLxgQL7VSZbUBrHoX3CboG9Q== 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)(39860400002)(346002)(396003)(136003)(366004)(26005)(7696005)(16526019)(52116002)(186003)(66946007)(2616005)(66556008)(316002)(36756003)(956004)(966005)(5660300002)(66476007)(54906003)(6666004)(478600001)(2906002)(4326008)(6486002)(8676002)(8936002)(6916009)(83380400001)(86362001)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EF6U3ZBW2BKSp4U3b0VcRWpD8R0P7wQmTj9q5M2NBYUA6lK6G7dbApsAFIB9SYwBHFGV1aAXarauk5znrGmLS7gloU5umkcHd8zEpeYDDel9A6r/XQ2hqYxXZ5/OEK3eyuf33di4DSZyrevsyA5Fj5MFHFsTTUsepGjWMOGfdj9pFsVSTUgvZjWFznJjfoZx9zWkf2Q/ul3D9RJJamtKFOEdmtbEVZRZVrgfULQ42uI6lqHWBHUn8JNPIxkajw981/IlbP/4ULUb5qW1U+NvXZxESLH/eobBjZdIBd3sX1lkw1FBJPRKPZ0qNSU39FD+e5sbT9h8+Rtubuym7ucB/F3KMnXWtoUEUw2pxAI5WNDnSfC0PO4FqPM2wrdVED+sXDCGGB4l1wvr2yT/k14nvRfORoV2Tp3CiCL/LIiKuB0H+AHFwbnQ3cpCHALP6UbsispkqPgR5WE9nZe6uVIurfBtmQi/MmvWxZA1mxryhOc= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef457342-077d-41f7-58f0-08d83241e626 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2020 15:29:48.9770 (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: ahjGiZxyvDZ+j9zlqRDEtsP6OhixVwtxZLKP9cmjSqDcX2G0+BvwN0dRTCnUvTrNS6KmrM5vo/OuJL9NLkPBLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1163 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