From nobody Fri Dec 19 20:38:05 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) (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 9A16C1F8EF5 for ; Wed, 8 Jan 2025 20:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736367944; cv=fail; b=eN1f/HhAgX2e9PBa59gdPTMart5FwfkyexB5HpeZpTebDiP8RIxNvRy+N/uWoIDdRNXCL6ks0xyYJpbcHrDp1MRdvo17CVR7tUa04iJ8hLQHdfAMpVPGwWJAHg5K3tSnFyN+d8WEInMuBQHhk4uo99NGkMIIgphwk0GrTCS4M08= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736367944; c=relaxed/simple; bh=MAu/1c7npKgTG/iUBN1SH7WAti/pV/Xrh9MiPfKH2Kc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sQMHdkEUYt3B77jyeLXZ36395ImgSZYmYu3+1U7eaBB4FCE2vKJ8mIKhx9ruqECSpvrQZSGvXLH/llV25OWa754hUQFaxqSfeLq579QA7JBBYdz975wVrPamBbf8hEoo3dZK4AtdYynsRguCZtamfPO8oFow7ck8UkNT9CUSY1M= 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=LAiQ+FL+; arc=fail smtp.client-ip=40.107.243.46 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="LAiQ+FL+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B7no1PAdQixwAEchCzplcNU+UKsb3oPiryDPh9ITujIFNbnT9JvOhYdiNfo+QpXiBIK1cvLte8WzzfkGkxvbw8b8Be+6Z3k/Bn50hJsnFXMCQCS6tje28KjU/liY73maGb2+Rx8PNvOAZBILzGyM4rB6GScd7jLhKM/UFqCqrdW0QjNYUvP3iHnUZvwuNKWUcwPE7I3PftH886NYw0i59aGc9dpWN41TBRRpq0OEpomma6v0NNDpw+2/rrhtW51tFTh3JImdZIx99WjoQ1xvjJXH5UJ8iL8aaspvL6Wx0X7qdmgjFJ+JlP7tYV6VMfCwLV7CzciLRBV3xrfO2ju+uw== 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=3a0oaiom8mKBNKeH8B7r8v4sGk8+vh+R6QhQTfV/YZs=; b=xmEzA20hC6jfs2JH7plqHXNbs5EvBD2iUdnmmQvUlfdbfL2xIa1o8963GSQbIpmFfjRnV1ZNH1PD4M/4PcLMpG4Osu+uykHde9mc7j8Qz2y/kfDMLASUa6CM8aL8WV0uLT+fR2lhm1aPm+jtlKQrXXmh3Lj8toiaIU71WNrXwfxcqRCvCsyFytFAyfqCsamABv9OBUm/6xj7GOTk3Pcj+FLr6pO4i1bK4gmpKROO7HM155bkqJ3zlywXUc0apNJfgbbTEwvjtivoIu8GYuxymD8Iwp8FjXieY1FcwD6bjf+7FZkgKQ11Bp0+FyPtJs4+4cWhcmBNGMYzQa3/fxLNUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de 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=3a0oaiom8mKBNKeH8B7r8v4sGk8+vh+R6QhQTfV/YZs=; b=LAiQ+FL+yWwjNs6BTbfDSqmL6iDpFLkwTHrGtKN+jHTZTA1/9kpTuzNJQsenCGYRfKq0gLswZcZhU+6wEfkbzv5JoB4X+gvAKc/FaBzBje9DpudmjC8A9Veoxrq2FBK5HET9tHjqINaAvfgZfYWx+ruxJqCx/GCLsC3bQ+QZbC8= Received: from BL0PR02CA0106.namprd02.prod.outlook.com (2603:10b6:208:51::47) by CY8PR12MB7731.namprd12.prod.outlook.com (2603:10b6:930:86::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.11; Wed, 8 Jan 2025 20:25:37 +0000 Received: from DS3PEPF000099DB.namprd04.prod.outlook.com (2603:10b6:208:51:cafe::c8) by BL0PR02CA0106.outlook.office365.com (2603:10b6:208:51::47) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8093.23 via Frontend Transport; Wed, 8 Jan 2025 20:25:37 +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 DS3PEPF000099DB.mail.protection.outlook.com (10.167.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Wed, 8 Jan 2025 20:25:36 +0000 Received: from tiny.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; Wed, 8 Jan 2025 14:25:35 -0600 From: David Kaplan To: Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , , "H . Peter Anvin" CC: Subject: [PATCH v3 01/35] x86/bugs: Add X86_BUG_SPECTRE_V2_USER Date: Wed, 8 Jan 2025 14:24:41 -0600 Message-ID: <20250108202515.385902-2-david.kaplan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108202515.385902-1-david.kaplan@amd.com> References: <20250108202515.385902-1-david.kaplan@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: DS3PEPF000099DB:EE_|CY8PR12MB7731:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e709bf5-808c-48a2-d852-08dd30229c83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?s39iB9DC/GmyUNnsyWXxfXwib46NSBafAdjgyCTAQxqyZZmq92GO1XFdjUUy?= =?us-ascii?Q?AKBlpXjYgXeToHZ7hfvf4mXSD+KZ1n15ENCspxgj0QjwBL2NMn3Z5vQbyvXG?= =?us-ascii?Q?oghY/KT9XrotU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SS0e2jSEnnuut?= =?us-ascii?Q?ipQhH6I6FroIQycI0n6hyT901P06bbInX651WU+vTNeP4Hr0CZ/dyhief+4f?= =?us-ascii?Q?MlXynrvtHYzClA71i/FtzASengYj+4bVonCQqijlpI1CgsjWmJeKbGGpctbK?= =?us-ascii?Q?A3Uw/C5d1cHeyTC0ShekA0cpuigZeWUzE1ORANNHYN63acZfdmWXiL0rgU/a?= =?us-ascii?Q?rhH/5qenc1X5NCShXjcbmJsQd4nkgh4TUeWT853VS6E1wuCD14Y/3/nzJvuc?= =?us-ascii?Q?9itXSmGoKShuLec03PSQo4Gi/K7+xY7DXfx/zms8eoD8ITtCuTB/+RRmnPVL?= =?us-ascii?Q?0zta7IcE30n9bnrjvQoR30MqcfHbqO1TyKFwWBtJMT7QP2tNCJhxOMshmurY?= =?us-ascii?Q?/NZzo5Yu9z0R476FbtdLPTYOUIzvb6VqIIkRgF072sPwSq36QlrvxvieY4nW?= =?us-ascii?Q?lmIvKbHjoqYocYbyGAiZLTjEZ7JeWgjYYDF5ZCK2+edjZzYg02JR+BgZoB0i?= =?us-ascii?Q?/uFSlA+A9uQ8q68=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)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2025 20:25:36.8292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e709bf5-808c-48a2-d852-08dd30229c83 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: DS3PEPF000099DB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7731 Content-Type: text/plain; charset="utf-8" All CPU vulnerabilities with command line options map to a single X86_BUG bit except for Spectre V2 where both the spectre_v2 and spectre_v2_user command line options are related to the same bug. The spectre_v2 command line options mostly relate to user->kernel and guest->host mitigations, while the spectre_v2_user command line options relate to user->user or guest->guest protections. Define a new X86_BUG bit for spectre_v2_user so each *_select_mitigation() function in bugs.c is related to a unique X86_BUG bit. Signed-off-by: David Kaplan --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/common.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index 508c0dad116b..f77073507647 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -534,4 +534,5 @@ #define X86_BUG_RFDS X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Re= gister File Data Sampling */ #define X86_BUG_BHI X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch= History Injection */ #define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB om= its return target predictions */ +#define X86_BUG_SPECTRE_V2_USER X86_BUG(1*32 + 5) /* "spectre_v2_user" CP= U is affected by Spectre variant 2 attack between user processes */ #endif /* _ASM_X86_CPUFEATURES_H */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 7cce91b19fb2..1e80d76dc9c1 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1331,8 +1331,10 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x= 86 *c) =20 setup_force_cpu_bug(X86_BUG_SPECTRE_V1); =20 - if (!cpu_matches(cpu_vuln_whitelist, NO_SPECTRE_V2)) + if (!cpu_matches(cpu_vuln_whitelist, NO_SPECTRE_V2)) { setup_force_cpu_bug(X86_BUG_SPECTRE_V2); + setup_force_cpu_bug(X86_BUG_SPECTRE_V2_USER); + } =20 if (!cpu_matches(cpu_vuln_whitelist, NO_SSB) && !(x86_arch_cap_msr & ARCH_CAP_SSB_NO) && --=20 2.34.1