Merge tag 'for-linus-6.9a-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 May 2024 19:10:41 +0000 (12:10 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 May 2024 19:10:41 +0000 (12:10 -0700)
Pull xen fixes from Juergen Gross:
 "Two fixes when running as Xen PV guests for issues introduced in the
  6.9 merge window, both related to apic id handling"

* tag 'for-linus-6.9a-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  x86/xen: return a sane initial apic id when running as PV guest
  x86/xen/smp_pv: Register the boot CPU APIC properly

arch/x86/xen/enlighten_pv.c
arch/x86/xen/smp_pv.c

index ace2eb054053f95e53ac43992d9b778335e68748..9ba53814ed6a9e392b60c53477246977d649f20e 100644 (file)
@@ -219,13 +219,21 @@ static __read_mostly unsigned int cpuid_leaf5_edx_val;
 static void xen_cpuid(unsigned int *ax, unsigned int *bx,
                      unsigned int *cx, unsigned int *dx)
 {
-       unsigned maskebx = ~0;
+       unsigned int maskebx = ~0;
+       unsigned int or_ebx = 0;
 
        /*
         * Mask out inconvenient features, to try and disable as many
         * unsupported kernel subsystems as possible.
         */
        switch (*ax) {
+       case 0x1:
+               /* Replace initial APIC ID in bits 24-31 of EBX. */
+               /* See xen_pv_smp_config() for related topology preparations. */
+               maskebx = 0x00ffffff;
+               or_ebx = smp_processor_id() << 24;
+               break;
+
        case CPUID_MWAIT_LEAF:
                /* Synthesize the values.. */
                *ax = 0;
@@ -248,6 +256,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
                : "0" (*ax), "2" (*cx));
 
        *bx &= maskebx;
+       *bx |= or_ebx;
 }
 
 static bool __init xen_check_mwait(void)
index 27d1a5b7f571a3487cfa68a037e51516a6b9b287..ac41d83b38d3c49d3116dff58d5998a5fe9efb62 100644 (file)
@@ -154,9 +154,9 @@ static void __init xen_pv_smp_config(void)
        u32 apicid = 0;
        int i;
 
-       topology_register_boot_apic(apicid++);
+       topology_register_boot_apic(apicid);
 
-       for (i = 1; i < nr_cpu_ids; i++)
+       for (i = 0; i < nr_cpu_ids; i++)
                topology_register_apic(apicid++, CPU_ACPIID_INVALID, true);
 
        /* Pretend to be a proper enumerated system */