]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
arch/x86/smp: drop booting_cpu variable
authorKrystian Hebel <krystian.hebel@3mdeb.com>
Tue, 13 Jun 2023 16:58:21 +0000 (18:58 +0200)
committerKrystian Hebel <krystian.hebel@3mdeb.com>
Fri, 26 Apr 2024 16:11:00 +0000 (18:11 +0200)
CPU id is obtained as a side effect of searching for appropriate
stack for AP. It can be used as a parameter to start_secondary().
Coincidentally this also makes further work on making AP bring-up
code parallel easier.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
xen/arch/x86/boot/x86_64.S
xen/arch/x86/smpboot.c

index 61040315f9dcd262fea764e204c7cb1f88bddbf4..a5f1f681c9f09be7a7cf03604775267cae2dd5ac 100644 (file)
@@ -20,20 +20,24 @@ ENTRY(__high_start)
         jz      .L_stack_set
 
         /* APs only: get stack base from APIC ID saved in %esp. */
-        mov     $0, %rax
+        mov     $0, %rbx
         lea     cpu_data(%rip), %rcx
         /* cpu_data[0] is BSP, skip it. */
 1:
-        add     $1, %rax
+        add     $1, %rbx
         add     $CPUINFO_X86_sizeof, %rcx
-        cmp     $NR_CPUS, %eax
+        cmp     $NR_CPUS, %rbx
         jb      2f
         hlt
 2:
         cmp     %esp, CPUINFO_X86_apicid(%rcx)
         jne     1b
 
-        /* %rcx is now cpu_data[cpu], read stack base from it. */
+        /*
+         * At this point:
+         * - %rcx is cpu_data[cpu], read stack base from it,
+         * - %rbx (callee-save) is Xen cpu number, pass it to start_secondary().
+         */
         mov     CPUINFO_X86_stack_base(%rcx), %rsp
 
         test    %rsp,%rsp
@@ -101,6 +105,7 @@ ENTRY(__high_start)
 .L_ap_cet_done:
 #endif /* CONFIG_XEN_SHSTK || CONFIG_XEN_IBT */
 
+        mov     %rbx, %rdi
         call    start_secondary
         BUG     /* start_secondary() shouldn't return. */
 
index a0fc6bd3e077681bc5ad7a78241b477c3e20866e..87587b489acac2e513b4002c1093e2dbf20ba9a0 100644 (file)
@@ -234,8 +234,6 @@ static void smp_callin(void)
         cpu_relax();
 }
 
-static int booting_cpu;
-
 /* CPUs for which sibling maps can be computed. */
 static cpumask_t cpu_sibling_setup_map;
 
@@ -323,15 +321,14 @@ static void set_cpu_sibling_map(unsigned int cpu)
     }
 }
 
-void start_secondary(void *unused)
+void start_secondary(unsigned int cpu)
 {
     struct cpu_info *info = get_cpu_info();
 
     /*
-     * Dont put anything before smp_callin(), SMP booting is so fragile that we
+     * Don't put anything before smp_callin(), SMP booting is so fragile that we
      * want to limit the things done here to the most necessary things.
      */
-    unsigned int cpu = booting_cpu;
 
     if ( slaunch_active ) {
         uint64_t misc_enable;
@@ -352,7 +349,6 @@ void start_secondary(void *unused)
             asm volatile ("monitor; xor %0,%0; mwait"
                           :: "a"(__va(sinit_mle->rlp_wakeup_addr)), "c"(0),
                           "d"(0) : "memory");
-            cpu = booting_cpu;
         }
     }
 
@@ -381,9 +377,9 @@ void start_secondary(void *unused)
      */
     spin_debug_disable();
 
-    get_cpu_info()->use_pv_cr3 = false;
-    get_cpu_info()->xen_cr3 = 0;
-    get_cpu_info()->pv_cr3 = 0;
+    info->use_pv_cr3 = false;
+    info->xen_cr3 = 0;
+    info->pv_cr3 = 0;
 
     /*
      * BUG_ON() used in load_system_tables() and later code may end up calling
@@ -632,8 +628,6 @@ static int do_boot_cpu(int apicid, int cpu)
      */
     mtrr_save_state();
 
-    booting_cpu = cpu;
-
     start_eip = bootsym_phys(trampoline_realmode_entry);
 
     /* start_eip needs be page aligned, and below the 1M boundary. */