Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp704756imw; Thu, 14 Jul 2022 09:16:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tlIN+vAsLEySnls0Dv4+M1x1TiY8yepgZ16+sY1ryu6MSFne4C2XFp2IfqEZ7jrV6zNqF9 X-Received: by 2002:a05:6830:1e63:b0:61c:7977:23c9 with SMTP id m3-20020a0568301e6300b0061c797723c9mr1395165otr.82.1657815368161; Thu, 14 Jul 2022 09:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657815368; cv=none; d=google.com; s=arc-20160816; b=grFy+8gOJ+liaMdycqQ05ewSlbOj0xG4AlPqw0coibcGdhb5jXCZkgEHYpqEffGZ8/ i5dN9lvVwKalPI8miTTKSpZrrT2kIA1cXEbzzf8Ig/TJgOhEm6wagdONr5w3NPDNOYlE xTa2VHaS9IgbT6ref97Dx8n6r9J9LhZQ+JQZelS0GLLS5XIqhTdnlvxI4F3kuvIvGtBV Vs7+8TWOtV9gXiousQLd4sE9eQWl1ztzErDwBuyGmSVwqqz7OwMeCY7QaTC13a8JeYI8 TopBLTBVdASQwR2nnLcNIHsVy1Kaxo5o01FqqtFSZrD4PNaZgt9fnAAw2m9kZEkMxuoV 5v5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w4zOf+etRiySdiu6kBgQjMDPQJUPDhFXhJm7PJWnmKk=; b=K/gVliud/ekcEgQ6mPiDIFZR39mVl07v9sF5zaQt4TvsGJ0CVQoKj3uFHCaOVXG6oq ZoO+i+wCDjQ20R8fL3J/mtEP7NmMPd2HoLh/FO6IpFmb81qhPZS/Hp1ODBZTs6u6MfMW 0P62evyowBFqsxTGUDHx00otNrHhLaUqPp3lj0ZzzhPfqD8b5Fsew3dkIz0COO3XEEw+ jHpfkukZkLV7BnRSsCDuz8CEUbssdz9I0McaiY5Bfb+vKvH9ug02y/E4RsR8Q7Ac2kaq uRUlRlC4keOkMcvps9n8x9dWgNOUf6qB6c5SPBiEOACg1frb6HR3W9URIQvdrsEbqU/a ZYbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KgE475X3; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 95-20020a9d0f68000000b00618d560b800si1698733ott.221.2022.07.14.09.15.53; Thu, 14 Jul 2022 09:16:08 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=KgE475X3; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231511AbiGNQBN (ORCPT + 99 others); Thu, 14 Jul 2022 12:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbiGNQBL (ORCPT ); Thu, 14 Jul 2022 12:01:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3237E15A03; Thu, 14 Jul 2022 09:01:10 -0700 (PDT) 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 C5A4A61FD6; Thu, 14 Jul 2022 16:01:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DB72C34114; Thu, 14 Jul 2022 16:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657814469; bh=KW36fiDdd/VMDpKD/6Q7toG5lBwxSVebvEd9T4QRPx0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KgE475X3ybdFezB0Oly95qbl9WLtvxZ8GqMKNHijCSRaKYts273nZ1ziA3CBaZWmk zVw50nHLb+CObD33nIHArY1HSwGUt8ajnoi7O/UeQWWrEBo5RBYu8VT9vrevGqBVcQ mmP5+Kn4nc4HC/UyamWc26ElX5dWoVwWJZqLL55HB/XwJKJ/r8cQ93nyy9sm4/YE2c ZE/69bU3aXguHi+E8ER1AaA+u+sPcbpJOMn2jUsQsIW0sBz6gsk4yF7/my97nnof1w ZtjIlsCj97nN7lkQFzscqX6okEeVFUCOvqXzsYeRsi0LoPfk5HMchv/owRIcEH63uk xyZUchucEcIVw== Date: Thu, 14 Jul 2022 09:01:06 -0700 From: Josh Poimboeuf To: Peter Zijlstra Cc: Thadeu Lima de Souza Cascardo , Pawan Gupta , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com Subject: Re: [PATCH] x86/bugs: Switch to "auto" when "ibrs" selected on Enhanced IBRS parts Message-ID: <20220714160106.c6efowo6ptsu72ne@treble> References: <0456b35fb9ef957d9a9138e0913fb1a3fd445dff.1657747493.git.pawan.kumar.gupta@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 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 On Thu, Jul 14, 2022 at 01:42:11PM +0200, Peter Zijlstra wrote: > On Thu, Jul 14, 2022 at 08:17:26AM -0300, Thadeu Lima de Souza Cascardo wrote: > > On Wed, Jul 13, 2022 at 10:32:37PM -0700, Pawan Gupta wrote: > > > Currently spectre_v2=ibrs forces write to MSR_IA32_SPEC_CTRL at every > > > entry and exit. On Enhanced IBRS parts setting MSR_IA32_SPEC_CTRL[IBRS] > > > only once at bootup is sufficient. MSR write at every kernel entry/exit > > > incur unnecessary penalty that can be avoided. > > > > > > When Enhanced IBRS feature is present, switch from "ibrs" to "auto" mode > > > so that appropriate mitigation is selected. > > > > > > Fixes: 7c693f54c873 ("x86/speculation: Add spectre_v2=ibrs option to support Kernel IBRS") > > > Cc: stable@vger.kernel.org # 5.10+ > > > Signed-off-by: Pawan Gupta > > > --- > > > arch/x86/kernel/cpu/bugs.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > > > index 0dd04713434b..7d7ebfdfbeda 100644 > > > --- a/arch/x86/kernel/cpu/bugs.c > > > +++ b/arch/x86/kernel/cpu/bugs.c > > > @@ -1303,6 +1303,12 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) > > > return SPECTRE_V2_CMD_AUTO; > > > } > > > > > > + if (cmd == SPECTRE_V2_CMD_IBRS && boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) { > > > + pr_err("%s selected but CPU supports Enhanced IBRS. Switching to AUTO select\n", > > > + mitigation_options[i].option); > > > + return SPECTRE_V2_CMD_AUTO; > > > + } > > > + > > > spec_v2_print_cond(mitigation_options[i].option, > > > mitigation_options[i].secure); > > > return cmd; > > > > > > base-commit: 72a8e05d4f66b5af7854df4490e3135168694b6b > > > -- > > > 2.35.3 > > > > > > > > > > Shouldn't we just use the mitigation the user asked for if it is still > > possible? We could add the warning advising the user that a different > > mitigation could be used instead with less penalty, but if the user asked for > > IBRS and that is available, it should be used. > > > > One of the reasons for that is testing. I know it was useful enough for me and > > it helped me find some bugs. > > Yeah this; if the user asks for IBRS, we should give him IBRS. I hate > the 'I know better, let me change that for you' mentality. eIBRS CPUs don't even have legacy IBRS so I don't see how this is even possible. -- Josh