Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp435084imw; Thu, 14 Jul 2022 04:24:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tgQnOtIYM/VflLVyanWrYPa4P286lb3ZGt00xh1zhvk2ou78zf4rW9D2NqAskRx8bfTrAd X-Received: by 2002:a17:907:6d04:b0:72e:e204:a70b with SMTP id sa4-20020a1709076d0400b0072ee204a70bmr1728033ejc.432.1657797855333; Thu, 14 Jul 2022 04:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657797855; cv=none; d=google.com; s=arc-20160816; b=xJaXZIpuxkTyMVXgHsNW+kHy1MqGHhtyg15vb0q19agW7tWW7rB8Ga41LW5htsKOKb M5ZQJ+Aw+UGeJVdq/NB1tQB1GiQrvG4RHygPrXvJtOhu6vqAG+bht51CAV/ZqAN052Gn xwIKV4zXhi2zP1c2LxmkBCylweJYr6Hsb0oH4d2TV0HCdgajlu/RlsqN7xj2nUeLbxj1 DXMibAx2JvXnSIifbKt2m0Pw/Gm0W58pq5UnsxfvN+9oOiTKrdWyBRCjUffvGxnp2HgJ 6Jz8198SFh25FQhrLKU6eXnSrdWRtnrDTJDuVk6KY4ChY+sDn2Fm3Wweb7bzH7LAk5bN FokA== 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=fWFv+RFz/llfCdkXnbXZ80kWIaRC3ju+kgm5LZk6q5I=; b=NgrkOtJkAOe+01DzPCwFaLPr4HGcrP+8qamOEqtbWcPx88g6Z3WEuuz5UfHmlmPY3M p3q/fu+PLVj6rvohS0zQIHcCgCn1IoAH0g9qQHtg5wls1YlLU7Kdt9E7EDM5Jq40qoGe ib0v10VsRVZ0Oazzl7DyrF3GQrfCHxTO3ZodFiGalCofexOadpNMS5pL07+YYh0SbMJk cSpN2L2CNVrH4hbyxG6AgRX/qNy92cRJGadVmKtFEZ6z9Ht4i0wFzrhSopwnWMh/1G1M yjagwsqnvzN5UK0kCMR/X5ErdoXFzFGq7MmUaTz5kr4ZvO/sSRlUnHN7pnNu2EJ0JM2J kFeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="JvEF/7/d"; 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=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw22-20020a1709066a1600b00722e89d8994si724964ejc.430.2022.07.14.04.23.51; Thu, 14 Jul 2022 04:24:15 -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=@canonical.com header.s=20210705 header.b="JvEF/7/d"; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238168AbiGNLRi (ORCPT + 99 others); Thu, 14 Jul 2022 07:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbiGNLRg (ORCPT ); Thu, 14 Jul 2022 07:17:36 -0400 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E235F501A8; Thu, 14 Jul 2022 04:17:35 -0700 (PDT) Received: from quatroqueijos (unknown [177.9.88.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 8339E3F382; Thu, 14 Jul 2022 11:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657797453; bh=fWFv+RFz/llfCdkXnbXZ80kWIaRC3ju+kgm5LZk6q5I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=JvEF/7/dJS41ORhT0juyMzcdB/gU0LGjiI0eDAc4tu7h8BYdfrlcW7V6QVzpXdjQW kmlUlVy7uIr1fmj+8lC+hf0Of7SErkTK472rC/IhhepgoIVDM0bt1O7bEPyUhpYtZu 3rwX5oVJP3sjXIvheBxVGIlOEUsLCdOHOU34CtUfcGDOkipqNOj3vGB2Rcc/rk/GyA oTdw07yPg7/wXHQS6hbk+gjMkIrm0MvRPphfzqf+H3XX0HHEtMUb6cAYAwx7OUNcSQ r/Xu+fNamXRaKl1WUJTAbdiv7wSkee4CHOhRj1ZsMh4qYYBTTiWSREJRVGfNwc6YcK ccfsmxnCGHj3g== Date: Thu, 14 Jul 2022 08:17:26 -0300 From: Thadeu Lima de Souza Cascardo To: Pawan Gupta Cc: 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, Josh Poimboeuf Subject: Re: [PATCH] x86/bugs: Switch to "auto" when "ibrs" selected on Enhanced IBRS parts Message-ID: References: <0456b35fb9ef957d9a9138e0913fb1a3fd445dff.1657747493.git.pawan.kumar.gupta@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0456b35fb9ef957d9a9138e0913fb1a3fd445dff.1657747493.git.pawan.kumar.gupta@linux.intel.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 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. Cascardo.