Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1882918rda; Tue, 24 Oct 2023 06:22:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlAi2xsfotrYQNA6aCb2/FVQQez+ildNTczTf0PPyaT3t1GDRAw5cB3kl6jODFiVbhDw6e X-Received: by 2002:a05:6359:2e0d:b0:168:d387:d2cb with SMTP id ro13-20020a0563592e0d00b00168d387d2cbmr5692083rwb.9.1698153724173; Tue, 24 Oct 2023 06:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698153724; cv=none; d=google.com; s=arc-20160816; b=Ol7CAfLShCEZsjkZGCXIH5R0MBmkvWhDxgT9pIXglXgQ5TScxq/9Nye4CQXa2ku5y0 xgMJtLrIXf6TI1gL9Mr+CgKqMar7xnB+iiMwJkl14iN6c2AfyKq5DzIcb27/anA8pjhq yMH0LXhv5o8aLxNacnJSdWBidAHBgg0oZ/OvM4/Ab6D1MpyA/UYj5R3MSMh/+W7Ssf5y zuY3PyhUon+Z5xpC/wieBK2wo60AWR1Q8XOrYVmq9UsQLOWhAWXyH/e8oD1puyj5sr3t eIMzZsKoLiZhtUq3Sl1tydAO2bFm+vSAoR3OuluM04ztl6IxaatoaqiUTbT2Tem3sano UQTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=3HRwjwSDCstpcUBGnUCVNfDdoW5MMSv2b52r2sciB7A=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=Bgd4iPDhs29lgqFZs48W7aiQGes7zX4U+Pdst8NaiE4Oa+qt7skhC5DqpxBuqJvPoZ jAa/9C1HfWtPtm+TrsJa+cakm7XgJBFB41fRMPab7Qh8BG5Mri0OEnNd55b9QZ/XiGSe KEEU0Jxn0+PZI7arZGCN1knB6lNsKGmPOQLxAKIm6wGDeoARDN79pBqqkoXVAz1L64mR y2qiiouf8cOzOkraq+w9rU6lFQDa58BRypHO3F5KBRWiES/JfPIIRkKSTTGYmazdE9sH fM/EWsDGUNH1LSFj0+RzYrKhgvNxzsOoWQOyzJnMtQAroWgzKzrWLykZlwK4/iT6w4cL FJfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YimTm0OG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=QUZrUBsK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bq8-20020a056a02044800b005b57aa8517bsi9225004pgb.91.2023.10.24.06.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 06:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YimTm0OG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=QUZrUBsK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EC8A8802C7C3; Tue, 24 Oct 2023 06:22:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234562AbjJXNVu (ORCPT + 99 others); Tue, 24 Oct 2023 09:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234544AbjJXNVA (ORCPT ); Tue, 24 Oct 2023 09:21:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C2D210C9; Tue, 24 Oct 2023 06:20:55 -0700 (PDT) Date: Tue, 24 Oct 2023 13:20:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698153653; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3HRwjwSDCstpcUBGnUCVNfDdoW5MMSv2b52r2sciB7A=; b=YimTm0OGQ041F0Qu+ap0GIA+LuMAU3sF8JLC6k1pMKa01nPyN+R/hzB281ajncmk6WMMFb 4pmCse7kmGaZhtbqMuqm4Aw7+HOhCfR6RiLMlni3hIFKr5s5ZrErG42TgfnyklbsVgZEsa OtnPwhnvIHf8P41TRSl4wJ5xNzSQWl7HVLeiOhE3wdnBXY58EGSbRKgsnO0dVlLOdjGPat IgNmGp2w7gMKnHxoznBD/SDzXOEX8g2BNBx60kmya7Ui9AXg60jhK+hL0aNk254mlhkoKo 0j8ecAx/X1yA++u44fMHjRKwe1HtDN4CQGKjAbkqW8m9K8JZgVygs04eSG5Uxw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698153653; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3HRwjwSDCstpcUBGnUCVNfDdoW5MMSv2b52r2sciB7A=; b=QUZrUBsKTZ7sLz30pmCEhinra6QmHudUvo7TSRht0/KYQcj02CP/PJ8FW8oiZzTfhOKQft /wDlgXPyvlGUzfDw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/microcode] x86/microcode: Replace the all-in-one rendevous handler Cc: Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231002115903.433704135@linutronix.de> References: <20231002115903.433704135@linutronix.de> MIME-Version: 1.0 Message-ID: <169815365245.3135.13257369178148876293.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 06:22:03 -0700 (PDT) The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 0bf871651211b58c7b19f40b746b646d5311e2ec Gitweb: https://git.kernel.org/tip/0bf871651211b58c7b19f40b746b646d5311e2ec Author: Thomas Gleixner AuthorDate: Mon, 02 Oct 2023 14:00:03 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 24 Oct 2023 15:05:55 +02:00 x86/microcode: Replace the all-in-one rendevous handler with a new handler which just separates the control flow of primary and secondary CPUs. Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231002115903.433704135@linutronix.de --- arch/x86/kernel/cpu/microcode/core.c | 51 ++++----------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 1ff38f9..1c2710b 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -268,7 +268,7 @@ struct microcode_ctrl { }; static DEFINE_PER_CPU(struct microcode_ctrl, ucode_ctrl); -static atomic_t late_cpus_in, late_cpus_out; +static atomic_t late_cpus_in; static bool wait_for_cpus(atomic_t *cnt) { @@ -304,7 +304,7 @@ static bool wait_for_ctrl(void) return false; } -static __maybe_unused void load_secondary(unsigned int cpu) +static void load_secondary(unsigned int cpu) { unsigned int ctrl_cpu = this_cpu_read(ucode_ctrl.ctrl_cpu); enum ucode_state ret; @@ -339,7 +339,7 @@ static __maybe_unused void load_secondary(unsigned int cpu) this_cpu_write(ucode_ctrl.ctrl, SCTRL_DONE); } -static __maybe_unused void load_primary(unsigned int cpu) +static void load_primary(unsigned int cpu) { struct cpumask *secondaries = topology_sibling_cpumask(cpu); enum sibling_ctrl ctrl; @@ -376,46 +376,14 @@ static __maybe_unused void load_primary(unsigned int cpu) static int load_cpus_stopped(void *unused) { - int cpu = smp_processor_id(); - enum ucode_state ret; - - /* - * Wait for all CPUs to arrive. A load will not be attempted unless all - * CPUs show up. - * */ - if (!wait_for_cpus(&late_cpus_in)) { - this_cpu_write(ucode_ctrl.result, UCODE_TIMEOUT); - return 0; - } - - /* - * On an SMT system, it suffices to load the microcode on one sibling of - * the core because the microcode engine is shared between the threads. - * Synchronization still needs to take place so that no concurrent - * loading attempts happen on multiple threads of an SMT core. See - * below. - */ - if (cpumask_first(topology_sibling_cpumask(cpu)) != cpu) - goto wait_for_siblings; + unsigned int cpu = smp_processor_id(); - ret = microcode_ops->apply_microcode(cpu); - this_cpu_write(ucode_ctrl.result, ret); - -wait_for_siblings: - if (!wait_for_cpus(&late_cpus_out)) - panic("Timeout during microcode update!\n"); - - /* - * At least one thread has completed update on each core. - * For others, simply call the update to make sure the - * per-cpu cpuinfo can be updated with right microcode - * revision. - */ - if (cpumask_first(topology_sibling_cpumask(cpu)) == cpu) - return 0; + if (this_cpu_read(ucode_ctrl.ctrl_cpu) == cpu) + load_primary(cpu); + else + load_secondary(cpu); - ret = microcode_ops->apply_microcode(cpu); - this_cpu_write(ucode_ctrl.result, ret); + /* No point to wait here. The CPUs will all wait in stop_machine(). */ return 0; } @@ -429,7 +397,6 @@ static int load_late_stop_cpus(void) pr_err("You should switch to early loading, if possible.\n"); atomic_set(&late_cpus_in, num_online_cpus()); - atomic_set(&late_cpus_out, num_online_cpus()); /* * Take a snapshot before the microcode update in order to compare and