]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/smpboot: Simplify boot CPU setup
authorBrian Gerst <brgerst@gmail.com>
Fri, 24 Feb 2023 15:42:34 +0000 (10:42 -0500)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Sat, 25 Feb 2023 07:59:57 +0000 (07:59 +0000)
Now that the per-cpu GSBASE, stack, and GDT descriptor can be derived
dynamically by CPU number, the boot CPU can use a fixed CPU number and
take the same path as secondary CPUs.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Tested-by: Usama Arif <usama.arif@bytedance.com>
Signed-off-by: Usama Arif <usama.arif@bytedance.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/x86/kernel/head_64.S

index 9ed87ba0609f9f319e09fbd9db302d5ae71f66cf..8bd29ab523dd6a5799d30d98b2766e960128a484 100644 (file)
@@ -235,11 +235,6 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
        ANNOTATE_NOENDBR // above
 
 #ifdef CONFIG_SMP
-       /* Is this the boot CPU coming up? */
-       movl    smpboot_control(%rip), %edx
-       testl   $STARTUP_SECONDARY, %edx
-       jz      .Linit_cpu0_data
-
        /*
         * For parallel boot, the APIC ID is retrieved from CPUID, and then
         * used to look up the CPU number.  For booting a single CPU, the
@@ -250,13 +245,13 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
         * Bit 29       STARTUP_APICID_CPUID_01 flag (use CPUID 0x01)
         * Bit 0-24     CPU# if STARTUP_APICID_CPUID_xx flags are not set
         */
-       testl   $STARTUP_APICID_CPUID_0B, %edx
+       movl    smpboot_control(%rip), %ecx
+       testl   $STARTUP_APICID_CPUID_0B, %ecx
        jnz     .Luse_cpuid_0b
-       testl   $STARTUP_APICID_CPUID_01, %edx
+       testl   $STARTUP_APICID_CPUID_01, %ecx
        jnz     .Luse_cpuid_01
-       andl    $0x0FFFFFFF, %edx
-       movl    %edx, %ecx
-       jmp     .Linit_cpu_data
+       andl    $0x0FFFFFFF, %ecx
+       jmp     .Lsetup_cpu
 
 .Luse_cpuid_01:
        mov     $0x01, %eax
@@ -277,7 +272,7 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
 
 .Lfind_cpunr:
        cmpl    (%rbx,%rcx,4), %edx
-       jz      .Linit_cpu_data
+       jz      .Lsetup_cpu
        inc     %ecx
        cmpl    nr_cpu_ids(%rip), %ecx
        jb      .Lfind_cpunr
@@ -291,18 +286,13 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
        hlt
        jmp     1b
 
-.Linit_cpu0_data:
-       movq    __per_cpu_offset(%rip), %rdx
-       jmp     .Lsetup_cpu
-
-.Linit_cpu_data:
+.Lsetup_cpu:
        /* Get the per cpu offset for the given CPU# which is in ECX */
        movq    __per_cpu_offset(,%rcx,8), %rdx
 #else
        xorl    %edx, %edx
 #endif /* CONFIG_SMP */
 
-.Lsetup_cpu:
        /*
         * Setup a boot time stack - Any secondary CPU will have lost its stack
         * by now because the cr3-switch above unmaps the real-mode stack