From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.80]) by mx.groups.io with SMTP id smtpd.web12.5629.1595366581075516144 for ; Tue, 21 Jul 2020 14:23:01 -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=OFAIGIhu; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.94.80, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n5erAB/i5j/NX+01qgB3hlfuYgAxnmao+MPQnBkmpqXKYheWqil56tO6M48e73PjKbS55kRcQIrFrPY8WfjnFYj87Dy+pB2VH6FEwF+4O8YqW6P7olnAEXvDYoo9EFOvVw5M5VkwebX3mvSeRMgB3G6CDPp7k/pRo6cLACOvpCiq8ztJd45mAUnLUJUt96NtFaVd9/ceiycFHibBri3D3Nsz3axcUphLJcSez5BL/xr54QBkKrdl9y+uqdNEi+P+3dNu2Z2jOgkrs42Aytjo4X2MlYHp0Dolr3cNJQFdu+upcxFxtljPWwS+EcEwfyC7xSGO6mOkd+n8kBQ4chQeXw== 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=NYyW2a/9cj49jjIAs04Y/7bm7vQ6voBlubC+2c2AKK4rFIyPRZWH4yUdROEZrWDd9rhHAwsroToycQuDvRNuSvST06/D0kRK9P9kgbWRxtA8QVnG46ggezKPeCCdC3Cr4AV+UXXbZ8HAZzyygQJmJsaKLj3rSf4ne19y3mezm1/ppic98ZBVIyg+WL0Vl5qqDumfRYjFHpixvQ0DprX+CoknPadIQL61olQV3K7dFvnwD0Pwt1PBQtz1cl4wPyQw46QAdh6Dc9xBu/wRYcPRcTgQtSEXKhDVokil+Cm6qfEFXEJWEcn40F25SjI2EIBut0AYyxiySB3dmwpb7LlLGg== 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=OFAIGIhusJhMfTYyLHQnW92We3SFEMBLhW3Xlw2ZcPsAX5ysCqlYsSp+gkXfzRxzlWumYxCLDV+YBFJPspwr63GmLIKxubMfirpEL8kbjMc5S06KRkdXykG1+ubJUhoYdeTa+Pl2bAH4i4ARhCU31QeVNf8t3snYhe7snrubzEU= 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 CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1143.namprd12.prod.outlook.com (2603:10b6:903:38::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.25; Tue, 21 Jul 2020 21:22:59 +0000 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.3216.020; Tue, 21 Jul 2020 21:22:59 +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 v11 24/46] OvmfPkg/VmgExitLib: Add support for MONITOR/MONITORX NAE events Date: Tue, 21 Jul 2020 16:19:01 -0500 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM6PR12CA0028.namprd12.prod.outlook.com (2603:10b6:5:1c0::41) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) 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 DM6PR12CA0028.namprd12.prod.outlook.com (2603:10b6:5:1c0::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Tue, 21 Jul 2020 21:22:58 +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: ab6c464e-0f6c-4c95-1281-08d82dbc3e4e X-MS-TrafficTypeDiagnostic: CY4PR12MB1143: 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: uU4Me1jI5sSS02Wiyf3hlgIEG5koJRXK+ROFkKRrN8Nd4IplCZbAKPcfxq2SPiuDWEdWPyCePjm4pKS7krlEBMpXB1YFZO6xIw9k1LXv+MEfpqaJg4YUyQ/vn1k6VZ3fF9dd1HpsfyNWaRcIhh8O+RVTPF0oYabH3EEDQSYBfdRsxM0FMrsa5eMzEri/0pPnkvlJ0iDJCoc/dKDDOO/PtKONQ/5SadmouUPFvSDlMl9zvmFqysCRJYmUafKT09S3iuxzgLwPlo6YgFY5eqoMUqQZOY9gCjACzVqrdufk6Q4TyKicKxt1PwVFiSpvgi3GVntRwGWwKDfVnpYLR5svts6pwE3aADFq5A7Yv058G20bOj27L2fzAxttr27WVgY2bWFKimwD9ZG8vPAwujdff/C14iR0kvPRiWmVvso1QYW0npmJwqajns8swjMSxDFdkcomQ8Ebvranlb436ovdkw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR12MB1352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(346002)(136003)(39860400002)(376002)(366004)(966005)(6916009)(26005)(6486002)(86362001)(8936002)(2906002)(66946007)(36756003)(8676002)(16526019)(186003)(2616005)(956004)(54906003)(478600001)(4326008)(66556008)(66476007)(7696005)(6666004)(52116002)(5660300002)(83380400001)(316002)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UTbiyyoSuE14G5jUN6/TrJnCAcbHhHP+7bRlQcQT/7Vb6g3PvwZ5tVAJSGZ6DHLgzBZV4RQWRR3+K21DqkQuteHwQgdLGtWYOtTzPvTSyVHdbrxxyJF4WNu1ZjyEqyACXK0uIAqsYsXJbWoYUzgL1PDOKU9f8tEAR1u4y78lt5HA4H5eom8iRMMPvwzeBDd7Rxh9TelbOKDJY6vAcenVLyM24fPU/TldFNaMtCpzOVyQk+HpoYcugeALdarJNOWQf6d5CHQWLHiKCstKjGMjodCkpFG5TphGQzE4oExymdeFtcCqS+VESc/54n74bkD9zz7/xMs4HkwCLVtr/X3R6OcmDeujGCBZi9S5HE/9S+Q/pXzxntTZe5htgzTUSiMR3geAuqmymnDUZnuBvmrWAiawWTA+UzkxtBd4prWEC4zQzl1wn1KS3zaET4auv42Zo4entr3qsYDOcMbalqyf5T/SqWeZI1BDYSF+o1KyU2Y= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab6c464e-0f6c-4c95-1281-08d82dbc3e4e X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2020 21:22:59.7189 (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: sy2cqJK4vr4KbP1pnfJh+HyWHGUYR35hYbGtbJrPvbFg8rtGq9E8aAcDa2M4oqf9sPxxXw/zOwdo92+vSQ+YJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1143 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