Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2754666ybt; Tue, 16 Jun 2020 14:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmmwuCFHx7FHUQ/L2P3mdERHAIKoQ40VnI+5XLW/lbZZrUzzzccqqQHD33oacRLlXhIr9/ X-Received: by 2002:a17:906:8294:: with SMTP id h20mr4422039ejx.17.1592342522945; Tue, 16 Jun 2020 14:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592342522; cv=none; d=google.com; s=arc-20160816; b=fHjZhtDfeGzPEgTAVjg4ORadg+L2XiJCvUvoPvEnp5Gd+dWg4vI00WaR9Ga2QxkUso S1ymyXHIGokGyQ+X0knKn3ZSncAyNBZwxHQo/EKcjS1/u+YHCAyT7aIqt0BS/p/3remm F2iLOR+V2yLnK7Enq9MMQ+xmBsBlpUyVSrm2pVXMDqrgMi1ejv/0v7Fqwx3bZGutSu0A k+wtk+PP6OTYCVuwVKgiGEpJ6B12V4Xe6q69en9mCNQBHHxfogPvTRU1v6bNT5DrnTPZ YmyQxNuySKuq1KXHbw3PTxLdxJJLJXSqlwaIilZCqvlFQCMbrpwCpltadHTBBynE52eq SrzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=pS60VhE+YP8QqerMop0PA6ow/I4E0MVHtvubctxI0kc=; b=l7oE1NZ8KLVrR0pHU6ggG5SypildFGi5qm6BUToOhwawc9C5B+TzPuLMeXS7aZK/eF 2VXASUMfKYvvvNa5CAMXCMBmaYLWcZ9YSi5LYyUFLc9+TMdAA8L1S3trVbXEN08ku7Dv 5DBAMqDgLKqSgjvpBKxB8jI9dO5IBW1jyfTtV4cHciSyExWAShovf1AxaxWbsRqFEGVw cgiQ+yc71+hfXo0bnsu1MVrXwlQEjc7FmkyjtbejHFQQxiYAGFjIVNLOUp44owEL1ZOL Ns7gmbrDw4rg8qY9jBLA2A3MXAfWEeSOtx1jEsoGv8mlQ6GupIVLLZ7H6qzrw2+Gwacz Fhjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si11280889eja.130.2020.06.16.14.21.40; Tue, 16 Jun 2020 14:22:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726303AbgFPVTu (ORCPT + 99 others); Tue, 16 Jun 2020 17:19:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbgFPVTu (ORCPT ); Tue, 16 Jun 2020 17:19:50 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EC88C061573; Tue, 16 Jun 2020 14:19:50 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jlIzi-0001iA-Fm; Tue, 16 Jun 2020 23:19:46 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id D506A1C0095; Tue, 16 Jun 2020 23:19:45 +0200 (CEST) Date: Tue, 16 Jun 2020 21:19:45 -0000 From: "tip-bot2 for Borislav Petkov" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cpu] x86/speculation: Merge one test in spectre_v2_user_select_mitigation() Cc: Borislav Petkov , Anthony Steinhauser , x86 , LKML In-Reply-To: <20200615065806.GB14668@zn.tnic> References: <20200615065806.GB14668@zn.tnic> MIME-Version: 1.0 Message-ID: <159234238559.16989.14154672782950729079.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/cpu branch of tip: Commit-ID: a5ce9f2bb665d1d2b31f139a02dbaa2dfbb62fa6 Gitweb: https://git.kernel.org/tip/a5ce9f2bb665d1d2b31f139a02dbaa2dfbb62fa6 Author: Borislav Petkov AuthorDate: Mon, 15 Jun 2020 08:51:25 +02:00 Committer: Borislav Petkov CommitterDate: Tue, 16 Jun 2020 23:14:47 +02:00 x86/speculation: Merge one test in spectre_v2_user_select_mitigation() 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 --- arch/x86/kernel/cpu/bugs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 0b71970..7beaefa 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -763,10 +763,12 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) } /* - * 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; /* @@ -778,12 +780,6 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) 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: @@ -1270,7 +1266,6 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl) * Indirect branch speculation is always disabled in strict * mode. It can neither be enabled if it was force-disabled * by a previous prctl call. - */ if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT || spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||