From nobody Tue Nov 26 22:11:20 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+46108+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 1566301168294166.78950802971224; Tue, 20 Aug 2019 04:39:28 -0700 (PDT) Return-Path: X-Received: from NAM05-CO1-obe.outbound.protection.outlook.com (NAM05-CO1-obe.outbound.protection.outlook.com [40.107.72.63]) by groups.io with SMTP; Mon, 19 Aug 2019 14:36:11 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E4EhOhk56PHunWLIj00dKWJq2J1rGyNxbEkqo+91HEBX0xLygsM9z+ocxlVR5Semp2DWgy+a+FUayM8gTlmbPdcF1B61N7HwWPyBfN4Hvcd6MkSEr+ppmHpZ7h40AqeAJvMCOkkfBIOr7UsSOzK2fbNNbUdo08WLiIUNyzKSMauMSuxbhc4LWafy8ZF+O0QQSwDRlgksLWivDFqT8Y2v7A+GkkgDAyl8izEZ30+Q5A+Tm+fO8vCGWNcZDiiD4ajzKFuOV3jfLVAANq0zmFd2FIAXLu1/sHsuCDOCxDltxtZl+35VcjNRrJr7R3Db0qa13WyYkZaI9+olAq6w4gkV9A== 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=5qzvQSwBnUK7nph8OQ1RGhWaoJJr2owY+HXhOJgR+is=; b=fpjD9LYe/5mxfkfQxH0JxrhL/q1bEBmX5S+tO0sLkvMn7FJEG+KAg/ShQVytdeLnHVuD4bTPDuOHwyeOWD62zqkSGWfE1ARf5oXP1i9H6a9GSEUPoXsb3BAMd7Vh8Ic9pL/xjKjNv3fGxlat6vGDM0EdGvBgG3Z6oiIRpe0a7bzpI1+fk2BcTZEeOhYz9NgOPR7K6VK7T7EuVtrQu1EZQy2Ui6vPq+kaE0EjG4RDJgdp7mC3/eR6b1DBKroALQ2m2Fha9BQTwA2saTuSTbFa5nlwulPMyMCSVOpzuNcKijonVO0gId2d4EQWwPQf4HeR7IdOEUNXEt9wNBebHV32Rg== 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 BYAPR12MB3112.namprd12.prod.outlook.com (20.178.54.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.20; Mon, 19 Aug 2019 21:36:09 +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:36:09 +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 17/28] UefiCpuPkg/CpuExceptionHandler: Add support for RDTSC NAE events Thread-Topic: [RFC PATCH 17/28] UefiCpuPkg/CpuExceptionHandler: Add support for RDTSC NAE events Thread-Index: AQHVVtYdDCJP8rih+Umnr4RO6nv7Zw== Date: Mon, 19 Aug 2019 21:36:09 +0000 Message-ID: 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: c64babb3-9877-4419-95a3-08d724ed3ff5 x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: BYAPR12MB3112: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; 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+46108+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: 8Y+GwroZzauVbi9pCpnL0TDJa94+eti0e/MtKQFcpb0ZUJSWKwGbQ71Y3p5ygiizd9pHyOPwX9aya6/YURYdndNioHBPPsyKlVontxU7M9BFCokQv8eEkWMGatvCe/lLM22YtNG6TAVY2kIgvhSwe4AIROVfVlQvMc/vTHgqKb6WQ9WIgV65EYG3sGSL0P9N5/jnZdAuXyK+yclL1WFSQYYMbdOaFhds8puLrhydu3nlwkLBBuCQlg8VLY9nJGhIgFrVaoxcc4OJAADUmfBur53tjY4Adqq/YLV7oTcLZcdtbOPgnQDHrcLL9IgaZ9s+m22spgKswbteNeiwE88edUS8inK92e36fX0peE/UlpWh/mkkwsujGEUFJFVpc521MubeNJZ7FjFr/rv4x7opMLdo2O2mRKa0A4OuaPD21eg= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c64babb3-9877-4419-95a3-08d724ed3ff5 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 21:36:09.7841 (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: Ch5F84WS7D0alBFaAFPqcAwIjQqVwa6/mrzuQUrgGm4CsrV2hAUagh7laAi7XucCgf1BaGL4MhLDP94yRwD5Mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3112 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: Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1566301167; bh=jAslzw/nozmlsTSrDqBaABq6X8VD+7QTWj/RNDjZJ1k=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=qYbfQpKYKt0MgmPjLI/VHMgahgLq55Se13QhQIyofN7O0EcTpWXyuktCQN0LEpoQoxt +224C15vEtWejxBFMu9tycP6drkXdDcsn8wooSdCnhasi9lJxX7NGwNw7FviEUGJepng6 YHHEzbCRZh6ynq8sGxA3r7qS9UmAZXSFSgc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky Under SEV-ES, a RDTSC intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Signed-off-by: Tom Lendacky --- .../X64/AMDSevVcCommon.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index 78d9b315c446..198b979bbb01 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -857,6 +857,32 @@ CpuidExit ( return 0; } =20 +STATIC +UINTN +RdtscExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINTN Status; + + Status =3D VmgExit (Ghcb, SvmExitRdtsc, 0, 0); + if (Status) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax) || + !GhcbIsRegValid (Ghcb, GhcbRdx)) { + VmgExit (Ghcb, SvmExitUnsupported, SvmExitRdtsc, 0); + ASSERT (0); + } + Regs->Rax =3D Ghcb->SaveArea.Rax; + Regs->Rdx =3D Ghcb->SaveArea.Rdx; + + return 0; +} + UINTN DoVcCommon ( GHCB *Ghcb, @@ -873,6 +899,10 @@ DoVcCommon ( =20 ExitCode =3D Regs->ExceptionData; switch (ExitCode) { + case SvmExitRdtsc: + NaeExit =3D RdtscExit; + break; + case SvmExitCpuid: NaeExit =3D CpuidExit; break; --=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 (#46108): https://edk2.groups.io/g/devel/message/46108 Mute This Topic: https://groups.io/mt/32966280/1787277 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-