Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1467643ybg; Thu, 11 Jun 2020 10:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTCFEI6jPVLbqHKhALAMMNtNaaiRn7cBoNywJfn5owj4AOi4mzfb5GMxYtUqFsPHZaFd0H X-Received: by 2002:a17:906:b1c3:: with SMTP id bv3mr9563637ejb.292.1591896799929; Thu, 11 Jun 2020 10:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591896799; cv=none; d=google.com; s=arc-20160816; b=AYLP2nrwQQA6BDPwV6xSN5i7t1xgMBYA7Nfum+VUKONKuO4cwgmTkX5hVe7yl/R17J nnyZqa0mRP9ZbhLc2R8aoYQFuRTI1faj1A/+XgT3motOmhLYrl47V6UNm//cR5xx/QuP prkiA+jxxZxgkOMou2ZIBtPDpHpJaIEsQVjdewZ2YkMYrfz9tbBiZbZLqa7SoIQyHB92 ouLTgPaGid5fQ1xNsLMedvoQB+BQ0SWd0SSKcZ4FZwvif26Gw1TE4uhNNlp737F98iKw wLkWrGabd0mqapP03bH4WlQnudpK4u/fLLbg7WzOofQxqftdbtYtblMWY+whbPcHoZrD ZYsA== 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=JU5IVpy1hwebQASLTWrwgg71St1itM4pRG6bPPA0pxI=; b=i7csArm2txbWZFR6gJ2abTCIAR8FTSd8LCVnslULtOWfzJ8zWSCuhXqCS+XHD7Noe1 iGJH0hqS5gUnDQ+8Xmzo1Xmqi0ajLiLGGliAX+Al4gcW6ujItbpl5tycw95Dtql4XRol PmsFslMjY9U/MMhbh2lFmY9zGn8gYcZQn1MiRY/EeHwftoDrN5qQY1I5gwPB7x7LQ/f5 2AAoIeYkzSYf6A/K0BRvHSLyQ08qmNxb3KUS0IP3pjNdgpSNADEd3zZXhcRETkXh0meZ g6SCLi8OoN4M3ibZoFpuhndWQUYbSJ47llCRqL1vPTRs/EmXzlRB/xRB6tz2u7RnDgbO wL6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ohP+4Y0r; 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 rp9si2296556ejb.718.2020.06.11.10.32.57; Thu, 11 Jun 2020 10:33:19 -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=ohP+4Y0r; 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 S1727963AbgFKOKA (ORCPT + 99 others); Thu, 11 Jun 2020 10:10:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgFKOKA (ORCPT ); Thu, 11 Jun 2020 10:10:00 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5365C08C5C1; Thu, 11 Jun 2020 07:09:59 -0700 (PDT) Received: from zn.tnic (p200300ec2f0bef00e16d68ab941b81be.dip0.t-ipconnect.de [IPv6:2003:ec:2f0b:ef00:e16d:68ab:941b:81be]) (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 E0E081EC02AC; Thu, 11 Jun 2020 16:09:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1591884597; 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=JU5IVpy1hwebQASLTWrwgg71St1itM4pRG6bPPA0pxI=; b=ohP+4Y0r6eetmXUM/0YQ7W1ZbY0uQqHyv+KTkfyjr4J9kJtD+2eavOfM92CifFx8dFUY5/ +SuICaXRTVHLLvaRxjlFfXwXotYUvswnx8Uylb6o7Szla0KlQDB7cKPYHBjphzDWvJhEFb Padg0/tPzalZtwPoKGEVml4x26mITzc= Date: Thu, 11 Jun 2020 16:09:51 +0200 From: Borislav Petkov To: Anthony Steinhauser Cc: linux-tip-commits@vger.kernel.org, Anthony Steinhauser , Thomas Gleixner , stable@vger.kernel.org, x86 , LKML Subject: Re: [tip: x86/urgent] x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS. Message-ID: <20200611140951.GD30352@zn.tnic> References: <159169282952.17951.3529693809120577424.tip-bot2@tip-bot2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <159169282952.17951.3529693809120577424.tip-bot2@tip-bot2> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 09, 2020 at 08:53:49AM -0000, tip-bot2 for Anthony Steinhauser wrote: > @@ -672,23 +665,36 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) > pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n", > static_key_enabled(&switch_mm_always_ibpb) ? > "always-on" : "conditional"); > + > + spectre_v2_user_ibpb = mode; > } > > - /* If enhanced IBRS is enabled no STIBP required */ > - if (spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED) > + /* > + * If enhanced IBRS is enabled or SMT impossible, STIBP is not > + * required. > + */ > + if (!smt_possible || spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED) > return; > > /* > - * If SMT is not possible or STIBP is not available clear the STIBP > - * mode. > + * At this point, an STIBP mode other than "off" has been set. > + * If STIBP support is not being forced, check if STIBP always-on > + * is preferred. > + */ > + if (mode != SPECTRE_V2_USER_STRICT && > + 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 (!smt_possible || !boot_cpu_has(X86_FEATURE_STIBP)) > + if (!boot_cpu_has(X86_FEATURE_STIBP)) > mode = SPECTRE_V2_USER_NONE; Can we merge this test into the one above? Diff ontop: --- diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 8d57562b1d2c..05b3163e1b8c 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -673,7 +673,9 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) * If 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; /* @@ -685,12 +687,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: -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette