[PATCH 05/16] x86/cpu: Move per-CPU actions out of the vendor early_init() hook

Andrew Cooper posted 16 patches 1 week, 4 days ago
[PATCH 05/16] x86/cpu: Move per-CPU actions out of the vendor early_init() hook
Posted by Andrew Cooper 1 week, 4 days ago
cpu_dev.c_early_init() and .c_init() is a spilt we inherited from Linux.

In Xen, these are called moments apart in identify_cpu().  The only logic
between the two calls is filling part of c->x86_capability[] and collecting
the the long model name.

We are going to want to repurpose .c_early_init() somewhat, so move the logic
wanting running on all CPUs to the .c_init() hook, which is only marginally
later.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Julian Vetter <julian.vetter@vates.tech>
CC: Teddy Astie <teddy.astie@vates.tech>
---
 xen/arch/x86/cpu/amd.c   |  4 ++--
 xen/arch/x86/cpu/hygon.c |  2 ++
 xen/arch/x86/cpu/intel.c | 12 ++++++------
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index fc496dc43e08..970cb42e9e0b 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -621,8 +621,6 @@ void cf_check early_init_amd(struct cpuinfo_x86 *c)
 {
 	if (c == &boot_cpu_data)
 		amd_init_levelling();
-
-	ctxt_switch_levelling(NULL);
 }
 
 void amd_log_freq(const struct cpuinfo_x86 *c)
@@ -1018,6 +1016,8 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	u32 l, h;
 	uint64_t value;
 
+	ctxt_switch_levelling(NULL);
+
 	amd_init_de_cfg(c);
 
 	if (c == &boot_cpu_data)
diff --git a/xen/arch/x86/cpu/hygon.c b/xen/arch/x86/cpu/hygon.c
index b99d83ed4d75..bb1624882499 100644
--- a/xen/arch/x86/cpu/hygon.c
+++ b/xen/arch/x86/cpu/hygon.c
@@ -32,6 +32,8 @@ static void cf_check init_hygon(struct cpuinfo_x86 *c)
 {
 	unsigned long long value;
 
+	ctxt_switch_levelling(NULL);
+
 	amd_init_de_cfg(c);
 
 	if (c == &boot_cpu_data)
diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index eec6ee763040..141dc2368143 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -327,10 +327,6 @@ void __init intel_unlock_cpuid_leaves(struct cpuinfo_x86 *c)
 
 static void cf_check early_init_intel(struct cpuinfo_x86 *c)
 {
-	/* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
-	if (c->x86 == 15 && c->x86_cache_alignment == 64)
-		c->x86_cache_alignment = 128;
-
 	if (c == &boot_cpu_data &&
 	    bootsym(trampoline_misc_enable_off) & MSR_IA32_MISC_ENABLE_XD_DISABLE)
 		printk(KERN_INFO "re-enabled NX (Execute Disable) protection\n");
@@ -350,8 +346,6 @@ static void cf_check early_init_intel(struct cpuinfo_x86 *c)
 
 		intel_init_levelling();
 	}
-
-	ctxt_switch_levelling(NULL);
 }
 
 /*
@@ -615,6 +609,12 @@ static void init_intel_perf(struct cpuinfo_x86 *c)
 
 static void cf_check init_intel(struct cpuinfo_x86 *c)
 {
+	/* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */
+	if (c->x86 == 15 && c->x86_cache_alignment == 64)
+		c->x86_cache_alignment = 128;
+
+	ctxt_switch_levelling(NULL);
+
 	/* Detect the extended topology information if available */
 	detect_extended_topology(c);
 
-- 
2.39.5


Re: [PATCH 05/16] x86/cpu: Move per-CPU actions out of the vendor early_init() hook
Posted by Jan Beulich 1 week, 3 days ago
On 26.01.2026 18:53, Andrew Cooper wrote:
> cpu_dev.c_early_init() and .c_init() is a spilt we inherited from Linux.
> 
> In Xen, these are called moments apart in identify_cpu().  The only logic
> between the two calls is filling part of c->x86_capability[] and collecting
> the the long model name.
> 
> We are going to want to repurpose .c_early_init() somewhat, so move the logic
> wanting running on all CPUs to the .c_init() hook, which is only marginally
> later.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>