From nobody Tue Nov 26 00:21:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63865+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63865+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 1596829375459752.422698760944; Fri, 7 Aug 2020 12:42:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6dTvYY1788612xPP2xk4tb6D; Fri, 07 Aug 2020 12:42:55 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.50]) by mx.groups.io with SMTP id smtpd.web10.4194.1596829372180631883 for ; Fri, 07 Aug 2020 12:42:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JccK+nYeiCqaFVldn4CN9Q2LqJx99LmCGhycaALbXcFv5/Yz04M4rg/8b6d6y3iSd72cN0GAO+2ufMx5ZF0VBUoeFKhtvUZhZFcbMUIUrXVmE0P3nKdha2meYj/BWugmXgYPKZwcIz27DMRicdokOuoNdqC/Wy2adHp90d3XrYTpfKcBIn9Zp+aOddrq677By4wmy/fi0zgozvA8QkbUC2tC70GOOuq1MrZgix++CjzOkUncdaa3ySPIWiktcOFyOlPSb06aJtmgALGqySlloRVKD99f1jVu/UJlQpGMxeP31zh6i9P8K9vR+jSEk/kAuqgfNPeNTpAg2imDJqDqkg== 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=5teiAq1eAXmkeZ9hYTs+aZivrTRKKj5B0JXYx2XU70w=; b=i+t8AY+Re+wJWa/YnL+z/9j9Bz8K+I8mCXonB/snldtjzCm4YMXhBzXslyW/h4AtEhGzK1hCrN7o/YMTXmt/Tq5Gpf9cLM2+OHGTf6yyUIFQjsHnJYoRrOIZCRJJOcNPgONjWQkF/Ve1Fs5K1aMAsb4PRq+EKjiFZkqA7JAIJzwtHKEtW72OGtQvmzem9MJ2B9Olf6jWmnTBprDDcrImTZa/ki9L9RSRAxpCFX0Q0Cx+JiCkYtTS3XBp+UC+t3j0q8Szax0UDI6Ke9ocavDWrPOg+YUvl3JkbUgAiHCtIfj9wr35u4Fl2lHudGNlGPUEayxjCXWnA2+zJ8e+sjd2ig== 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 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:50 +0000 X-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:50 +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: [edk2-devel] [PATCH v14 23/46] OvmfPkg/VmgExitLib: Add support for RDTSCP NAE events Date: Fri, 7 Aug 2020 14:39:08 -0500 Message-ID: In-Reply-To: References: X-ClientProxiedBy: SN4PR0501CA0078.namprd05.prod.outlook.com (2603:10b6:803:22::16) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from tlendack-t1.amd.com (165.204.77.1) by SN4PR0501CA0078.namprd05.prod.outlook.com (2603:10b6:803:22::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.5 via Frontend Transport; Fri, 7 Aug 2020 19:42:49 +0000 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5122e948-868a-4969-f991-08d83b0a119c X-MS-TrafficTypeDiagnostic: CY4PR12MB1798: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: yCGvLVQ2/p3Dvhy38OaymzOJwrblJNOI7EpE587UOolYE0AsY/FNhrIYEGaYG9/OFNm/lbcrG/lFJz1O/QWnRGCw5NYGAodJtsTCyTRrmXDeejRfLUusWWpniBJV4vK77jZaqHHRguYMuLuaH/RESKr6CkNNc7Faq0qucnI6ZhVi5Fm3OqV/8hA7nIM2AipMvdjmUSjARDy28N8uVl7JUAbDIE/lXNXcuDzFRxkdt3jzCZbRQGVYqgWv2ktCPAWjaymCZMM2NJSrTynjipjunvVnCmhudefPoQ6/ZRhkjrIpjryxk3uI2hz0M/SsKMFXglz4WiDWEXnBuC9OxAQaPGx75/1ro6zBr5begsyYN9YbQJQGGucQDuqqS7jx8GzkCsCqXXJt7jGtVaxwgnn8Jht9sPJNo9cg4OsVsP1ute2TFGjrahmiAj+CMOtLmqMSCmehOD2BZLPude1eQMG+gw== X-MS-Exchange-AntiSpam-MessageData: hGId623kne3dtIqzPqAPT3EYqs/3H743sXvCwkZtzw9uHD38goQLlw00ri5nmQ9AW2kwup43mH8MXb0KOeICfTf5TbkCXxj4Ogv5TDn5O50aw1qwtWmNgjFXz0lcnJeOVNWGvYxvpaDaLxCLh9bNR+jXm9jGbmFknl+m5npKJIan9gqXynh1drYcOhaclpFl3imoIVEsYbL2LlKT4XxWar8W28svWverUiGVqhX1eBFw4X0vRMK22X8MyJStUWanptSaaX72beRfIM3SThYCMwQT/TDOy1V5RDH8ZZyrfYHanH+UJuhc7KE7voX4n2xcxUcThAye94bAZvcKT9ZC2BsvDP5TrXyGzMME+nxqSiGIJids83KFpcMBQ/HJpa5GIhw9EwngASPoNSecjt60BmgI9FtQ482Zwe1HF4f2+wG1a0fUNDoJCIShL7it3+cf9si+ovi2FESaJ3m/xYsHm8aWLl3xp7wQi6OsIwokR4uVp/Tjvvi9wm/3uo51MmvbD2UVv7TW4KONDPgsi4P7McfvkXvvYiEwIxiaiylrVjXDx7k4I2fxf8uI8QbxAZYjcLkyV21dwvUZliiBU70BaQXT1prM1MltZn1UvoeXpa27tOtJb2a8s8rM5XbDuVjBZQU6wsTMzxDweA3tt6DW8A== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5122e948-868a-4969-f991-08d83b0a119c 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:50.5836 (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: QEIBxRFQeda2iHgF7XVP1ZjyygvuhUvTAnwIT+GgAakImcJCTfsIGIcHqb6JI2Z/CxVsouOt0V3LMRdJCFjFew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1798 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 X-Gm-Message-State: J27b4VH85jkzgG2asTsb1zmJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596829375; bh=WK7ggEZdvfjJCIniFvFLVXFMXkwo7ld+lgdbSug3VSA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=JbauPj/ASsRqGDxsVHb18sU3a6EZ3gNeVwtru2LVTAfm6NpQe2HcJ7pv90oHN9SYfEa 5GMigmHKjBZ6LtU5Lmbg82Q/fZHspXehKy7MJq0cstgD3tzz0KF2bjtq2jV0sMTH+EvLH vOkMpDXAFVhNTCj2HT1JHujpehrh824ZdEI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Under SEV-ES, a RDTSCP 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 | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index 54134f37e614..a1cf792d4d0b 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -881,6 +881,49 @@ WbinvdExit ( return VmgExit (Ghcb, SVM_EXIT_WBINVD, 0, 0); } =20 +/** + Handle a RDTSCP event. + + Use the VMGEXIT instruction to handle a RDTSCP 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 +RdtscpExit ( + IN OUT GHCB *Ghcb, + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, + IN SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 Status; + + DecodeModRm (Regs, InstructionData); + + Status =3D VmgExit (Ghcb, SVM_EXIT_RDTSCP, 0, 0); + if (Status !=3D 0) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax) || + !GhcbIsRegValid (Ghcb, GhcbRcx) || + !GhcbIsRegValid (Ghcb, GhcbRdx)) { + return UnsupportedExit (Ghcb, Regs, InstructionData); + } + Regs->Rax =3D Ghcb->SaveArea.Rax; + Regs->Rcx =3D Ghcb->SaveArea.Rcx; + Regs->Rdx =3D Ghcb->SaveArea.Rdx; + + return 0; +} + /** Handle a VMMCALL event. =20 @@ -1443,6 +1486,10 @@ VmgExitHandleVc ( NaeExit =3D VmmCallExit; break; =20 + case SVM_EXIT_RDTSCP: + NaeExit =3D RdtscpExit; + break; + case SVM_EXIT_WBINVD: NaeExit =3D WbinvdExit; break; --=20 2.27.0 -=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 (#63865): https://edk2.groups.io/g/devel/message/63865 Mute This Topic: https://groups.io/mt/76056541/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-