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: 156038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp991128vqb; Fri, 20 Oct 2023 04:39:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdH40U8We3psfnyoQ8auMeYhfPrYV3MDtb4//QgIwohkQHmNIxWE/ci0vPXwHC/zntvrMD X-Received: by 2002:a05:6870:7e0e:b0:1ea:2506:3e90 with SMTP id wx14-20020a0568707e0e00b001ea25063e90mr1944001oab.35.1697801968129; Fri, 20 Oct 2023 04:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697801968; cv=none; d=google.com; s=arc-20160816; b=U1cuORxKfVUGLFBuu4RJQfsX491Zrpk7YHEW/lElyJ55bypZLyT0feDxhrYsXUGcF9 F38JsWGsaEuL1oNuFGfsXq4xI90GY9vDvWyWvc8AAsZoDeQK4v9/7kIX2cVYEreUPnrW myC7+mBlILrazaZHim54NvH86aq0AC1IAMzGBkEf6u1CYChpIpCFPwEtxCGs58H0Ru8n G7Ha7EBx3NA9g8WCaF8YFlIVrOLcNU5EixGjynUpGt/gEbi9uEATd/0aPwBYAl2Skz7k l+T0H0KyM+s8v9c2XxP/sIeSlOrPd+2cAyHBafltf2ra4r55S1AaLScnjHilez6EaNy7 4Spg== 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=IE4qIEV7mKAb3r8BjNRhXGXu3vaFi31zar6tkq6ay5M=; fh=TJa98jjcJcAUyvo2yQiOqi+wukdLlQU80th5XskGe8U=; b=kGrpWxeVkP4yGTPNYM+HwOs/OZHbZmaAqf0VQuGHItWW2u8wSG+hakjTxPZcrTtYZO qu8KTe+s3Kv79BV79IN1ElQyUW4s6bHSnzhHZjwBo72iRIW7gI3YfkgOB0FTGeyIYuCI V8OTIe195k82w41yzjvqqmhe6RYFDAVDiDAQDmzrC1in2nlnsJFok4Kkg7SnB+A91+Qc 2jZwN+2LkRHwWny+Aovn/Mhx12fZytiHhpeXYWnHK/J2mv7ieNIfioxdjx6d+wCK3gzE t/ecafTQP98J47qQYL+06s5581MzuyOEr7WpSwIzpSda/hXYnXhXGdMapjIFlurHts/j 7/Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qBoH3awi; dkim=neutral (no key) header.i=@linutronix.de header.b=4Z5VYxPG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a73-20020a63904c000000b00578c9144913si1635229pge.364.2023.10.20.04.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qBoH3awi; dkim=neutral (no key) header.i=@linutronix.de header.b=4Z5VYxPG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 205B2834C859; Fri, 20 Oct 2023 04:39:18 -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 S1377266AbjJTLh4 (ORCPT + 25 others); Fri, 20 Oct 2023 07:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377186AbjJTLhX (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 CFF01D4C; 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=1697801840; 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=IE4qIEV7mKAb3r8BjNRhXGXu3vaFi31zar6tkq6ay5M=; b=qBoH3awiYyzEEn5KfdA6tLIJzkbtMLZIfLlAGgGb/Mx0gosjMlTiLFEbckPc40Mk6EQnQ1 3FdQghKPMlFnpjqxnXPBh/7w2d9+C7gkROM2VGlbLFhN6tmI0yGWnXpvg0cUrCHoJVZjAp y9SaEWHYOvCf4eIZ/sZqzgzrL8MO14sYM/dh0kJowVcwriovg1hs81HL9vvQ0hjXcHGMKg ads6P2Q/YePXkZPHMMJ1d/QuiEhybb74t4m471LYBs31RkX1zYD2eVtn5Tid0CJb9HkXpL KHJi68cnW2dtsK+HdmAuDQbe4wAkAoOVb7aiXdl6clbXIfX6aH/VwW+qD0lORg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697801840; 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=IE4qIEV7mKAb3r8BjNRhXGXu3vaFi31zar6tkq6ay5M=; b=4Z5VYxPG2z+nbJ8LFIabh+GDUsBgP6WGe09v+Fj+xhpdOnJg2flf1bhhu0Stcdqy/uMIEm dQM/TxJM+n/YN9DQ== 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/srso: Remove 'pred_cmd' label 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: <169780183981.3135.133408986432395971.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:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777465040340453870 X-GMAIL-MSGID: 1780274396281598387 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: 55ca9010c4a988b48278f81ae4129deea52d2488 Gitweb: https://git.kernel.org/tip/55ca9010c4a988b48278f81ae4129deea52d2488 Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:04:57 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 20 Oct 2023 12:26:59 +02:00 x86/srso: Remove 'pred_cmd' label SBPB is only enabled in two distinct cases: 1) when SRSO has been disabled with srso=off 2) when SRSO has been fixed (in future HW) Simplify the control flow by getting rid of the 'pred_cmd' label and moving the SBPB enablement check to the two corresponding code sites. This makes it more clear when exactly SBPB gets enabled. 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/bb20e8569cfa144def5e6f25e610804bc4974de2.1693889988.git.jpoimboe@kernel.org --- arch/x86/kernel/cpu/bugs.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index e45dd69..4f1ad23 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -2410,13 +2410,21 @@ static void __init srso_select_mitigation(void) { bool has_microcode = boot_cpu_has(X86_FEATURE_IBPB_BRTYPE); - if (!boot_cpu_has_bug(X86_BUG_SRSO) || cpu_mitigations_off()) - goto pred_cmd; + if (cpu_mitigations_off()) + return; + + if (!boot_cpu_has_bug(X86_BUG_SRSO)) { + if (boot_cpu_has(X86_FEATURE_SBPB)) + x86_pred_cmd = PRED_CMD_SBPB; + return; + } if (has_microcode) { /* * Zen1/2 with SMT off aren't vulnerable after the right * IBPB microcode has been applied. + * + * Zen1/2 don't have SBPB, no need to try to enable it here. */ if (boot_cpu_data.x86 < 0x19 && !cpu_smt_possible()) { setup_force_cpu_cap(X86_FEATURE_SRSO_NO); @@ -2439,7 +2447,9 @@ static void __init srso_select_mitigation(void) switch (srso_cmd) { case SRSO_CMD_OFF: - goto pred_cmd; + if (boot_cpu_has(X86_FEATURE_SBPB)) + x86_pred_cmd = PRED_CMD_SBPB; + return; case SRSO_CMD_MICROCODE: if (has_microcode) { @@ -2501,11 +2511,6 @@ static void __init srso_select_mitigation(void) out: pr_info("%s\n", srso_strings[srso_mitigation]); - -pred_cmd: - if ((!boot_cpu_has_bug(X86_BUG_SRSO) || srso_cmd == SRSO_CMD_OFF) && - boot_cpu_has(X86_FEATURE_SBPB)) - x86_pred_cmd = PRED_CMD_SBPB; } #undef pr_fmt