]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - arch/x86/kernel/smpboot.c
Merge tag 'objtool-core-2023-04-27' of git://git.kernel.org/pub/scm/linux/kernel...
[thirdparty/linux.git] / arch / x86 / kernel / smpboot.c
index a6da3f94b7b62fb64a725385c209f5a970816702..352f0ce1ece42911271023391f1848df5a7b657c 100644 (file)
@@ -121,17 +121,20 @@ int arch_update_cpu_topology(void)
        return retval;
 }
 
+
+static unsigned int smpboot_warm_reset_vector_count;
+
 static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)
 {
        unsigned long flags;
 
        spin_lock_irqsave(&rtc_lock, flags);
-       CMOS_WRITE(0xa, 0xf);
+       if (!smpboot_warm_reset_vector_count++) {
+               CMOS_WRITE(0xa, 0xf);
+               *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH)) = start_eip >> 4;
+               *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = start_eip & 0xf;
+       }
        spin_unlock_irqrestore(&rtc_lock, flags);
-       *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH)) =
-                                                       start_eip >> 4;
-       *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) =
-                                                       start_eip & 0xf;
 }
 
 static inline void smpboot_restore_warm_reset_vector(void)
@@ -143,10 +146,12 @@ static inline void smpboot_restore_warm_reset_vector(void)
         * to default values.
         */
        spin_lock_irqsave(&rtc_lock, flags);
-       CMOS_WRITE(0, 0xf);
+       if (!--smpboot_warm_reset_vector_count) {
+               CMOS_WRITE(0, 0xf);
+               *((volatile u32 *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0;
+       }
        spin_unlock_irqrestore(&rtc_lock, flags);
 
-       *((volatile u32 *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0;
 }
 
 /*
@@ -1059,8 +1064,6 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle)
 #ifdef CONFIG_X86_32
        /* Stack for startup_32 can be just as for start_secondary onwards */
        per_cpu(pcpu_hot.top_of_stack, cpu) = task_top_of_stack(idle);
-#else
-       initial_gs = per_cpu_offset(cpu);
 #endif
        return 0;
 }
@@ -1086,9 +1089,14 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
                start_ip = real_mode_header->trampoline_start64;
 #endif
        idle->thread.sp = (unsigned long)task_pt_regs(idle);
-       early_gdt_descr.address = (unsigned long)get_cpu_gdt_rw(cpu);
        initial_code = (unsigned long)start_secondary;
-       initial_stack  = idle->thread.sp;
+
+       if (IS_ENABLED(CONFIG_X86_32)) {
+               early_gdt_descr.address = (unsigned long)get_cpu_gdt_rw(cpu);
+               initial_stack  = idle->thread.sp;
+       } else {
+               smpboot_control = cpu;
+       }
 
        /* Enable the espfix hack for this CPU */
        init_espfix_ap(cpu);