Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10186544rwd; Wed, 21 Jun 2023 18:12:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73UdwOwCfAspBg5IXwJLqsqP2imLFcPmHCDTtRdno+4+Aj92eoA8LG1Z6kq6UFuy+BbRps X-Received: by 2002:a05:6a21:7897:b0:122:8a34:bd85 with SMTP id bf23-20020a056a21789700b001228a34bd85mr6527959pzc.48.1687396368532; Wed, 21 Jun 2023 18:12:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687396368; cv=none; d=google.com; s=arc-20160816; b=PnnHstKIoYRD41P3xpCRgMsdS731oJhLKWqGGQZFJOkBgBAPrUGS7v3J9UlDmpKFag 1LIWsmTimD7lbtgvNXCZBW8ilz3eyfAD4hhwrOEajCsrqSdPDY5zWhxq0YoJV9gYtvx3 Fg/B3md7Gr1NEDdDE7f3UsVQz3kXLzkLcTkPvN3ZKhqTmjtdX/y/nem8iTwSmu+P6hw4 gxXnVECqKVldBA8DwkUF35FGnzjAoZbSw/Bs+BqaPHIDUUl5I3GhxAu1c3e1tl5/36Oq iWP9gC31omR57tQKKqw34ZmeRiIWcqnHFn6wB9o/Y2PzJ426DWSX1dLoESSKvS1hyBU1 mpEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZnY7DyJzG9u4tj8u43HUsl2yxKZDOEzNFGoyTY9ZN9E=; b=Vc0K9InwgmmiNsYmwhFaJ8KAHcz9qm4gEepU1UOMh5DiITsOrHfommSkZby4OiY9i/ ywQZt7lKxMx8cdsJKLzdgIZB6YcyHw8vOWED5fkCcJjfK2sSP3flR+vjTVNPCX2vEXwz rv7oO08XezWGjPrpvLTaoHZxw2uKY38vm+HIWN3xJdaM1PbhMjUTgTuDZ6zGkC3jmWrM Ewb4sGwKuG5/0mY6nLPmk/NlvmVccBvc5tVagGa2DPIEHyUx8QEY/FfESUVOq0PeKxT2 4zsXOFpPNnpLVerxc+RZ7YBu3fUKonM6Si991//cqt1naX4dPCA45oTWR2Ujpqp4UTZO 6/ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JDLg7nKd; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a17090311c600b001ae7f85061bsi5817533plh.609.2023.06.21.18.12.36; Wed, 21 Jun 2023 18:12:48 -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=@redhat.com header.s=mimecast20190719 header.b=JDLg7nKd; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229832AbjFVAhe (ORCPT + 99 others); Wed, 21 Jun 2023 20:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjFVAh2 (ORCPT ); Wed, 21 Jun 2023 20:37:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98EE21996 for ; Wed, 21 Jun 2023 17:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687394208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZnY7DyJzG9u4tj8u43HUsl2yxKZDOEzNFGoyTY9ZN9E=; b=JDLg7nKdQKg/0qSrLO2QEDbLWQGp4BimwcVoFEoMPfXVoaMx4FYSpelqQJkzTMaBCbm5pa hJgkh2NWpla+DGyVaTxFPCfzbJrPwBdjv2Nl7/i3GkPAxUfwC+Dp+zyd4WhR0m0JxanbgI Aib0xdpKIVBy5zHXaMrpwknFi8RBgYI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-328-8lweGLeKPVGsRXDFNdxTew-1; Wed, 21 Jun 2023 20:36:44 -0400 X-MC-Unique: 8lweGLeKPVGsRXDFNdxTew-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9663B805AF6; Thu, 22 Jun 2023 00:36:43 +0000 (UTC) Received: from llong.com (unknown [10.22.33.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1D12112132C; Thu, 22 Jun 2023 00:36:42 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Josh Poimboeuf , Pawan Gupta , Jacob Pan , Len Brown Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Robin Jarry , Joe Mario , Waiman Long Subject: [PATCH v3 2/3] intel_idle: Sync up the SPEC_CTRL MSR value to x86_spec_ctrl_current Date: Wed, 21 Jun 2023 20:36:02 -0400 Message-Id: <20230622003603.1188364-3-longman@redhat.com> In-Reply-To: <20230622003603.1188364-1-longman@redhat.com> References: <20230622003603.1188364-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 When intel_idle_ibrs() is called, it modifies the SPEC_CTRL MSR to 0 in order disable IBRS. However, the new MSR value isn't reflected in x86_spec_ctrl_current which is at odd with the other code that keep track of its state in that percpu variable. Fix that by updating x86_spec_ctrl_current percpu value to always match the content of the SPEC_CTRL MSR. Signed-off-by: Waiman Long --- drivers/idle/intel_idle.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index aa2d19db2b1d..07fa23707b3c 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -181,13 +181,17 @@ static __cpuidle int intel_idle_ibrs(struct cpuidle_device *dev, u64 spec_ctrl = spec_ctrl_current(); int ret; - if (smt_active) + if (smt_active) { + __this_cpu_write(x86_spec_ctrl_current, 0); native_wrmsrl(MSR_IA32_SPEC_CTRL, 0); + } ret = __intel_idle(dev, drv, index); - if (smt_active) + if (smt_active) { native_wrmsrl(MSR_IA32_SPEC_CTRL, spec_ctrl); + __this_cpu_write(x86_spec_ctrl_current, spec_ctrl); + } return ret; } -- 2.31.1