From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (NAM02-CY1-obe.outbound.protection.outlook.com [40.107.76.43]) by mx.groups.io with SMTP id smtpd.web11.13460.1574280454277505127 for ; Wed, 20 Nov 2019 12:07:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=mKj62+TO; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.76.43, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJAvjeSk57ytqijPYfr6EM4JrcEbkZSOY7uoDS3JpA0BE93ELTikIKrVeEYwPR0uIRRmlPRsHSSS0tSD8isd5hrzuMJoBS8+jKmj2//SRCQhFWpZWXZ0jDiJMFhGFDiq/phOtnDAqZ474QM3v/WvPMTd+ysWa8L3l3SRBJNCe+AOHacF/wKvtt4ZMEVROPh1Z6dSQcdyWX5glo2JI6fvc+/+1AKPhY3IiDbYW3HcH5+SF9UXG49KlYxCP4zVT99mms0A+sFfVFmq0hkheQjda0Vc2koUsAKdLdCTuq+X6JokPhurR30bOt/ieQVOitdFKurGcp8gNy7b6TDBGnwEuQ== 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=9DbKgOhQPJmqFp89BTCglqc7dzhDpZORzCTE1dnVSIk=; b=fDMrG+G/FXROejp9YdHWTnkgTUCSIs3CMYaJYBXJHJERZppUlE5VN4Xua/JYMpnoaML7aXpPTMONq3GpXMmDr9JHLquBQNGuWksWcjfNwDemG4L9d0ZVBMS4G//vnV1mDpBrVu256f7nfnZNtp/gwbV3wCj7NDlJ4NXFUQcxojUwsb2ezfcMn//mXUl9Ft10hXtRa6odAGRFixqy3UdNmfUVBFiF4GOkakbmu2nC8fB7KyAE9CVr87vvQi360Ootm/2HJGWVCHhMzsGlyS9UmplAvaQD32rvUR8qdgZjijJ7cH53K67NPfcclzZ39qHKjqNIskAdXto4++EQReIWIA== 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=9DbKgOhQPJmqFp89BTCglqc7dzhDpZORzCTE1dnVSIk=; b=mKj62+TOzFOW3klaOpDo6EW/l3j4T5maQmLfs7lDvJ91oYFaRqfD7ANxLUr1aXklrehejZxjTBwsen8PZ+OQxCQL/JbKENFI1PV8DV5omNN/4KbSAYlHvEoDRAzLdZ+F6vBYqf0WBMuZgiFNYlBXs6uW+kPn3jd+MuXrxlyyZoY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3675.namprd12.prod.outlook.com (10.255.76.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.28; Wed, 20 Nov 2019 20:07:33 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::dd0c:8e53:4913:8ef4]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::dd0c:8e53:4913:8ef4%5]) with mapi id 15.20.2451.031; Wed, 20 Nov 2019 20:07:32 +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 , Brijesh Singh Subject: [RFC PATCH v3 16/43] UefiCpuPkg/CpuExceptionHandler: Add support for RDPMC NAE events Date: Wed, 20 Nov 2019 14:06:38 -0600 Message-Id: <1e85d168f3373cfc80e48611e4eac9481b620c56.1574280425.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM3PR12CA0087.namprd12.prod.outlook.com (2603:10b6:0:57::31) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ece2a11d-d4e0-4113-8233-08d76df54732 X-MS-TrafficTypeDiagnostic: DM6PR12MB3675: 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: 02272225C5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(1496009)(4636009)(376002)(346002)(396003)(39860400002)(366004)(136003)(189003)(199004)(2361001)(50226002)(81156014)(81166006)(8676002)(2906002)(6486002)(99286004)(66476007)(486006)(47776003)(66556008)(25786009)(2616005)(476003)(54906003)(11346002)(118296001)(8936002)(316002)(2351001)(7736002)(305945005)(66066001)(6916009)(86362001)(16586007)(3846002)(6116002)(48376002)(14454004)(478600001)(966005)(5660300002)(66946007)(446003)(76176011)(36756003)(51416003)(6506007)(386003)(50466002)(52116002)(4326008)(6436002)(6306002)(6512007)(19627235002)(26005)(186003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3675;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: BCL:0; X-Microsoft-Antispam-Message-Info: XrXg7i9sNStS9tpkroP1e74Jo6L+ENyagUI4q9CRN5s3y70RxtR+6xlZjNX0A3Grjlf4vRdl3DbjPanC5V7ToermzaSgdMrVekW8eTKAPaspE0BCQ+f6dkaFHietqCxSehrtoneskVFBgr9WNCBMGHWVjsDMbZi9ZQHj6FNk6HhDI9E5zKd8hF7LjqQAg8P22ZvFP2oQYeMs6KhLbAIbH9HQ4u+5J+z7TIk+kyLNniykoP6YyWocEqm7XJXJ9KSLpHrgPYQGIld9N9LBZr0eFslhuk2rJ4PL2T6oRFpF/R083vxU//gIyjj0jDk3Pvo5DTYeb7VaKCA/a1FNrduV/gjSZyJlFe+o6zjg8fs++RrOl4XrxlH1wC0qtRIS/2XqpPpzNrB0mPO7FTLpe5pX/z1A68MM5C808U0S03FLZOcLUPUBejwDhSFy7kf+64okA2U41JbdWugH7FOA61LuzgI5reu5DMMMlfOE+jQBQuI= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ece2a11d-d4e0-4113-8233-08d76df54732 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2019 20:07:32.7110 (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: yDwUAlGgDWoF16eTGBWJY0XCrjyWvu3pqCESQJ8KSqAQPlyrfxWYQHWvUir8hlQVBnjz995br/JRfJREj8Rncg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3675 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 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 1b08a855cda0..5fb3766ef138 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -895,6 +895,35 @@ CpuidExit ( return 0; } +STATIC +UINTN +RdpmcExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINTN Status; + + Ghcb->SaveArea.Rcx = Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + + Status = 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 = Ghcb->SaveArea.Rax; + Regs->Rdx = Ghcb->SaveArea.Rdx; + + return 0; +} + STATIC UINTN RdtscExit ( @@ -941,6 +970,10 @@ DoVcCommon ( NaeExit = RdtscExit; break; + case SvmExitRdpmc: + NaeExit = RdpmcExit; + break; + case SvmExitCpuid: NaeExit = CpuidExit; break; -- 2.17.1