From nobody Tue Nov 26 22:32:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46112+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1566301169057436.39123927663707; Tue, 20 Aug 2019 04:39:29 -0700 (PDT) Return-Path: X-Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com [40.107.77.53]) by groups.io with SMTP; Mon, 19 Aug 2019 14:36:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SlVd9JiUGhj776tV8AzBvQV4kJ0YaBHtDkeP5SgJ1bNJab5oBnw+zaEXAuZWRMaf7vjPQMxqBBxx0phjFpC1Tx1sx/3ZY9VadiFn+GxOz/ZZw3qzU2jcrqm5S0bZtOR3RxJmP0MydlJKjigwKWUdBpYWvtxCSKxY3AWLK4Zu27bAWNpby3IL9WXYAlsnxPse6zsPPjmIjEDdQAmeah8JPiE3lnXf3KFCGL74XYD2BgCkbsj3RW6TaQfng9y1EhcYPEwDHINKl9UOpvFQh665/UEEW7DcajyKxOrAEhXxlU9vvx0uGgZKlIIwCQcivve9xLzHfcm4A2PN0TIwwz7ytg== 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=eVgT3psR97sAECyp0sDdgbEUTwZq11eJhts1TfIZ9RU=; b=K34EX+vy1XjuHWeB26r7fuKLx6Y/lBBdYg/EvBriEbkxEbCokXGOvIeWyMRTsocSBvUujuOss60FQj5Kir/PpjQvGwjc5cVmkFPXQ9EwnAbNS27IFSsWRWzWZy3UXMC2H6AlDYubJz2hkszikg7JhmdBsTHTIcFfETvDq0a0b/1S9s3gU2tkU20i+E/N8a0WKDbAo+9SPENUOqj9K0zwpHOw53UlwDJBnpQLU7gatu51+OKX9ZKlGlg+BhESP2jEb0eElT7zarmJW+mkJI5GC8fEsEw+QNszzbdU/vKDs0+gHFCEDlMuSgm+kI1eUEi4lsQeKgIiBt/XvtGDzP/7bg== 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 X-Received: from BYAPR12MB3158.namprd12.prod.outlook.com (20.179.92.19) by BYAPR12MB2965.namprd12.prod.outlook.com (20.178.52.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18; Mon, 19 Aug 2019 21:35:58 +0000 X-Received: from BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27]) by BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27%6]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 21:35:58 +0000 From: "Lendacky, Thomas" To: "devel@edk2.groups.io" CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , "Singh, Brijesh" Subject: [edk2-devel] [RFC PATCH 09/28] UefiCpuPkg/CpuExceptionHandler: Add base support for the #VC exception Thread-Topic: [RFC PATCH 09/28] UefiCpuPkg/CpuExceptionHandler: Add base support for the #VC exception Thread-Index: AQHVVtYWuB1gx3cKxUihpXcQ8P/SXQ== Date: Mon, 19 Aug 2019 21:35:58 +0000 Message-ID: <81a4c47369cb5566274143dc09fc0917d0928050.1566250534.git.thomas.lendacky@amd.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN2PR01CA0031.prod.exchangelabs.com (2603:10b6:804:2::41) To BYAPR12MB3158.namprd12.prod.outlook.com (2603:10b6:a03:132::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b5cabe1f-92a8-40ee-8357-08d724ed390b x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: BYAPR12MB2965: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+46112+1787277+3901457@groups.io; helo=web01.groups.io; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: H5jL4rztHV3dsKTQlL9UldAsaYgwB5sTqhC6ODHakH6Jxuzs86YeHFb8ToqOXhi0KNyShBa6hLbPE5BreBRpU3dWzOPAYre7JMpYZjeK5+YCdVCpSvcI1WnOwETL2ckpteW0YARxRKr8/oMIs307q3qhnJDNMYjek2UNEWIeZo8xKDcA8i5Qi+NmouJBi2mu50SMOhR/CcLmCMSb2D+Wl3BKL9HjtAaidHuNIlN602FTXRVb6gVXBpUyzkQ+sDeA+cr0ZUd4bdETbn4J7e61owT3bLqX3CYy2kZmmfrxxYWgkw0Uci1yaxA5AwcHMTlSGS8utuj1UaYIaBGvzj8Zh9U+lELMzcmnwHMbVxtXG6KDP+XtULddGNyGToW0PeW05U16HyiChYJWgtG3XmHo6KCV8cS0YWOm55aShQmSsko= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5cabe1f-92a8-40ee-8357-08d724ed390b X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 21:35:58.2287 (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: yhguUQ81GOGQbpFULSSFb6fNP2sMpF16GnHg1ijabIxssT5djL3//98zGtOmiOBmAmzTAtcf1oLVsIlJ31yE+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2965 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com Content-Language: en-US Content-ID: <5B60B824893F494AB357A3250EA9ECD5@namprd12.prod.outlook.com> Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1566301168; bh=l03Eeg9MSJ1Pw4GPxgf7x1CaJ3eyFxRkmdRDNbpYmHA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=pQt7B3hBuvXSF64xzNHG9YtosG0o1XhVxfvYa8XxrW1pyFBeRPm5sreqaImQZzbXdIg 8hhI8JCDHPLAK3biqtWILidVuxU0JSrsz+8jBjjLDrnCJPcQFdJOBFSETDippqupVdlyX lhU1FCfrrJTlI0xT55dz3nAh3sL5quFET9U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky Add base support to handle #VC exceptions. This includes a stub routine to invoke when a #VC exception occurs and special checks in the common exception handlers to invoke the #VC exception handler routine. Signed-off-by: Tom Lendacky --- .../DxeCpuExceptionHandlerLib.inf | 2 ++ .../PeiCpuExceptionHandlerLib.inf | 2 ++ .../SecPeiCpuExceptionHandlerLib.inf | 2 ++ .../CpuExceptionHandlerLib/AMDSevVcCommon.h | 12 ++++++++++++ .../CpuExceptionHandlerLib/CpuExceptionCommon.h | 2 ++ .../CpuExceptionHandlerLib/CpuExceptionCommon.c | 2 +- .../PeiDxeAMDSevVcHandler.c | 11 +++++++++++ .../PeiDxeSmmCpuException.c | 16 ++++++++++++++++ .../CpuExceptionHandlerLib/SecAMDSevVcHandler.c | 11 +++++++++++ .../CpuExceptionHandlerLib/SecPeiCpuException.c | 16 ++++++++++++++++ 10 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/AMDSevVcCommo= n.h create mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeAMDSevV= cHandler.c create mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/SecAMDSevVcHa= ndler.c diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandl= erLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandle= rLib.inf index e41383573043..331ae7334c45 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.i= nf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.i= nf @@ -37,6 +37,8 @@ [Sources.common] CpuExceptionCommon.c PeiDxeSmmCpuException.c DxeException.c + PeiDxeAMDSevVcHandler.c + AMDSevVcCommon.h =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandl= erLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandle= rLib.inf index f31423ac0f91..89b5d496e56f 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i= nf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.i= nf @@ -37,6 +37,8 @@ [Sources.common] CpuExceptionCommon.c PeiCpuException.c PeiDxeSmmCpuException.c + PeiDxeAMDSevVcHandler.c + AMDSevVcCommon.h =20 [Packages] MdePkg/MdePkg.dec diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHa= ndlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException= HandlerLib.inf index 6d25cafe2ca3..5e5ab6244b11 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLi= b.inf +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLi= b.inf @@ -36,6 +36,8 @@ [Sources.common] CpuExceptionCommon.h CpuExceptionCommon.c SecPeiCpuException.c + SecAMDSevVcHandler.c + AMDSevVcCommon.h =20 [Packages] MdePkg/MdePkg.dec diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/AMDSevVcCommon.h b/U= efiCpuPkg/Library/CpuExceptionHandlerLib/AMDSevVcCommon.h new file mode 100644 index 000000000000..ee52f3b5220d --- /dev/null +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/AMDSevVcCommon.h @@ -0,0 +1,12 @@ + +#ifndef _AMD_SEV_VC_COMMON_H_ +#define _AMD_SEV_VC_COMMON_H_ + +#include + +UINTN +DoVcException( + EFI_SYSTEM_CONTEXT Context + ); + +#endif diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h index 805dd9cbb4ff..0f274e7ea328 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h @@ -24,6 +24,8 @@ #define CPU_INTERRUPT_NUM 256 #define HOOKAFTER_STUB_SIZE 16 =20 +#define VC_EXCEPTION 29 + // // Exception Error Code of Page-Fault Exception // diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c index 8adbd43fefb4..39e4dd9e9417 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.c @@ -14,7 +14,7 @@ // // 1 means an error code will be pushed, otherwise 0 // -CONST UINT32 mErrorCodeFlag =3D 0x00227d00; +CONST UINT32 mErrorCodeFlag =3D 0x20227d00; =20 // // Define the maximum message length diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeAMDSevVcHandle= r.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeAMDSevVcHandler.c new file mode 100644 index 000000000000..1e027b3f2964 --- /dev/null +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeAMDSevVcHandler.c @@ -0,0 +1,11 @@ + +#include "CpuExceptionCommon.h" +#include "AMDSevVcCommon.h" + +UINTN +DoVcException( + EFI_SYSTEM_CONTEXT Context + ) +{ + return 0; +} diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuExceptio= n.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c index 72c2aeca4c13..0c248e7eb904 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c @@ -7,6 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 #include "CpuExceptionCommon.h" +#include "AMDSevVcCommon.h" #include =20 /** @@ -86,6 +87,21 @@ CommonExceptionHandlerWorker ( break; } =20 + if (ExceptionType =3D=3D VC_EXCEPTION) { + UINTN Status; + // + // #VC must be handled for an SEV-ES guest + // + Status =3D DoVcException(SystemContext); + if (Status) { + // Exception not handled - Status contains the desired exception now + ExceptionType =3D Status; + } else { + // Exception handled + return; + } + } + if (ExternalInterruptHandler !=3D NULL && ExternalInterruptHandler[ExceptionType] !=3D NULL) { (ExternalInterruptHandler[ExceptionType]) (ExceptionType, SystemContex= t); diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecAMDSevVcHandler.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecAMDSevVcHandler.c new file mode 100644 index 000000000000..1e027b3f2964 --- /dev/null +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecAMDSevVcHandler.c @@ -0,0 +1,11 @@ + +#include "CpuExceptionCommon.h" +#include "AMDSevVcCommon.h" + +UINTN +DoVcException( + EFI_SYSTEM_CONTEXT Context + ) +{ + return 0; +} diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c index 20148db74cf8..998a90ba61a6 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c @@ -8,6 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include #include "CpuExceptionCommon.h" +#include "AMDSevVcCommon.h" =20 CONST UINTN mDoFarReturnFlag =3D 0; =20 @@ -24,6 +25,21 @@ CommonExceptionHandler ( IN EFI_SYSTEM_CONTEXT SystemContext ) { + if (ExceptionType =3D=3D VC_EXCEPTION) { + UINTN Status; + // + // #VC must be handled for an SEV-ES guest + // + Status =3D DoVcException(SystemContext); + if (Status) { + // Exception not handled - Status contains the desired exception now + ExceptionType =3D Status; + } else { + // Exception handled + return; + } + } + // // Initialize the serial port before dumping. // --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#46112): https://edk2.groups.io/g/devel/message/46112 Mute This Topic: https://groups.io/mt/32966284/1787277 Mute #vc: https://groups.io/mk?hashtag=3Dvc&subid=3D3901457 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-