Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp903995rdg; Fri, 11 Aug 2023 03:57:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVDsRpjCFOiBfVOXDXMBY/iwTNWaLjuPJ01CYm5t+2svIejtBCmHEs9whmi9NXxh8U8VMy X-Received: by 2002:a05:6808:52:b0:3a7:2621:2d9e with SMTP id v18-20020a056808005200b003a726212d9emr1668511oic.27.1691751456953; Fri, 11 Aug 2023 03:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691751456; cv=none; d=google.com; s=arc-20160816; b=sf/t1Z3YMr3hlI3OlUChukOeiXb8j474bZl0XOrBtlYuPjA99BeTOEw8X6G2lk/FSL d1X/lVKjaZ6FI01ttQPVDUym4RvcxjK2APbEg7pIfZXE37YPQHLyp0Dav4fKuIPUkL+8 T/+FjhZxuKwnQ0EtYePHkHOWEE7nmAApRyvLdeD2uGiXT36fMB0672uxPmvmUMGExsR1 e5e22c28h7NXSbvjhRYSWTaMsM9UrLaE69w0HWYCHqYPfwvAaOyHB1Xfwm+uQoyUB1h+ BD8o2jpzLBVHjFj1vwArKWdB8mPWh1/U/4DqFrKADLEmEHY6XL9ZzsPe9Jcc98g4kv2P vodg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=3ZYjFfz1bwCo59gNGTrSPl6TjkdV/FBgZNeoD4PLlQI=; fh=XigQS259tYj+gbRgQr4+hsPaaBH3ha6THjrkE4ZXet4=; b=H4oAJmzJtS9kkhgXd+nzHk8Nep35wBEQluI9/CUatwVGE79spVNdDpf+yHICsewA9/ qVMgLIoimU+vUf2ngVKkQ9YflljrbuVncmmUOo+8RaZNM9kPtcKeqU4f12Uku9EgK2q8 dTjE6RIb+y2TIoT9jD2E+YHOOb2vngWunMLcNUicvuN/Rt8gJYQezesD8kddXhARnDzn KNsbXSObyweqFy0+q3pLw+AnMh/b6QULJJsjzrvFnGOtyXuopAEql4r6acRI58pIqp6E RjHViMm4G13l1TIHWKQ5jONu1Bt+YDWcjMbe0fsG92lMEBhXpnC3q/v5GAz2AZdDk11v 2H+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=d4C2zLm9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=LluljunD; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca20-20020a056a02069400b005655bf61e32si2715174pgb.23.2023.08.11.03.57.23; Fri, 11 Aug 2023 03:57:36 -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=@linutronix.de header.s=2020 header.b=d4C2zLm9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=LluljunD; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235458AbjHKJhp (ORCPT + 99 others); Fri, 11 Aug 2023 05:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235603AbjHKJhM (ORCPT ); Fri, 11 Aug 2023 05:37:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 267E83C0B for ; Fri, 11 Aug 2023 02:36:55 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691746613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3ZYjFfz1bwCo59gNGTrSPl6TjkdV/FBgZNeoD4PLlQI=; b=d4C2zLm9eRHmKD/S5hkf0GDZ+PI9WEYaI+NUB0g6yUpaDL3VWcMZIw2uI4/SuandtNbZe1 xf+ujBGIb6UV5pr+J5ENLr5bXhkZ85hqjQIENeG5ShkUa67S1yhfPvKrxcFWdEHXm5HbSW tbLxCUC5NMXu/jnCPSGPSFDrruLTQOJI1HhLCjpRy4y9Tx9eNc6Xm55QhKtK3g/4rCxdgp 1+Tm3FzLs6F0ybPLqPLO9aUW5eMOjoc7TITJvlXm4iwnCOHYxS0QtIhpRXLPgKdw3qW1VE cMVDqMRTZorL/1aiiaGM3Lec/IXiiLwJiNM35Nv/3Jiq1nkUrL0wAl6F/CAHyw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691746613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3ZYjFfz1bwCo59gNGTrSPl6TjkdV/FBgZNeoD4PLlQI=; b=LluljunDprMFkeyznxgdeA/pyAnX8KjdCMywa/7YAQSySJQzgtjEZs5ncuQFTzvqJyHeTK g5Z5biqD4RwA0bBw== To: Peter Zijlstra Cc: LKML , x86@kernel.org, Borislav Petkov , Ashok Raj , Arjan van de Ven Subject: Re: [patch 28/30] x86/microcode: Handle "offline" CPUs correctly In-Reply-To: <20230810204605.GF212435@hirez.programming.kicks-ass.net> References: <20230810153317.850017756@linutronix.de> <20230810160806.562016788@linutronix.de> <20230810204605.GF212435@hirez.programming.kicks-ass.net> Date: Fri, 11 Aug 2023 11:36:53 +0200 Message-ID: <874jl5j4y2.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 Thu, Aug 10 2023 at 22:46, Peter Zijlstra wrote: > On Thu, Aug 10, 2023 at 08:38:07PM +0200, Thomas Gleixner wrote: > >> for_each_cpu_and(cpu, cpu_present_mask, &cpus_booted_once_mask) { >> + /* >> + * Offline CPUs sit in one of the play_dead() functions >> + * with interrupts disabled, but they still react on NMIs >> + * and execute arbitrary code. Also MWAIT being updated >> + * while the offline CPU sits there is not necessarily safe >> + * on all CPU variants. >> + * >> + * Mark them in the offline_cpus mask which will be handled >> + * by CPU0 later in the update process. >> + * >> + * Ensure that the primary thread is online so that it is >> + * guaranteed that all cores are updated. >> + */ >> if (!cpu_online(cpu)) { >> + if (topology_is_primary_thread(cpu) || !allow_smt_offline) { >> + pr_err("CPU %u not online, loading aborted\n", cpu); > > We could make the NMI handler do the ucode load, no? Also, you just need > any thread online, don't particularly care about primary thread or not > afaict. Yes, we could. But I did not go there because it's a fricking nightmare vs. the offline state and noinstr. OTOH, it's not really required. Right now we mandate that _all_ present cores have at least one sibling online. For simplicity (and practical reasons - think "nosmt") we require the "primary" thread to be online. Microcode is strict per core, no matter how many threads are there. We would not need any of this mess if Intel would have synchronized the threads on microcode update like AMD does. This is coming with future CPUs which advertise "uniform" update with a scope ranging from core, package to systemwide. Even today, the only exercise what online SMT siblings do after the primary thread updated the microcode is verification that update happened which creates consistent software state. But in principle the secondaries could just do nothing and everything would work (+/- hardware,firmware bugs). Sure we could lift that requirement, but why making this horrorshow even more complex than it is already ? There is zero point to support esoteric usecases just because we can. The realistic use case is a server with all threads online or SMT disabled via command line or sysfs. Anything else is just a pointless exercise. Thanks, tglx