]> xenbits.xensource.com Git - people/liuw/mini-os.git/commitdiff
Add PV-GRUB
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 18 Jun 2008 08:36:47 +0000 (09:36 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 18 Jun 2008 08:36:47 +0000 (09:36 +0100)
This fetches GRUB1 sources, applies the {graphical, print function,
save default, and ext3_256byte} patches from debian, and applies a
patch to make it work on x86_64 and port it to Mini-OS.  By using
libxc, PV-GRUB can then "kexec" the loaded kernel from inside the
domain itself, hence permitting to avoid the security-concerned
pygrub.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
arch/x86/mm.c
blkfront.c
fbfront.c
include/x86/arch_mm.h
main.c
netfront.c

index 96c433b13541212aac5d5ff9943a284fc7cf0b66..ea8158045b89687edd11e9637d0b5a5a3fb5b75e 100644 (file)
@@ -372,7 +372,7 @@ static pgentry_t *get_pgt(unsigned long addr)
     return &tab[offset];
 }
 
-static pgentry_t *need_pgt(unsigned long addr)
+pgentry_t *need_pgt(unsigned long addr)
 {
     unsigned long mfn;
     pgentry_t *tab;
index 9e5411bce68b5205aa8013b05f518c8afa6598f3..48704bd1c41a98a62b5826e714d0bc40f27d38fe 100644 (file)
@@ -242,9 +242,15 @@ void shutdown_blkfront(struct blkfront_dev *dev)
     err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
     xenbus_wait_for_value(path, "6", &dev->events);
 
+    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    xenbus_wait_for_value(path, "2", &dev->events);
+
     xenbus_unwatch_path(XBT_NIL, path);
 
-    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    snprintf(path, sizeof(path), "%s/ring-ref", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/event-channel", nodename);
+    xenbus_rm(XBT_NIL, path);
 
     free_blkfront(dev);
 }
index 6517cdf4b58727df9687acb95ef8e2f5d9462cb1..245ef468eda7c069893fbeae879adf43dce11763 100644 (file)
--- a/fbfront.c
+++ b/fbfront.c
@@ -229,9 +229,18 @@ void shutdown_kbdfront(struct kbdfront_dev *dev)
     err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
     xenbus_wait_for_value(path, "6", &dev->events);
 
+    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    // does not work yet.
+    //xenbus_wait_for_value(path, "2", &dev->events);
+
     xenbus_unwatch_path(XBT_NIL, path);
 
-    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    snprintf(path, sizeof(path), "%s/page-ref", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/event-channel", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/request-abs-pointer", nodename);
+    xenbus_rm(XBT_NIL, path);
 
     free_kbdfront(dev);
 }
@@ -561,9 +570,20 @@ void shutdown_fbfront(struct fbfront_dev *dev)
     err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
     xenbus_wait_for_value(path, "6", &dev->events);
 
+    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    // does not work yet
+    //xenbus_wait_for_value(path, "2", &dev->events);
+
     xenbus_unwatch_path(XBT_NIL, path);
 
-    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    snprintf(path, sizeof(path), "%s/page-ref", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/event-channel", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/protocol", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/feature-update", nodename);
+    xenbus_rm(XBT_NIL, path);
 
     unbind_evtchn(dev->evtchn);
 
index a7e013bc06b43c5dbb43bd2b389ded661969ac3f..4a04812891be334cd35f842c12c6f735c768c314 100644 (file)
@@ -221,4 +221,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)
 #define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, 0, L1_PROT_RO)
 #define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, 0, L1_PROT_RO)
 
+pgentry_t *need_pgt(unsigned long addr);
+
 #endif /* _ARCH_MM_H_ */
diff --git a/main.c b/main.c
index 6c26e960577f50ec262bc4e7b3847203581263fc..dac185a528f11eb1201c084be018a75e2ec1249c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -59,11 +59,13 @@ static void call_main(void *p)
      * crashing. */
     //sleep(1);
 
+#ifndef CONFIG_GRUB
     sparse((unsigned long) &__app_bss_start, &__app_bss_end - &__app_bss_start);
 #ifdef HAVE_LWIP
     start_networking();
 #endif
     init_fs_frontend();
+#endif
 
 #ifdef CONFIG_QEMU
     if (!fs_import) {
@@ -154,7 +156,7 @@ void _exit(int ret)
 #ifdef HAVE_LWIP
     stop_networking();
 #endif
-    unbind_all_ports();
+    stop_kernel();
     if (!ret) {
        /* No problem, just shutdown.  */
         struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_poweroff };
index 00f159c332bd040accd05f779e989b3f01e8b4b1..d01ce6927b2373560000201f06b627786c6867a9 100644 (file)
@@ -497,15 +497,26 @@ void shutdown_netfront(struct netfront_dev *dev)
     printk("close network: backend at %s\n",dev->backend);
 
     snprintf(path, sizeof(path), "%s/state", dev->backend);
+
     err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */
     xenbus_wait_for_value(path, "5", &dev->events);
 
     err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
     xenbus_wait_for_value(path, "6", &dev->events);
 
+    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    xenbus_wait_for_value(path, "2", &dev->events);
+
     xenbus_unwatch_path(XBT_NIL, path);
 
-    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
+    snprintf(path, sizeof(path), "%s/tx-ring-ref", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/rx-ring-ref", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/event-channel", nodename);
+    xenbus_rm(XBT_NIL, path);
+    snprintf(path, sizeof(path), "%s/request-rx-copy", nodename);
+    xenbus_rm(XBT_NIL, path);
 
     free_netfront(dev);
 }