]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
inmates: Demonstrate shutdown rejection in apic-demo
authorJan Kiszka <jan.kiszka@siemens.com>
Sun, 12 Jan 2014 19:56:41 +0000 (20:56 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 16 Jan 2014 16:06:39 +0000 (17:06 +0100)
Enable managed shutdown in the apic-demo and reject the first request to
demonstrate the mechanism.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
configs/apic-demo.c
inmates/Makefile
inmates/apic-demo.c
inmates/inmate.h

index 65c6cb412b2961052f5a3fee9effc6f05803e81e..7cf028bf3e63992cc3f286dd4051e50d8db1c4c3 100644 (file)
 struct {
        struct jailhouse_cell_desc ALIGN cell;
        __u64 ALIGN cpus[1];
-       struct jailhouse_memory ALIGN mem_regions[1];
+       struct jailhouse_memory ALIGN mem_regions[2];
        __u8 ALIGN pio_bitmap[0x2000];
 } ALIGN config = {
        .cell = {
                .name = "APIC Demo",
-               .flags = JAILHOUSE_CELL_UNMANAGED_EXIT,
 
                .cpu_set_size = sizeof(config.cpus),
                .num_memory_regions = ARRAY_SIZE(config.mem_regions),
@@ -47,6 +46,12 @@ struct {
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
                                JAILHOUSE_MEM_EXECUTE,
                },
+               /* communication region */ {
+                       .virt_start = 0x00100000,
+                       .size = 0x00001000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_COMM_REGION,
+               },
        },
 
        .pio_bitmap = {
index fdb410723a323cbba064c313f3cc30880a5abb66..c78e36d76551fdcaff521030da03c8ccf5e285d0 100644 (file)
@@ -14,7 +14,9 @@ LINUXINCLUDE := -I$(src)
 KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
                 -Wmissing-declarations -Wmissing-prototypes \
                 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
-                -fno-common -fno-stack-protector -I.
+                -fno-common -fno-stack-protector -I. \
+                -I$(src)/../hypervisor/arch/$(SRCARCH)/include \
+                -I$(src)/../hypervisor/include
 ifneq ($(wildcard $(src)/../hypervisor/include/jailhouse/config.h),)
 KBUILD_CFLAGS += -include $(src)/../hypervisor/include/jailhouse/config.h
 endif
index c3c11497eaf322df68b83d1e646e198c447fe54a..3f81a3ad1a8194650f3ec5e259d145b628fc50c8 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <inmate.h>
+#include <jailhouse/hypercall.h>
 
 #ifdef CONFIG_UART_OXPCIE952
 #define UART_BASE              0xe010
@@ -37,6 +38,9 @@ static unsigned long apic_frequency;
 static unsigned long expected_time;
 static unsigned long min = -1, max;
 
+static struct jailhouse_comm_region *comm_region =
+       (struct jailhouse_comm_region *)0x100000UL;
+
 struct desc_table_reg {
        u16 limit;
        u64 base;
@@ -127,7 +131,17 @@ void inmate_main(void)
        if (init_pm_timer())
                init_apic();
 
-       while (1) {
+       while (comm_region->msg_to_cell != JAILHOUSE_MSG_SHUTDOWN_REQUESTED)
                asm volatile("hlt");
-       }
+
+       printk("Rejecting first shutdown - try again!\n");
+       jailhouse_send_reply_from_cell(comm_region,
+                                      JAILHOUSE_MSG_SHUTDOWN_DENIED);
+
+       while (comm_region->msg_to_cell != JAILHOUSE_MSG_SHUTDOWN_REQUESTED)
+               asm volatile("hlt");
+
+       printk("Stopped APIC demo\n");
+       jailhouse_send_reply_from_cell(comm_region, JAILHOUSE_MSG_SHUTDOWN_OK);
+       asm volatile("cli; hlt");
 }
index a1e2bb7d1b19ba5f1d3096a20678086c5ecd3e2b..6f0b7f8c8f0dfa8ff55cd120ddfe7c3e9e372e1e 100644 (file)
@@ -28,6 +28,18 @@ typedef unsigned int u32;
 typedef signed long s64;
 typedef unsigned long u64;
 
+typedef s8 __s8;
+typedef u8 __u8;
+
+typedef s16 __s16;
+typedef u16 __u16;
+
+typedef s32 __s32;
+typedef u32 __u32;
+
+typedef s64 __s64;
+typedef u64 __u64;
+
 typedef enum { true=1, false=0 } bool;
 
 static inline void cpu_relax(void)