Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10444138rwd; Wed, 21 Jun 2023 23:25:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rnNuQQdMLWGpaHLZZUAZHUr6eZZKPzII9Nbv/31NzLVRlTXvKmAWsHWEOn7/u0F79VU7X X-Received: by 2002:a17:902:d509:b0:1b3:d418:7599 with SMTP id b9-20020a170902d50900b001b3d4187599mr8869761plg.13.1687415126887; Wed, 21 Jun 2023 23:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687415126; cv=none; d=google.com; s=arc-20160816; b=DxEmg0jlRghCpZrhLXhkZbhHtWtqMKMNQ39Hm+N7t1duzM7Z7VzCQ/MwgEVsOLW5qh Cqqda7ILWxBoLUZ8pr0fNhPl9M0e8Za4vADAwcMdQf6iCeQYsoePE3etTZKUeH7JpixQ Hz1nqrufvzGkIKbZRerPJnXPxhShXTNLmOyOL61rsaYVWAYiBjF47Url7XMdk71na2fm WQYvViwFt/uY5N7OXNNK4tRF8J06EpMzUgSqP8o7nLoPyxvGSQ0JTIp+Hx0Rf9X244kN MZ+BaPfg7Y3A3fJoUptKaJup4B/FxLcqlgigLFKxvqhWVJ4U/Giwo1Wf+JLAlQdfnEfd n4sg== 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=afUIqeR13byNoTXeeNwLJkJvx3BxVpwOBXJsDkMdF1o=; b=SEuaLOJB5Wr0s7BwilubOA/MElvXoYM3yrHxM7IO6akW86nYZczrcU9aJkzcTFkdTz BAfy8wvxxcM/NxgbXsXWN2TgVEzjSaREcGBufBHck7DZIfvg0hxpoZbS9ZdfXeYAZbTT 9lx56qGEBZVapc2XKrdK3cnzx4xjPVR419gGEh7NUc6JoVkklcrwRtw/v2ZEM4YYetVu JLh4KYzaTUQ3hISLLdAt1NHdJ2Q1ui+F0gkDHvpj6wXBo5AVHZT4Mb7NiuYPQtpk/1IP zxpMtumhhyaVN30nR+y5gnoMoCIXN6jcKbBOwppFnpB2jyx+1xhv5CiwfQv6UgJISRhX az4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bq7A6O6+; 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 ku4-20020a170903288400b001a6b273fef3si962069plb.442.2023.06.21.23.25.14; Wed, 21 Jun 2023 23:25:26 -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=Bq7A6O6+; 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 S230475AbjFVFqj (ORCPT + 99 others); Thu, 22 Jun 2023 01:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbjFVFqh (ORCPT ); Thu, 22 Jun 2023 01:46:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E45B19F; Wed, 21 Jun 2023 22:46:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E342F61767; Thu, 22 Jun 2023 05:46:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8568C433C0; Thu, 22 Jun 2023 05:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687412795; bh=uZclBeKStX/fZ+zdzQQVR/V73bJdFZL4odhSDY8NQjs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bq7A6O6+DP7oA07uYhI6eQ6ytpwKtm5ktEsOBlSqqvPrkPQlce8pldPPtJgLBOEwO Z/CYLUyh9rjEpnIya0YHz+55v/aBAneZfqJgYHSlcfKqugD1RF5YHpWl0kabLqkwrm p/ijqPHNTdR6LH5VgfJqf+lTslaa/j8EH2j/XCLl22/nf/6Of79oTtsc/v3PRShdIm nt4LZ0VM4Kva4479ggSWvM2aaoryCZ5O1SDDN+rjFCkfGnh8ZgIQdxXm59qo1pyUyY hQNFWrShbM/U6BEDVCj92kTgc5xULWuh4MDf0V1XVJi4v3av5fL6PjADgix5LIv8Gs QNkBf27Uhvy6g== Date: Wed, 21 Jun 2023 22:46:33 -0700 From: Josh Poimboeuf To: Waiman Long Cc: Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Pawan Gupta , Jacob Pan , Len Brown , linux-kernel@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Robin Jarry , Joe Mario Subject: Re: [PATCH v3 2/3] intel_idle: Sync up the SPEC_CTRL MSR value to x86_spec_ctrl_current Message-ID: <20230622054633.ulrurzzvzjijvdhn@treble> References: <20230622003603.1188364-1-longman@redhat.com> <20230622003603.1188364-3-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230622003603.1188364-3-longman@redhat.com> X-Spam-Status: No, score=-4.4 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, Jun 21, 2023 at 08:36:02PM -0400, Waiman Long wrote: > 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. Is this fixing an actual bug or is there some other reason for doing this? > > 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); > + } More candidates for update_spec_ctrl()? -- Josh