]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: Factor out generic panic_stop/halt services
authorJan Kiszka <jan.kiszka@siemens.com>
Tue, 4 Mar 2014 19:14:51 +0000 (20:14 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Wed, 5 Mar 2014 09:25:54 +0000 (10:25 +0100)
These functions already contain too much generic logic, and panic_halt
will gain even more soon. Move them under the hood of the control module
and split them up into generic and arch-specific pieces.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/arm/setup.c
hypervisor/arch/x86/apic.c
hypervisor/arch/x86/control.c
hypervisor/arch/x86/fault.c
hypervisor/arch/x86/include/asm/control.h
hypervisor/arch/x86/include/asm/fault.h
hypervisor/arch/x86/mmio.c
hypervisor/arch/x86/vmx.c
hypervisor/control.c
hypervisor/include/jailhouse/control.h

index d1e2997063dc4f5b3ced63ca1f0204aa1dea68ed..a24e5986634916d63c25623e3e02a60fb204b77d 100644 (file)
@@ -66,3 +66,6 @@ unsigned long arch_page_map_gphys2phys(struct per_cpu *cpu_data,
 void arch_paging_init(void) { }
 
 const struct paging arm_paging[1];
+
+void arch_panic_stop(struct per_cpu *cpu_data) {__builtin_unreachable();}
+void arch_panic_halt(struct per_cpu *cpu_data) {}
index c60e9a76f8711be128586ce34bbb7e5e70af19eb..7fbdebca093dccc2b43cdf2258ce2b9994246461 100644 (file)
@@ -18,7 +18,6 @@
 #include <asm/apic.h>
 #include <asm/bitops.h>
 #include <asm/control.h>
-#include <asm/fault.h>
 #include <asm/vmx.h>
 
 #define XAPIC_REG(x2apic_reg)          ((x2apic_reg) << 4)
index db3ef6142e3185a744023ddbbc7ee25b5a38ccc7..c9c1bdf3bda24233b983402bb3deb8708cf3117a 100644 (file)
@@ -163,7 +163,7 @@ void x86_send_init_sipi(unsigned int cpu_id, enum x86_init_sipi type,
 }
 
 /* control_lock has to be held */
-void x86_enter_wait_for_sipi(struct per_cpu *cpu_data)
+static void x86_enter_wait_for_sipi(struct per_cpu *cpu_data)
 {
        cpu_data->init_signaled = false;
        cpu_data->wait_for_sipi = true;
@@ -218,3 +218,16 @@ int x86_handle_events(struct per_cpu *cpu_data)
 
        return sipi_vector;
 }
+
+void arch_panic_stop(struct per_cpu *cpu_data)
+{
+       asm volatile("1: hlt; jmp 1b");
+       __builtin_unreachable();
+}
+
+void arch_panic_halt(struct per_cpu *cpu_data)
+{
+       spin_lock(&cpu_data->control_lock);
+       x86_enter_wait_for_sipi(cpu_data);
+       spin_unlock(&cpu_data->control_lock);
+}
index 26d5b9d7f559265cc39274e5c518e0288a3b508f..3edaa5a12d8b3a0fef94ba5712132c3bdbdd3bfc 100644 (file)
  * the COPYING file in the top-level directory.
  */
 
+#include <jailhouse/control.h>
 #include <jailhouse/printk.h>
 #include <jailhouse/processor.h>
-#include <asm/control.h>
-#include <asm/types.h>
 #include <asm/fault.h>
-#include <asm/vmx.h>
 
 struct exception_frame {
        u64 vector;
@@ -39,31 +37,3 @@ void exception_handler(struct exception_frame *frame)
 
        panic_stop(NULL);
 }
-
-void panic_stop(struct per_cpu *cpu_data)
-{
-       panic_printk("Stopping CPU");
-       if (cpu_data) {
-               panic_printk(" %d", cpu_data->cpu_id);
-               cpu_data->cpu_stopped = true;
-       }
-       panic_printk("\n");
-
-       if (phys_processor_id() == panic_cpu)
-               panic_in_progress = 0;
-
-       asm volatile("1: hlt; jmp 1b");
-       __builtin_unreachable();
-}
-
-void panic_halt(struct per_cpu *cpu_data)
-{
-       panic_printk("Parking CPU %d\n", cpu_data->cpu_id);
-
-       spin_lock(&cpu_data->control_lock);
-       x86_enter_wait_for_sipi(cpu_data);
-       spin_unlock(&cpu_data->control_lock);
-
-       if (phys_processor_id() == panic_cpu)
-               panic_in_progress = 0;
-}
index 935fcaac7f92204abd4013ce1148e19e2e91ec08..71d7b3ec4fc469dedde4127dc3718cbee7733566 100644 (file)
@@ -17,5 +17,4 @@ enum x86_init_sipi { X86_INIT, X86_SIPI };
 void x86_send_init_sipi(unsigned int cpu_id, enum x86_init_sipi type,
                        int sipi_vector);
 
-void x86_enter_wait_for_sipi(struct per_cpu *cpu_data);
 int x86_handle_events(struct per_cpu *cpu_data);
index b22d5b354303759933caac5045fe0a0064700fdf..8ff7d94d4c2f1678d650b3f8679ad2d7791f36e4 100644 (file)
  * the COPYING file in the top-level directory.
  */
 
-#include <asm/percpu.h>
-
 struct exception_frame;
 
 void __attribute__((noreturn))
 exception_handler(struct exception_frame *frame);
-
-void __attribute__((noreturn)) panic_stop(struct per_cpu *cpu_data);
-void panic_halt(struct per_cpu *cpu_data);
index a1b28d7f46a092f5d0b37c51a77ab0683a7d5f08..e766e898032fa9869adef4685600d8174e227d38 100644 (file)
@@ -13,7 +13,6 @@
 #include <jailhouse/mmio.h>
 #include <jailhouse/paging.h>
 #include <jailhouse/printk.h>
-#include <asm/fault.h>
 
 struct modrm {
        u8 rm:3;
index febab8cd90dcb03cdf239402b7371e1165db2dc1..582f3e5d4fe4d1b87e09302ce6daec48dafca385 100644 (file)
@@ -19,7 +19,6 @@
 #include <jailhouse/hypercall.h>
 #include <asm/apic.h>
 #include <asm/control.h>
-#include <asm/fault.h>
 #include <asm/vmx.h>
 #include <asm/vtd.h>
 
index cea0b15d9ddd796db5ad1c7a099a43d16b14ce7d..dd7d81c564c9752cc6778f6c2cd2c72880aa67e1 100644 (file)
@@ -14,6 +14,7 @@
 #include <jailhouse/control.h>
 #include <jailhouse/printk.h>
 #include <jailhouse/paging.h>
+#include <jailhouse/processor.h>
 #include <jailhouse/string.h>
 #include <asm/bitops.h>
 #include <asm/spinlock.h>
@@ -452,3 +453,28 @@ int shutdown(struct per_cpu *cpu_data)
 
        return ret;
 }
+
+void panic_stop(struct per_cpu *cpu_data)
+{
+       panic_printk("Stopping CPU");
+       if (cpu_data) {
+               panic_printk(" %d", cpu_data->cpu_id);
+               cpu_data->cpu_stopped = true;
+       }
+       panic_printk("\n");
+
+       if (phys_processor_id() == panic_cpu)
+               panic_in_progress = 0;
+
+       arch_panic_stop(cpu_data);
+}
+
+void panic_halt(struct per_cpu *cpu_data)
+{
+       panic_printk("Parking CPU %d\n", cpu_data->cpu_id);
+
+       arch_panic_halt(cpu_data);
+
+       if (phys_processor_id() == panic_cpu)
+               panic_in_progress = 0;
+}
index c50f835dd8fbfff4bfb21e2f88ffe1f55022e09a..5cffac7c6714fa66d5499410bf0d8f0b1a5aa681 100644 (file)
@@ -43,6 +43,9 @@ int cell_get_state(struct per_cpu *cpu_data, unsigned long id);
 
 int shutdown(struct per_cpu *cpu_data);
 
+void __attribute__((noreturn)) panic_stop(struct per_cpu *cpu_data);
+void panic_halt(struct per_cpu *cpu_data);
+
 void arch_suspend_cpu(unsigned int cpu_id);
 void arch_resume_cpu(unsigned int cpu_id);
 void arch_reset_cpu(unsigned int cpu_id);
@@ -58,3 +61,6 @@ int arch_cell_create(struct per_cpu *cpu_data, struct cell *cell);
 void arch_cell_destroy(struct per_cpu *cpu_data, struct cell *cell);
 
 void arch_shutdown(void);
+
+void __attribute__((noreturn)) arch_panic_stop(struct per_cpu *cpu_data);
+void arch_panic_halt(struct per_cpu *cpu_data);