From patchwork Thu Apr 18 19:41:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13635310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1050FC4345F for ; Thu, 18 Apr 2024 19:45:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98B7D6B00A6; Thu, 18 Apr 2024 15:45:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93BE76B00A7; Thu, 18 Apr 2024 15:45:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DD496B00A8; Thu, 18 Apr 2024 15:45:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5F2766B00A6 for ; Thu, 18 Apr 2024 15:45:22 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1D9AE1C1A7F for ; Thu, 18 Apr 2024 19:45:22 +0000 (UTC) X-FDA: 82023681684.12.BF1321A Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2054.outbound.protection.outlook.com [40.107.92.54]) by imf13.hostedemail.com (Postfix) with ESMTP id 5B73420025 for ; Thu, 18 Apr 2024 19:45:19 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=wLiPkh8c; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf13.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.92.54 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713469519; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Bx+UiV/8mdVOtuDMjYEt0x2o+sh50xZzYMq3LpQNu/k=; b=n4XJDhIPLysyD0llKAg9NTRSsu98sNqmFs6neXZM/lFJRUxMZ5Q31WY0bDSSL0GB1Qb/LU L0X0aLUzm2sHW9M4GsEgeQ+L7Xx3igCLtMhQMhvRTN0B5DvT52TsqheEEbed4e3VnrvaX7 WaEvp/IoHnb6Yv+4MRvVBHtMm9Ldbu4= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=wLiPkh8c; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf13.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.92.54 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1713469519; a=rsa-sha256; cv=pass; b=lMLnicBruyEyd1E6i5AQu8OM5FV6vhURHZCXinzWXD5WYZ5a0XC79D5yLU9xjyoG+CdlqZ 1coGDpqWRegoEk1F2jvid6xDqSpKjPJgG1GCDKFCSmRbPl2peoaT6LK5BtmgI3NuSML59a HBC3UeOV0bmWEvd2fVHmif0ravEKG4g= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mG9auSHwDrYrhO2jpUKjNOHDr/N6eyheXTa+4VfPTqO3TMFND6SMCjVe6EaAFFX3IcSfqZ84o10uHTbLIuDTfDGL2JszbDaFbiNMCKVDO3iDpO3UE3XwZfqyQ1skJkAwJro+VfnNb4dZyKF990obTLpR1VasI1yUE+dr/BuyIwMPYfRwrZOb1Gscq1zbCKGxvvqHvn/F9RxirVd5iYcj1r27s06dbqNPPDM5qAXM9sa3FcPNBXXAkPiapJleXU117E6X7U3BFcwHZWHsCc/mNvJQrKHQ52Ou0jorSAoP0Dz6KGrZ13utWTHBVtm0XI3jlwVHb4KHPLGubaK9JSXKZg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Bx+UiV/8mdVOtuDMjYEt0x2o+sh50xZzYMq3LpQNu/k=; b=h0l3uR1En71OA9ip/IyvGSpBEne8AfO+YApp9WbkqQAiq5GP+2F3spfDl/+mf5AvCAS5cku3EZ02RTnGjE9cxEnyWuqJbUHUGTx75lQztcMtzXIHW8zG0hq632c+PdCxhKCT88l/V59vqbprWIbZzlwls4WjhJnQlNUp8hrJwdmPxgxsPN2zEvL3gUFThkUek+FDVcpNLEW2TI0vwAVaxbWnveMREmz5q5W/CiLeRqgd5ziI1nNPUPrUZYSxUAoQRanR6Rjp3RZDHBJwUrviWZDEepIguD2XR+Gq89MS1ohDkp8hVhWe3uB4aX6aEzIfD10wjtVLJMY2Id5HMzI39w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bx+UiV/8mdVOtuDMjYEt0x2o+sh50xZzYMq3LpQNu/k=; b=wLiPkh8cItOydS7Gq3V4h+R2HAHob+fDLsXP+QsjJJXVxe4cx+6HFQ7WtKoHZ7By4xduhYfNasdHOu+c6ys0w0/ZjIQJefZZWK87KYpvMfcc86GpeeDVoGIjliCwwsHV4YSYUU055ZFTyG++cNbkAe28+9WS5IXos4kQTjbaGlI= Received: from SJ0PR05CA0176.namprd05.prod.outlook.com (2603:10b6:a03:339::31) by PH7PR12MB7377.namprd12.prod.outlook.com (2603:10b6:510:20c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Thu, 18 Apr 2024 19:45:16 +0000 Received: from SJ5PEPF000001C8.namprd05.prod.outlook.com (2603:10b6:a03:339:cafe::12) by SJ0PR05CA0176.outlook.office365.com (2603:10b6:a03:339::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.12 via Frontend Transport; Thu, 18 Apr 2024 19:45:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ5PEPF000001C8.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Thu, 18 Apr 2024 19:45:16 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 18 Apr 2024 14:45:15 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 17/26] KVM: SEV: Add support for GHCB-based termination requests Date: Thu, 18 Apr 2024 14:41:24 -0500 Message-ID: <20240418194133.1452059-18-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240418194133.1452059-1-michael.roth@amd.com> References: <20240418194133.1452059-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001C8:EE_|PH7PR12MB7377:EE_ X-MS-Office365-Filtering-Correlation-Id: 244273cd-9da7-4496-a46d-08dc5fe01278 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rFuUwldkLH25m03dkf6YY/11rMjS7H7hJru+uOCHHIUZUntJ6ul2L+ATuc/lmpH7cA8m46mogtxk87a4r1uSDozr2DPXIxIq68oacyFNzl/NRcwcIACdT5aH040jX+wrvPbBsqbm05aY5x6ndHf4OdD8pXpmbPv0djxqw2APx5gwdZUt28hpF8ogcX6SurDBFUAhAkcFsNtgngBMP6Cf2A3eg0Tj8TRxDGtJySZJwGzJ6hDealNp2YrWkcHe5iv0JG1XQwHCczttHV0YEnLhlwVbDApVS2WOyzDM7bzm+GOUz3A64Ts+dy4n4/kG1SJEeTouvKacrCMjPzHJH2rW+24iF++/Vyx4nAacz30fBKBrbBtsduA7aGduROkWaaLLAkYqHtNIy1dQhfyJNH7Lt+guV+PEEWHHwBDjAO1ekBCLr4IuEWgA1kZFSHFZDXOcFfdaC+Eza/HwXudvTtdBgZhVzQf542+wJ9MEXz4s/r+GsSaBUuVfadOoZm+vHI9nSdyRE5bM4LeKGe6qylJaZuMFgE5yWEcGq/chNKzsmV8YInQI2UGNCIrIKSyYQLWhfFQK3dJAqYdM2Uk4sxEpfEjUoiD9tMIgzImlRi69G9piwHPWBx9pAYeglRRwHxZBBtFBakyA5nbdfWULAhYZq3i1t7prlOjh28kRoAxbq9utPB6sn8soodQtRpBYbisSIBwr4eS/+oyCE9/yvozjjPvU8jadJnTpBmiGo8d611kSYxkjI5T2T1qpNmZvhnLO X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(7416005)(36860700004)(82310400014)(376005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2024 19:45:16.5727 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 244273cd-9da7-4496-a46d-08dc5fe01278 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001C8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7377 X-Stat-Signature: cfckmd83fuhmts3ngqb9kznkm8hdb4uf X-Rspamd-Queue-Id: 5B73420025 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1713469519-966613 X-HE-Meta: U2FsdGVkX1/dddty+iRaSy9KOMcNkG9hNIZc5lkNT6KRGUOqgX0+YsbkSHFbmAhy7JE0/snZA7scO+iG2FdixJMC6DciYlLoEfI+wmhZ0UKHSyWuXTLSexkLw8R73Yd8mOMke2O2QfccvdiKtztQLDc8Sa8PpIoe291jf17IaoqnManK84Qs8dtBmC2OxCA3d6AhJ12W3VfJsOaptKJn1AtFP5UO+MB2no3f2TcR6J3DiLyautSx6vel3kRuMaVN71vtsaBFViwM6cB2QczxlIEfNC/UbQ3FpjzLAQnlp9Psg++r+6qwN/c0DSlxw1phVk2nMT80kMVZBqGPxOm5CBc1vXNM0l4CuSMfo8GJkbdmO57BGILIfOv/nKGiX0rMoZ0LCFUKp2ZikyoU8dpuG7+uKbL40B/4oi8nt08FCA1YbqSxI1xzLgtHUXnkqBP+cpW1OLV1g/w1f1DUAsbUb/39giNRMw0fM6KADeqHPk68hwaPTsF9lRJla4gRdMpJwRVvl88uivXeEStByuQDe1YFfFzgF2SDs4TEPzbJrSwUngrbeHIcQK5ri4ZrKDYmcmdS3z+4xyJ70cQE0v4TeMG6rrE0iI1NCX6EfvMxfeMf4RpgEO1W+xCvTTQH23GIpDEYxn/FKLLs32M9F/jllMxqRAR00irgS4lmZ3+mnIV57irj4KhBMX3yjzsobTPZ1SvcZFVdEs67cjvrg7nLRqswHw6RGlm8dDWFcsS47ERl4S1npGf6tvNwFnSDmud+WOoKp/TbytDtpHt3h0rvqkK0BK/bfFKm98NkrosBUybXE0dRABfZcG4Alk0IOF49biFkmvbeMdSQ3kuDx06I8M7Kd/nqVCI1Vk/YeaZ1mMF0pgsHLlB4dUQcqvdBxBlO8Z1Tl+7D8qL3w/yFElsU/xLzKKWXXxHCD7x2KGbkdrX1KMEzECowiXRc9Za4lir6fgw6BvVP6/NxRc9Msbr Jwg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: GHCB version 2 adds support for a GHCB-based termination request that a guest can issue when it reaches an error state and wishes to inform the hypervisor that it should be terminated. Implement support for that similarly to GHCB MSR-based termination requests that are already available to SEV-ES guests via earlier versions of the GHCB protocol. See 'Termination Request' in the 'Invoking VMGEXIT' section of the GHCB specification for more details. Signed-off-by: Michael Roth --- arch/x86/kvm/svm/sev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 2de3006fec65..2e0e825b6436 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3272,6 +3272,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm) case SVM_VMGEXIT_UNSUPPORTED_EVENT: case SVM_VMGEXIT_HV_FEATURES: case SVM_VMGEXIT_PSC: + case SVM_VMGEXIT_TERM_REQUEST: break; default: reason = GHCB_ERR_INVALID_EVENT; @@ -3967,6 +3968,14 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; + case SVM_VMGEXIT_TERM_REQUEST: + pr_info("SEV-ES guest requested termination: reason %#llx info %#llx\n", + control->exit_info_1, control->exit_info_2); + vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; + vcpu->run->system_event.type = KVM_SYSTEM_EVENT_SEV_TERM; + vcpu->run->system_event.ndata = 1; + vcpu->run->system_event.data[0] = control->ghcb_gpa; + break; case SVM_VMGEXIT_UNSUPPORTED_EVENT: vcpu_unimpl(vcpu, "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",