From patchwork Fri Oct 20 11:37:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 156037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp991109vqb; Fri, 20 Oct 2023 04:39:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHy+ytd+9NW5JqKyDf6PQ86rQiKlqGyQcp4F3t394IY9NoDVKYDA0E+SQzHSXfjb/GW/bKR X-Received: by 2002:a17:90a:d50d:b0:27c:f20d:841f with SMTP id t13-20020a17090ad50d00b0027cf20d841fmr1505879pju.8.1697801965475; Fri, 20 Oct 2023 04:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697801965; cv=none; d=google.com; s=arc-20160816; b=SHIOtww5Fj5EftVs6THipjC/wE1PSnpr/PIZRnOgD1T8rZjcruKbmm8I32SbrTfrUX 3e1Wzizzyw0/rcWC/ZVP1gfhzr1ml3EkHrLn+qL2AaPoYo700PqcttQdbAwKqVl4ZYgu 4U9VHsA/hGWkgt5ss5YZ5EYZ/dXJEHluLbeXRbwwbL9YGxmC7OkymlgGfRwrU8nM8uxR qoy+EjABDul9H2sxswmv8x6HN4VGgQ0TKFZzW6Rqx412pNlF0BYcfViKSL75lzb6Rc0q W0BZFxnxziafq6/Cp58WFyYevtOH1JRfiAA5oCok9NnshntdC/aGj/Gir5Lh4rQrWJT8 owOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=DAx/phgFk6CHt6PsrNUnH2GX8PNm3lc+PlI+cE9BWqU=; fh=TJa98jjcJcAUyvo2yQiOqi+wukdLlQU80th5XskGe8U=; b=IB6EWjRCWJe0FF7OdUMR2gK4Y7TygDfo+yckJ8Uo9LmF4ufHYu0u+kOx6n6RY1QcTw mzpYhLvESeB9ThP8UuL1PDqInAZ3WjDe7fSh65XAAzrK5FSR/T3OGKArElnMcPbEpmxu 07eoGgHwJOUQnUl2wEJ+JYnl16BOkS2zAaa2byHMAtsHydtcTeC09RXyBppcW1hShARA 4OANmK7N+sbPQ1ccmGgGwG8F5hELT9a2H9ZTW4zVev5Q8j7oCAytfKp5si6h6iO0+PxA H4rMcvACKbeF+8NemnSyJPIuX4kkvqzvra4tvFZyJaMnptt1B/L5UTVU2kO/ExWhbHiN k0Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mGXiAvGr; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id o2-20020a17090ac70200b002791d2ce94asi4182165pjt.81.2023.10.20.04.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:39:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mGXiAvGr; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 02CB5834C850; Fri, 20 Oct 2023 04:39:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377322AbjJTLiE (ORCPT + 25 others); Fri, 20 Oct 2023 07:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377184AbjJTLhX (ORCPT ); Fri, 20 Oct 2023 07:37:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7951A8; Fri, 20 Oct 2023 04:37:21 -0700 (PDT) Date: Fri, 20 Oct 2023 11:37:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697801839; h=from:from:sender:sender:reply-to: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; bh=DAx/phgFk6CHt6PsrNUnH2GX8PNm3lc+PlI+cE9BWqU=; b=mGXiAvGrD5l0RDtkSpzkf0uD2efAq96p+ioGhm8IHv7H9G53QvMpHoqvkmdwp24fR959IK ODuDtlbtcqnyeLCZu21c0mbSM9s9ov2zPP91EW8N0xmrbtSjdo9zhTnnNZv9V3VXU0VYxv jZUXNQVtLLNM7NdbvY1f11aisoNgjHbCuNopJM7LYp1JOgRh5EBU1wi/3x7/RhUTDbznqN +JbGjsCqp5O1B4UOEi1vT3pX7Sv2WqdVBOvoE0f3DjepvuSpeuAQuottkI/0fXrAinL1Xs ZAxbEl3Isz4/kIu8daIxYGNXIUn9bwiuv2ZvRiMabbkAeo/w88ryGv5CfQJPdA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697801839; h=from:from:sender:sender:reply-to: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; bh=DAx/phgFk6CHt6PsrNUnH2GX8PNm3lc+PlI+cE9BWqU=; b=/3EPiY0xoMRBjp7vM3el7ZIJje7OudnJt2jDKvABIiVIh/KsotT5m53n+E/0aY+bpoVSU2 t7DLVlhYAZ6pU3Bg== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/bugs] x86/bugs: Remove default case for fully switched enums Cc: Josh Poimboeuf , Ingo Molnar , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <169780183929.3135.15016421021971691203.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:39:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777490317107486921 X-GMAIL-MSGID: 1780274393497524005 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 0a0ce0da7fe66d54e497fb4e97d101b478f57e00 Gitweb: https://git.kernel.org/tip/0a0ce0da7fe66d54e497fb4e97d101b478f57e00 Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:04:58 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 20 Oct 2023 12:28:44 +02:00 x86/bugs: Remove default case for fully switched enums For enum switch statements which handle all possible cases, remove the default case so a compiler warning gets printed if one of the enums gets accidentally omitted from the switch statement. Signed-off-by: Josh Poimboeuf Signed-off-by: Ingo Molnar Signed-off-by: Borislav Petkov (AMD) Acked-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/fcf6feefab991b72e411c2aed688b18e65e06aed.1693889988.git.jpoimboe@kernel.org --- arch/x86/kernel/cpu/bugs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 4f1ad23..941ac94 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1019,7 +1019,6 @@ static void __init retbleed_select_mitigation(void) do_cmd_auto: case RETBLEED_CMD_AUTO: - default: if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { if (IS_ENABLED(CONFIG_CPU_UNRET_ENTRY)) @@ -1290,6 +1289,8 @@ spectre_v2_user_select_mitigation(void) spectre_v2_user_ibpb = mode; switch (cmd) { + case SPECTRE_V2_USER_CMD_NONE: + break; case SPECTRE_V2_USER_CMD_FORCE: case SPECTRE_V2_USER_CMD_PRCTL_IBPB: case SPECTRE_V2_USER_CMD_SECCOMP_IBPB: @@ -1301,8 +1302,6 @@ spectre_v2_user_select_mitigation(void) case SPECTRE_V2_USER_CMD_SECCOMP: static_branch_enable(&switch_mm_cond_ibpb); break; - default: - break; } pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n", @@ -2160,6 +2159,10 @@ static int l1d_flush_prctl_get(struct task_struct *task) static int ssb_prctl_get(struct task_struct *task) { switch (ssb_mode) { + case SPEC_STORE_BYPASS_NONE: + if (boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS)) + return PR_SPEC_ENABLE; + return PR_SPEC_NOT_AFFECTED; case SPEC_STORE_BYPASS_DISABLE: return PR_SPEC_DISABLE; case SPEC_STORE_BYPASS_SECCOMP: @@ -2171,11 +2174,8 @@ static int ssb_prctl_get(struct task_struct *task) if (task_spec_ssb_disable(task)) return PR_SPEC_PRCTL | PR_SPEC_DISABLE; return PR_SPEC_PRCTL | PR_SPEC_ENABLE; - default: - if (boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS)) - return PR_SPEC_ENABLE; - return PR_SPEC_NOT_AFFECTED; } + BUG(); } static int ib_prctl_get(struct task_struct *task) @@ -2504,9 +2504,6 @@ static void __init srso_select_mitigation(void) pr_err("WARNING: kernel not compiled with CPU_SRSO.\n"); } break; - - default: - break; } out: