From nobody Tue Nov 26 00:50:32 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+63862+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+63862+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 1596829348820664.6825529636418; Fri, 7 Aug 2020 12:42:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id MVUPYY1788612xfjq5r9S4jl; Fri, 07 Aug 2020 12:42:28 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.60]) by mx.groups.io with SMTP id smtpd.web11.4250.1596829347827318178 for ; Fri, 07 Aug 2020 12:42:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oil223olcoPXFf3bEWEzf1qM26CZvSJev5ehUfMEYOHzWfPkrfAg4Cn2AmEJ9ZY+ysjhRgodtXy1/s1otqxGCkSdRFdHoTrB/bHGWeC9DvpN/2jLcGNhWN2guASNHa0A6QVNjiXPf8l1pZnmMY/AV9MeDPHWc2g4See8gUm+PIoKnh/xKndjeqnmwzmxziFa7E044/0aDQLo5HS3RyBeBoOgKbEtpNOc/CDXPsBE3eJOiqY08dPl+U/J1ZEDGHgDgmXO/vWNMp8RR5t8rJbjTm43VVde6UicjzYc20JvkaOxCBP/ONFNjIA8RLgTjLpG41Ld2/s2qFvQqyCff/YGBA== 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=4O6+S0hN1CMnpBWLQIazWEUnN+r5+tUBAtS8g+NsqAw=; b=Cwy8ZPrcwpqMgBUqXKJ9IPvcZyHcW8VLL2/Hb4z2qC9/M1MwCXcHSNAVPyTTRbqyPtft3IjFaSyVtjEGt+1rww6vNWI9tEFxxR0kMrH3kZOgmlYzBnmXyygGKbBLNvwLB3PZM/kaVfrrEzh0f5PdN+sCShO1J8782zJNOluKZ01CXWRN4gdtohbTJDd6GEOwwmEM2kj9ey/1FR9W44ynekrmUx/dFJ+4ZTSIKfU8PgKbEjtensUlLyo8miHp0yyCqzs1pTjCwleyGnxgCneWC9W0xSTb5zVjst6miY31NffA+xoE9uYyMNLw3LgS7OSRVMsCXUzL8yhcn9N594IK0g== 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:26 +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:26 +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 20/46] OvmfPkg/VmgExitLib: Add support for RDPMC NAE events Date: Fri, 7 Aug 2020 14:39:05 -0500 Message-ID: <69cb6f8349d4a4dafa791b73d5b24c43c15507b3.1596829170.git.thomas.lendacky@amd.com> In-Reply-To: References: X-ClientProxiedBy: DM5PR07CA0090.namprd07.prod.outlook.com (2603:10b6:4:ae::19) 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 DM5PR07CA0090.namprd07.prod.outlook.com (2603:10b6:4:ae::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.15 via Frontend Transport; Fri, 7 Aug 2020 19:42:25 +0000 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 10ce0a97-f71e-4b33-f0e0-08d83b0a0311 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: oBS/kuzFTnYvaAD4aGvJ8Fh9Fb330M9WoAIfcQCqoYH+cyjsNcQBhNERUnAf8NNWmhYsUXCOmtiK47f2wIcqwJ1OYLgo3HQJ6j7vVjlA+8oJIG23XbxG9qu7dIjbfwbPD29WqQODm3Qf3C5DPnr2Wv+81xmK4v9h3Yrzf1CZhuMhza+n84j9mRbM2H2ihwnsYZ5quYCqYivNfQ/YKBcp7vwAJjBxp6+0E2IipEDpjWU/0i/IuE6f9wNzqZtLJNW7npNylBCWfww5EoY74aBtnHryrNVIoI/WdO4Y/CeUgRJQggAOq1x08byFz18rnYyr5UoaJMOJNmWnX1Pws62wMwA+2dpfosIyYlub9Hp/16Pdwhn2wPHoiLG/uwYKk9Ffxrw2UQxIPs5vhlYP+QWcpvCSOm6WyaBnmmZVLBU7s3wC7CTrnstqDawsefPmJw8SNGFeULRlBNbhX+yv74R6Hw== X-MS-Exchange-AntiSpam-MessageData: ni7lZ8bAT15AfyRsvHHGsbU/Fntkc4ReBBKnjmAnJgBZHh7SkDbyJRT5h2tn/PAwLphf+zBh3jcB3iBX5LYGvWYHhH89oYj1hcfXkjhB1Tln//9PByeiaAZ3mVrMXAYn6rI50T8ARgs82kgxRLUqKHO+8BcMqb3qiRWZmRKD9J/L7EDqWejf6+u5HckPtPL48IYjR8l2Y4iMYkofjEV7WBSIiwrt0bSu/hw9mO+AYv0RfZXhJQ3JGCSTJMwkzEQWEVWT0MzxlXLmYJdfo+J24ff7vajYqCO58LPo6X9Q6YiAYflUDyiyYXpEbfVOCqVOq/AcicOedhyXLlALZR8dA848gsVrMNwVHbzZnB/aB0ZodLzRYQu9n7Jw8U+RHU1CSd6wSCmzfUCRBZYcbAkNfyftdobtdgmpfP9erp6jug2h2wcb9Bn2IvCzdVWDQA+Nmxd1cwci7I2X4hx6yOKs7FZIZqtHI5qU6/ovBkysCi8QYS0psxngEEC9KgUULBqxNwT0B2RLA9G12SCyfi9dx8nqvhgzJ99NffzrKjuhes1VLjP8NCNtHnvOp5/uJ+GXbh3Fv2PqglQSth+fazJMFwOX+L6TIfHXXIXUmkMdl0pNPT7sjxv1AuhOBSm9RAY1phpPOtr2ZN70PzA9NC36UA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10ce0a97-f71e-4b33-f0e0-08d83b0a0311 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:26.2483 (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: aM/+xYU9Z7SORrSGszUvxUp1pIbSW/AL0yxgIUpQYNGbTXW8XdFUF7+6o9PaFKNUUNVXvtBHOaJQ3j3HdB6mxQ== 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: lDYfzwbZTUi9bBkSEHL5srosx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596829348; bh=4w0rZipRZB3yKPXx0+1AfnVHHVdZpswMiqXfUrmi/nk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=nWfkSbI3LVwgfFThGN3Aqn4Qum8Ike1NaQFiZRoGg3g6Lksxk8vVs61uOIDyzaxcLiC mj6bBii2I6IfM5eD6hyRYWMPQXWZJxlQvzPJX71QwW8I2daFASbmBr7rvaNoxbiWdu+71 mgW2i4wBS5Fy2PlycfpDFo7p+X+67IEzzBs= 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 RDPMC 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 | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index 65af57046063..b19bd3ee8906 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -1221,6 +1221,48 @@ CpuidExit ( return 0; } =20 +/** + Handle a RDPMC event. + + Use the VMGEXIT instruction to handle a RDPMC 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 +RdpmcExit ( + IN OUT GHCB *Ghcb, + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, + IN SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 Status; + + Ghcb->SaveArea.Rcx =3D Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + + Status =3D VmgExit (Ghcb, SVM_EXIT_RDPMC, 0, 0); + if (Status !=3D 0) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax) || + !GhcbIsRegValid (Ghcb, GhcbRdx)) { + return UnsupportedExit (Ghcb, Regs, InstructionData); + } + Regs->Rax =3D Ghcb->SaveArea.Rax; + Regs->Rdx =3D Ghcb->SaveArea.Rdx; + + return 0; +} + /** Handle a RDTSC event. =20 @@ -1308,6 +1350,10 @@ VmgExitHandleVc ( NaeExit =3D RdtscExit; break; =20 + case SVM_EXIT_RDPMC: + NaeExit =3D RdpmcExit; + break; + case SVM_EXIT_CPUID: NaeExit =3D CpuidExit; 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 (#63862): https://edk2.groups.io/g/devel/message/63862 Mute This Topic: https://groups.io/mt/76056529/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-