Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1450996ybt; Mon, 15 Jun 2020 00:02:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfi40EgJ+7trPptMa8pOLKjlj0a9J2aCg96vQxXVuP8BbZpfzdYsBDRoQbreVP5WntbgMQ X-Received: by 2002:a50:f044:: with SMTP id u4mr22775682edl.226.1592204561986; Mon, 15 Jun 2020 00:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592204561; cv=none; d=google.com; s=arc-20160816; b=hcLrVTJXNxWs3KiOQBwPmSd4IXpd/rP5TzcuAt/4xs0ps2wPO+7A2k8547Ws8fMEzp 5yDu8zLRnM1DwAUgCK/I11zcV3iQv9SR3PWdrK1IaqtPzr+pGbeiIKm2ijhXCNkHx0Gi sTA2qtANqGvO8pqKyp6Hhe9F5FUFGp6ih4Nsf+MJ7dZHusugwOyQPCOSB+oiffHFF6kw NI9O/Qa9Nz+5A/SA7bQAdyROHpNXjfI7yrJpiNNgmEVrEFAEj3q3oZNYtGMY8vbgACW8 dg9MOiHuf/6/fUK5OC2U/bg3DarH/tnXG5GsZNcBhSXWKQni1CMGWTbxrdcFsUV0jRbQ Vdkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CR5WZsxSRd8wp7PRr2IddZUw7c7yYSIxMJrU72FZPyc=; b=kU44pDMNYlE2m+sOqoPC4lVO0R0mcEEQsfyc6RgtqJEuH0Fk7cPj/d3T3LoGbW7gcM 0KB+TaoEiQs2MfftrpAU3EFOxH8+RD2iaLWEIQNNmcRoZRQpz5uPybdvX01PKl+0i6Y1 RGrtcMfuOQTuXVMo//CuG3kPnco7TW9nILTgT0wJ2+LL6epLDs5FkUvwFvX+LF8R5sa+ Q5dw4DP3INgNUgNmC8Kkwqg/fKOinLC58Zy/AQc14PNw/ozeTo+VHJeGGpSoERPo1/XD ioZ2vimWOaag6Dgv1QEvVoBC7+Y836cApkxS0rQSsGdhhHykGuImYLZZonSydDCxGcEn F4Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=MlWYFLP9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si8285216ejh.543.2020.06.15.00.02.19; Mon, 15 Jun 2020 00:02:41 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=MlWYFLP9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbgFOG6O (ORCPT + 99 others); Mon, 15 Jun 2020 02:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728236AbgFOG6N (ORCPT ); Mon, 15 Jun 2020 02:58:13 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EDC7C061A0E; Sun, 14 Jun 2020 23:58:13 -0700 (PDT) Received: from zn.tnic (p200300ec2f063c003187a4190bac43a1.dip0.t-ipconnect.de [IPv6:2003:ec:2f06:3c00:3187:a419:bac:43a1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 605D21EC035B; Mon, 15 Jun 2020 08:58:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1592204289; h=from:from: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:in-reply-to:in-reply-to: references:references; bh=CR5WZsxSRd8wp7PRr2IddZUw7c7yYSIxMJrU72FZPyc=; b=MlWYFLP9sJ5Q7JUJ8QL5SNrTmi0dnIhtDAbSg4yv0XgSfFC//8sn49UW1FcqR0+ba765zB ysLDXkylZK/hPafkdc9cWvkKAwG3U96CsGRgMcdzHCWK0jblIHgzr/FErfaviIqI+X3haH ZbTW6iKntgeylRmrGPqsgu20AYPMoOY= Date: Mon, 15 Jun 2020 08:58:06 +0200 From: Borislav Petkov To: Anthony Steinhauser Cc: linux-tip-commits@vger.kernel.org, Thomas Gleixner , x86 , LKML Subject: [PATCH] x86/speculation: Merge one test in spectre_v2_user_select_mitigation() Message-ID: <20200615065806.GB14668@zn.tnic> References: <159169282952.17951.3529693809120577424.tip-bot2@tip-bot2> <20200611140951.GD30352@zn.tnic> <20200611154356.GE30352@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200611154356.GE30352@zn.tnic> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (dropping stable@ from Cc). --- 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 --- 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 0b71970d2d3d..7beaefa9d198 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 || -- 2.21.0 -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette