Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10194161rwd; Wed, 21 Jun 2023 18:21:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4UMh94P578b/+1g7+JtqG2LF4Yk9yhaGON4KBNGFa3zcM78MJzgaGBuL5hdf9VGAB4QET1 X-Received: by 2002:a17:902:e544:b0:1b6:7c9a:3a53 with SMTP id n4-20020a170902e54400b001b67c9a3a53mr7066456plf.67.1687396885104; Wed, 21 Jun 2023 18:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687396885; cv=none; d=google.com; s=arc-20160816; b=mcF79Xmlw3BnbkkgPMrAJpgMOCLi8cJjiJIgXIVQatv3Fy5EgWicw4Jdw3GH9L3Jl8 Ahf975GMBylgUDkm2Hxwx2olUPyp1hoeJFXt7cTExxSsFT7ihQoxtzetQSr+2MR9WBJi cTabPytxnWEREhnJj2w8m37mDA4437iv6uTO9eNID8p/4VyEPL6l98Q+PPlBUbvDMeWb hGMxKu5S0VMbJ2NkYZq5ggNZaIObrKUx+t31Iqc7FP/VisEMV2kY9GtdFEholLyA0iso kjotelPgV4v295NbeSBtgRD0oWrLgXXV7p2qtosI0GBkrpAZUAaQEi2Kjlcmys2gcppl VULQ== 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=Y2K8vEOPDcz7x2LNRwFb2B2QKeE2WWX5WNiQAkU03hs=; b=W5lW5LtZm+v+2wHRCWIqY2O45h78l2Aqcot9VGV34RIY0rDjkggCcCL0f2cl6QwGya Gskrn9iohL5FmPTiFV4KDQKNdj1D7Rm9nKkINY4o6MgIQBOxq1LQuqV1ICVnb4DBTBDn 4tUorHUH0imisRohBd7JPTQL36+0R+VCaVLan2pNw5ze/rCp50wuMniEyxVpdyMmbR3U 7J//6gQnTlDH5YFwecwWIR1DW/Dk5G7NiCCp70p/WGy5/YXa5dxBoWje7xdz0H5QJQaA azmcp+IE3gGA31RhEGtOtryoFV8wdH8ldfSKYd/GI67oA4jJa5a9QcTtjLEeLoCx8LbB lb1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="gI/jtJe2"; 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 d18-20020a170903231200b001b50a1d188dsi5964849plh.257.2023.06.21.18.21.11; Wed, 21 Jun 2023 18:21:25 -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="gI/jtJe2"; 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 S229956AbjFVAhh (ORCPT + 99 others); Wed, 21 Jun 2023 20:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbjFVAh2 (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.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EFC6198B for ; Wed, 21 Jun 2023 17:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687394207; 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=Y2K8vEOPDcz7x2LNRwFb2B2QKeE2WWX5WNiQAkU03hs=; b=gI/jtJe2eF1/nXGfpAG0TGcyKi4YoWcpu5k+zl9DpaTcyTfPB04VGrQeriyrS3+Gie3lE6 FK37i8FeFUzqpCkL+jGdlncE+U4vuTvtlgfGd1SU/74MI6XcpEq3CKlHad2F+/z7384nmm Xx72ickvbYJzFwuV8vldGu9z+BwgoP8= 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-225-bkmuxB6oP4CXjIe5kkZ_qw-1; Wed, 21 Jun 2023 20:36:44 -0400 X-MC-Unique: bkmuxB6oP4CXjIe5kkZ_qw-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 BEC2D85A58A; Thu, 22 Jun 2023 00:36:42 +0000 (UTC) Received: from llong.com (unknown [10.22.33.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09587112132E; Thu, 22 Jun 2023 00:36:41 +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 1/3] x86/idle: Disable IBRS when cpu is offline Date: Wed, 21 Jun 2023 20:36:01 -0400 Message-Id: <20230622003603.1188364-2-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=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 Commit bf5835bcdb96 ("intel_idle: Disable IBRS during long idle") disables IBRS when the CPU enters long idle. However, when a CPU becomes offline, the IBRS bit is still set when X86_FEATURE_KERNEL_IBRS is enabled. That will impact the performance of a sibling CPU. Mitigate this performance impact by clearing all the mitigation bits in SPEC_CTRL MSR when offline. When the CPU is online again, it will be re-initialized and so restoring the SPEC_CTRL value isn't needed. Add a comment to say that native_play_dead() is a __noreturn function, but it can't be marked as such to avoid confusion about the missing MSR restoration code. Signed-off-by: Waiman Long --- arch/x86/kernel/smpboot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 352f0ce1ece4..7bc33885518c 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -84,6 +84,7 @@ #include #include #include +#include /* representing HT siblings of each logical CPU */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map); @@ -1836,8 +1837,17 @@ void __noreturn hlt_play_dead(void) } } +/* + * naitve_play_dead() is essentially a __noreturn function, but it can't + * be marked as such as the compiler may complain about it. + */ void native_play_dead(void) { + if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS)) { + this_cpu_write(x86_spec_ctrl_current, 0); + native_wrmsrl(MSR_IA32_SPEC_CTRL, 0); + } + play_dead_common(); tboot_shutdown(TB_SHUTDOWN_WFS); -- 2.31.1