Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp195985imw; Wed, 13 Jul 2022 23:00:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vYWMGnD3wGGqso2uhGG/cV1y5Upd8j867DOzjdXcp7rXvtUyYS0En6sVx93oSSM4T3O1Ib X-Received: by 2002:a17:90b:4d11:b0:1f0:414b:586e with SMTP id mw17-20020a17090b4d1100b001f0414b586emr14610983pjb.111.1657778454272; Wed, 13 Jul 2022 23:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657778454; cv=none; d=google.com; s=arc-20160816; b=f4j0bznLT4Mvt0xYqEgw1ZQ6jpLNa21QeiJsq6l8aZUUqf3+LpT0YKSbDCQ2jI+0mg 7vgiWVghSkAkkf85SkdoZRRGn1vXq4IhhKhmwY1tP5YvKPEj0PdJ6osPN60Yb3TxL3zF en+vLuDF8sTOzafwWqflIFh0u6P6OZIVHMBYhD2oUIqxH6q5Qo4m2/wIb7Gp95lh8k1a wPbhTXQCM4RRiZ2tt2XJtcG8nWu9AZPWzea1yVzoUGMptBdVt1hTRnRvz90m6T2mzi9p wU96x+jrD6uiDHrYL9Ug8/dKV7jC7x6Sme1kaRmW155xF6y0BRYP9vbL8tiHRnLkoyP6 8CAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=BWCxQiHlyL59RuHcWIqZox7VdRoTx0nc+ovVOnhaZuE=; b=fqn9cJXyIgw7dfkYoMqSJn+M25SnE+8f7cH2fKM2q5LVrIIoeLcNR4R5f6FEc1YVVi 2ZZ0Y5+FSc0LbIJ9CaULpZjNiFsIBKhYeye2Ll3vaV5Cz03W2jUwLRdRXEEW1zaIqGoJ wHFTQsoCVxsx2yV9an1M777s88AaM7jqom8IztE3vso9+6v1fXPN8kZtzFyAEf94HfdU SF5s8E/djoAJn4NC4g64yqn1FNSVVUNqsKJy7e14zsJU3hZD7E9AQTr7oLxnD5jkzaMY l76fwzTOw4awXVc6booyw5L+XgOLL6CHeueLMP/+Tsln6wFtmjQ3LlX8WACnRkGfr/+a Sxsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dm+rkUwd; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g21-20020a17090ace9500b001ef9401c3bdsi665259pju.75.2022.07.13.23.00.41; Wed, 13 Jul 2022 23:00:54 -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=@intel.com header.s=Intel header.b=dm+rkUwd; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234312AbiGNFcz (ORCPT + 99 others); Thu, 14 Jul 2022 01:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234625AbiGNFcv (ORCPT ); Thu, 14 Jul 2022 01:32:51 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BC2C20BEF; Wed, 13 Jul 2022 22:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657776771; x=1689312771; h=date:from:to:cc:subject:message-id:mime-version; bh=g3JhouRCSU7SAPZqa1QXPR7km+MMP1OzGRbcWLjGIBc=; b=dm+rkUwdHg6rTyd0I88Bo2IPQD8Cee74n1wssixFf0D2t65ULZHien0j zZFqBgm9P5eYoNhJ2Gl6vk0BZo5VIQ3MLDTCD8hEseXjCOWch8Cw4A4Hv QerlxhbgG9QRcmXZoOJA2uS+9BtWgTGz0DcziJRQKcuC31fJI4dOIoe3d N1ItER9joqNW8lRDKxrMXIiADx4olGj8jcHS1ITP8URs2H4yb1Yo4DvkH ItmApJXhsx5qihu69TRJb/MeRMUE3AaBbKgQbDkDSt1CV+bD2zDBlEpll G/fl/BWIJZ4Ue3nttxdvXNyMIu5bEDIMZ25vSBLlf7KF/wdzB+1TT+Uq+ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10407"; a="265208550" X-IronPort-AV: E=Sophos;i="5.92,269,1650956400"; d="scan'208";a="265208550" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2022 22:32:38 -0700 X-IronPort-AV: E=Sophos;i="5.92,269,1650956400"; d="scan'208";a="653719713" Received: from pfische1-mobl1.amr.corp.intel.com (HELO desk) ([10.251.18.51]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2022 22:32:38 -0700 Date: Wed, 13 Jul 2022 22:32:37 -0700 From: Pawan Gupta To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com, Josh Poimboeuf Subject: [PATCH] x86/bugs: Switch to "auto" when "ibrs" selected on Enhanced IBRS parts Message-ID: <0456b35fb9ef957d9a9138e0913fb1a3fd445dff.1657747493.git.pawan.kumar.gupta@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,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 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