Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35815074rwd; Mon, 10 Jul 2023 13:05:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlGxn+A3UcQ4pRddHg4sNdsrRCCAJsmXdHw7h++wDWWf+8NuevookzfWGcCzZmux7MefH5cc X-Received: by 2002:a05:6512:52c:b0:4fa:21d5:c0a3 with SMTP id o12-20020a056512052c00b004fa21d5c0a3mr11436261lfc.36.1689019546380; Mon, 10 Jul 2023 13:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689019546; cv=none; d=google.com; s=arc-20160816; b=jHkwBgIHuR5MySV7WboKwZ1ua/bHrCybpVdHa3oi94FvACdHRq9u97ydRh1KWDl0nU YuMq8LB3um5dbwu53W2lIbNL8wCOBg1/Qgy+/x//J1PXNoxLISdddmlkAsACmAMYaU0T jVix/7SoonCreCwgfQFMzHt9tpkK1P1FSTpmkWq+/X2PfQj3gKmcElv0gBPu7HC4bfkO 4C+uuOKJ3ebcoHO+BmuMMoEvr0iZ9XjeAIr68AcJ9Uuaq+QbOsgibd+asGpEkNnZNaG2 s3f+v3k7OK+1y+e5vSb9VbyUu9x1opQ9+B+8RWx3O+ek9VRDzdyQhFnJjSC96aphYncu PBJQ== 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=V8XTPlLt8h9osvtrHWj/nnm4IOfNvjA5a3kfsjNIri8=; fh=O5hGN+g8auw9Ax2YMVhoIJ+3XXizvyZrFj7plzReJck=; b=QgNONlHnvkjkA6V2YwO0I4iFGO8faA+Nhdo7/FrG9GEARV6c6VObJmtyHFWnlaz5CK PY2F5BYkyGs6GNrDHwcZz8pZuyLrsUpR/hb6rxjBGKNgrsembC/6jvETzYjY9lb8/MeO SzplR1kw+4AqY/nnrpYpx11b4dJb+hQJugohi/zHStceGFr1RbBWkXTXmFc65ZGH0QWv lR5vZxXY2leMt+3EWd6TzbR+yjvWauZLQLD04TL2xweqqbUh5Yvu8fIn0dYNYwthRRyV UjK3p6kax83zT3KG3kiJC2Tp3ogx0wIbwTP778t+BPZtAXrIi9v4Wt8FqGKYMVs+2rjl TfaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sv0ABw3O; 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 l25-20020aa7d959000000b0051de2ee33fdsi282226eds.433.2023.07.10.13.05.21; Mon, 10 Jul 2023 13:05:46 -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=Sv0ABw3O; 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 S231224AbjGJTut (ORCPT + 99 others); Mon, 10 Jul 2023 15:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjGJTus (ORCPT ); Mon, 10 Jul 2023 15:50:48 -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 2D4EE1A7 for ; Mon, 10 Jul 2023 12:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689018556; 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=V8XTPlLt8h9osvtrHWj/nnm4IOfNvjA5a3kfsjNIri8=; b=Sv0ABw3OfO5huNgVTTEFjqYs+gl+Bl09bR3VsrP1pvmE+KogLLe96IFu5UGwcXkgMqAgdg MVGTUS56gy7CoFbREDrDRjpk4OiN02Up+N53gKq5hyBSGbNtLVlrxEt0fkIjNCBiQjZray 5lVM34HZ4GuQxp5gxWcwE+BWX14bAL0= 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-449-cOWTCb-nMjCc6MG-0HCf_A-1; Mon, 10 Jul 2023 15:49:09 -0400 X-MC-Unique: cOWTCb-nMjCc6MG-0HCf_A-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 1A10F104458F; Mon, 10 Jul 2023 19:49:09 +0000 (UTC) Received: from llong.com (unknown [10.22.18.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38CC4111E3E6; Mon, 10 Jul 2023 19:49:08 +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 , Jonathan Corbet , "Rafael J . Wysocki" Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Robin Jarry , Joe Mario , Randy Dunlap , Waiman Long Subject: [PATCH v5 2/4] x86/idle: Disable IBRS when cpu is offline Date: Mon, 10 Jul 2023 15:48:55 -0400 Message-Id: <20230710194857.2898284-3-longman@redhat.com> In-Reply-To: <20230710194857.2898284-1-longman@redhat.com> References: <20230710194857.2898284-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_H4,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 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 Acked-by: Rafael J. Wysocki --- arch/x86/kernel/smpboot.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index e1aa2cd7734b..68e2e044ab8b 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -87,6 +87,7 @@ #include #include #include +#include /* representing HT siblings of each logical CPU */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map); @@ -1743,8 +1744,15 @@ void __noreturn hlt_play_dead(void) native_halt(); } +/* + * native_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)) + __update_spec_ctrl(0); + play_dead_common(); tboot_shutdown(TB_SHUTDOWN_WFS); -- 2.31.1