From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.49]) by mx.groups.io with SMTP id smtpd.web10.1353.1585071690420697658 for ; Tue, 24 Mar 2020 10:41:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=anWgB+4f; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.49, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=biUxkbltKtBH9Ve0Lyw7qy1M0BdUIBxmJnXQk/SqrhuzGY8APWelUt+baEQHqL7qoviEG6WtHupWncVws2j0hmj/kn6eYsny1xfrk1BJQ6tVK/iLaBB0YC9SxAwkslfdGoMeixTc3A5tNL8Ch1nzwL9cv2yEcHvdTT9kRDHnJyeiRxVoXagL36rbHAJ3OIfykkPsAO9Jfvut7P/Qy3NdrfT0HYWVIcL8I5ySxyh5+n13mSD6ElgJs4AiMavX9Nh0oXcOdXW+N05hS5qhe4nrlYfQaRpN02jTmMKENmrGkHrLgUXIwY/gQGUVsj6ch1nvGAedlxy4NOgvl2O7FbYKOQ== 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=oUbH2V5PloIxebrcN8CWTq1iPx+P4q5XlxTlex4NI+I=; b=Te+LxdoUdNTeNjW1GDqyhdCl5+a8ogXntrpLSSN5WQa91j2vo2AIn0IwisL5CEkQmMAPwM/vKRbmJl+XeMn4jvreU/d9xRok4Sj5KoxGrDq14325DnUW1tjY1ki/Y9hEZQpg0Q56Lc86A3L2JQB79TznUkFfLWlCoCbztmHAfC/06I7YH1xOoJWxLH/GZ2Ug1yeqTYEHiinI8YP9JgH0abNpC0nssqyJ7/1KfuNegsnnrsg6XEkx/1CDg0RLheb7NHCMSzPMAS+/W9ErHxOE0S+1gI/GethlA60E4hL+X57POaPA7j6byQvuOp+Zaot5SysD3IuU02Kmd8bvs6mVEw== 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=oUbH2V5PloIxebrcN8CWTq1iPx+P4q5XlxTlex4NI+I=; b=anWgB+4frumhEm5+MNpDB1LvXvwMpaIINdrQJidobE7sWXVnv4CTKBpf7ZM/7Q3C64mz20fyDSPSE9WXgPcDI0z5ne8CaLNnlKpTAAdDv3i6AIDoYWVjpilQudN7uFFK7BCxjFAa05a0VrYMaCPC8PyrM5gq+7AGR2F480SO/e8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) by DM6PR12MB3915.namprd12.prod.outlook.com (2603:10b6:5:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.22; Tue, 24 Mar 2020 17:41:29 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733%7]) with mapi id 15.20.2835.023; Tue, 24 Mar 2020 17:41:29 +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: [PATCH v6 20/42] UefiCpuPkg/CpuExceptionHandler: Add support for VMMCALL NAE events Date: Tue, 24 Mar 2020 12:40:34 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Tue, 24 Mar 2020 17:41:28 +0000 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: c797506f-c9e4-4f5c-c63a-08d7d01a953b X-MS-TrafficTypeDiagnostic: DM6PR12MB3915:|DM6PR12MB3915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-Forefront-PRVS: 03524FBD26 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(366004)(346002)(136003)(396003)(39860400002)(8676002)(8936002)(186003)(316002)(54906003)(16526019)(956004)(66476007)(36756003)(6486002)(19627235002)(66946007)(6916009)(66556008)(2616005)(26005)(4326008)(966005)(81156014)(478600001)(81166006)(5660300002)(2906002)(6666004)(7696005)(52116002)(86362001)(136400200001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3915;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; 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: I8dedXG4yuAV/wJSglgjQ4c+keJAAWdvoKFiicSgclaXoMxTQXnEi55+AKY7K1tkh2VI1MqlMVV2N++7BHEN4LNkwOslG6+dobshCLM27VFV86BZRMGJIgKLUHssBEPujMgWPaORJGw8PsbKAqx1dc/9vZZXJRs/e/hQMcm8Q7+u/EuNAIVkvpEFcAMAnrfAPRDo5hgV+2z2S2BPtMI/sdAhA/HkAEuIk+i5heTAMZz9Rt8+6f/OCGNtLWg3jZajYIPkHeJ6YulIVwOx3jtYLBR1r5Tu0Q6SdeI1Lmj/5fzfLSbbGDxFNFRf8tutbBfkpEIsB2tvJTlv62/f872WNP1Wqp1LoHJFFw3uzNI9thFGlIcZdmwc1ZcaBSmqNXiOGOD9s/h/kzOTBBuVgkpXA+PqFe+KbXJ5N/Pj4lKhe937KiLo/jBIluojAx5XDrhiGfQ7a1/6rQF5+W8eKtcuX9jzv62Xwq2txUX5L8Ih0mMMMIWEg88ol5CRtU3VQT15uP7UHWKlphJnxhxymHNsqQmc7mcYMMBNpdFwnhMxQV5W+jbq3F3KMHCgl1Mbwt3arBijsNlIBG5Wcodc5QlQwg== X-MS-Exchange-AntiSpam-MessageData: yGST1nbe+ijIAiI7CyV/4snro3LaG7K4AA54Y9WpbzF4d3JubZ6aCY0dEkBXXpG/5xp39lB9ienEQ9WLmfxEY8Pm0sNasc/gqKpCsFrr5REZVV3/VKSQfGDYoNLQYEDsziPsNyUxHVszssOrhtTW8g== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c797506f-c9e4-4f5c-c63a-08d7d01a953b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2020 17:41:29.0782 (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: k0n+aeGXqcOQL4zYN3VpXjyhhiFthCGqDgozp5KJ/bXHTbPDKczvkPL6e5pi4eqJnaZAdv9I9wcJgG8v8k6nZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 Under SEV-ES, a VMMCALL 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/ArchAMDSevVcHandler.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c index acba14d995cb..7b57229a770c 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c @@ -609,6 +609,36 @@ WbinvdExit ( return 0; } +STATIC +UINT64 +VmmCallExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax = Regs->Rax; + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Cpl = (UINT8) (Regs->Cs & 0x3); + GhcbSetRegValid (Ghcb, GhcbCpl); + + Status = VmgExit (Ghcb, SvmExitVmmCall, 0, 0); + if (Status) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax)) { + return UnsupportedExit (Ghcb, Regs, InstructionData); + } + Regs->Rax = Ghcb->SaveArea.Rax; + + return 0; +} + STATIC UINT64 MsrExit ( @@ -1005,6 +1035,10 @@ DoVcCommon ( NaeExit = MsrExit; break; + case SvmExitVmmCall: + NaeExit = VmmCallExit; + break; + case SvmExitWbinvd: NaeExit = WbinvdExit; break; -- 2.17.1