From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: <linux-kernel@vger.kernel.org>, <x86@kernel.org>,
<tglx@linutronix.de>, <mingo@redhat.com>,
<dave.hansen@linux.intel.com>, <chao.gao@intel.com>,
<abusse@amazon.de>, <tony.luck@intel.com>
Subject: Re: [PATCH v6 3/7] x86/microcode/intel: Establish staging control logic
Date: Mon, 13 Oct 2025 14:16:27 -0700 [thread overview]
Message-ID: <faead017-128f-4d63-9552-82b536ea7612@intel.com> (raw)
In-Reply-To: <20251013134250.GAaO0B2rb_smA83z32@fat_crate.local>
[-- Attachment #1: Type: text/plain, Size: 809 bytes --]
On 10/13/2025 6:42 AM, Borislav Petkov wrote:
>
> Fixups ontop:
Thanks!
> diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
> index daae74858347..216595a45564 100644
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> @@ -315,15 +315,18 @@ static void stage_microcode(void)
> int cpu, err;
> u64 mmio_pa;
>
> - if (!IS_ALIGNED(get_totalsize(&ucode_patch_late->hdr), sizeof(u32)))
> + if (!IS_ALIGNED(get_totalsize(&ucode_patch_late->hdr), sizeof(u32))) {
> + pr_err("Microcode image 32-bit misaligned (0x%x), staging failed.\n",
> + get_totalsize(&ucode_patch_late->hdr));
> return;
> + }
Yeah, need to keep in mind more consistent about emitting error messages
in this area.
Include the updated patch:
[-- Attachment #2: PATCH6a-x86-microcode-intel-Establish-staging-control-logic.patch --]
[-- Type: text/plain, Size: 3852 bytes --]
From 809f1845cf76023f97b8f9c03dd8e10fdda2aac6 Mon Sep 17 00:00:00 2001
From: "Chang S. Bae" <chang.seok.bae@intel.com>
Date: Fri, 15 Mar 2024 23:05:34 -0700
Subject: [PATCH v6a 3/7] x86/microcode/intel: Establish staging control logic
When microcode staging is initiated, operations are carried out through
an MMIO interface. Each package has a unique interface specified by the
IA32_MCU_STAGING_MBOX_ADDR MSR, which maps to a set of 32-bit registers.
Prepare staging with the following steps:
1. Ensure the microcode image is 32-bit aligned to match the MMIO
register size.
2. Identify each MMIO interface based on its per-package scope.
3. Invoke the staging function for each identified interface, which
will be implemented separately.
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Tested-by: Anselm Busse <abusse@amazon.de>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/all/871pznq229.ffs@tglx
---
V6 -> V6a:
* Add an error message for misaligned image size (Boris)
* Fix typo: id -> ID (Boris)
* Shorten the error code printout (Boris)
---
arch/x86/include/asm/msr-index.h | 2 ++
arch/x86/kernel/cpu/microcode/intel.c | 51 +++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 718a55d82fe4..0736e44f7c69 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -1222,6 +1222,8 @@
#define MSR_IA32_VMX_VMFUNC 0x00000491
#define MSR_IA32_VMX_PROCBASED_CTLS3 0x00000492
+#define MSR_IA32_MCU_STAGING_MBOX_ADDR 0x000007a5
+
/* Resctrl MSRs: */
/* - Intel: */
#define MSR_IA32_L3_QOS_CFG 0xc81
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 371ca6eac00e..216595a45564 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -299,6 +299,56 @@ static __init struct microcode_intel *scan_microcode(void *data, size_t size,
return size ? NULL : patch;
}
+/*
+ * Handle the staging process using the mailbox MMIO interface.
+ * Return 0 on success or an error code on failure.
+ */
+static int do_stage(u64 mmio_pa)
+{
+ pr_debug_once("Staging implementation is pending.\n");
+ return -EPROTONOSUPPORT;
+}
+
+static void stage_microcode(void)
+{
+ unsigned int pkg_id = UINT_MAX;
+ int cpu, err;
+ u64 mmio_pa;
+
+ if (!IS_ALIGNED(get_totalsize(&ucode_patch_late->hdr), sizeof(u32))) {
+ pr_err("Microcode image 32-bit misaligned (0x%x), staging failed.\n",
+ get_totalsize(&ucode_patch_late->hdr));
+ return;
+ }
+
+ lockdep_assert_cpus_held();
+
+ /*
+ * The MMIO address is unique per package, and all the SMT
+ * primary threads are online here. Find each MMIO space by
+ * their package IDs to avoid duplicate staging.
+ */
+ for_each_cpu(cpu, cpu_primary_thread_mask) {
+ if (topology_logical_package_id(cpu) == pkg_id)
+ continue;
+
+ pkg_id = topology_logical_package_id(cpu);
+
+ err = rdmsrq_on_cpu(cpu, MSR_IA32_MCU_STAGING_MBOX_ADDR, &mmio_pa);
+ if (WARN_ON_ONCE(err))
+ return;
+
+ err = do_stage(mmio_pa);
+ if (err) {
+ pr_err("Error: staging failed (%d) for CPU%d at package %u.\n",
+ err, cpu, pkg_id);
+ return;
+ }
+ }
+
+ pr_info("Staging of patch revision 0x%x succeeded.\n", ucode_patch_late->hdr.rev);
+}
+
static enum ucode_state __apply_microcode(struct ucode_cpu_info *uci,
struct microcode_intel *mc,
u32 *cur_rev)
@@ -627,6 +677,7 @@ static struct microcode_ops microcode_intel_ops = {
.collect_cpu_info = collect_cpu_info,
.apply_microcode = apply_microcode_late,
.finalize_late_load = finalize_late_load,
+ .stage_microcode = stage_microcode,
.use_nmi = IS_ENABLED(CONFIG_X86_64),
};
--
2.48.1
next prev parent reply other threads:[~2025-10-13 21:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-21 22:48 [PATCH v6 0/7] x86: Support for Intel Microcode Staging Feature Chang S. Bae
2025-09-21 22:48 ` [PATCH v6 1/7] x86/cpu/topology: Make primary thread mask available with SMP=n Chang S. Bae
2025-10-15 16:52 ` [tip: x86/microcode] " tip-bot2 for Chang S. Bae
2025-09-21 22:48 ` [PATCH v6 2/7] x86/microcode: Introduce staging step to reduce late-loading time Chang S. Bae
2025-10-15 16:52 ` [tip: x86/microcode] " tip-bot2 for Chang S. Bae
2025-09-21 22:48 ` [PATCH v6 3/7] x86/microcode/intel: Establish staging control logic Chang S. Bae
2025-10-13 13:42 ` Borislav Petkov
2025-10-13 21:16 ` Chang S. Bae [this message]
2025-10-15 16:52 ` [tip: x86/microcode] " tip-bot2 for Chang S. Bae
2025-09-21 22:48 ` [PATCH v6 4/7] x86/microcode/intel: Define staging state struct Chang S. Bae
2025-10-15 16:52 ` [tip: x86/microcode] " tip-bot2 for Chang S. Bae
2025-09-21 22:48 ` [PATCH v6 5/7] x86/microcode/intel: Implement staging handler Chang S. Bae
2025-10-15 16:52 ` [tip: x86/microcode] " tip-bot2 for Chang S. Bae
2025-09-21 22:48 ` [PATCH v6 6/7] x86/microcode/intel: Support mailbox transfer Chang S. Bae
2025-10-15 16:52 ` [tip: x86/microcode] " tip-bot2 for Chang S. Bae
2025-09-21 22:48 ` [PATCH v6 7/7] x86/microcode/intel: Enable staging when available Chang S. Bae
2025-10-15 16:52 ` [tip: x86/microcode] " tip-bot2 for Chang S. Bae
2025-09-22 13:09 ` [PATCH v6 0/7] x86: Support for Intel Microcode Staging Feature Borislav Petkov
2025-09-22 19:53 ` Chang S. Bae
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=faead017-128f-4d63-9552-82b536ea7612@intel.com \
--to=chang.seok.bae@intel.com \
--cc=abusse@amazon.de \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox