From patchwork Sat Sep 23 12:20:09 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: 143937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp253832vqu; Sat, 23 Sep 2023 09:01:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEutOTj7/CUjfMAD7hhM+B8FGI96WfCELhwgyUAtXkc0Bo0xqU/cFckel3TIX3EpC461Q8w X-Received: by 2002:a17:90b:1d0d:b0:277:1bd8:abe8 with SMTP id on13-20020a17090b1d0d00b002771bd8abe8mr2270758pjb.18.1695484866156; Sat, 23 Sep 2023 09:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695484866; cv=none; d=google.com; s=arc-20160816; b=qrZ5HMNU/Ij5/P5fGCzZsmUfLlTiL3VrAXEclPKUQHnSJHk8ih/wTFPUFURrGQoAXS psnH+oZ/Bt5VCPuH+Tiwy7dvClG1VMCvn18m0/R0pGt6hLiNqg6AkCdPyns6+HY1rdlF QV8XOHIImNs1nmZglEISF5WgDTkELrsp7g2sUrUS3M6X5k/TDQXc9REVCOllALbadTCZ Dftq03+MZTs/SrmnchcsIgKPNXrlOml9+zU93QnNWt8bN3A5vBA9B+rnqhaiRDGHVeWN +hBQTjxcQGNywqRtPDNt+U2vRr5SM1qNWZ8GEhWlpCfcs5I9HmEQDWMppS+wajGT7EL0 iFtQ== 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=ixaPWLbBb/Ht01BTFWXyWT9jP7AiCF6GndUZ/uEuauM=; fh=TJa98jjcJcAUyvo2yQiOqi+wukdLlQU80th5XskGe8U=; b=ApMHWHr/RWkOzVTDgrPk34vnnXkaAMRmqkoIE7eBknZCmOL8zxn2YCLAq0bN/RrgsS DIlXRAAnuwdoQu2D2qr4iqHc2RoNiRU5ihlHESEe1y31xvGjafnHoY9SFXqacrRPCJaJ lmOXcVhzcaRQoIv+c2vBrN/4G47IvFWZsErRBCF4yVAxzxdgmAKqw6bqpNllHmmEmMiR 2wv6RoeascR541q4fHGNKRn4+KkAB5qDQB2VjAPCa6uvDk/GZMppoAj3P83UrMpcGU03 bgwsZPfWQ/epiUf4N5I31Pp+GC7T9lzyw4PFw7o20bshEomvp87vxF/RTtZT74Dg4yRS TDTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kkvkF90v; dkim=neutral (no key) header.i=@linutronix.de header.b=upTsvdy+; 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 k5-20020a17090a9d8500b0026376acd6fesi1227122pjp.22.2023.09.23.09.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 09:01:06 -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=kkvkF90v; dkim=neutral (no key) header.i=@linutronix.de header.b=upTsvdy+; 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 06DED850D4CB; Sat, 23 Sep 2023 05:20:51 -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 S231627AbjIWMUe (ORCPT + 29 others); Sat, 23 Sep 2023 08:20:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231618AbjIWMUS (ORCPT ); Sat, 23 Sep 2023 08:20:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0F3719F; Sat, 23 Sep 2023 05:20:11 -0700 (PDT) Date: Sat, 23 Sep 2023 12:20:09 -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=ixaPWLbBb/Ht01BTFWXyWT9jP7AiCF6GndUZ/uEuauM=; b=kkvkF90vSQN0/sFSrwtjfWy4W/t0XYBwVGJf+cBGhMRDL3vQJGpK6ReRvSXfEDetJIWK6I xJKp/e7+adZyin+tilHrJ+FTmFmCT1jm0rUqPoFDqObd8j9orNtyxd1E7dxPmefNH7yj3/ PPFkb9nbUNeqsqbcZ1xICIxt04dkhCUiyROyJ5340oaX590MjU3YH44NtdfRE06GMLWUWY eipQnsEFivoJCFmqSydsKkAqNj6GWnl3ttmfLNpdJr6q2F7moqDFChz87K7mk5seU2ZRVr d60YOwDTzgkCJkHNnAuz8hAtnPUgWkDWEH+YeoNsLafme+wR0ZEI/2MNPshtDg== 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=ixaPWLbBb/Ht01BTFWXyWT9jP7AiCF6GndUZ/uEuauM=; b=upTsvdy+Rn9U04WD7x4T2RyfK97pYGrAEzETbbAGIdE7Y+zuqp3mtXCOPdGbSexF8dLMl6 Djq4qsiI8/npwrCw== 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: <169547160930.27769.12655009892934110336.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Sat, 23 Sep 2023 05:20:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777465040340453870 X-GMAIL-MSGID: 1777844739251374213 The following commit has been merged into the x86/bugs branch of tip: Commit-ID: e2ea4bea46ad9b71ab0c9617d8f4e09310973344 Gitweb: https://git.kernel.org/tip/e2ea4bea46ad9b71ab0c9617d8f4e09310973344 Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:04:57 -07:00 Committer: Ingo Molnar CommitterDate: Sat, 23 Sep 2023 14:13:03 +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 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