From patchwork Tue Sep 19 09:53:11 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: 142041 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3583521vqi; Tue, 19 Sep 2023 11:07:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8AR0iw0tB64ZJs2deBWCDcqdu7BmHlMxq+uJV7FtXTPu9TNepD3FHQ/pASmyC7ML4Z+0L X-Received: by 2002:a17:903:32c8:b0:1c4:7541:ecea with SMTP id i8-20020a17090332c800b001c47541eceamr255143plr.33.1695146863094; Tue, 19 Sep 2023 11:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695146863; cv=none; d=google.com; s=arc-20160816; b=vVc15WMjd3eqgJ+mrs8YQ2oEpmw/N6678KdxQ/U7lJ5O1UxtMlDkrIQfGWsYAqBrUU VbVxvwCN/kBlqi+MhMhDPgEl5tRHVOImtpyNzqmBcmA4MGgUfg8eiHcAJN1jAa7hBQXq NRwWZDVr64Nxrz3d9CbbXY04SJAUdSEDaFjnZ3IY04dcltFvqsROJZZeCFqYZELEX7tW Z5FrXkghLrHvALUeDlz1wrgkB+IX6dYLu8OBEiKMnjJm9CjEnqb4ya8IzGc0fQfydmeP stt6aDU+FiTmG25HVYc0reyJNl8lcbm1xOFeEMR9BmhwxAyYIa3gbXYGF//1JjP/hUmN XT2Q== 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=v1jbTjBfDbK1CWObm4ygyLtd0LzPx++Vwq+bD8WxJMc=; fh=TJa98jjcJcAUyvo2yQiOqi+wukdLlQU80th5XskGe8U=; b=Wng9EgPvm5V8YOBjVRPbDjs3GreDvjvZg3Wyv1tpfdZ9+EpjEzc5nvlwCLcET7cjLb WNiqW1GB6nyxiRosoX8wQCMvebf1tzig6P0u2n0rQXIS0b6O0dARTv5oAcRbjELxB6AY uLRef9YOhIsGk53dvaHdlM0Sh01GwDe1wt13jfZMXiL3Cx5enJvd0aW8g7GH+Oo8Jvde uwK02tfRAtJzav7K+nOE+yqkMErsp/kmny0uQ2mJw3R6AlR9d3d3x5xuS+fFa8KLWLer LTq3dLE/UFAhrOrnrDFo8qVDGdBma9fIfN/4uQHKWbzESfkpQf0FDxy1K0oCmW161R4U MFxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sFhg1vYR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=067mdyfx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id j4-20020a170902da8400b001c1f1394bf9si10725537plx.357.2023.09.19.11.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:07:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sFhg1vYR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=067mdyfx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 5C0F5801F2B1; Tue, 19 Sep 2023 02:54:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231965AbjISJyG (ORCPT + 26 others); Tue, 19 Sep 2023 05:54:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbjISJxV (ORCPT ); Tue, 19 Sep 2023 05:53:21 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1291F5; Tue, 19 Sep 2023 02:53:14 -0700 (PDT) Date: Tue, 19 Sep 2023 09:53:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695117191; 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=v1jbTjBfDbK1CWObm4ygyLtd0LzPx++Vwq+bD8WxJMc=; b=sFhg1vYR6bZTj3u3VQ3MlJBxMc84weEQVTKgFa1ypwnI8+uZJEIWYpnndfOxjTKA+raClK b2qQuYxmIaCYn1Yiu66PymSp9Opd5gAIyI7+ey6PDBS0birUoWvWHbMMA0bGf/WpCbAF0q dwH22SagmLykxpzT4eDxAI0yrys1km9cFIuTBaiHM/kk8axnBCjZHJzPUJNoAwYsSKu/Hb MrK4wQQKKuejZyFaOBHQ5If6pwIUwDhpEMEVq4l0QhOM63QoQMA4WzrRjde6MVSz7MVZzS 9NT8iPwiAoQ6L4T5PxfCe/8wB8BIrVGJi03I84mNtGWmFr7MOfUknw22hxEAqg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695117191; 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=v1jbTjBfDbK1CWObm4ygyLtd0LzPx++Vwq+bD8WxJMc=; b=067mdyfxCpC5P8m7YFkGEvwriqohRHPIe3fXhweWptMzBMskrDuSod2UTIjJF/qJS2ekyZ 1TTOD9CiDzK+WGCA== 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: <169511719111.27769.6185412152878380724.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:54:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777490317107486921 X-GMAIL-MSGID: 1777490317107486921 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 44bd14590309118cb0103b51f7681f369cfca6d9 Gitweb: https://git.kernel.org/tip/44bd14590309118cb0103b51f7681f369cfca6d9 Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:04:58 -07:00 Committer: Ingo Molnar CommitterDate: Tue, 19 Sep 2023 11:42:48 +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: