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.44]) by mx.groups.io with SMTP id smtpd.web10.1756.1596134828161493087 for ; Thu, 30 Jul 2020 11:47:08 -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=t9O94Shv; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.94.44, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ug3MPcAI30Ca+OGxpGRkdgm5bhpVG/tNizh0jijLrNfB141mByHUVU4z5hWvwsgURRhWS1Pfr5dB0zHQ9FXBFQw1poIa/iOnOzWoZdEz6ml+dsxualCkt/wLk+uHfEu/7pR/B7/HXYEyWzomgx+kBzjO9HVn021zZsOhcXzO/Ei5MB79KZUb76FBEyFvjzkBZhA7iQl9ibk1IiessEJAuuTgHRalx0cLt18vOrHn9wCAQxC6ySrphSCt32RUNuTsElDAyTYR/6eq44y5jvE7RUGEvV0P/AbLRHrgT5/FVnk3LdUrJrr1Rgw7NbW6l8zhkqhxje54Li/MxYhVomSPnw== 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=l1iZwTrfTvr3dO0+Kni5Q05GfL8LknPS7B9eGfrirxYzSRzz1hpJV2qMF+EB+BF5pKP02AHDUJSc0t0u1WFG+kgvzhiaWp1FiW5/IiRLfx9Iuf1r+XcXR2DUtjInAGP9H/4pBxk8LDZGK4yzH/+HubX1QiR5XLmrtKAMRm7/gZfPy+1xXcCBacVsiZqownYxX/9p7sUgdCvZp44dpAQIpH5mgdj4VWWxkZZnRKkm9y46pfw2NhTLNnA3zmLWPh7usFDtO4NtZ5AxDzX2ZsuknJWj6j/YgI72O+JuxUvqGexcr7bGdPTQEEtt2e5dcsyFtAlACgVf9BGFIGjagfZquA== 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=t9O94ShvgFqB8tpbbHX8el7H9ZWGcsOVVF1u8hOT6fNw8V68fRN3h6FaQwioT6ijUd2LV2ePvpAb8/s5Y9aGqgkUksfPyk4GQPb5LpTDED7+mUdHop22kjyDGjqyXKKWnJP5ANjKgEjqVBxN6Yxjz3TGjrvMv83A064OsfR4eio= 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 DM6PR12MB4092.namprd12.prod.outlook.com (2603:10b6:5:214::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Thu, 30 Jul 2020 18:47:07 +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.3239.020; Thu, 30 Jul 2020 18:47:07 +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 v13 18/46] OvmfPkg/VmgExitLib: Add support for WBINVD NAE events Date: Thu, 30 Jul 2020 13:43:30 -0500 Message-ID: <2fe1203af85920953e6690cefe5f4c72dee8861b.1596134638.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR1101CA0023.namprd11.prod.outlook.com (2603:10b6:4:4c::33) 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 DM5PR1101CA0023.namprd11.prod.outlook.com (2603:10b6:4:4c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16 via Frontend Transport; Thu, 30 Jul 2020 18:47:05 +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: d6acb41b-639e-4e9a-02f5-08d834b8f546 X-MS-TrafficTypeDiagnostic: DM6PR12MB4092: 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: u0cMMJHxBIcq5kxxB6iCrKgsvuuWFQY0REIssB5IPffVUHBg0NU3kwH/GttgsGiYzTk9fr54q+tjjwD3ZcUZPr8RJS3bDL04e6bxBLGilvuBW52Nzb+K7TPwqBqnZSnFDsLgKqCLUocOrsBWI/q52+k2cw6kKcdp11f3vPRLpeHi/uB8MqEGH2WkUphVeM3mLabXWEQS/m3SbP1lMBP+MxJdfGtOCXEH28P5rOi1PW4CczYU6rxrs1Xpba9PZ1kTvgt+XwcIRSwUihmgYroA2BrDj1axRwXCeAP3zU84Hbxcq3IuhFomvoKjuDb93Hw2gMvqNXyRgUU/FDzeJfr+DlpFDCmyATPs7lCtX+UiP7xMQt6JOUP0uIuJKSCMPT1GTiRKmGJEML5vUGJmysOxgTEZFqOi0bg/UspJiKG2V39qhOIJ1zMyuG0Pn3gAq6pvYgpqkdSNCMTPQ6SjJbX8BA== 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)(366004)(346002)(39860400002)(376002)(396003)(136003)(6486002)(52116002)(7696005)(26005)(5660300002)(186003)(16526019)(54906003)(66556008)(4326008)(66476007)(66946007)(316002)(6666004)(86362001)(2906002)(2616005)(6916009)(36756003)(966005)(8676002)(83380400001)(478600001)(956004)(8936002)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kkjyWP9kNoZShz8IgUuCCIKeYTJ10iwVSlz6XDlOO+e/k2G33ihXh3SEFsIbBBMsMcQOC3JPeafVae3xfEcz/UiSDZLTQ9jEPNYK/ddnNsngm9rpmopbzLh9FvEqLrFhTzHlsnwqeG+tuzwe0A1RYt6xa2IBqyz/jZXVjkaxGw+3VeT70pJTx1du4atP0c06xONnYgv1izbFf9AuFhOJ+R82JCXBy+9hT0/SDM7NL+uiWV0t5QLSgl09ulZr6qqqFUqU3be04BqX1Uwn0IQkaoDzA423vsPb+rwdwjpcJxuBOmZlyFeGV8TInoc4L714mPoP6UTuA4PIJ8Zbbcqh5yaPFSahvrbUSLxuP+K7LZ5GiAAAlNJtMy8ZLRdTjlIMyOQb0sqFrCHXGPBuP4MVqixY2p/QwCy5dhhTgLDk2ZaLJmB8VG4QOC6UelWnSoGShxa1RknLOwcORYQMIzCPSPZhEe5OnK+EXptkLSoMlB/rn5DgQa4Po3+7LxJwZuorRv4hrgtbQmDCz4GVf35GHmb6uC54d7qls58sOkAdtMi+RysZ+tKW45MXlqgFAiYl6PBObdlS35WC0gPvyQ6vfyLanZPJLjEOqQybNkYwTtKcpULcjULOtw+WJk6TugDk+bEjhdgWpgJ2EwBjfBxWYQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6acb41b-639e-4e9a-02f5-08d834b8f546 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2020 18:47:06.9936 (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: 5vWa3/cbADQRACbu02M+o78yYGICFYn9R/LQ/UH6JVwztIKwBLtpqRUpLuBUH14+WCT01ASRt8awrayQ3D1yWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4092 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