Skip to content

Commit b9acc49

Browse files
arunksudhilalctmarinas
authored andcommitted
arm64: Fix deadlock scenario with smp_send_stop()
If one process calls sys_reboot and that process then stops other CPUs while those CPUs are within a spin_lock() region we can potentially encounter a deadlock scenario like below. CPU 0 CPU 1 ----- ----- spin_lock(my_lock) smp_send_stop() <send IPI> handle_IPI() disable_preemption/irqs while(1); <PREEMPT> spin_lock(my_lock) <--- Waits forever We shouldn't attempt to run any other tasks after we send a stop IPI to a CPU so disable preemption so that this task runs to completion. We use local_irq_disable() here for cross-arch consistency with x86. Based-on-work-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Arun KS <getarunks@gmail.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 90f51a0 commit b9acc49

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎arch/arm64/kernel/process.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void machine_shutdown(void)
135135
*/
136136
void machine_halt(void)
137137
{
138+
local_irq_disable();
138139
smp_send_stop();
139140
while (1);
140141
}
@@ -147,6 +148,7 @@ void machine_halt(void)
147148
*/
148149
void machine_power_off(void)
149150
{
151+
local_irq_disable();
150152
smp_send_stop();
151153
if (pm_power_off)
152154
pm_power_off();
@@ -165,10 +167,9 @@ void machine_power_off(void)
165167
*/
166168
void machine_restart(char *cmd)
167169
{
168-
smp_send_stop();
169-
170170
/* Disable interrupts first */
171171
local_irq_disable();
172+
smp_send_stop();
172173

173174
/* Now call the architecture specific reboot code. */
174175
if (arm_pm_restart)

0 commit comments

Comments
 (0)