Skip to content

Commit 6fa99b7

Browse files
wildea01Russell King
authored andcommitted
ARM: 7405/1: kexec: call platform_cpu_kill on the killer rather than the victim
When performing a kexec on an SMP system, the secondary cores are stopped by calling machine_shutdown(), which in turn issues IPIs to offline the other CPUs. Unfortunately, this isn't enough to reboot the cores into a new kernel (since they are just executing a cpu_relax loop somewhere in memory) so we make use of platform_cpu_kill, part of the CPU hotplug implementation, to place the cores somewhere safe. This function expects to be called on the killing CPU for each core that it takes out. This patch moves the platform_cpu_kill callback out of the IPI handler and into smp_send_stop, therefore ensuring that it executes on the killing CPU rather than on the victim, matching what the hotplug code requires. Cc: stable@vger.kernel.org Reported-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 6a1c531 commit 6fa99b7

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

‎arch/arm/kernel/smp.c‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,6 @@ static void ipi_cpu_stop(unsigned int cpu)
510510
local_fiq_disable();
511511
local_irq_disable();
512512

513-
#ifdef CONFIG_HOTPLUG_CPU
514-
platform_cpu_kill(cpu);
515-
#endif
516-
517513
while (1)
518514
cpu_relax();
519515
}
@@ -576,17 +572,25 @@ void smp_send_reschedule(int cpu)
576572
smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
577573
}
578574

575+
#ifdef CONFIG_HOTPLUG_CPU
576+
static void smp_kill_cpus(cpumask_t *mask)
577+
{
578+
unsigned int cpu;
579+
for_each_cpu(cpu, mask)
580+
platform_cpu_kill(cpu);
581+
}
582+
#else
583+
static void smp_kill_cpus(cpumask_t *mask) { }
584+
#endif
585+
579586
void smp_send_stop(void)
580587
{
581588
unsigned long timeout;
589+
struct cpumask mask;
582590

583-
if (num_online_cpus() > 1) {
584-
struct cpumask mask;
585-
cpumask_copy(&mask, cpu_online_mask);
586-
cpumask_clear_cpu(smp_processor_id(), &mask);
587-
588-
smp_cross_call(&mask, IPI_CPU_STOP);
589-
}
591+
cpumask_copy(&mask, cpu_online_mask);
592+
cpumask_clear_cpu(smp_processor_id(), &mask);
593+
smp_cross_call(&mask, IPI_CPU_STOP);
590594

591595
/* Wait up to one second for other CPUs to stop */
592596
timeout = USEC_PER_SEC;
@@ -595,6 +599,8 @@ void smp_send_stop(void)
595599

596600
if (num_online_cpus() > 1)
597601
pr_warning("SMP: failed to stop secondary CPUs\n");
602+
603+
smp_kill_cpus(&mask);
598604
}
599605

600606
/*

0 commit comments

Comments
 (0)