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.89]) by mx.groups.io with SMTP id smtpd.web11.13461.1574280456337538850 for ; Wed, 20 Nov 2019 12:07:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=XnAGXvv0; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.76.89, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZA5l2Tr4TGJmYtTstTor951XxOygoGG8h1BwehXUEAUBzr0E/tJ/YEz1SIKNa8g/dtcJcSJFS7+Kg6pz+12nRMmeMdQerNkg2NZXBPWbwhZbE3PRcsdPFdcSbdijJNY9SeBkFx3AZTzrSSa4Gg532A0zZ85YCyf5lE/mNqdGm9oHGhYEH8WyQAZXuktWYbpXqHLMUCbgoLHQL+K+jNdNFxZ3GDzQExCWLfQfFx91UHysk0N5cQ/8YFyrQdeAMh8Dpq/LwIHVqXBBKaUa+t+LbMZc/76H0JR+sK98q4w+WKCBC9rug9J7XuF6Yq/Gp78cO1X6bMGdwAvxSaX99IWpoQ== 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=EkuV9NgVqc9mnDUnPTNgj2a8Nob66r2KxS0k4IFHNBo=; b=Pi1y5OWWp3LPPnAOeZYjTnEbOJgajClpr4PIj9aRaUOYOlzNebw4g5Gc7JHvjXOCXiHwVGUZzyzshps92SC7Bf+EgdWe85LyA0+ovF0GZcWRKo58U6a2P+OzrRkMhRDtpBvtIAqkcPA66WkwAl69OIrjD4SWVGv195BNwEDLkKZsZRZ2YyRDZHqb4RJiQWcaozNyQ8XvPuzm0KndHfLIBKR+NKycL8QgyRzLpuHY6uGB/AbJ/4Vx+QWBL7K0FC5PLAOUxt+qsxmJgJ7+Ho4JZy2ZMWAGxVoNWouLjcyM+rV9h02dFqaVU7f1ppfsTYN9JEhzD+tVLwJ/fl1QeyaRwg== 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=EkuV9NgVqc9mnDUnPTNgj2a8Nob66r2KxS0k4IFHNBo=; b=XnAGXvv09Hhrj3puAFsia3KP17m6l9xFWHtpEhRjPxqtRRF85a82T2HguvvVq0lp12CWTPxf8JY33ashaWv16EkfyPx5+8tDFeot4omcboQQ49+uV1oJ5fQLT3IJgDE9R8AqYd1IfpRBV41g2kdfdRuN5j3KaCu9b6i340tVd0c= 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:35 +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:35 +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 18/43] UefiCpuPkg/CpuExceptionHandler: Add support for VMMCALL NAE events Date: Wed, 20 Nov 2019 14:06:40 -0600 Message-Id: <5786e57e5776b5d1943bef0dddcd469ae02b33a2.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: 5b99798f-c7d6-4589-8688-08d76df5486a 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)(6666004)(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: GdQN0aohjhvNUP48e/RdY08TGApr3Bduz6fdEqlaKmEukolNbYX5ZdURXMr5A7uZl7rriEM8tuKgPs5jQGPB+Wp8Wame9oy7YnjXPGbm979YGp/Sk0uDH1kQpcUpIPAYu4r1y+iJIFVO4zkBDogF7LolxBqI6BqhF2GIbkk8AJ+7Muf6hGAcRd9OGz+USu/TS/M0zUndXvun8rPmn0hKYpgtlcPMI2oeCgnp0pVo5J6HXCsHr/DzN+j6EX081Rt7dd2tjBIrvCrVf4A4HzOGs+ENlpIMh/FP28pBcX4T2k2f3bezjdNbxIrIf79b6+Lv61qJorQo3l3u/3Az6ll/adJcHxvxXRsTIG6TXw4VIwEBIOaURmbpHc5L6n3JyuDxbvZ8PLt0dmOJq0wvNqaeWRYj45Od/qTs0Ts2iZ1QZIxW1knmgr/TKpj+YQCjgF0xADvkC+4a4+ZwC7cpGvW69isrCZUXXVNLlIcXTAtyJ5c= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b99798f-c7d6-4589-8688-08d76df5486a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2019 20:07:35.2056 (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: 8u6eqyBPVzqK+/hryKkFlrqnk5+pJQsE2Xdl0pmjv3FXYrTfNwaHS2c+4n6OY4OAHpAOFaRBW5pYef3L2oPkAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3675 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/AMDSevVcCommon.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index a9dd98250c58..8b0192bf0a0e 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -603,6 +603,37 @@ WbinvdExit ( return 0; } +STATIC +UINTN +VmmCallExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINTN 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)) { + VmgExit (Ghcb, SvmExitUnsupported, SvmExitVmmCall, 0); + ASSERT (0); + } + Regs->Rax = Ghcb->SaveArea.Rax; + + return 0; +} + STATIC UINTN MsrExit ( @@ -1008,6 +1039,10 @@ DoVcCommon ( NaeExit = MsrExit; break; + case SvmExitVmmCall: + NaeExit = VmmCallExit; + break; + case SvmExitWbinvd: NaeExit = WbinvdExit; break; -- 2.17.1