From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=0QLMJzzZ; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.78.78, mailfrom: thomas.lendacky@amd.com) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (NAM03-BY2-obe.outbound.protection.outlook.com [40.107.78.78]) by groups.io with SMTP; Thu, 19 Sep 2019 12:52:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bD2Z9OdZVodJ93oMqNGzYH+zlKj7zwqT7MZg5FzWQtkb7iK9Id97JBiKQKvpIzYQKDGhSSx/KIfRr6Du3K68mVwPucApuNb+bDkFbClCK0/XrnIRdP1Fj7QYWQveG/CitWlHaaRVnETSRi9nia8NJlM5iziQsxIEBkP8Pktc9Tm28NZPGXz3/ImUXsqRBGHdvOmUeQ2asqCWUXDihkvfNLP3/h1edrVKM9/tBsgglBp+IN6gYWyx1ZdI+wM1/6vy13AA8eRLMVkEl0lpCXhK9+mFrZ6bPdUVMfKUXNkIPeVHttQK6bH3Aa2mMRIgDoPbBEYYNorucL15ZJgXtMZl7A== 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=VjynJNW0AmLV9t+V38eXADPgNKBxtUq57f8fvp1EP1Q=; b=gCqGdcKG6q+41RldywgRalsMLF2rsJU+OxQ/N0/6x6pJuAaL8QIw7eE4DZ1cdeon8KLVaRA8b4YGyxa3KH7IPNQxfubegsEz9l0tHh3U+hkmSiMvADNdaGr8XimHSUfJ3jwE/f0sknYEV2qL8GtEjlND2YC1cjjvMA8qLMA6pNbYYQTrOHUj9o3VH6+OvkcjQ7+SBSGP+KRD1WQJqkpAtQPSaFiF0E2zdr0JcEtH5MLzty8sVnwI4qs2srpwN1ldRgZwu6hfOTxRYkfwxcwgcSkSHN0SFRUVkZIQtvwCD5XITSO4qbndXsbnuOVb43smQ44Y2x2SHwH+d6ZBMfgUIQ== 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=VjynJNW0AmLV9t+V38eXADPgNKBxtUq57f8fvp1EP1Q=; b=0QLMJzzZLQV3InJJnSKwuSsYUGl7dMUNXSzoAbGAiKsfY3i0wFPoBWoiUcfwjdq2Xh0yqZxwW+H9yt8z3z5b2q6UmCvYVO1r6fJ2aDxxp5CbS0kNFDyZxCknB30Ltdv9/bFpLhSuYpVe5XkArsq+NbPYwKJ/oW8MytbuCw5LeTY= Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.104.150) by DM6PR12MB3228.namprd12.prod.outlook.com (20.179.105.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.13; Thu, 19 Sep 2019 19:52:55 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc%6]) with mapi id 15.20.2284.009; Thu, 19 Sep 2019 19:52:55 +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: [RFC PATCH v2 27/44] UefiCpuPkg/CpuExceptionHandler: Add support for RDPMC NAE events Thread-Topic: [RFC PATCH v2 27/44] UefiCpuPkg/CpuExceptionHandler: Add support for RDPMC NAE events Thread-Index: AQHVbyPUPRi3LlSKTkyMrgwk1jLBWg== Date: Thu, 19 Sep 2019 19:52:54 +0000 Message-ID: <9db048b65455e17fc9c4a339ef5520037a9f2ede.1568922729.git.thomas.lendacky@amd.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: SN4PR0501CA0146.namprd05.prod.outlook.com (2603:10b6:803:2c::24) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:182::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 54e32e48-22b7-49b3-ee4a-08d73d3af663 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:DM6PR12MB3228; x-ms-traffictypediagnostic: DM6PR12MB3228: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(1496009)(366004)(376002)(396003)(136003)(39860400002)(346002)(189003)(199004)(4326008)(26005)(446003)(25786009)(52116002)(19627235002)(71200400001)(71190400001)(8936002)(81156014)(81166006)(256004)(8676002)(186003)(50226002)(2351001)(2616005)(102836004)(486006)(11346002)(476003)(66066001)(386003)(6506007)(66446008)(14454004)(76176011)(99286004)(6486002)(36756003)(5640700003)(66556008)(118296001)(3846002)(316002)(7736002)(2501003)(1730700003)(6116002)(5660300002)(478600001)(54906003)(6916009)(966005)(6436002)(2906002)(64756008)(305945005)(86362001)(6512007)(6306002)(66476007)(66946007);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3228;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: EM7/CaqOI7OR2BaEj7os+IojuR+aacax04kZ1AZXPIBey7aoXzb8dnYst5qWk/ZacKV7dGuHzagY3Cc86e+LUbywbkt1V7jkAkgxaMiK8xC5RYIGlHU/P7s2ej0wnNfKIJIrB3/B+hzJx6CLTUCw4R9HI/rgryhBGmlzO0O9sUC2BAw7xsM7St+pLuKhM8YW1J5+MHj1sZoUDbKwJU/P2dIL1/+k6221MpRfmSP5ZTp/PEPeyu/8FznXYc/h6s5twP4u+MB30PuCHVXfoBM3VP3eVTwdI0WJlTrxy8p5U/sYxcK2X3eOcGJVQw8P39kDijRkFY2MewRmcw5Ijg/HD7VP+MNyWvYkrpu7Aq/2vgfF5LNeb0iODmQ/tNlxdP6OBzc/M3reIq6d5YTmF2mtkNEARJqvIN55aOw/urJ/1+s= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54e32e48-22b7-49b3-ee4a-08d73d3af663 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 19:52:54.9644 (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: khDbQilhI6a7OmdI1YFg1ATOsLo3fg4hCnFddHpv8/hntjfb3fRkAWEisHa+F4GMpkjVizZOP4QpLtIIFKRstw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3228 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable 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: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Tom Lendacky --- .../X64/AMDSevVcCommon.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index 1f6a1f9a30ce..a6534e1a59bb 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -865,6 +865,35 @@ CpuidExit ( return 0; } =20 +STATIC +UINTN +RdpmcExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINTN Status; + + Ghcb->SaveArea.Rcx =3D Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + + Status =3D VmgExit (Ghcb, SvmExitRdpmc, 0, 0); + if (Status) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax) || + !GhcbIsRegValid (Ghcb, GhcbRdx)) { + VmgExit (Ghcb, SvmExitUnsupported, SvmExitRdpmc, 0); + ASSERT (0); + } + Regs->Rax =3D Ghcb->SaveArea.Rax; + Regs->Rdx =3D Ghcb->SaveArea.Rdx; + + return 0; +} + STATIC UINTN RdtscExit ( @@ -911,6 +940,10 @@ DoVcCommon ( NaeExit =3D RdtscExit; break; =20 + case SvmExitRdpmc: + NaeExit =3D RdpmcExit; + break; + case SvmExitCpuid: NaeExit =3D CpuidExit; break; --=20 2.17.1