Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1884048rda; Tue, 24 Oct 2023 06:23:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoGGmQ8m3eNE4TABpYQbYdPUYOMlCKzqDv/pp4g2NDVvvdSWb+U+FCJ+w/UzUwE+ltUlXf X-Received: by 2002:a17:902:f944:b0:1bd:c7e2:462 with SMTP id kx4-20020a170902f94400b001bdc7e20462mr8485498plb.11.1698153824866; Tue, 24 Oct 2023 06:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698153824; cv=none; d=google.com; s=arc-20160816; b=KF3ppIad1KetVfbhR0xC+eAaaersZMqgu0lUsaJNIacwrF0Hwnh7bJf/RprX+VESfT 9IZHw14hzFxBB/e9XssSnnMNac1EtkpqTe4ZLxy7+jk5L4VpOyB4bUJMN1RuFCtaU9Ii tq4rc/tWcOdzvQvdWDyDfCjX/Filg+ZxxjB9/PcvMx61F23TF7UXpsBkK+UsXwVEy/Pi hg45J03lZt9YZb/JT5rO36V00jpnfbwlfqSwqlWgzpvQsyHc2My1BJxe23gfPzv74CTS /wGgQ9KdmtYFuFtQJq73LxLGbqJevaxMlSEbmc2aWjMzA6dVF7Im+z0QtcIxEeJIlj+d PabA== 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=vw8iqs9QsHpfzltom5MR2q4mLnKifyKOmiEkeG+S3lw=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=GYIWoGDYqygYnKOvfKFpV9UrBVdv5Zle+T2gEC7pN9EJjJZ5fwI9yb7bGUSWLLXUII 6XMCfRnn2qOckNCavXmu2LP1GD7hgHp6jLHL/vbme6Mpb+6wm6Tn8asxzTvfuK3O/PRz fSrtBnb9SGfxqpWoTBS8vS7HDYLrFGna1fjlqZt+EMXylEGH/4QzzOdQX0U2QuwhiBV9 tFVXGXjQIIYK8SFG3bXUftNiLp4Srv/AZbkWsdqcIJkzKBI/W0vlm74Qlyr9n3X82lE4 cahY+YFxuBkCt1BGQYlvBn6WACI5NsWfiFZXyqMiZi9zDxXNM7tyf3gDYydfQtNRPyPC K57w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KivRIFaD; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t23-20020a1709028c9700b001c60783985esi8543960plo.93.2023.10.24.06.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 06:23:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KivRIFaD; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 2C34C80785CE; Tue, 24 Oct 2023 06:23:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234512AbjJXNWC (ORCPT + 99 others); Tue, 24 Oct 2023 09:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234587AbjJXNVO (ORCPT ); Tue, 24 Oct 2023 09:21:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FDD510C2; Tue, 24 Oct 2023 06:20:56 -0700 (PDT) Date: Tue, 24 Oct 2023 13:20:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698153655; 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=vw8iqs9QsHpfzltom5MR2q4mLnKifyKOmiEkeG+S3lw=; b=KivRIFaDSOR7ggKVZpynIX7t0yeSQsxyya9TuC3DpNXw5PMwc0m9M3RB6BP1L46v1RLyQz Ejy2HRtHpr3FEkyU8WUi6fYlRSO+koJxSUtRblNIu8+INxmfruUC96Cg985jCRQ9WaskeA 9I4882CfYf6ZooqMs8+lpSnx9Jg/9UbuN3y5ecTkw7ScYwXDPERRClBK8AQJn0r5d7ovg4 MRxJiHPsxGkiBaTToX30GxAeNNRD2xSXnPj47R8vIc9khrPjJzTaRerBBf3/JEle+tYAId 7z4Ch2Tt0FhA2s9lKmld8T+yDSWqyHB1gXM3KEtJINUWXX3QZtZSP5wTxqKAgw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698153655; 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=vw8iqs9QsHpfzltom5MR2q4mLnKifyKOmiEkeG+S3lw=; b=O1PJheN8bBG8sCAOVIJWut+bMSC/MtAVNcoyfci9oraJCO+6VgVF2ia4WHYFAXmzi7byq9 Hevtvvf7wBaPnjBw== 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: Add per CPU control field Cc: Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231002115903.319959519@linutronix.de> References: <20231002115903.319959519@linutronix.de> MIME-Version: 1.0 Message-ID: <169815365431.3135.1927037057530742543.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=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 06:23:31 -0700 (PDT) The following commit has been merged into the x86/microcode branch of tip: Commit-ID: ba3aeb97cb2c53025356f31c5a0a294385194115 Gitweb: https://git.kernel.org/tip/ba3aeb97cb2c53025356f31c5a0a294385194115 Author: Thomas Gleixner AuthorDate: Mon, 02 Oct 2023 14:00:01 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 24 Oct 2023 15:05:54 +02:00 x86/microcode: Add per CPU control field Add a per CPU control field to ucode_ctrl and define constants for it which are going to be used to control the loading state machine. In theory this could be a global control field, but a global control does not cover the following case: 15 primary CPUs load microcode successfully 1 primary CPU fails and returns with an error code With global control the sibling of the failed CPU would either try again or the whole operation would be aborted with the consequence that the 15 siblings do not invoke the apply path and end up with inconsistent software state. The result in dmesg would be inconsistent too. There are two additional fields added and initialized: ctrl_cpu and secondaries. ctrl_cpu is the CPU number of the primary thread for now, but with the upcoming uniform loading at package or system scope this will be one CPU per package or just one CPU. Secondaries hands the control CPU a CPU mask which will be required to release the secondary CPUs out of the wait loop. Preparatory change for implementing a properly split control flow for primary and secondary CPUs. Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231002115903.319959519@linutronix.de --- arch/x86/kernel/cpu/microcode/core.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 67b8932..001c004 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -252,8 +252,19 @@ static struct platform_device *microcode_pdev; * requirement can be relaxed in the future. Right now, this is conservative * and good. */ +enum sibling_ctrl { + /* Spinwait with timeout */ + SCTRL_WAIT, + /* Invoke the microcode_apply() callback */ + SCTRL_APPLY, + /* Proceed without invoking the microcode_apply() callback */ + SCTRL_DONE, +}; + struct microcode_ctrl { + enum sibling_ctrl ctrl; enum ucode_state result; + unsigned int ctrl_cpu; }; static DEFINE_PER_CPU(struct microcode_ctrl, ucode_ctrl); @@ -398,7 +409,7 @@ static int load_late_stop_cpus(void) */ static bool setup_cpus(void) { - struct microcode_ctrl ctrl = { .result = -1, }; + struct microcode_ctrl ctrl = { .ctrl = SCTRL_WAIT, .result = -1, }; unsigned int cpu; for_each_cpu_and(cpu, cpu_present_mask, &cpus_booted_once_mask) { @@ -408,7 +419,12 @@ static bool setup_cpus(void) return false; } } - /* Initialize the per CPU state */ + + /* + * Initialize the per CPU state. This is core scope for now, + * but prepared to take package or system scope into account. + */ + ctrl.ctrl_cpu = cpumask_first(topology_sibling_cpumask(cpu)); per_cpu(ucode_ctrl, cpu) = ctrl; } return true;