From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.56]) by mx.groups.io with SMTP id smtpd.web11.4246.1596829331614841472 for ; Fri, 07 Aug 2020 12:42:11 -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=lXh90V7r; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.92.56, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PLUrGFmulCElyWHZnh/0Un1q0VgVS2jj33IGvBB9UElmC1oFuRyZ94LLwhXODsDzDzqxhRuPrxiO2rU5C663ZPvIgNQu5EA0Cfs5TbH2DWYPMk4ojKhU1v0AHs5gXlO6yUqx75Il93LZYsXDWVtMlyoR46qvjSASuBqhQClCWdSIILGY42njhHOq82amCD1bXS3/zca3BYWC3WDdg7n3t/2HBJkXMUXfW4Nivs0oU7YVUkn+1IJiDqBMpNqHqvPrhVo9yJ6aRBB2Aq2ZpU36JHV//MW2uw1gZHmiJK0jmob/ZBN4L0zsELBL7wt+VrjhjLCa3CNETuXkP3mTSMDuuw== 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=crbmyZ65afRC34Vt1/yjGXXSEbQgatvY+leMn0es1AI=; b=cT7/csKTQd85nMsrhPzyNsp6MkVjGrUoZi6j0eTvedfpH+Ul6fV1AR1aUr3Pu+NtB3zFLPFA1per4u1P3sPhEKLr+FJcVXYDcJrn41ecNuMwWBTVGlJisOaPa6DMMW+W+68oJl0FSP5NUyO3nEbdg1q72Smmtpo7jTkq/wCAWPJTlCSP7Rnrmptd08turrGNfqUG+hyOlvrtQLfROSP0GhB9f0ZtF5rAazySAwd0yMZ09mz3m6BzHVVH4e4u4j3gjdtltK8ndtGRStM8kSyJlO723HQ7fXDjVXMnW94a6g26IhOnaMogzQGE5dm5DJu4VGHVVUmIAM/IN6rsjXjHEg== 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=crbmyZ65afRC34Vt1/yjGXXSEbQgatvY+leMn0es1AI=; b=lXh90V7rLPWa+n9IJdfG+M8rNky5adXmIOIHE7sQw9gMo4eDiKu04NwsknsavZQNJ6KfGTKkvISBTGvfS4jbNw90y2F2DH5z235dq1L9rdf+Nej/fWR4J6LZR328aOzFFMJb9FuG42+aCVP8/ICjTzNLAm1HjhE1TBIhlP/VpQA= 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 CY4PR12MB1798.namprd12.prod.outlook.com (2603:10b6:903:11a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Fri, 7 Aug 2020 19:42:09 +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.3239.024; Fri, 7 Aug 2020 19:42:09 +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 v14 18/46] OvmfPkg/VmgExitLib: Add support for WBINVD NAE events Date: Fri, 7 Aug 2020 14:39:03 -0500 Message-ID: <7114e4024f2af77999a7a35c1e928e8103732a6e.1596829170.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM6PR11CA0057.namprd11.prod.outlook.com (2603:10b6:5:14c::34) 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 DM6PR11CA0057.namprd11.prod.outlook.com (2603:10b6:5:14c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.17 via Frontend Transport; Fri, 7 Aug 2020 19:42:08 +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: 42c0cbba-fd37-495c-f09d-08d83b09f942 X-MS-TrafficTypeDiagnostic: CY4PR12MB1798: 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: lUa7gbHBEqkOW7LlJNJ9O6WPeXq5hVOnZR4q/rF14mqJzbQVudZRLaRsk/GmER/6ehyba3UeQm913appPLxK7BK/13QUyPpslkqudqWDdaOguBO+IecApuvnZEL0Jv4J6emc1PlGwbOSrjNkIQyi+dx7ylUqBHmcQJkzzqWEJyzjXpp6IQqdyRC6YHhbcjcAm/MSE6i3GCcGvyQ/O3ldrqAIg+y6W2La4yN24Yy88p8iWBPY035mQvBhU3mYlBpTfKN8uHmw9J5TtMsBPcFKTwszafJLkak81+RAkU7RbJXWJkH+SzbhqJ+VKyExZwQMZMIWklo0suXAoAoA8UV8vXqlBeibdhuikCDoAW/9UamZSg3F15tobKhk58y5gmVhhIIvBc38DGbf6yowLBK6RPejExZ5LyZCFmSFfbLrHwXOlt86Bh7h2ZrnQriSH/PqSLb0PywGSGVaRkGbNQ83RA== 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)(376002)(136003)(366004)(39860400002)(346002)(396003)(4326008)(66946007)(6486002)(2906002)(66556008)(66476007)(5660300002)(966005)(478600001)(8676002)(7696005)(26005)(8936002)(16526019)(186003)(86362001)(956004)(6916009)(36756003)(2616005)(6666004)(52116002)(316002)(54906003)(83380400001)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DlT1XJIvawx+oEFdLIY1fdABnKMifR9gf8w8SX7+1kG0wTXYFE5tyNyHiRTLTk3oVirEuxK2xct5stLlXoYynL02A8+h4kdTM6rb+Lmzke1Q2XnghYSRw4SKeuRp2U3Yw3HKwQ2qG3ClXDlV3PfS0CIX8xYJ+DMt+O7yVo1wnnFRcNOdHPVhkD6Er3kiLqyuYOAb89+qRwgJ4XG2By/T7uLa27T0YihjL98wTu8B8qhVIuHeq7YvXBBvMi5MXy2ChuI4y9PC9NwV6tHdZXN74R+QGg9BQCiSx53r1wzcNS5DoET5U2C9WWs1wgwvFWq9u3qiRPuvbjnnb9f5cv4krwX8lYijpEe3Ar97EBBOL2Up+br2iIyTcSLx7WLZ6okp1rf6HIo8zynZ2Ty9n76/ysa50+nkASBb6t/AaF92VnxbGOhzARM1YghR8N8zAb6I6xB3ojcD+2g7cYRcsQOG2DPGDGV05aUgFe9Rnmx8TV0G0yKZhlT+XvrXw3DTlQt+jTGa4Dc2y/+VdU+ilThTK+PP1F8hSNgxoXdwNfXpp//pWTN+7+hAvkFcf3C/pKT9LpkdPnH1ItT3yCeIXC1K0CYN6oMbyMjQlX7K3bVmV3sD/SW0MYOktsoZI99n1oQ7jXaBEu7UfW0i9tetSJP8Lw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42c0cbba-fd37-495c-f09d-08d83b09f942 X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 19:42:09.7402 (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: B5qpHoUY18uL5A7SFIacnPpKPhWNCTAOEvSJ8sibLFq2bnikos+JsTxe0PKLdDETxVyZUGUbEwJ83/zgF8vCrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1798 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 WBINVD 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 0e502ac14819..bf07f960e380 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -856,6 +856,31 @@ MmioExit ( return Status; } =20 +/** + Handle a WBINVD event. + + Use the VMGEXIT instruction to handle a WBINVD 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 +WbinvdExit ( + IN OUT GHCB *Ghcb, + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, + IN SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + return VmgExit (Ghcb, SVM_EXIT_WBINVD, 0, 0); +} + /** Handle an MSR event. =20 @@ -1252,6 +1277,10 @@ VmgExitHandleVc ( NaeExit =3D MsrExit; break; =20 + case SVM_EXIT_WBINVD: + NaeExit =3D WbinvdExit; + break; + case SVM_EXIT_NPF: NaeExit =3D MmioExit; break; --=20 2.27.0