From nobody Wed Nov 27 10:41:00 2024 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2041.outbound.protection.outlook.com [40.107.100.41]) (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 2A9651C3F18; Thu, 10 Oct 2024 12:15:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728562522; cv=fail; b=QP0cKY8/37eugoudIVPb0M19MgGvi98gBbE0MVnjwC1KswYsiMF0s0DwtwvUXPfjwob+qEuVGhddtfGc1Fq4hHAMDmZzdLa4b4W8BV2lVQ3LDo7X6TNRN3xStot5PswaISjrFHw9CEQl08wX0tmckKDxY5U/wsPr4s+uJShVeF0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728562522; c=relaxed/simple; bh=LlCxj/gaqnhgIzMtbHxrCWYkJ2IvoGgUj4EeaOvSAnc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EkHMNXTDLjj+PdaR3QyebQUbegVau8dLuhJIBQIxOb0FLG+Vccp/VcTjMeXVqSvA50dfioF++cTotTy4cGBdiwoPYEBN9O0i1GWil8Q4LOoobeoqNMpIw/HK8GR8iyDOJccvgGKaOJh3ePYw7mkhQ0XAKegw2TnnY0uo34cyCsk= 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=gcXM/qwI; arc=fail smtp.client-ip=40.107.100.41 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="gcXM/qwI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XSynuDX214A6JSS5NfYgsCotv4cJjHn1tEzAtI5z+6D/zpPZUXz+11AaKnmhGGlTv7I202gyU+t1DuyAeOtLQIjPzWUo+LVxM2pWEFACGopfABVRB3EzxXGDKFztg5agLUYNn1uISdvfFLszaVbILoRvDyjRqGbymLaQdUNlqoxw+7zG5n2LtPSgDWTSXsHss+MGWjWhDjE8KfjrfeP7neug4JejKWAYeowhY/ciZ9URv33L1gGQJMxFbQh3UZiev8VLSms5jQRqiJchZA+AxkGqFbDvppP4rPOFa/CfneSeMXyJfUHIiJcuq/KszIdZ8YpOZgfN8KOCAZpqKRcN1Q== 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=U8lmCdmyRyarOKU9cQRwnCBCVlhhH7zBEmOJCi+Uwu8=; b=XymO3TWUZuZQT4koE7JTf4dO4ShHjfhXJwvMsvOjsuc9QOsKl9VdV3MPaDwdQCuCnpGlFL1Stzxb7/NsKiH/g7imW/RyQnWOrB7EIEq7/IECNMzkJtM9/jZ6AFV1ZUqhTU8DiIUPlEiUmdFZySeZQcGhM7iIQN7FV52alC+gcxJGmCnpXUtqOio/VLKMeYAIz9NYeKGTxq0xbOBSGUhZMPwMr6N0lr6mdcoHRHbT3NcX3++BXQwmc9hhOnREHoy0u4TjTjjELjKrQQ9rIp1Z4bpz32vo93W5i3oP4zO2YZRzHFCtMcRQMIYvOZQqeitrWpG0qHYApyJSx6cqTI219w== 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=U8lmCdmyRyarOKU9cQRwnCBCVlhhH7zBEmOJCi+Uwu8=; b=gcXM/qwIp68fY0PzEMJ32ROVmelETdeI/DEcANVzNdsNDcuNvfLR07brLALufjrCJlGMwCnqSbV+KEQPQ0poilawHb8Ed0B/Tqm8c5NqjD2tmw+Ll9kFBQDpsuIbiN5j+nVddyEXtAn1HavKagKmpXCY/9k/Gum9lW6JSEjS+yg= Received: from MW4PR03CA0325.namprd03.prod.outlook.com (2603:10b6:303:dd::30) by PH7PR12MB6667.namprd12.prod.outlook.com (2603:10b6:510:1a9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 12:15:14 +0000 Received: from SJ5PEPF000001EC.namprd05.prod.outlook.com (2603:10b6:303:dd:cafe::e8) by MW4PR03CA0325.outlook.office365.com (2603:10b6:303:dd::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Thu, 10 Oct 2024 12:15:14 +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 SJ5PEPF000001EC.mail.protection.outlook.com (10.167.242.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Thu, 10 Oct 2024 12:15:14 +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; Thu, 10 Oct 2024 07:15:13 -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" , Dhaval Giani Subject: [PATCH v6 1/2] x86, KVM:SVM: Move sev specific parsing into arch/x86/virt/svm Date: Thu, 10 Oct 2024 07:14:54 -0500 Message-ID: <20241010121455.15795-2-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010121455.15795-1-papaluri@amd.com> References: <20241010121455.15795-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: 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: SJ5PEPF000001EC:EE_|PH7PR12MB6667:EE_ X-MS-Office365-Filtering-Correlation-Id: c2cc8989-cf5e-428f-9b4e-08dce9253220 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HAx55+DFbx2GkCtPyBmQE1+buyNrobIxHvql0+/umsT1EahNCyTlSe/Ud5H3?= =?us-ascii?Q?Z/ir+LoDHFq0tgWk9/AbAeSpEcoo/hVkIdX/2lFX/14aahqzpPUx2YaObac2?= =?us-ascii?Q?o4EgBNLHVxPQdlOBhykI/JYMx7tbAd9J5ZqFg8NtU9WEFk0GDeFr4MlXFzOe?= =?us-ascii?Q?6M6p9fUT5bdyb6XILtnqw4S1sbrl21d1v+W5ekFyzmX8T2qI7KDsUltuU1p7?= =?us-ascii?Q?M4YzoBRMurNTY8NgM/n0mtcqz7f2q+wViUV6y8Dx4RQtCZjSDt16sruBnO9L?= =?us-ascii?Q?4l7VrEki8YsxoAn79xkR6xbcd0I8irRtkcnPE5aCj5lq68hiTce4oKrEIBRj?= =?us-ascii?Q?mmXUb7wnWVrXbmaIaLvqVyicUvbdfibBtRdIceYUlEjlBhwgBMl6nX5lQaf+?= =?us-ascii?Q?6heozzKPLzValjTXLYDa6EC6t08Ouy9Oh6cVpaH+lAIvmNdIf75GgzMn+Xyl?= =?us-ascii?Q?2Ez/ExRaXc3upWcxQh0g5SQpG3k3yUMM9TEhaOuB4dYpqHKc6VgunZAu9O3z?= =?us-ascii?Q?XJEBPpeiyyZOr369TuJqjNNxF4Zwash+foNaaIbbC2dyJaquVpQ0u6FPOmI2?= =?us-ascii?Q?JJi5iCYoF5crLxRBWOolDrI2U92QXaL7PzJsnmvFF5gwB5KYoONICKXqXYU9?= =?us-ascii?Q?NwLDSH0Vir0f6Rci1SWYMU0A+khYg1yl6yMJo6UE5HCb6iGMpKhJ8QXtqkoj?= =?us-ascii?Q?oXo4jHHC5PdOqj87w5hmyfv5pkQWo/7s4yKbmqHL1WSkBYDkErY9t0S4Gliv?= =?us-ascii?Q?EklNKWzO10kxJhF/6T/oN2XNPldq5BZ/I/lExhyAWh0QL5iFZ1SKkcbkxIdW?= =?us-ascii?Q?+Zv8XLM2zxietnvWLNZJ/l9bp96NVRF7uWf6So3TWbs6EjyrSQOZhsG0pw8d?= =?us-ascii?Q?1lA6HwA/xzmH8SitouPQa+S7ci7trubZJHT8Qk7cl876lCtON4+SBNnBico2?= =?us-ascii?Q?NGEMirfOjlJyO6MCRIjreGMF/r0XkXibpEAFNPWWSO8C55pUvaSq22bMm18x?= =?us-ascii?Q?MgWHnYXqCOBRQZbXiCs06WZY9P+NWtkuDS+DHpXlHbD29TLfQ6zcM8LXE4EC?= =?us-ascii?Q?/73LeJOP+Q692jIDXX/sdhIp9HOEiSC+0OHdUvh3oC3v8VfjCpXSoqSRP2cc?= =?us-ascii?Q?WwlbApno4utC2HyJDE1d/NQlU1/W+loonk4Te0KOf6sE+XDwTahMv9ieYXw6?= =?us-ascii?Q?LcZpL7XrZDc1yHMg6DjtCVHRdbBuskQwxMS2Kqse9XktQxNmg1+9+lupmPqp?= =?us-ascii?Q?9aUU75qJuCoc8nGjgz2io1cycmGsPu/mnQKgUGA5fAkFQHc0PH/kT7rDlGim?= =?us-ascii?Q?igMcj5FavJivd1LBGL4LN+lGMMaKC446G942FajuU99cKGcJESb/+3opmGZ1?= =?us-ascii?Q?nUjk5M8=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)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 12:15:14.2420 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2cc8989-cf5e-428f-9b4e-08dce9253220 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: SJ5PEPF000001EC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6667 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 | 27 +++++++++++++++++++ arch/x86/virt/svm/Makefile | 1 + arch/x86/virt/svm/cmdline.c | 32 ++++++++++++++++++++++ 4 files changed, 60 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..50f5666938c0 100644 --- a/arch/x86/include/asm/sev-common.h +++ b/arch/x86/include/asm/sev-common.h @@ -220,4 +220,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 Wed Nov 27 10:41:00 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2052.outbound.protection.outlook.com [40.107.243.52]) (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 532681C3F18; Thu, 10 Oct 2024 12:15:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728562531; cv=fail; b=euYZY3R9z7kQ615RCcP6ovpwiAQPWGEWphMl7gU4oEmcIYTu+A26HNFUr5aTi35Phlu/FiAYzdWkquDniG2m5eCZhiiFcux+LgawS3iUjEKrqCMXPwQqG0w4EC5wAV872SFdrohyYNve10YS4+sqgFfXhVXOp3kcfo1EilLusFk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728562531; c=relaxed/simple; bh=fuJI24g+lqVG7snhxlrsiuRR33+OAk6lyJx+tFD0bpc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KKOVEVoxafnMMe61raemXuWDBpVrq1PJgsDTNFZsb4naUVHUs5TLuBZmTHhMMTMmFP9LwERp4eP7jUYaweeeydWcW8WGF9y/5e9bSiRtjMS+AThc+7fuisdvqVCW2FXYjCZ2X/Rr0aFBgWjQVrNtDv2PRt8CNdKfgeXfufg9ny8= 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=A3wGX7M5; arc=fail smtp.client-ip=40.107.243.52 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="A3wGX7M5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UwFTWY+pu56oXcuUbuTJLPbsU4AeJV10MLu+UIC12S2zFsC9KkVJQHs1FaWqxz8eDtM/uZi26asCY253w6AFlsChMV/Uq5zOqepEMZ++CqM65wlKjbpWX+OwD8PdToz+zpwdRGu9RONxqtTLJ8lF5LqVfl6V55xJHfBKq+3dxllL+sWmbaaGhwkBtq3XtOM+t4VC4kw3JgPVZNOYjy2KSyYUru7nB6gxBtXPU1lhzdK2sPSlt8vl9Op62XgyexKrVehDO6PMJrd+m9yHhuCSxeuzG82e2fpMOw9dwFCFy+SduSatyKAH/IABsIOdmRDvvx2wRHAwLNA11xuZC5671Q== 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=91DX+f/Xb/MiOMiKXzxRufE8kaNCoS9bFbGmvzdyaCQ=; b=oYlyjeiW1fnVD5CaIqXJHy/Vv/418ZlRbBR28iw/CusrAQKkIfnHOYym7MA2sa+IcdV8QHz0eazzFVMioXxZ5qgS6C3Gr8nyiXZUrjIlAOHXoqUIiGXzAGU6dtQ5i3FICSSWm78GSiDBiboHquhWz3LKeH6IDELk+ViU5l5ZD5+hyt7iSFy23qoHv/alyaZBMh9KAIylu2aeFlAfdITB7KdGZquZqaPRv7PftXigz/1ESR9PpaYolKIwnEBUYMUNf1v3tdyoULReE8gd75BubC+Mss8ad1K0Flrhcp47wioYa1Y+/cWoLhO7hLgDelwZ+pMPrXK4is56Bqsgwlk58w== 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=91DX+f/Xb/MiOMiKXzxRufE8kaNCoS9bFbGmvzdyaCQ=; b=A3wGX7M5nD+VAYFlxKG5+w9TxJKwIbSWPf+gkUENRigpk/zLDFDm5a27laPs7ICmnzbxLEu2TTLdyMU68cBhoZdqyfwu4OHdKjaoHSxC/q3N44xxZ8FaR7eh98j6W3Da31VADt52gGvqOC5amxvcIQP+Y+Xm0Rjonrbzdav+jZs= Received: from BY5PR20CA0027.namprd20.prod.outlook.com (2603:10b6:a03:1f4::40) by PH7PR12MB9065.namprd12.prod.outlook.com (2603:10b6:510:1f7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 12:15:25 +0000 Received: from SJ5PEPF000001E8.namprd05.prod.outlook.com (2603:10b6:a03:1f4:cafe::58) by BY5PR20CA0027.outlook.office365.com (2603:10b6:a03:1f4::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.20 via Frontend Transport; Thu, 10 Oct 2024 12:15: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 SJ5PEPF000001E8.mail.protection.outlook.com (10.167.242.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8048.13 via Frontend Transport; Thu, 10 Oct 2024 12:15:25 +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; Thu, 10 Oct 2024 07:15:24 -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" , Dhaval Giani Subject: [PATCH v6 2/2] x86 KVM:SVM: Provide "nosnp" boot option for sev kernel command line Date: Thu, 10 Oct 2024 07:14:55 -0500 Message-ID: <20241010121455.15795-3-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010121455.15795-1-papaluri@amd.com> References: <20241010121455.15795-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: 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: SJ5PEPF000001E8:EE_|PH7PR12MB9065:EE_ X-MS-Office365-Filtering-Correlation-Id: 073d4354-8329-4047-aef1-08dce92538c8 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?Wp4EE0uyhlglsQJIJAnsWekwq7gDEkymwIh4Ffsha5r9VNpF9tp434bf1O1Z?= =?us-ascii?Q?/bK9PZJV59Tz9ckRGmsFYqss6Q1HlxNf4iIe2to6zQGPbktVx6q0jnxcCBdo?= =?us-ascii?Q?3U1Nyvfrp/9JpfO+cRnc007nyhcNxm9eLRtRRAAqWufCkoSaPq8N1naiOIrM?= =?us-ascii?Q?cjDltdVN5Kr1KIoO9/UQ8bYYjcv8451jgpDGbsv8osaUrJd8x0O1iR5OtbIg?= =?us-ascii?Q?pSwxREjhQhahr+DjFwE7P/uCj1KZ97dZT2FGzUdtzSwxXY5hYIjsCRAU51aO?= =?us-ascii?Q?d3MdjVwnrX+9qRIX5jCp1+nY+MHM/HdrPwmaWxiIR2CWMfd1gp8W1e5aOAZG?= =?us-ascii?Q?dy+29bFlJ46SpDDYr4ujguTZqrEIgayYxIy1QKZLDwxTfMQEwcw5Y2cvPpOL?= =?us-ascii?Q?kio2oyF7DNvVh73jq7csN8KpNWvBnx83Vl3hEKzmTe/gpmmE7ply72dk85Zv?= =?us-ascii?Q?17GkMwBQKWpNpGYehlHy8IXzlFN5rx8R03/8sh5hrYT0KoV6LYo2x4knVqt9?= =?us-ascii?Q?c45WNz3noO/sIB5Q7WBDfyKlj+Xz4wfxPGYR3C/4oG3yoT1JXfIv2v/XOZwK?= =?us-ascii?Q?uZosJVwNlHZctPY4fLMFWdLV8rLne/A2rpXFNFkKhEKYOIvlIuI3zZL4d/gy?= =?us-ascii?Q?zRLrep6pwuQFPNXz7g2lxhWYIV4gl9kPWrJRqTFXnOZsMRiEbSwr778P7FLw?= =?us-ascii?Q?30xvvZern2VxdRroYV8PWLq57hyU0SXEMrjt8SbIqQFW3aa8a8lm3NoNywjl?= =?us-ascii?Q?O8WT7fnLmNmImQOrs2ftgwMkmTutJf0Q/hpzpbN74pjO+r9lz42wsg3hUrur?= =?us-ascii?Q?bYc9zE44AiT05kJqjW3wwRF48geZpcNRXWPJgBr6lsUhQTekMrEDZiaSofxV?= =?us-ascii?Q?LW1dROlqaZFFZm/RO40Q2hkZL5wTnACCmWcI2VL6bFAjxXa8PCZliEON1Z6N?= =?us-ascii?Q?ypgwaiiI5990ZOfWOQBybrwI8PxIpQJA0OXYAfdfMZc+uVvjuawbClItEmAj?= =?us-ascii?Q?j2snutddwVGFb1OLkwa+SWYBKNoDlljDrdrmwtT6ChhrkusTo6UGT7+KVt+V?= =?us-ascii?Q?DOcchcedUQkye2UbMbN9stxk+/rMzM7zExqfeiyLdfCH1bGgFMDHoEJKWel1?= =?us-ascii?Q?gQEKsYx/gcdq5O/ZEmxntGVQ5JzgEwtPDzM/zIRcZeMqGCtfouFdQUTPmm7H?= =?us-ascii?Q?zKXgaGA2RHGIYxCKTmwXnMetXWPFpljwDCZ5xfg8DAEet5QiZ9S/XBHc1y8T?= =?us-ascii?Q?1muqPbO/KTyIzI7T/d9BtU1C6PzHvob+cEOhkGcryY0XoDV6nEP0mCc2dQek?= =?us-ascii?Q?wR4HDN8bgqEdy9NV0+uKV0dymsesQ8PBvHk65X4QTrOzruLo32fCKAKrvf//?= =?us-ascii?Q?jhOMCpdLxTQMvuY2uKjM51l2/8G3?= 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: 10 Oct 2024 12:15:25.4099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 073d4354-8329-4047-aef1-08dce92538c8 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: SJ5PEPF000001E8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9065 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 | 5 +++++ arch/x86/virt/svm/cmdline.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/Documentation/arch/x86/x86_64/boot-options.rst b/Documentation= /arch/x86/x86_64/boot-options.rst index 98d4805f0823..d69e3cfbdba5 100644 --- a/Documentation/arch/x86/x86_64/boot-options.rst +++ b/Documentation/arch/x86/x86_64/boot-options.rst @@ -305,3 +305,8 @@ The available options are: =20 debug Enable debug messages. + + nosnp + Do not enable SEV-SNP (applies to host/hypervisor only). Setting + 'nosnp' avoids the RMP check overhead in memory accesses when + users do not want to run SEV-SNP guests. 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