Skip to content

Commit

Permalink
Update cpu shutdown code to ack the local APIC EOI register before
Browse files Browse the repository at this point in the history
invoking sti/hlt. This is needed to get hot-plugged CPUs to re-online
in Pisces/Linux on some architectures
  • Loading branch information
briankoco committed Aug 1, 2018
1 parent ecbd861 commit 2d81c18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 14 additions & 2 deletions arch/x86_64/kernel/cpu.c
Expand Up @@ -9,6 +9,7 @@
#include <lwk/aspace.h>
#include <lwk/xcall.h>
#include <lwk/cpuinfo.h>
#include <lwk/interrupt.h>

#include <arch/processor.h>
#include <arch/desc.h>
Expand Down Expand Up @@ -453,6 +454,17 @@ phys_cpu_remove(unsigned int phys_cpu_id,
void
arch_shutdown_cpu(void)
{
local_irq_disable();
halt();
/* The LAPIC can end up in a weird state if we go into sti/hlt without
* acking the EOI first. Of course, this is only the case if we are in
* interrupt
*/
if (in_interrupt())
lapic_ack_interrupt();

local_irq_disable();

while (1) {
halt();
cpu_relax();
}
}
6 changes: 4 additions & 2 deletions kernel/cpu.c
@@ -1,13 +1,14 @@
#include <lwk/kernel.h>
#include <lwk/xcall.h>
#include <lwk/smp.h>


extern void arch_shutdown_cpu(void);

static void
shutdown_cpu(void * info)
{
arch_shutdown_cpu();
arch_shutdown_cpu();
}

/*
Expand All @@ -16,5 +17,6 @@ shutdown_cpu(void * info)
void
shutdown_cpus(void)
{
xcall_function(cpu_online_map, shutdown_cpu, NULL, 0);
printk("CPU #%u: shutting down all CPUs\n", this_cpu);
on_each_cpu(shutdown_cpu, NULL, 0);
}

0 comments on commit 2d81c18

Please sign in to comment.