Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1723365pxp; Thu, 10 Mar 2022 10:49:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxp0u6nWseu/9lduQXcAWB7/MobpR7Nwih4aV4qlrs6qp5fW6bofGynKcQYOQfw3uMZsbVj X-Received: by 2002:a17:902:a614:b0:153:196d:634f with SMTP id u20-20020a170902a61400b00153196d634fmr5686698plq.39.1646938151139; Thu, 10 Mar 2022 10:49:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646938151; cv=none; d=google.com; s=arc-20160816; b=Mh0/hQO7eVjLyDqgWLZf0gZ9bjhkTy3FeObPn1bDEXj8c9WxdcHY2pe37baAQcC+A+ PeYYsklslmDmnEHK4bxqtgX3/Hn09O1cUPqf1DAHveDcjwvEmjxPmHgueGh4MMcxWA1A kzTceCO0Mipg4KN0vhAWRZTYhmdV0MylnO7FRkXnQGQUNlwDlWhCM/NJwC9jgqINA0o1 SOaWnLIm/Bc2a+1Qv5VBz8jTqZ2tKTttNJVwLCkPz8KUiKk9jXATeXdeDRdmU2/MCdc/ AEtTssx/Te/dvAOfD8fxOjjuR1U7CiMJImZpkElwN7dg86fp/plEQweGY/v6LOdmGija tteg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0kuyXyWpa//BoL94BDBDJoOLL1/t0tOpmlDvg2cfL9Y=; b=0TznQki4V74kkk7NaijN4konKpT52prNjVYdjT4QJzKrkwgzwMdn8QkU7dvZs07lvu 2d+yK1nAPl+F71nREuHitPPPYxW0DSSR60HjXUzxHFg70w6vViaoFCZFI9Clz5o7fSFL qoapOm7v2uOrAjmaVGyp0GQ05lCeOBLwkZt0IUryfoAsyOSqyTs7d6dGqVECBWfQZKwH Bbj/vOYIhGxwhS0YwpwRWLsTVnhndwKi3PEw4iihAl3Pk5FZ+Pwi68Ssa7V0EsVKLitO FpOgj+5SJBwHgVguU/RPbX5Ghi8rnhvtKop/yfAgnTHz96jV9p9MByG10maA3jIUJV0r MgqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qdClAeoF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca10-20020a17090af30a00b001bed521b961si2629254pjb.10.2022.03.10.10.48.54; Thu, 10 Mar 2022 10:49:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qdClAeoF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243596AbiCJOXF (ORCPT + 99 others); Thu, 10 Mar 2022 09:23:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244271AbiCJOTG (ORCPT ); Thu, 10 Mar 2022 09:19:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1866E170D66; Thu, 10 Mar 2022 06:15:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9500461B5F; Thu, 10 Mar 2022 14:15:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99C0BC340E8; Thu, 10 Mar 2022 14:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921710; bh=rzqdBWxT9hdyPrcwgYhGnVFeo744NwfXD7+4fOLZF78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qdClAeoFpxL7Wc7ypcCS0jf5++IcptRHmNHVJsuaVrDBo4ZwhBLWlo6OEUjmAgbQF CPgN76WOIPzoUefBuVycU9kASEE4KPfw0GXmvi9OFRZgs2RuV/WbNdAvUR0tqCad9X PiiCdCft01gJ0tyAz+na0Bt8cNjknPcptDCqYUgA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Anthony Steinhauser , Frank van der Linden , Ben Hutchings Subject: [PATCH 4.9 07/38] x86/speculation: Merge one test in spectre_v2_user_select_mitigation() Date: Thu, 10 Mar 2022 15:13:20 +0100 Message-Id: <20220310140808.351995623@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140808.136149678@linuxfoundation.org> References: <20220310140808.136149678@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Borislav Petkov commit a5ce9f2bb665d1d2b31f139a02dbaa2dfbb62fa6 upstream. Merge the test whether the CPU supports STIBP into the test which determines whether STIBP is required. Thus try to simplify what is already an insane logic. Remove a superfluous newline in a comment, while at it. Signed-off-by: Borislav Petkov Cc: Anthony Steinhauser Link: https://lkml.kernel.org/r/20200615065806.GB14668@zn.tnic [fllinden@amazon.com: fixed contextual conflict (comment) for 4.19] Signed-off-by: Frank van der Linden Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -755,10 +755,12 @@ spectre_v2_user_select_mitigation(enum s } /* - * If enhanced IBRS is enabled or SMT impossible, STIBP is not + * If no STIBP, enhanced IBRS is enabled or SMT impossible, STIBP is not * required. */ - if (!smt_possible || spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED) + if (!boot_cpu_has(X86_FEATURE_STIBP) || + !smt_possible || + spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED) return; /* @@ -770,12 +772,6 @@ spectre_v2_user_select_mitigation(enum s boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON)) mode = SPECTRE_V2_USER_STRICT_PREFERRED; - /* - * If STIBP is not available, clear the STIBP mode. - */ - if (!boot_cpu_has(X86_FEATURE_STIBP)) - mode = SPECTRE_V2_USER_NONE; - spectre_v2_user_stibp = mode; set_mode: @@ -1254,7 +1250,6 @@ static int ib_prctl_set(struct task_stru if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE && spectre_v2_user_stibp == SPECTRE_V2_USER_NONE) return 0; - /* * With strict mode for both IBPB and STIBP, the instruction * code paths avoid checking this task flag and instead,