From patchwork Sat Sep 23 12:20:08 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: 143903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp176742vqu; Sat, 23 Sep 2023 06:26:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFecj5WBR/+2R1Vt7bdujsLCZsbKGSpDlRHWOAAyKqqCYWBTxf86TaBHV1dz7QxlK/2f3Z+ X-Received: by 2002:a05:6a00:1254:b0:68f:bb02:fdf with SMTP id u20-20020a056a00125400b0068fbb020fdfmr2527395pfi.27.1695475566263; Sat, 23 Sep 2023 06:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695475566; cv=none; d=google.com; s=arc-20160816; b=xW9a7yh0od9DGCx/Jx94LrLdMCtB3JzkMysrhtV2akXJ4m83js0Y/WklbJZscej011 iPHx0z7tjEehcQXnYl0q0sBxgtXmW8iwVRytbLgErYHdB1qYFXJ01kguNTSFaB0Qi4xv s9m2pKx1Zf+33H6BrdS67Cj1Oa7SFkmWjBSuSe/t8FMfXV0uVwai/XuNn0jiJ2wWMEpH evh4ez01/qx/rrAKsh32FTi2HN/IV4iGDNkyVZMLZS5RSSNV/w4ez8PANPPoaqBEjOIR Lqo0vl5hwSzHDOu2ObB90X3he7d1VO3lntg1e5FbSO1VbuDZ8KSkOQCGPrZHNHc1e6eP XbsQ== 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=Kh91L5ZDwFn9HB7mIljVlaeZY3ao0w8gMQ62BPYMZds=; fh=TJa98jjcJcAUyvo2yQiOqi+wukdLlQU80th5XskGe8U=; b=cRl7i5lbH93o2jeE8VcFtUBQuPH9F5CXAu2g8OVcihuecEHh463W0gApGaMoHPO5zj hXdpGD8LfoNJATQKWZpbrhgSDrQqS2aedolXfntqsBL1zQPsVZcjdGagRwHmjNePy6q+ Rx5p0WjRKQSAQGxNaa3VNPAcdH5jfmL246gxoAhYLrxI2US7hdTmnA0gEtVG92dfWz9y D7Nj54nfx9se1++ij3O9EhSn0AzjhRCobcHUhIU498bacwuvujnDO581W/kCp92nbJFk JIgec1x1Z9gdr7eLD5DBQ97XqAmoBRY+dVPcAvRl9phGsl2Re8F+A+Dy3Jn2y5hBAth+ t9IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fm+fE2VW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=p0+cG3TU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j9-20020a056a00234900b00690fe3ec830si6421795pfj.55.2023.09.23.06.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 06:26:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fm+fE2VW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=p0+cG3TU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 406B18114ED7; Sat, 23 Sep 2023 05:20:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231730AbjIWMUb (ORCPT + 29 others); Sat, 23 Sep 2023 08:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231592AbjIWMUS (ORCPT ); Sat, 23 Sep 2023 08:20:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D5519E; Sat, 23 Sep 2023 05:20:11 -0700 (PDT) Date: Sat, 23 Sep 2023 12:20:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695471609; 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=Kh91L5ZDwFn9HB7mIljVlaeZY3ao0w8gMQ62BPYMZds=; b=fm+fE2VWPeqOyUplDOR7nCqCyzmLXcGxsGivyKoZSF2eHvYFQTKgrKAQvNrSQYG2inlxLw VQCs2tciUE2kUX2agGdCHu1jBu36zVcK3osK732leCQe/Pcw8mkGcO50DimhrF4hwFloWp IqbKBtuI0CN+ZTDAxivv1HZkVKkY8oxyCMzu3X591bgk2JuNdJ1Ohr2WezV91jnW3sx3ks wDeFJrKzaBBeXBGo/gNgHLkPiEs/h/nhUGv+lLSzjrq/A9eqGejlBYUQaLDhlcfKXCrRC+ VaV/+4I+LhGBEbgmYx40xAGVXtmah1kD/NOxMQCabkoudjI+VYckeao8Er9OVA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695471609; 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=Kh91L5ZDwFn9HB7mIljVlaeZY3ao0w8gMQ62BPYMZds=; b=p0+cG3TUBep8ycm2KRkcFcy2yJ4MIM+e/igO7ABMT/iNhOf7G879F9y7KF1HBlN9Dkh4PU gFlHBf9fVcLXc5Aw== 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: <169547160881.27769.4772445455882672034.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sat, 23 Sep 2023 05:20:51 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777490317107486921 X-GMAIL-MSGID: 1777834987620403362 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 365d8a5f4fe4faa88a813b849ea8eac58645289b Gitweb: https://git.kernel.org/tip/365d8a5f4fe4faa88a813b849ea8eac58645289b Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:04:58 -07:00 Committer: Ingo Molnar CommitterDate: Sat, 23 Sep 2023 14:13:03 +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 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: