From nobody Fri Nov 29 10:20:47 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2057.outbound.protection.outlook.com [40.107.223.57]) (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 4FDB31917EF; Sun, 22 Sep 2024 03:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726976250; cv=fail; b=MqSeDvFPRKS0MgL7X0dTxYViEOAvS6FMam2v7kGL3t8ua2e52/0hwNfrgzjXOHNHbdr83bnrRdhVzTMQ7xIfer6sUISg7HZ/L0s0ZeHNWPTkqA3xxyMw95J4A+Wijcm0ImveRRwTolUIVTIcAtDpReQf5wfgSvAZTIv+ugkgG0o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726976250; c=relaxed/simple; bh=hExtzreLpTluuLKLSU0EeqSzaHKKl9KhEdXS/bqYRzk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DOMyUDZHZ697a3x9gE9yLKzaGOOd24WHhMa3fhcE2DcS/kJL2h0JBEHcI+x/7TeNMe3A2SuXDU0V5DmWzDZRFJbQd5efrL75IwMWKIcT0LY+MjxVCE8dvzHjdwRgWMgfUNN6iQRNkMOvVhieaZCLfcEPkVbyeBPDK8BJVa0cThc= 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=w/KaDx11; arc=fail smtp.client-ip=40.107.223.57 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="w/KaDx11" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rr9WVADksr2iBaCjI2L8TVwqiojDc7yE8pflxURAY9q/PSJv0iwVG/nA1XHdVVoVHdawdp4+NVIoRz5P6Ei/fAf7rL1L1U3U8yzfupaN0uCDi+6G6HrHcfOqnRnmqdHlP/fA3zEEvpRGpptQfox80RTH1eszvKOTW1DzfkeB74KoyfWEuUNArn+HC3zwf1vm9MJESnriO9o+QjmoL599iYmEAN9SoDYqun0G52pMsfQ12T9CsiGHG+Idkhk5YacV1Z94ubGlApnjtvV+prSRgqXlYuLM3y+5kWvuUGP/oX74CTsdwPnfxVFBcXcL/Qthq4GaI67FBl+ZI/4gi8W2ew== 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=eghMVy5Lkb2dtkjjrhp1WkhnPCmRzpN+cQl9bbvxAcU=; b=yMkHeoSutI1luOzWp6Yh3Hwv9puKSqTpNa0GvHsukJiAeEvI63LosIa9IgYv0AI9VnQ/OYMmznE8XClzNuxaOAY3FFSmMuYEEH8dYFUGOG3p81LUZnBEeS/ukvelbOfMGMvvXWOk5AuIMx5EC+tFK99++QeChuYB65QOkC5kO7vdVSetIpFdUXOSf76v//snvRCTp7Tc2XcDsRJhxOft6hCz3Zdludm6/hnf3iLzkFKbf+dCCUjnaTkpUOsAFt24Kymf0AoOTERRDrLoiDmC02NcBslD3rtp/2TB3My/TchTlbON8XmeXDmPOrzv3Gliu6XTCIiItGOZOjm10uqxBw== 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=eghMVy5Lkb2dtkjjrhp1WkhnPCmRzpN+cQl9bbvxAcU=; b=w/KaDx11v/PPsDuXcsrAP+nM6ilo4Ov0hI6Ah1RbzauqQpgQap3YwRzz05R8kjMI70u3wxJW9OUawIjU2FzbFrY0frh39wnpYkFvYabZDB5Ch2rK61B08i+mW8TFUw8icsLDiyTcskaNxGAUjU3SLu1NjzR9JiyYKFhSr0CWRCU= Received: from CY5PR15CA0107.namprd15.prod.outlook.com (2603:10b6:930:7::16) by IA1PR12MB6602.namprd12.prod.outlook.com (2603:10b6:208:3a2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.23; Sun, 22 Sep 2024 03:37:23 +0000 Received: from CY4PEPF0000EE32.namprd05.prod.outlook.com (2603:10b6:930:7:cafe::db) by CY5PR15CA0107.outlook.office365.com (2603:10b6:930:7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.26 via Frontend Transport; Sun, 22 Sep 2024 03:37:23 +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 CY4PEPF0000EE32.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Sun, 22 Sep 2024 03:37:22 +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; Sat, 21 Sep 2024 22:37:21 -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 v4 1/2] x86, KVM:SVM: Move sev specific parsing into arch/x86/virt/svm Date: Sat, 21 Sep 2024 22:36:25 -0500 Message-ID: <20240922033626.29038-2-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240922033626.29038-1-papaluri@amd.com> References: <20240922033626.29038-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: CY4PEPF0000EE32:EE_|IA1PR12MB6602:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bcfa3d8-e858-40d3-d324-08dcdab7de7b 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?GuwOuoYspbzj5NoqmmREKI6RHv+g2CO9pwD0OJZ9Dl3hh4+vCWDLN2KSXUfp?= =?us-ascii?Q?Xsvulvy6C8AE1wv2+mH3QaQUkqi4aSxO09cB4+fjneK2IR26vrnQsx0wf1xS?= =?us-ascii?Q?U8sDdkfSzc1/Vb92qPVPkeKxerYKN7wcm6B+rzNVP5DEJ06nonxShqv8zZSV?= =?us-ascii?Q?vFelJePVJc9ivHJxI+7Z7FnImCvzsQW89zhb6y/pJqOekrYvz5YTWinz+GXH?= =?us-ascii?Q?xb5OvqKq6tBDF/4ZUfkvfNt5azUlL5+hpyNOO/UVu/FiuBkShhjJ/To242aa?= =?us-ascii?Q?Ta14yJRpbkDtdlwafCVJpBkkSim+5X5q/OTOlchkuCNNCD/njV+crM4aVWhA?= =?us-ascii?Q?MC39h7foyMmkEtpBtlIc3JpQepiMVzoZTaiWoqdAbdIDLFMMz6KJWxA2VT47?= =?us-ascii?Q?ypx3molHdA1kvXH9c9eSa1MhO1T74cIBOAf7b53DUrgvl4ULafQSJsfh3stV?= =?us-ascii?Q?NZ9pm4qI0lbp0GkU6k1U9+vRLM4mty+DtkJR4uGOngsrdnWsSg0hBE6+i7nf?= =?us-ascii?Q?/yN7wufBHvzAOoAqKyhAvBZkr7/iBYrq9v8wHDH34NEBE0geh3LKGNLSXrHA?= =?us-ascii?Q?IZVFA5XtQ7C9zN5mwlGQBa6u1sdcAHbVzRstnV7j8CIS4zcvyZikK/z1emcA?= =?us-ascii?Q?OpXDBPc1rWhTnpVYO/c1rxlVQAJBQS1fCYZ20Qvf+I0z3t53mAfEZQhYtsO4?= =?us-ascii?Q?FLCtTsL7Ozig3XgBWX1m8gUMssDdqiFHXkxhBIOq3ThWHPBdwysNb3GF8+xF?= =?us-ascii?Q?z3fGHabHiJH/t+LBHwaRYO/fOXr7EHkDh6J+I2n/XCId3u3DlvUNJWJOpuAW?= =?us-ascii?Q?RlCm5PeJfXmygpuO32KRpqbQygUDszfhmnMEQb0mFosHg2CElZnNWMBdulE+?= =?us-ascii?Q?D6MbAPMwLh93g1gzFLqvHiZ11qp9ToEAMleYBbyZLH3PWa6Pqgbhah21bPTC?= =?us-ascii?Q?cmFDI5pDmirBeg0QtS7wRBu3Je+aQa6XNUNVVdgmklH6B10+yvF4cLB78TkL?= =?us-ascii?Q?xuo6eif2nCD3V21wnp2bX8Bj3lchWUo15nQygONo80eYf/lzbBHB/qCuxZ6K?= =?us-ascii?Q?h8h+cv3abV6dXUOo5DxMEcUTWRljOeRopAQPYRLCVD+zw6A/+gQW+v+H2XHv?= =?us-ascii?Q?qtJPaV42lRjqRddT+wORTTyBzhuPREm28pPe4a1D3fEGxxJemFhU3LXk2Pdm?= =?us-ascii?Q?OhKp7cJCTDdTysZHSsJsQ59oIafssWREz+56wbSgtjcbBpmf7il7j3W9kcFo?= =?us-ascii?Q?uJps7NcFNNbpp+g2TeCcyN5wo1C6Y5cvM5BW8alM4PFmVBWy4Byt9lfe264U?= =?us-ascii?Q?yeaOwYx7YccFIT350qVf8PDIzgDLzA8qrowpy9VYKid63hmeQl7kEmFTbxLK?= =?us-ascii?Q?YwtKi1c=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)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2024 03:37:22.4576 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3bcfa3d8-e858-40d3-d324-08dcdab7de7b 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: CY4PEPF0000EE32.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6602 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..adddcf3edaf0 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 __read_mostly; + #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..964677ab02d6 --- /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; + +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 Fri Nov 29 10:20:47 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2082.outbound.protection.outlook.com [40.107.244.82]) (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 31A7019340E; Sun, 22 Sep 2024 03:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726976258; cv=fail; b=O6HBmFP7J6hw2ZBY/5lhSSe3vGxk+lQauiTjHl9asTtZbatqNy0DSe8JNicejJ8o5gIs/LpAZ08OigKhxOBiID0dN/j4a+0PoMF+SSHWPaLXh/NysX/egC9A2LmxrTZIbSpytYervX3XvJ903eYWlRv9zNZi6OsGKjNVGPYvtGc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726976258; c=relaxed/simple; bh=8TYZxNRtUEIxP4fZY/f9t3LSZbxPhlrb9Rp/uGdzmN8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QQwUB5UpTiORnCAR04G8e/7c1C/PfWI5ZeLUuClRBJ8YRbi7rqLRxVJoCOv94ap31arH1T4g6wygWXBOmnvvXg2kJGIR1Yc3XrOCeLM1McflJU0VtK9kaMxUPhgQPIoCEESu/BVQ0mQFUtbS119AfZmAXv9YyGFY+pPHZAhQxDU= 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=oFFQr8ZY; arc=fail smtp.client-ip=40.107.244.82 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="oFFQr8ZY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Nr2X6XDymfhIc99D16R5ZhJtr7Kubr2fiQ7dFUU9VzJ7akD5eKECv1I2AtGRg1bv9tkTRuh+5Wwgd39nmEoDkfnLrmjDVZdftWtxie1+B+MLHa691iIh3dQd5fxZ7RYE6NoDEAErEn2em975R2EdJMu0i5NfQvbpdcqb/qQA4o109rGIHHcfrRunMTz9Q14OBfjZLBghskqrt4bUaz2LI3vL5tDqxw/VcdSQlX/CY5XH1mDsmMKiZflOFIhUEmxSKJZtJM2yJg/urnN4YGZYjJ02MmL2UFiEntKaQfJ2KnsXBKOympaXQyLruXhuZVv8/XLOlulfPiFc+PQzAc48Kg== 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=lK7JzzgPgY+vB73szTd/ngGCEFFtnOqUIDOwDsAsCXw=; b=LXXmrFrXtV0C5dLnIAE7yowgBsYgOE9Hcl4Kr+tGkilZ35RtjSTzoqRWCSjBU7N8A+SUYV3xn6quljnn0OtnJ0rP7HpunGxHAxn/61/GHT8elf6P6x2/wT2b37F+V2faBpSroJr2Ss7wb1ohwWxTEsSEyd1G8qZTi30+inDtQ3NVb3EcqskD9M0lFTuYFXAhQ1EYV/F/4LmnW451F7ZexYg8geT5oUiPRDCZmDsH3yY2ub2Bhp/T5wop738Vx9YPvfHU2Y1xiWkbN4TR/3B/bA49JR884b2ZnXf+63DLcRKV9kOS2f5ZK7ui346DLQE1B/bB93pgc7uxb8gu7AHvVg== 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=lK7JzzgPgY+vB73szTd/ngGCEFFtnOqUIDOwDsAsCXw=; b=oFFQr8ZYiK5juFMU2Q+sQkNVQXQX5iY8WOzx/+gW3WPZXXm7ezpO9aFJN+kH3d2Sd96UJd2zqHqL5bxfw0Ocf+UMVA5r+DdWd9SuhijYsoue/mdCXMO3j16aa9aXm3Hs+rsu6W+77TsGkSHLt42aYa/oSMwMCOfcllXEoZAurm8= Received: from CY8PR10CA0026.namprd10.prod.outlook.com (2603:10b6:930:4b::29) by SA0PR12MB4415.namprd12.prod.outlook.com (2603:10b6:806:70::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.24; Sun, 22 Sep 2024 03:37:33 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:930:4b:cafe::13) by CY8PR10CA0026.outlook.office365.com (2603:10b6:930:4b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.30 via Frontend Transport; Sun, 22 Sep 2024 03:37:33 +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 CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Sun, 22 Sep 2024 03:37:33 +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; Sat, 21 Sep 2024 22:37:32 -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 v4 2/2] x86 KVM:SVM: Provide "nosnp" boot option for sev kernel command line Date: Sat, 21 Sep 2024 22:36:26 -0500 Message-ID: <20240922033626.29038-3-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240922033626.29038-1-papaluri@amd.com> References: <20240922033626.29038-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: CY4PEPF0000EE34:EE_|SA0PR12MB4415:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bfdbea4-fdaf-4e9a-f0f0-08dcdab7e4d3 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?gr+kLc1fXSmUnoSi8srdzd6k6RbBwCOgfAZfvP+jW7C9qBaWsKPLQaHUy1P6?= =?us-ascii?Q?iIrFgROJNHjrnpSSI6rhWz8hS/Hcjb5TpRoTGEHU5GZDpoASoxIWksk72t9x?= =?us-ascii?Q?mJ+x+BSJ8ghc+bbdjXoOr4AQyDGWbw8csd9C1n/JKFt/SfzTtgAVpc+YXv3/?= =?us-ascii?Q?g65ckAR4M/J4XlRMkmJ30yDE5ySSgnvQ7WzLYiBpVzdPEJBU46U8Mo3ci38C?= =?us-ascii?Q?Td15wj7qKPv/vmfQfLjmfN6OaBzbmSDD+LYwfArFzBe670514crRLIEORolU?= =?us-ascii?Q?2x3rj93ke2On/Mvfntr/oN49eUiMgXCV3i9r9QtT8VSTReqWiHEgtTQTczx6?= =?us-ascii?Q?XoUeG0TyWUUuKs6D3kLGjR9DY04corX/vMAPaU0TpXC4wm+NXsnxwNijo/cC?= =?us-ascii?Q?EPpxh72Ial/ihFJJPXdRaQbrd7ZRL3XdyVbOADe0R1iXFoURHK9t8n3yazWe?= =?us-ascii?Q?/5gp3jjfL8RDczwKJr7QLx5+/u7DxXDH7nnFq5VPtATQaLEfk5qAVg1g6zJf?= =?us-ascii?Q?3HuhMkdzt3O3HUXQ6WflNsmW1Te4R01mBRxVUQtMbnerMstX5E6kK/1GyPqf?= =?us-ascii?Q?jRRmXqsHjoBd3TkyjgO2JWD3mwzo/97Nzv/s596hLgpqPcMJk3tqOamBoB+J?= =?us-ascii?Q?kBb8QHMyXxVWqsnOapZn5NebXsgfmViP7TJL5rV9L7RMSR7EEWfADYIp9bXU?= =?us-ascii?Q?egL9Vx5chBF0qCJos+/3AxpS5sClp6OyAPfVLfZjnG6p+DIcNGGNHThSxxiZ?= =?us-ascii?Q?TPNtGhKEb6RVBR0A11BbmQHC4W16gZifsSDPrGwt+u3N+o6d1lEStXnmqJEX?= =?us-ascii?Q?p3T0ekLVclHwJIO/XTbfdL2wDVo7gop++ZerXRulXqUJ7SehSXSsOdihnT9W?= =?us-ascii?Q?C4lbDObfV/f1nADdGHb4JKfFFR4wvmQQCfAJmVq5KogP5hxaRcjRWcCyTsc+?= =?us-ascii?Q?/hhB6h2yWoALPtY9pYQ8fODcqm9ArXFuiSUv+7ALav5fP8L0Tcqh8WLnhVlo?= =?us-ascii?Q?qIH+0RckX11RYjSnamktc5gGQXDWv/rdgUCQbAHByARMf0NzfNPIBolnAx8D?= =?us-ascii?Q?IErVFHO+JXW79rIALdDaHKETKJ3lik9H3FS3T7OZxAVveJS66wWcga1seBe5?= =?us-ascii?Q?ZayJLz5MEh6W+79wgZ3ZSFuFSNv/FE+Yg54Nnt5p6BdFgqhoBKDXEdqwQVrh?= =?us-ascii?Q?Xo/65JwIbAa+p7RUEhEFUOqQSAgph8RhfR5UHM1+XwkPs6CVwUpBRj/ngTJo?= =?us-ascii?Q?v73B+oqeyb1hq6UGGQaH67csoVtWmS2H/6lXkzKVVS+4vbrINpeRLjHmz1hY?= =?us-ascii?Q?Rna192CcVnDKlIBFMszIrtCx53nHP+9+l6K55JcloYWa15IY3Ne5YHRWppu7?= =?us-ascii?Q?Dkklo3++y4onWChNuNTZyvw/cEaG5ZEKRby8JdyqYHTuHGeHIQlvVSqTucr2?= =?us-ascii?Q?m4uUpjHo+AwrXthP5UYDRecPAIda5fFT?= 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: 22 Sep 2024 03:37:33.0858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1bfdbea4-fdaf-4e9a-f0f0-08dcdab7e4d3 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: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4415 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 137432d34109..3d4e9a7dccf2 100644 --- a/Documentation/arch/x86/x86_64/boot-options.rst +++ b/Documentation/arch/x86/x86_64/boot-options.rst @@ -317,3 +317,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 964677ab02d6..454574539c49 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; =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