From patchwork Sun Apr 21 18:01:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13637454 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 BF3D2C04FF8 for ; Sun, 21 Apr 2024 18:09:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FC176B00B4; Sun, 21 Apr 2024 14:09:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AB776B00B5; Sun, 21 Apr 2024 14:09:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34BF46B00B6; Sun, 21 Apr 2024 14:09:33 -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 130C66B00B4 for ; Sun, 21 Apr 2024 14:09:33 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CA4841C0A2E for ; Sun, 21 Apr 2024 18:09:32 +0000 (UTC) X-FDA: 82034326584.19.FBFE376 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2077.outbound.protection.outlook.com [40.107.223.77]) by imf25.hostedemail.com (Postfix) with ESMTP id D3811A0003 for ; Sun, 21 Apr 2024 18:09:29 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=TyI7gEWU; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf25.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.223.77 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=1713722969; 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=fgJgGQzmEQFn3qDjiul4utVDj7Am85Us4DHS4OSv5bE=; b=Iy48YHDEEt4jBRPN29tflqLFToEQb8FiuX5EPfCW3KCRTSI+KjR+Nl5vaoTBoUvvXCBi+4 iAaG5MNEzBleu5i/5SIITGCbB90HZC5KQbkrgLaoFnBfYnv6YjDWykZW2amkjpWcerKcpR higLMdltM2AkA/LLsT5bxe/RMMC5Hng= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=TyI7gEWU; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf25.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.223.77 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=1713722969; a=rsa-sha256; cv=pass; b=YEgxRePg0CaPEtMumROqEYZzTtvEf7UXJ8BxL+yhz/+97qjyQcSRV2lhBSODC9IpfiYyA1 MkEXxP4Sfq80ZOQl0RIB+LysX2Gt3WJlnp5vYcWJOZKy1xTLhb0L2cfLmbWEow75RZHtv1 caIwyeXh4Rx3xfwKMfLEz9eCrby5RlE= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IFjkivabxXx8qtNwWxwbBn1QAc1+sgmRxpJ/Hn2kpKH2aNH0odV1z32nm6m0q9qHLIdR7bGstjayBKGhJGAgiEQS6R9ZM5EE3alckFMLgkcdlh2/E6V+zlijfvfVAXwHrVWRazl7Nv3IE1mcETfF94IOmmWaK4OYR87NC0zgUQ2CQyfNo+KTWZFvJ6VJTjmQ0P646aGu3/41jFvl2TFRzCXVXZDZLYDNvldWxdcwcBqjmOm6X2U1jPNUWLSvkYSR5EKdYrGryXqOru2rK2LLcOlCZGd2gC+m8YjgatVvELXGNHJtWY6YeFcFjWkbmbcUii7rPIRCjoVgv4akMNZvEg== 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=fgJgGQzmEQFn3qDjiul4utVDj7Am85Us4DHS4OSv5bE=; b=NufusNhjKmOiYP66dpug1Gj+pepuUxEB+3xzxhQTgI6MaJwmO6n3yVkm3BwKFtwZDrAU0d+a3bdAxm+4OFB3WFRQEpy3xJUEB4PQ+sns1I56lbtsXhIKyJCsyqb/2oe7Ef18I9NOj4xR70JuSgeMm4VxuSmcsvWk3jjEzZaGpmodLfw2q8TXtUIeEe2JZx9MfEUZgv4WyDyj0DCVVv2KG+Ps7t5nqJkx4c0I5VbHt8Cj+ebeXMN9l2tZP2bncQgjx+RVf862EpmzH34PXrvJLXESha1pWQk4Qc6z6No1r/ib0rpol0RHH+G8AGQbkCkbnHqv8RU/ZHgb4lTTyFp0uQ== 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=fgJgGQzmEQFn3qDjiul4utVDj7Am85Us4DHS4OSv5bE=; b=TyI7gEWUllsimAfPIgcNHv1J/8wRYMmjRwCLEVQq0LkVW5DHkWx2UYAVT2DksGOb+4FPFXetG6Om7WZIp5h8gcl/C4myx3Fasscn1xAMUrMUTLX0tpc8fczN6XiQLJkUDT2yqVDcGA3hX10XSBJXVTwBYdltlA20Hs8ZzaY3S3s= Received: from PH8PR22CA0021.namprd22.prod.outlook.com (2603:10b6:510:2d1::7) by DS0PR12MB8814.namprd12.prod.outlook.com (2603:10b6:8:14e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Sun, 21 Apr 2024 18:09:25 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:2d1:cafe::7c) by PH8PR22CA0021.outlook.office365.com (2603:10b6:510:2d1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.33 via Frontend Transport; Sun, 21 Apr 2024 18:09:25 +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 CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Sun, 21 Apr 2024 18:09:24 +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; Sun, 21 Apr 2024 13:09:24 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh Subject: [PATCH v14 03/22] KVM: SEV: Add GHCB handling for Hypervisor Feature Support requests Date: Sun, 21 Apr 2024 13:01:03 -0500 Message-ID: <20240421180122.1650812-4-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240421180122.1650812-1-michael.roth@amd.com> References: <20240421180122.1650812-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|DS0PR12MB8814:EE_ X-MS-Office365-Filtering-Correlation-Id: fbb9d9f2-33ec-4297-c822-08dc622e2d6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TuCZ4d/xlryLJ/cd8oAhxCsR/JgoPRQlSPbbn3ctk9eAN3PhTTrZ8e6hs57qVm9t2dhNJR9132b8vzeQ8Qzo/57hcIoDphNvoJj0pUXKkS7Od7vFwMX7eAC3mJfCmagAF/THNh2cOiifF/9qZ9je8Mlhxu1+fd0zxl1TTKqGz1k9pzwS8mijVzQeiV+fJqh3p5TNlhN5h9oj3onb5H+tQ5mTQ23pkNpgX6GSR9AOkkH19zhrnYzPsrYpdJW9la7e9TaIYRL1rQ6gMjJwRDqtVBU4MZFFYNeiw9CxSoDgI5iT4x6sg4ykxyo4/Ghmn/S4LkoTSWv+/LLNRNKPhyW09bppVl+Nw5gutrHOmKYGT0lP1owSXooCSVAZKzeCp5gKLpZSwCouqyoZGo+7V8nHamsxt4hrlgIy6AeT44WGDXsEL3u4GA2u3B3qS4T7pAKB4ravE9w76rIW4fs3WTa4lge7UCY+CybQkhDRreERxubflH1BsSFR/Qa4WAgpIjkKxsyZ4Eklwx5lgl7XrUTg4mOIbj8xVMB72T/FhJYeNKshPltb1Si26Bh0UGbYAWfxfiXsgKEZxjL4mQ0vMgjyDc5eBJNr0t19ZqTyI4TEXL7YCi/sYdKfd4DAtBeRVSwqbrLIRmFpzjaVRENrP9QWctJzfvbVBCO33o4LrlGZwOHReBoCKh5YFAZJJexuGBI78+OR8Ci2Lb5ti1sgVncDY+y0qQx+HFQZ4K+W3UVKafdIynbD+SxASLx/uUzPEF6Yus+jcAbZiTTOGmWRAcM798OaBHwX3BXm3SqpEM4pZMNKgloMlPlyhbRRsTobWfZPh+sj80Aenz8XZnfll+zFnTgQnE54oFgx+k6U/P77eSqFY2wov7k0izdfx4MvMG+JI72npsI4Ucev+vqJFPqAgRAAIuWKUk6DDdt8fakkuKqRp7e/1oQMylOBEPuX4QtNut9w8z5HZ+Ya9ENjVR65LNb6Pirq8wdaoCCnqZpLWfN0zVKiSNbD3HDqypSwJBkraGp/MnWF0jeScp/o/4Gpe3R8h49tnGb4bBun5rZkkFIVvolaqTkc9DCLBBtsSqgFviMfccRFi+g7kwPbfgHihmy5i292ZZdsxJ7KAbNW9ehHY7N+euf6DDLaCVkmON3elNPB30tw0o8RaCge8MJDVKnhwnUSADVwEV9HpNHqphSv43EfcM59HjJqeIS1od+ScBgkIbyFxIEmzq0LZpI70ZvJA93oIDV7jk4lnbyaOLa4itJhRtfpgNtHbBiBl6XPbJaELNO3EPgogNOqQOuRtn12+hci4UcW9O8aZjhz8bjYamASphS4OLlTbwiRY20cn0w4Lk4rcf1341SYFy4xuD5LcSUJKG/71LntngFTkRo= 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)(1800799015)(7416005)(82310400014)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2024 18:09:24.8992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbb9d9f2-33ec-4297-c822-08dc622e2d6f 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: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8814 X-Stat-Signature: y63d4g8qkr8stgozmkupiq64eknsb4rh X-Rspamd-Queue-Id: D3811A0003 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1713722969-441527 X-HE-Meta: U2FsdGVkX19w8crUxjAy+k1btldpUj8SB1bfx0WzOIXo507/Q4XrnIsnLjGAkF0fkWA+qi0jWnDqw3Bvpo97lJM/Tljr4Zd1KUgs04QPCTGAX+DebUQ1/bMGQ67Z5B/zZyH7Z6AUQH3zvzjXfKBgRjisO4r1AfwLalLE5o5zz7lDJvx0sc92wzS7K9GixOZUi2tf7ZY1O3IoZPuKc/vtOtx25UwhBVd9+MrwZNE/VAUQagcGsjKDxxhIcKkOrJJw84qv93SncPj2rmNX8X943hK/ydknxkvr0UkGsT1RLvsosK0MlhefGB0mOe6N3VUSCAFKFrQ3rECJnTXYQ3YdOQlh6jr75EpsKs0J79Hpm1rxzX2bYBZ8oTF8goInvI3a3jDKDM3+UPr02NhS6Z5B3D7fakZwcpPoaCTdwf+OQIPAY6dCuYTU6e9beEaLKGEom1XwqHz0vUVPmzKM8lXKgW8RBwG11/itbBZHv4T6ltnDkTA+VFShf519Bx9zyUOb46Pn2seeYqoNXhV420L+8Oqi8rQL/u+hI2VUUbqaJ02cB6hrjJftY8Bq57ht4zaoT4wf81rA1NZ0I4GklUsJVFmVo8JfsRvh3KHOicyYq2iSJpBKlMH+bDjEOTP7GFHAMgc05OPjZwXMlbXelL5g98tsbpvcAbu/7w5vlf+oA/FaNBMlnUsa2N4M+9Ih+4nkWS4DIw40JuaE6O5OvgEYDXQrrqmtCGWSXPytvvKWQpE/sjLobXjIrO49JuRIc4W9akgQ/4GlAAbRPVg/MkMzybAvbtok0HU54EQ1jOR3SU+Megy1DH62gyrBfNyk9B1nUOwi/ld7BXlpaPKu4jst91mPcaxLdOYj5sFu9nlAaMomK5CVKY9831/mbMGuzmyCWg8xR5yE6SNX0NMdTgfa4SYPFEbTVP8O8vKIw8PFR5T1u3CN0xDj4FQHubMtky4m06WVPKjtcvUrjLT56TU 8rb4iN0u ApEhHuviByhfHhiStVH2MftKO03lak3NY6D1q/Yo0B+pifCLZb5Of+eu7oYkXQpuvnLFef4ZbDGzSqgu/XpV4dDTUHtku3faK9ctuRbqYtlp4kwChWbInpmGgj4dIuLSfu+WZgegVmp/PcddKwATXG216nz2fkBoTkC94nBCDnPi0V6lK4TlYeGR5zuENfc6O+4IBbiSJnDI01P8ncGGthAt41A0Iy7/dbRtDYHyaxptPTpsQTKirSa/5hy77VzTje1VJfN7TbuKZeVXTEu2uA6/Svg2pTyJ3O+PcsMPkVhtOOk3PoEBcsNsd9N5V4I/vSyemRj3hQ8CXDGjJyCOw1h4dhPeVfEvT/t3VH7k2UN7edZs1HyRlFTcOtw== 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: From: Brijesh Singh Version 2 of the GHCB specification introduced advertisement of features that are supported by the Hypervisor. Now that KVM supports version 2 of the GHCB specification, bump the maximum supported protocol version. Signed-off-by: Brijesh Singh Signed-off-by: Ashish Kalra Signed-off-by: Michael Roth --- arch/x86/include/asm/sev-common.h | 2 ++ arch/x86/kvm/svm/sev.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h index 01261f7054ad..5a8246dd532f 100644 --- a/arch/x86/include/asm/sev-common.h +++ b/arch/x86/include/asm/sev-common.h @@ -101,6 +101,8 @@ enum psc_op { /* GHCB Hypervisor Feature Request/Response */ #define GHCB_MSR_HV_FT_REQ 0x080 #define GHCB_MSR_HV_FT_RESP 0x081 +#define GHCB_MSR_HV_FT_POS 12 +#define GHCB_MSR_HV_FT_MASK GENMASK_ULL(51, 0) #define GHCB_MSR_HV_FT_RESP_VAL(v) \ /* GHCBData[63:12] */ \ (((u64)(v) & GENMASK_ULL(63, 12)) >> 12) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 6e31cb408dd8..1d2264e93afe 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -33,9 +33,11 @@ #include "cpuid.h" #include "trace.h" -#define GHCB_VERSION_MAX 1ULL +#define GHCB_VERSION_MAX 2ULL #define GHCB_VERSION_MIN 1ULL +#define GHCB_HV_FT_SUPPORTED GHCB_HV_FT_SNP + /* enable/disable SEV support */ static bool sev_enabled = true; module_param_named(sev, sev_enabled, bool, 0444); @@ -2701,6 +2703,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm) case SVM_VMGEXIT_AP_HLT_LOOP: case SVM_VMGEXIT_AP_JUMP_TABLE: case SVM_VMGEXIT_UNSUPPORTED_EVENT: + case SVM_VMGEXIT_HV_FEATURES: break; default: reason = GHCB_ERR_INVALID_EVENT; @@ -2961,6 +2964,12 @@ static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm) GHCB_MSR_INFO_MASK, GHCB_MSR_INFO_POS); break; + case GHCB_MSR_HV_FT_REQ: + set_ghcb_msr_bits(svm, GHCB_HV_FT_SUPPORTED, + GHCB_MSR_HV_FT_MASK, GHCB_MSR_HV_FT_POS); + set_ghcb_msr_bits(svm, GHCB_MSR_HV_FT_RESP, + GHCB_MSR_INFO_MASK, GHCB_MSR_INFO_POS); + break; case GHCB_MSR_TERM_REQ: { u64 reason_set, reason_code; @@ -3085,6 +3094,11 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; } + case SVM_VMGEXIT_HV_FEATURES: + ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, GHCB_HV_FT_SUPPORTED); + + ret = 1; + break; case SVM_VMGEXIT_UNSUPPORTED_EVENT: vcpu_unimpl(vcpu, "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",