Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp705195pxp; Fri, 11 Mar 2022 12:52:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlMuf23Y9JsYnU6tE9z5viEgptg9vEXEI+GyGJ02QdyfG+4BRS1Dyz2hDcDL/kpNDYpQrZ X-Received: by 2002:a05:6a00:2181:b0:4f6:f1b1:1ba7 with SMTP id h1-20020a056a00218100b004f6f1b11ba7mr11703798pfi.73.1647031943089; Fri, 11 Mar 2022 12:52:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647031943; cv=none; d=google.com; s=arc-20160816; b=tzfNWeaWve8EmNXhYIl4sj0whMKvaB1qPqes/lTYvTNJREcWcqKVyAzOH9c/cdcO8r ZjRPd8W7GjyWBIX4ACC36K38jOrlDkGxFfs+dMJcaDzjszPVGNlFwztz7SdYkCxLFLlL 4CfFZ0tfeBRNMnugSFno8PQC0N1IblCNuhywZ6/H16zG+QYQYUhihP3HiSE2YCD5WzlG PrfxlU30CD4NxoahKYMrJWE+csJHcMkfWrYm9RleY6TmdrAl2pxJpjsdqvNJ76c4fAht b5UxjQtvkYPHC7yasOPwxBygFVoSOLDjVnCIXSuYmnfCu5E2VyPDi3+vSicxiie9Pa6y 4ibQ== 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=9ZEk9/RBJ9+XyZfTuXLn/WQKiRghyouqVWwjNsjuB1A=; b=OZ7RtGVpWeF/CqIBsm0OreTX3wdNTMjKbT2xttFUQ4EnHUaKuV3remYgC5ssSNCCoU KZuaeG9BLfR3v2STLhR9iWFoVPDMLVPMhJ+xI+6b9gV+rZuR1mKYb1TAj2+ghsc95aAY q0ihElXlSH9cUGp2SKRD0GnHJfmqZHZMZMDj46sUC+0rQYZgw/WaYn6XpJRJuSAdPXXB f3vMP6PaJqXS7ufRHY0rXZP/tJ/+XKqi/miA8AMG5upZ/nGJQeYjNb/JF90Bhb7PnBFs Yf9e/qUDQ7gotA0X41khib5Ks891/YR4X9PWoYYgUuZL76IQP5pgR9jkRcErmeSR2Jeq GjyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XjmULAcf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n5-20020a170903110500b0014f9a7c7ce0si9241975plh.307.2022.03.11.12.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 12:52:23 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XjmULAcf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E9B6E1DDFCF; Fri, 11 Mar 2022 12:44:35 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237501AbiCJOZR (ORCPT + 99 others); Thu, 10 Mar 2022 09:25:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241727AbiCJOVM (ORCPT ); Thu, 10 Mar 2022 09:21:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A775FBC; Thu, 10 Mar 2022 06:20:10 -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 E6CFA61D02; Thu, 10 Mar 2022 14:20:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6873C340E8; Thu, 10 Mar 2022 14:20:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646922009; bh=mSc6PRGfJhS8fiw4SnlPOu1Av93ntIA6/0VNlY/8NbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XjmULAcfMaCYfMSfgHprCBrOm7MHyvKxDDHGNvLXAFUNZlJfQpp/VfwsPY+5NSXSU By5g9GW91sZtTkCB72gHEWvJgCswMsRW3WQysrnx9O+wb4tpN1XtKGmU99JgtL4q3m yslPCOCJIj3H0SUaIUxdojLtfUv3gjZNtUXV44ls= 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 Subject: [PATCH 4.14 01/31] x86/speculation: Merge one test in spectre_v2_user_select_mitigation() Date: Thu, 10 Mar 2022 15:18:14 +0100 Message-Id: <20220310140807.570546096@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140807.524313448@linuxfoundation.org> References: <20220310140807.524313448@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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.14] Signed-off-by: Frank van der Linden 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 @@ -756,10 +756,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; /* @@ -771,12 +773,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: @@ -1255,7 +1251,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,