From nobody Thu Nov 28 13:50:26 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2064.outbound.protection.outlook.com [40.107.237.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 546DB185B78; Mon, 30 Sep 2024 23:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727737890; cv=fail; b=N9vIrUyo/wbO+FTM/KIKsHhJmQJfmFLb5pGqgl/Ah7QT/oqTItsRdpM7iiY+w8Iuf/ajzIjRNDOiX9vCCLJF1U+iFOJPjujq6swqDwRuX42zvq+vXjLRO4TQEVY6bq9zgTmcddJNKFaBAPvU/fHeEQ9Sebqx74kK2+7rxMvG+KE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727737890; c=relaxed/simple; bh=3DDcqfVeXFDE2HEGM/btMG9d5Pp3amyFNqbWoB4eZ5U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VoaSkrukanTnkQrzsiAfmq3wJqmPGKubJWKzKkS6JreseH9KBZtxINiHRd10Ms45G57yjOscpZWm43HiaMHzOdg8t9L1ezccu9YsztsJo4G5Q2jLP6/bFYx7h9z5QrQS/9uRciZprQLm6WUE0L8KQv4QQfkicG2vTSjHzTTT3EA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PLxkKvhL; arc=fail smtp.client-ip=40.107.237.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PLxkKvhL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J1QrcGgUEYJ8tAZlr7bjceln+9pM2sFrYb6NNm9qu4Dg12XOc4DBoTT3ZkvFSkE6uQM27D5CnmXK0fqknTeVgVBJCTTtd1VHRkawvpTQEjl+kE6CccHwID/FqWe4KSlxmzg9BkbrGnaYt011fBRJ45b3Thr+eG4b7wkUyTatbWRk2yzxTHBGJf0MkYSzT25f4EJv00rt/wTcI+C9kVN3YesKwOw9SmRCLD5hmPoBjtdI8NPQFAM15wvN6SzqPEjdISS7Ij9yd2rg5RlIUCIXuhD4vmqaWYMphc8G4Xaxk8yMHOHgLoxRnt39X37M3u9O4Nq7yu9iGFaNM99DMAX5KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=t+vTSSMIkY/W6dm6DoGGBOA1s263+nMZTxc7EP3Jej0=; b=brBflFLUSKY+QsanOhkWuJ9u55YNFfuQ9OCk9sb6RFT5cEyYE7fhMPxsipoxo6vb6y8S9A3CT9PAo9XbglhGQjRN2/JyzImSBFRotjfGqrS/xQcTELbWOTD6pIT3m7ZA0I8y14GR9YowdDzxwVhsmXtdh4KhNkRS6cqDUBSgxT+LFIjvAauE/fXUReA1+lMjq1fV6BHZFLhIVYmTUBjWe3Bt4K24hUrl4DjHSjNU79y2j7DL218LnfWMbq36wMZYP1ij/fyX/ZIcethGqiF8jEYB3v2CamBIUGT77f9nRtgLLD6XbeZ/wnYCP/zOmqHgpOcgVKGuOdkb8SamtgFDow== 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=t+vTSSMIkY/W6dm6DoGGBOA1s263+nMZTxc7EP3Jej0=; b=PLxkKvhL90/L039uv874U3qmBCtJLgUtlt1Uy4cwz+mZ5YUN/Ukmf7UqNwprFf4cUhYLYwKj+2wzyiMDR4lqVatPn+pwxYjbCHx84HbihHPq3US9U3NsfNBw7L3nnNd5abYmR21Roduboh7jP9MHT+E8U1Zue18Pk1wv8UhbtaM= Received: from CH0PR03CA0032.namprd03.prod.outlook.com (2603:10b6:610:b3::7) by CH3PR12MB7739.namprd12.prod.outlook.com (2603:10b6:610:151::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Mon, 30 Sep 2024 23:11:22 +0000 Received: from CH1PEPF0000A346.namprd04.prod.outlook.com (2603:10b6:610:b3:cafe::87) by CH0PR03CA0032.outlook.office365.com (2603:10b6:610:b3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27 via Frontend Transport; Mon, 30 Sep 2024 23:11:22 +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 CH1PEPF0000A346.mail.protection.outlook.com (10.167.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Mon, 30 Sep 2024 23:11:21 +0000 Received: from ethanolx16dchost.amd.com (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.39; Mon, 30 Sep 2024 18:11:20 -0500 From: Pavan Kumar Paluri To: CC: , Borislav Petkov , "Thomas Gleixner" , Ingo Molnar , Dave Hansen , Eric Van Tassell , Tom Lendacky , Ashish Kalra , Michael Roth , "H . Peter Anvin" , "Peter Zijlstra" , Pavan Kumar Paluri Subject: [PATCH v5 1/2] x86, KVM:SVM: Move sev specific parsing into arch/x86/virt/svm Date: Mon, 30 Sep 2024 18:11:01 -0500 Message-ID: <20240930231102.123403-2-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240930231102.123403-1-papaluri@amd.com> References: <20240930231102.123403-1-papaluri@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH1PEPF0000A346:EE_|CH3PR12MB7739:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a342540-1c53-4294-1a3c-08dce1a532e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?u8wks5yiq3csYZ+cjESWL6YpTRNEv2nhvwTO0dEOdC+m64DF/n7PFD/cEj1B?= =?us-ascii?Q?PHWm3JEHooeYCUOcY+1qUJaR9WtZfEbP+bvabEVkReUDs2t786kPnFexHocj?= =?us-ascii?Q?oDsxkmRHX5OQDMl/uj1sdC5jRap/rxMKF2iW7SkhVKoAJizb9lQlXlhM/6Fx?= =?us-ascii?Q?PI5umZJvJwVz9BjDEmdG+jZ+UnwuwVzSKskusCZeXq4hKzB6DYbVY26LlRD7?= =?us-ascii?Q?AXIgB20E6N6L6Z2d8QgeiXlFppf0JGTpmBvk52tEa2ZzUWtpnteHE5vAapQS?= =?us-ascii?Q?ftYbhdVeJWR9sRqUF4oZemyCOTa1rD83BcKPzDggu3Dv6i3Zhpqj6wcbgrq2?= =?us-ascii?Q?0bOVlj9quH9zS2feGVgSZe7fpQFhsKX1orDDcq+Y6U6HOFIyLewflxz8HHpO?= =?us-ascii?Q?5QQeT+0yg3d6GmAGfyuA3PWb0HT1NTNsV68deFGhAwR4DJcXBIvres3zsqGW?= =?us-ascii?Q?LVE39sD/TKm18AX3lTpSI65sjq/WdslAvH8f3iYH612+zpdrIzXprnAy7wqr?= =?us-ascii?Q?vDlOVY3t8qRznBV4w7W5Ts5CyfSG3FSgNAw2LDXY0/T0/W8tFlri6eY6T7Rq?= =?us-ascii?Q?ihrBmedWHz2pmDlLRRBvBYZnYfVk4KdivY0GoTiTye7QAbRMo1pe/0R17sec?= =?us-ascii?Q?uTS/mH8vI4vvvwDc8lMOEG17h7er8ujOJf+rDz1x3nVLB3Dav5fv0Rtewb4Q?= =?us-ascii?Q?Wt6pH9EA3kgRVvq18a7I0+lYbzfrg+mkj2ZvW9lUMZZSL8MmGO0NTNwDKt3w?= =?us-ascii?Q?uWz9xjV4wrpzdTE5488b2QRaa62eLKVbW/zSVPXjcWv25kclRmFlmRJUbLWY?= =?us-ascii?Q?RV4JXBOc30czB5yfFIUHnIcTitvNV0J0VeXHEfeHSG0Pdd69aYZOkHxtB9Vg?= =?us-ascii?Q?DWvRoxQBYKT+4caa0/iatrcFLieNZB84eyRZtH17VV5Zx3UwhqapKBLLI/2O?= =?us-ascii?Q?616TIppTlqA09cQEeYQoPve7xB9t0x904Co3pEaMKDZ6bpxIy5594kIvKu+3?= =?us-ascii?Q?GrdvxcFNRYNsp5r/y4GrMmfd2qsGQgxNMuJ/wtLpR/Vcs9A2vKcTrnVczzcc?= =?us-ascii?Q?CpmL5LYy0i8ioF6Hym3xRomU30rX3wa4FJtGh3YsHd4ql2hyP+LGx08+W43r?= =?us-ascii?Q?Vcza582Olo+7YcYlIKUbf+F2PacpqsGY7MZU4n+K3OGlqyiNp8HByO7L1yc3?= =?us-ascii?Q?Pv0r/hfe9aQiyM0dmfgQ1DW5ZY44XRjLZlh6OMc7NxxKweXbZTKdNXoSBsS5?= =?us-ascii?Q?hA+ywp8PBK8ZWNDprHr3I5wckiKz4i/qWt+uCKpoUk/PAR94HoNbQhYJnV1W?= =?us-ascii?Q?evVgT4YR8OYWPPOuTwIiTj6sPDM8qBmrf676e0eoMrNOwNe+am0uWUNyAwxl?= =?us-ascii?Q?qIPAlo8=3D?= 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:(13230040)(82310400026)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 23:11:21.8715 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a342540-1c53-4294-1a3c-08dce1a532e5 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: CH1PEPF0000A346.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7739 Content-Type: text/plain; charset="utf-8" Move SEV specific kernel command line option parsing support from arch/x86/coco/sev/core.c to arch/x86/virt/svm/cmdline.c so that both host and guest related SEV command line options can be supported. No functional changes intended. Signed-off-by: Pavan Kumar Paluri Reviewed-by: Tom Lendacky --- arch/x86/coco/sev/core.c | 44 ------------------------------- arch/x86/include/asm/sev-common.h | 29 ++++++++++++++++++++ arch/x86/virt/svm/Makefile | 1 + arch/x86/virt/svm/cmdline.c | 32 ++++++++++++++++++++++ 4 files changed, 62 insertions(+), 44 deletions(-) create mode 100644 arch/x86/virt/svm/cmdline.c diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index de1df0cb45da..ff19e805e7a1 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -141,33 +141,6 @@ static DEFINE_PER_CPU(struct sev_es_save_area *, sev_v= msa); static DEFINE_PER_CPU(struct svsm_ca *, svsm_caa); static DEFINE_PER_CPU(u64, svsm_caa_pa); =20 -struct sev_config { - __u64 debug : 1, - - /* - * Indicates when the per-CPU GHCB has been created and registered - * and thus can be used by the BSP instead of the early boot GHCB. - * - * For APs, the per-CPU GHCB is created before they are started - * and registered upon startup, so this flag can be used globally - * for the BSP and APs. - */ - ghcbs_initialized : 1, - - /* - * Indicates when the per-CPU SVSM CA is to be used instead of the - * boot SVSM CA. - * - * For APs, the per-CPU SVSM CA is created as part of the AP - * bringup, so this flag can be used globally for the BSP and APs. - */ - use_cas : 1, - - __reserved : 61; -}; - -static struct sev_config sev_cfg __read_mostly; - static __always_inline bool on_vc_stack(struct pt_regs *regs) { unsigned long sp =3D regs->sp; @@ -2374,23 +2347,6 @@ static int __init report_snp_info(void) } arch_initcall(report_snp_info); =20 -static int __init init_sev_config(char *str) -{ - char *s; - - while ((s =3D strsep(&str, ","))) { - if (!strcmp(s, "debug")) { - sev_cfg.debug =3D true; - continue; - } - - pr_info("SEV command-line option '%s' was not recognized\n", s); - } - - return 1; -} -__setup("sev=3D", init_sev_config); - static void update_attest_input(struct svsm_call *call, struct svsm_attest= _call *input) { /* If (new) lengths have been returned, propagate them up */ diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-c= ommon.h index 98726c2b04f8..9e36e8dcc997 100644 --- a/arch/x86/include/asm/sev-common.h +++ b/arch/x86/include/asm/sev-common.h @@ -8,6 +8,8 @@ #ifndef __ASM_X86_SEV_COMMON_H #define __ASM_X86_SEV_COMMON_H =20 +#include + #define GHCB_MSR_INFO_POS 0 #define GHCB_DATA_LOW 12 #define GHCB_MSR_INFO_MASK (BIT_ULL(GHCB_DATA_LOW) - 1) @@ -220,4 +222,31 @@ struct snp_psc_desc { #define GHCB_ERR_INVALID_INPUT 5 #define GHCB_ERR_INVALID_EVENT 6 =20 +struct sev_config { + __u64 debug : 1, + + /* + * Indicates when the per-CPU GHCB has been created and registered + * and thus can be used by the BSP instead of the early boot GHCB. + * + * For APs, the per-CPU GHCB is created before they are started + * and registered upon startup, so this flag can be used globally + * for the BSP and APs. + */ + ghcbs_initialized : 1, + + /* + * Indicates when the per-CPU SVSM CA is to be used instead of the + * boot SVSM CA. + * + * For APs, the per-CPU SVSM CA is created as part of the AP + * bringup, so this flag can be used globally for the BSP and APs. + */ + use_cas : 1, + + __reserved : 61; +}; + +extern struct sev_config sev_cfg; + #endif diff --git a/arch/x86/virt/svm/Makefile b/arch/x86/virt/svm/Makefile index ef2a31bdcc70..eca6d71355fa 100644 --- a/arch/x86/virt/svm/Makefile +++ b/arch/x86/virt/svm/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 =20 obj-$(CONFIG_KVM_AMD_SEV) +=3D sev.o +obj-$(CONFIG_CPU_SUP_AMD) +=3D cmdline.o diff --git a/arch/x86/virt/svm/cmdline.c b/arch/x86/virt/svm/cmdline.c new file mode 100644 index 000000000000..9640507342e0 --- /dev/null +++ b/arch/x86/virt/svm/cmdline.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * AMD SVM-SEV command line parsing support + * + * Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. + * + * Author: Michael Roth + */ + +#include +#include + +#include + +struct sev_config sev_cfg __read_mostly; + +static int __init init_sev_config(char *str) +{ + char *s; + + while ((s =3D strsep(&str, ","))) { + if (!strcmp(s, "debug")) { + sev_cfg.debug =3D true; + continue; + } + + pr_info("SEV command-line option '%s' was not recognized\n", s); + } + + return 1; +} +__setup("sev=3D", init_sev_config); --=20 2.34.1 From nobody Thu Nov 28 13:50:26 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2064.outbound.protection.outlook.com [40.107.220.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 582A9186E24; Mon, 30 Sep 2024 23:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727737896; cv=fail; b=f2BYjE6ajBb/dmFBa93bASRktqyEc7D1jIoJyp4r+2qmHu9/A/EVXvUx3kpUQTNCf8VHSqOMU9vfQw6hh/WvKwQy2kROwxW6IkiB34wmXJJqbIHLLOHaIozCA93ZyI4AGPb2eZGH8mXYPKeV59zflyIRHrjuYX1HeKMcjxWBkP4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727737896; c=relaxed/simple; bh=hroTRP738OghtaNu2KOoXMspeAzXmy2nwXkRcARulBA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nSSzhcCOUP1xggkj55lVjP7IB0orAPlSeAUFhCiXDjKrjg0LRcqJMNrBjdZG93qjS+E7amH11wAM8+/ZFOoI+pkRMgdeGmMIObJcN0ePYYy/WngvEKF6yhQ1DkUKiGCNhKA3FLyyD5NUvMWrvw8gWUWU5l8GS92tNLUEAoTJml0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=JCWSXbb5; arc=fail smtp.client-ip=40.107.220.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="JCWSXbb5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wc57YchSxGXnbTEPt/UvApkfumA/3knsss0ClV6Pab1glsbAUeDNIuc0/9BA9d+SAE8syZkNz4p1npUAHMpb2IiOo3gtcq2RBpCXVcnI/B0zuZHm8s4fjqQ0BmADhaWeJlC4wKZXQpTYBELdAJfdR/+deFreSWbsZvme2URme2+LrJkoXW2Dzu5FcbPvuPmtgPZf/M1gBa7H3V0fzj6DrjJ/bgV3UTZkiePDZtkT65zRu15xfeB2rtgKTwBL2qrq0b/vkyrVfI/59ESk+KMfmZ0SIRYLe/9bFCtgTe8yWRkL2r/IKvRFKBYqEGBZO5F4T0vRVsYXX8rZ3+mBtwWV9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5nL/0FNC6qWDEBaZ1+OnJnqPmWoEQikTtvbzKCSvDmw=; b=fTaLQAI/I6mG1AE/3arR1Zp+NyO8XWOFrWzC51fUA01Mm7hhYjRkuQLh7v6yI4IGusJ9b/PmHwIVPNYsfi0D1AkQDKlPORHfbQWzZJ3siwkxm7Gr4sRn/BbJCX410syCuP69acVjTye/PCdr1tJJ+SOSx0nZxqUQIJUNtlnwwjXxy4zcTz688PMTvJk4gv3PZvMQcwDY2p4y17r9osi8B8c6+bh1rnSJbJYboYzyTC4F+6k1wk02z+BsjvH75mLzHxx3937loJxmJ7HHHTrK8Y7AtzmNpuzEAAigVUS8wRkKbWfZu9XL5jN6iUtCwfPmYAa7Q0HoQjRc05OBw3fBkw== 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=5nL/0FNC6qWDEBaZ1+OnJnqPmWoEQikTtvbzKCSvDmw=; b=JCWSXbb5oXH+klbFP06zhYhSLfUPuVdzTp/U+STtk7B2JNj8bAFdv8WXCOJJf+j6ML/ZSOrbcCbMr8k8g5qKguiFu8/c5Gowk/1miWLFTKo8UrjMvANbHz1nlodDsmvOZqwzEs0GBFd7R0yC1PEsXsXH87EoVtxS7UlvEiVURP8= Received: from CH2PR02CA0026.namprd02.prod.outlook.com (2603:10b6:610:4e::36) by DM4PR12MB6085.namprd12.prod.outlook.com (2603:10b6:8:b3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Mon, 30 Sep 2024 23:11:32 +0000 Received: from CH1PEPF0000A345.namprd04.prod.outlook.com (2603:10b6:610:4e:cafe::66) by CH2PR02CA0026.outlook.office365.com (2603:10b6:610:4e::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27 via Frontend Transport; Mon, 30 Sep 2024 23:11:32 +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 CH1PEPF0000A345.mail.protection.outlook.com (10.167.244.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Mon, 30 Sep 2024 23:11:32 +0000 Received: from ethanolx16dchost.amd.com (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.39; Mon, 30 Sep 2024 18:11:31 -0500 From: Pavan Kumar Paluri To: CC: , Borislav Petkov , "Thomas Gleixner" , Ingo Molnar , Dave Hansen , Eric Van Tassell , Tom Lendacky , Ashish Kalra , Michael Roth , "H . Peter Anvin" , "Peter Zijlstra" , Pavan Kumar Paluri Subject: [PATCH v5 2/2] x86 KVM:SVM: Provide "nosnp" boot option for sev kernel command line Date: Mon, 30 Sep 2024 18:11:02 -0500 Message-ID: <20240930231102.123403-3-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240930231102.123403-1-papaluri@amd.com> References: <20240930231102.123403-1-papaluri@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: CH1PEPF0000A345:EE_|DM4PR12MB6085:EE_ X-MS-Office365-Filtering-Correlation-Id: 097ed8e0-4add-4af9-d8cf-08dce1a53963 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?H/bQLThXNUkx+UDZytJT8LVuTA4uT3lPyEWdYBpnbFMfUHt3QvRnCzWaPhgV?= =?us-ascii?Q?rzcon0TllNNPkVF3l1OKSzD+3PajrR1fjJrDo3Fo+C1i4zUVhYgrcuhThnHt?= =?us-ascii?Q?8u6JtEb5GAmIZg74HcPf1yezJbyQeZCbSUeplgmLH3HL3/6Nm374zs2Wu4Li?= =?us-ascii?Q?4erH6j63fnCfu5cBYfqI3vY6nCTjPpSZRPaY4Qof4DDIkco3Un6tfH902Am+?= =?us-ascii?Q?WU4d1vM3I8Pf1TBlQH/A8oghWIOEhXMRLHUrOEy7oEWWsH9KXlW7RbQHIlbf?= =?us-ascii?Q?8e1Z3TH2LNbsDIAU8P0MU03C63h4Mz7BcpWZuOkI6KLxYaNkS8KtsRaOYkkt?= =?us-ascii?Q?vehcR6dEmyMNT+SnlNl24tGdtgyMIiPXjz4cniuo0bqhdFQASuJuL2lcBIV4?= =?us-ascii?Q?m0vp/oQNO8bkCW3z619t5PsPXykdi7jvgCnXCs3Z3ucXtFNI58pvLKIsNKCP?= =?us-ascii?Q?qMi7xCZ7IuM0AW081WgLMuRsQwgJttrt1hK+GVqZfM9236TTLkVDwIU9QZ80?= =?us-ascii?Q?pUHb0gjuHeMWoJRcmlfGqUqQ2ab2Mfw2nrS0n17FkyWhMU/G7ZNPrBJ37UI5?= =?us-ascii?Q?42zxb9HmrCY5ACQLlokN9ps90IXZAR6KGAyZyU7+q4JRURFQ9I3OmRLBUzAG?= =?us-ascii?Q?co/pZjkDk7KCNSQa1d2TE0siu//HLFAhwgpZr2Un+xRxo3I1ZRnBaVelBrs3?= =?us-ascii?Q?LovMeHQvAMegepy0B9VCQUy2dsCCBmkEx5azlexl8z70urV28R21+IGiByxL?= =?us-ascii?Q?kGDMiWMiIhJT4gSKkHTZ0/vadAQb7Qqa97q3lonS6uZoJxRKh5VoiQhquKpg?= =?us-ascii?Q?2aKfa0rdstQc+wxyb3QI5n/xdqdqoCinQm2RzXYh0kck7guFD0pw38B9Ou+w?= =?us-ascii?Q?Et/j0NgI9Gf4WzeqAxGTkSFDE2fj9Lr1SYEKerF+weRG4+f4YfQjYlei4lJI?= =?us-ascii?Q?jqIFFlXLKZeAew00BgzMglaLMBTdIB5vv/XpsRWMK7zMTGdmgLXDfhIukEWe?= =?us-ascii?Q?MN+yhHWsGxxHwD9kIJmebHqcuWE0UleOwqLe5UZm2yrk5cRbpPsvN1kpFyWx?= =?us-ascii?Q?stb6vcm1uyw1Uc6CG2rrpUV3pAhU3fP67Rp4wp77EbKSclK8bPf+/DJMSQIi?= =?us-ascii?Q?DGst2IoMZtPiQevIlc3OgDmzLTW4zvAbGxrXk6HE9cumCem/Q4gyFSYrxkeL?= =?us-ascii?Q?Umik/J2H0aBcYmwI83+6sGA4BWxUoUwPyFeTtbyXKCVZXu5c5nbv+LkY/7nC?= =?us-ascii?Q?UYjXXOpxM1JQD9bdG/W1LIHvpUglA+E0b6NQTL7sRQ4OZdDxwWEdCP1F27lt?= =?us-ascii?Q?lFGrFwe8wsppSiaa37LVNCQrZGj6uPIaCJUpphfQhsWRP0Lq/rzF1MTtGEME?= =?us-ascii?Q?7aP5tDa0/Hv8LJohDI4RLyTzJRgm?= 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:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 23:11:32.7684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 097ed8e0-4add-4af9-d8cf-08dce1a53963 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: CH1PEPF0000A345.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6085 Content-Type: text/plain; charset="utf-8" Provide a "nosnp" kernel command line option to prevent enabling of the RMP and SEV-SNP features in the host/hypervisor. Not initializing the RMP removes system overhead associated with RMP checks. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Pavan Kumar Paluri Reviewed-by: Tom Lendacky --- Documentation/arch/x86/x86_64/boot-options.rst | 3 +++ arch/x86/virt/svm/cmdline.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Documentation/arch/x86/x86_64/boot-options.rst b/Documentation= /arch/x86/x86_64/boot-options.rst index 98d4805f0823..7ae6d882ea52 100644 --- a/Documentation/arch/x86/x86_64/boot-options.rst +++ b/Documentation/arch/x86/x86_64/boot-options.rst @@ -305,3 +305,6 @@ The available options are: =20 debug Enable debug messages. + + nosnp + Do not enable SEV-SNP (applies to host/hypervisor only). diff --git a/arch/x86/virt/svm/cmdline.c b/arch/x86/virt/svm/cmdline.c index 9640507342e0..313415d6f53f 100644 --- a/arch/x86/virt/svm/cmdline.c +++ b/arch/x86/virt/svm/cmdline.c @@ -11,6 +11,7 @@ #include =20 #include +#include =20 struct sev_config sev_cfg __read_mostly; =20 @@ -24,6 +25,12 @@ static int __init init_sev_config(char *str) continue; } =20 + if (!strcmp(s, "nosnp")) { + setup_clear_cpu_cap(X86_FEATURE_SEV_SNP); + cc_platform_clear(CC_ATTR_HOST_SEV_SNP); + continue; + } + pr_info("SEV command-line option '%s' was not recognized\n", s); } =20 --=20 2.34.1