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.64]) by mx.groups.io with SMTP id smtpd.web11.58128.1595863768047564703 for ; Mon, 27 Jul 2020 08:29:28 -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=bizMCox6; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.70.64, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Is1wF0zqezEN9q8NCv2CW/CYTiTiuENY/0pA7ou6OewDz2mBjzZTAZr/PsIgJYlSp+xlAoUgaexCN/3IMaBLSBe2XKJn8PCQmEPQsYDDkznNfkAJ2CmH2OsixLjl1hfBHSTHDekoCY9GyXlkF+/N4waf8nNxIQtJ0e+jd0BGH3H3ZtAcO8nmvY0uhf1E3fYbMnfMNLRtySBuEyNElssAvsHChB+JtF9QZiTnozEDhwKrJtlPT9vPszYESrPOmpVJD/amClLh+4kZ7TUaIuS4tRcheyVWyp6EXPyulPktKwMdvEkyoyR3/I38zNqN6Fd1NpkZ9DOQVcVY0oaND/2v2Q== 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=VWf8IlBLc5H2/zm6u8ihdDB1OPHPbvu83zMDyNap3VM=; b=dIKjIl8PF91/UZ/opJfbJm5XOabI1h5zEIkZFy4vJzCtWIVUlvgJQYw7HgEcdQtkgzPXtM+DrGRnwTvv/01kz82thK+/Xp8ZEc7XP8Q7QagJxnBfDp9RuIxFeNQNH0EGGslNST4CgGchpfEV5tJvOaAsy8t5QSsNzTcVphiYbkIsafP5zPTHxbg6cFlg2WpOoV5sbMCwg7U4qTSJj/pnggd+h0FhPh86bFD+E9Vg7g3i6uiWeZOBw0t7WDJ2i04IcJKE6iMEnDYU3w4s5WPAT8VmtZ0mD0VJlINJ9f+qLBDrGi+LnUDiLnr+DPkUyLcv2YF8TqhxqY8RAr3fKHyuqw== 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=VWf8IlBLc5H2/zm6u8ihdDB1OPHPbvu83zMDyNap3VM=; b=bizMCox6SfbRvg2Is9o1PbZqv3ruE/MhxHcySytceDazzjLLaflnc8jLoGXPldDUi5CdAfSjmCdgL9UJLmecNJrg92WZNIp1a5tOWVLiVGy9QFy/b+5weTQnuKK3A/U0c362AK/6pNhI/yCwvlMVtOi1CAdATsXho1cNn8d9RlU= 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:26 +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:26 +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 21/46] OvmfPkg/VmgExitLib: Add support for INVD NAE events Date: Mon, 27 Jul 2020 10:26:02 -0500 Message-ID: <0848e8b3c5fb6c311e22d1a8fbb109f2eab586fa.1595863587.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR21CA0042.namprd21.prod.outlook.com (2603:10b6:3:ed::28) 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 DM5PR21CA0042.namprd21.prod.outlook.com (2603:10b6:3:ed::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.1 via Frontend Transport; Mon, 27 Jul 2020 15:29:25 +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: 346f3db6-185a-4b0d-6e98-08d83241d87c 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: 9QYZP3qhv71E3HhzCxH229uyQTZmGnosKuH4JqiN8gSGPMDZbLqoa7AlJ5iUpQpHHz74SyYj7PsGMzRT46+FwZXCVpjLXHyZLtMgCQFBwgTPhmbe+1WN9PzqPtbCQdhu9LvdQXntNYeciHMP8csjUgyB4TXByfelj4ulIAqtGaHju1r4u5DgpGz5jNa5e6MPN7FOMBd0smsDqLWKmVlvKqAx/P+WbWlFAfaEBVczHGzFxGQye1udyR+WGUrRJAce20CB8kVseOIVX10s+YR3zrnsdrAGZx8JhA7h10UxuCw/9gldDtCREhVMLu+pNP91I4NWjscVqYakIyCqUUa+Jp72rCCM0KlZcSndIUZmka+cZAF8GDQD0zmC/14d+8+ojVC+F+0qLIqeHH+vZQalCOp+RIrrNmO9tD0dujXOgMdPrOT8BET2FuP7fczsNwQXMZINNyjzgY69LDDtsPx+Hw== 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: yvlM/OOPt4yUarX3UqOddBllnMYfIB9ldBOvIFE5ZRY6o0zpYhLunl+9XwrLXTPKrJhBZ6KFlpZfWI+ZtCseFXQOwNa/1RGg5xdCmuxJD5k4U1sPcj5vXl/d79Jsz/5hmwVWABc/w3j/0SxPVSE46ACswKl/ojsoRfug0C7+RnpXkGVDP7UUE9JtTnDVVPdOhDspbizo4J7OyOe5Dt0vGl8mVuNyxNHtoS8GG+lMAPHzNQ9eHpe0uT24VTlGgoZqG5Xgt5HjG+xlduG4u5kWWrAlPhHafXJSY4dBQDcRW1eq2C5nhK+ZZJYQzOA7UsWVi/T6iffDe0oE2hYmrl1VC2vZ14dmXgpnTg/6D0LmhxfHJZHFW7LI5DYU8rkTQJy8976+WgAOMSHVjwCnjL+vxXsdlk/b8iQF/g52Zw9Sax7NUr5E2Vtaxfx6GJRyXPPkapelKikkmxRlMVbgslRqCm4Yc+5KEXVl2rXTDj+/2to= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 346f3db6-185a-4b0d-6e98-08d83241d87c 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:26.0621 (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: evDCmY3rjp7ZUWbiz35dCV757wsCSO5ncZlj+NGMdlJj+cMtnwSPBetbt+mfAvGEyeQn+GrMbU7cHz4mWyZqFg== 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 INVD 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 | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index b19bd3ee8906..af5264095b98 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -1166,6 +1166,31 @@ IoioExit ( return 0; } =20 +/** + Handle a INVD event. + + Use the VMGEXIT instruction to handle a INVD 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 +InvdExit ( + IN OUT GHCB *Ghcb, + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, + IN SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + return VmgExit (Ghcb, SVM_EXIT_INVD, 0, 0); +} + /** Handle a CPUID event. =20 @@ -1358,6 +1383,10 @@ VmgExitHandleVc ( NaeExit =3D CpuidExit; break; =20 + case SVM_EXIT_INVD: + NaeExit =3D InvdExit; + break; + case SVM_EXIT_IOIO_PROT: NaeExit =3D IoioExit; break; --=20 2.27.0