[tip: x86/cpu] x86/cpu: Factor init_cpu_info() out of identify_cpu()
From: tip-bot2 for Ihor Solodrai
Date: Wed Sep 16 2026 - 22:06:16 EST
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 54a2882ab9f75ab8a77a4f113145d4d709d2387c
Gitweb: https://git.kernel.org/tip/54a2882ab9f75ab8a77a4f113145d4d709d2387c
Author: Ihor Solodrai <ihor.solodrai@xxxxxxxxx>
AuthorDate: Wed, 16 Sep 2026 12:51:59 -07:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Thu, 17 Sep 2026 01:54:28 +02:00
x86/cpu: Factor init_cpu_info() out of identify_cpu()
identify_cpu() unconditionally resets the struct cpuinfo_x86 fields to
their default values and clears the capability arrays with memset()
before rescanning the CPU to fill it in again.
However the boot CPU capabilities have already been scanned by
early_identify_cpu(), with interrupts disabled.
Introduce init_cpu_info() helper in preparation for letting the
callers decide whether the reset is needed.
No functional changes.
Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Link: https://patch.msgid.link/20260916195203.1099646-2-ihor.solodrai@xxxxxxxxx
---
arch/x86/kernel/cpu/common.c | 51 +++++++++++++++++++----------------
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 3716a6a..173748a 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1784,6 +1784,32 @@ static void __init cpu_parse_early_param(void)
}
}
+static void init_cpu_info(struct cpuinfo_x86 *c)
+{
+ c->x86_cache_size = 0;
+ c->x86_vendor = X86_VENDOR_UNKNOWN;
+ c->x86_model = c->x86_stepping = 0; /* So far unknown... */
+ c->x86_vendor_id[0] = '\0'; /* Unset */
+ c->x86_model_id[0] = '\0'; /* Unset */
+#ifdef CONFIG_X86_64
+ c->x86_clflush_size = 64;
+ c->x86_phys_bits = 36;
+ c->x86_virt_bits = 48;
+#else
+ c->cpuid_level = -1; /* CPUID not detected */
+ c->x86_clflush_size = 32;
+ c->x86_phys_bits = 32;
+ c->x86_virt_bits = 32;
+#endif
+ c->x86_cache_alignment = c->x86_clflush_size;
+ memset(&c->x86_capability, 0, sizeof(c->x86_capability));
+ memset(&c->cpuid, 0, sizeof(c->cpuid));
+#ifdef CONFIG_X86_VMX_FEATURE_NAMES
+ memset(&c->vmx_capability, 0, sizeof(c->vmx_capability));
+#endif
+ c->extended_cpuid_level = 0;
+}
+
/*
* Do minimum CPU detection early.
* Fields really needed: vendor, cpuid_level, family, model, mask,
@@ -1968,8 +1994,6 @@ void check_null_seg_clears_base(struct cpuinfo_x86 *c)
static void generic_identify(struct cpuinfo_x86 *c)
{
- c->extended_cpuid_level = 0;
-
if (!cpuid_feature())
identify_cpu_without_cpuid(c);
@@ -2013,27 +2037,8 @@ static void identify_cpu(struct cpuinfo_x86 *c)
int i;
c->loops_per_jiffy = loops_per_jiffy;
- c->x86_cache_size = 0;
- c->x86_vendor = X86_VENDOR_UNKNOWN;
- c->x86_model = c->x86_stepping = 0; /* So far unknown... */
- c->x86_vendor_id[0] = '\0'; /* Unset */
- c->x86_model_id[0] = '\0'; /* Unset */
-#ifdef CONFIG_X86_64
- c->x86_clflush_size = 64;
- c->x86_phys_bits = 36;
- c->x86_virt_bits = 48;
-#else
- c->cpuid_level = -1; /* CPUID not detected */
- c->x86_clflush_size = 32;
- c->x86_phys_bits = 32;
- c->x86_virt_bits = 32;
-#endif
- c->x86_cache_alignment = c->x86_clflush_size;
- memset(&c->x86_capability, 0, sizeof(c->x86_capability));
- memset(&c->cpuid, 0, sizeof(c->cpuid));
-#ifdef CONFIG_X86_VMX_FEATURE_NAMES
- memset(&c->vmx_capability, 0, sizeof(c->vmx_capability));
-#endif
+
+ init_cpu_info(c);
generic_identify(c);