two kernel monte (or equivalent) for 2.4

Erik Arjan Hendriks erik at hendriks.cx
Mon May 14 19:48:21 PDT 2001


On Mon, May 14, 2001 at 09:32:44AM -0700, Patrick Michael Kane wrote:
> Hi there:
> 
> Is anyone aware of patches for two kernel monte, or an equivalent
> boot-linux-from-linux solution, that works with the 2.4 kernel?

Here's the straight forward port of two kernel monte to 2.4.  The stay
in protected mode thing seems to have a problem but dropping all the
way to real mode seems to work fine.

- Erik

Index: kmonte.c

--- kmonte.c	2000/10/31 17:23:38	1.19
+++ kmonte.c	2001/05/15 02:44:37
@@ -1,7 +1,7 @@
 /*------------------------------------------------------------ -*- C -*-
  *  2 Kernel Monte a.k.a. Linux loading Linux on x86
  *
- *  Erik Arjan Hendriks <hendriks at scyld.com>
+ *  Erik Arjan Hendriks <erik at hendriks.cx>
  *  Copyright (C) 2000 Scyld Computing Corporation
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -21,21 +21,15 @@
  *  $Id: kmonte.c,v 1.19 2000/10/31 17:23:38 hendriks Exp $
  *--------------------------------------------------------------------*/
 
-/* Auto-configuration stuff for things living outside the linux kernel
- * source tree. */
-/* Include files, designed to support most kernel versions 2.0.0 and later. */
 #include <linux/config.h>
 #if defined(CONFIG_SMP) && ! defined(__SMP__)
 #define __SMP__
 #endif
-#if defined(CONFIG_MODVERSIONS) && defined(MODULE) && ! defined(MODVERSIONS)
+#if defined(CONFIG_MODVERSIONS) && ! defined(MODVERSIONS)
 #define MODVERSIONS
 #endif
-
-#include <linux/version.h>
 #include <linux/module.h>
-/* Older kernels do not include this automatically. */
-#if LINUX_VERSION_CODE < 0x20300  &&  defined(MODVERSIONS)
+#if defined(MODVERSIONS)
 #include <linux/modversions.h>
 #endif
 
@@ -53,11 +47,12 @@
  * seem too bad.  Fooling with the APICs looks like it will be a major
  * pain unless the kernel exports a few more symbols.  */
 #ifdef __SMP__
-#error "2 Kernel Monte doesn't work with SMP!"
+#warning "2 Kernel Monte cannot doesn't work with SMP!"
 #endif
 
 MODULE_AUTHOR("Erik Arjan Hendriks <hendriks at scyld.com>");
 MODULE_DESCRIPTION("Two Kernel Monte: Loads new Linux kernels from Linux.");
+EXPORT_NO_SYMBOLS;
 
 /*--------------------------------------------------------------------
  * Monte memory management
@@ -252,11 +247,11 @@
 static int monte_restart(unsigned long entry_addr, unsigned long flags);
 int (*real_reboot)(int, int, int, void *);
 
+static struct semaphore monte_sem;
 asmlinkage int sys_monte(int magic1, int magic2, int cmd, void *arg) {
     int err;
     struct monte_param_t  param;
     struct monte_region_t *regions=0;
-    static struct semaphore monte_sem = MUTEX;
 
     MOD_INC_USE_COUNT;
     if (magic1 != MONTE_MAGIC_1 || magic2 != MONTE_MAGIC_2) {
@@ -283,7 +278,11 @@
 	err = -EFAULT;
 	goto out;
     }
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
     down(&current->mm->mmap_sem);
+#else
+    down_read(&current->mm->mmap_sem);
+#endif
     if ((err = m_setup_page_list(regions, param.nregions))) goto out1;
     if ((err = m_check_page_list())) goto out1;
 
@@ -296,7 +295,11 @@
     printk("monte: failure (errno = %d)\n", -err);
 
  out1:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
     up(&current->mm->mmap_sem);
+#else
+    up_read(&current->mm->mmap_sem);
+#endif
  out:
     if (regions) kfree(regions);
     m_pg_list_free();
@@ -466,9 +469,10 @@
     struct pci_dev *dev;
     u16 cmd;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
     for (dev=bus->devices; dev!=NULL; dev=dev->next) {
 #else
+    struct list_head *l;
     for (l=bus->devices.next; l != &bus->devices; l=l->next) {
 	dev = pci_dev_b(l);
 #endif
@@ -480,14 +484,15 @@
 
 static
 void monte_pci_disable(void) {
-    struct pci_bus *bus;
     /* Turn off PCI bus masters to keep them from scribbling on our
      * memory later on. */
     if (pcibios_present()) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,1)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+        struct pci_bus *bus;
 	for (bus=&pci_root; bus != NULL; bus=bus->next)
 	    monte_pci_disable_bus(bus);
 #else
+        struct list_head *l;
 	for (l=pci_root_buses.next; l != &pci_root_buses; l=l->next)
 	    monte_pci_disable_bus(pci_bus_b(l));
 #endif
@@ -497,7 +502,7 @@
 
 static
 void restore_xt_pic(void) {
-    /* These following is taken from arch/i386/boot/setup.S
+    /* These comments are taken from linux/arch/i386/boot/setup.S
      *
      *     I hope. Now we have to reprogram the interrupts :-( we put
      *     them right after the intel-reserved hardware interrupts, at
@@ -535,9 +540,9 @@
      * off paging later needs to run out of an identity mapped page.
      * For simplicity we'll use page zero.  This page is normally not
      * mapped at all. */
-    set_bit(PG_reserved, &(mem_map+MAP_NR(__va(0)))->flags);
+    set_bit(PG_reserved, &(mem_map[0].flags));
     if (remap_page_range(0, 0, PAGE_SIZE, PAGE_KERNEL)) {
-        clear_bit(PG_reserved, &(mem_map+MAP_NR(__va(0)))->flags);
+        clear_bit(PG_reserved, &(mem_map[0].flags));
         return -EAGAIN;
     }
     /*----- POINT OF NO RETURN IS HERE --------------------------------------*/
@@ -593,6 +598,7 @@
 	   "monte: Erik Arjan Hendriks <hendriks at scyld.com>\n",
 	   PACKAGE_VERSION);
 
+    init_MUTEX(&monte_sem);
     real_reboot = sys_call_table[__NR_reboot];
     sys_call_table[__NR_reboot] = sys_monte;
     return 0;




More information about the Beowulf mailing list