commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd-l4/laden ia32-cmain.c laden.h loader.c


From: Marcus Brinkmann
Subject: hurd-l4/laden ia32-cmain.c laden.h loader.c
Date: Sun, 07 Sep 2003 19:35:44 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd-l4
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/09/07 19:35:44

Modified files:
        laden          : ia32-cmain.c laden.h loader.c 

Log message:
        Check for conflicts with laden itself, and with the GRUB MBI.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/ia32-cmain.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/laden.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/laden/loader.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: hurd-l4/laden/ia32-cmain.c
diff -u hurd-l4/laden/ia32-cmain.c:1.3 hurd-l4/laden/ia32-cmain.c:1.4
--- hurd-l4/laden/ia32-cmain.c:1.3      Sun Sep  7 15:49:01 2003
+++ hurd-l4/laden/ia32-cmain.c  Sun Sep  7 19:35:44 2003
@@ -41,6 +41,10 @@
 /* Check if the bit BIT in FLAGS is set.  */
 #define CHECK_FLAG(flags,bit)  ((flags) & (1 << (bit)))
 
+/* The following must be defined and are used to calculate the extents
+   of the laden binary itself.  */
+extern char _start;
+extern char _end;
 
 /* Setup the argument vector and pass control over to the main
    function.  */
@@ -49,6 +53,9 @@
 {
   int argc = 0;
   char **argv = 0;
+  l4_word_t start;
+  l4_word_t end;
+
 
   /* Verify that we are booted by a Multiboot-compliant boot loader.  */
   if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
@@ -113,6 +120,39 @@
      also to get at the multiboot info from other functions called at
      a later time.  */
   boot_info = (uint32_t) mbi;
+
+  /* Now protect ourselves and the mulitboot info (at least the module
+     configuration.  */
+  loader_add_region ("laden", (l4_word_t) &_start, (l4_word_t) &_end, 1);
+
+  start = (l4_word_t) mbi;
+  end = start + sizeof (*mbi) - 1;
+  if (CHECK_FLAG (mbi->flags, 3))
+    {
+      module_t *mod = (module_t *) mbi->mods_addr;
+      int nr;
+
+      if (((l4_word_t) mod) < start)
+       start = (l4_word_t) mod;
+      if (((l4_word_t) mod) + mbi->mods_count * sizeof (*mod) > end)
+       end = ((l4_word_t) mod) + mbi->mods_count * sizeof (*mod);
+
+      for (nr = 0; nr < mbi->mods_count; nr++)
+       {
+         char *str = (char *) mod[nr].string;
+
+         if (str)
+           {
+             if (((l4_word_t) str) < start)
+               start = (l4_word_t) str;
+             while (*str)
+               str++;
+             if (((l4_word_t) str) > end)
+               end = (l4_word_t) str;
+           }
+       }
+    }
+  loader_add_region ("grub-mbi", start, end, 1);
 
   /* Now invoke the main function.  */
   main (argc, argv);
Index: hurd-l4/laden/laden.h
diff -u hurd-l4/laden/laden.h:1.4 hurd-l4/laden/laden.h:1.5
--- hurd-l4/laden/laden.h:1.4   Sun Sep  7 16:56:46 2003
+++ hurd-l4/laden/laden.h       Sun Sep  7 19:35:44 2003
@@ -92,6 +92,12 @@
 /* Print a debug message.  */
 #define debug(...) do { if (debug) printf (__VA_ARGS__); } while (0)
 
+/* Add the region with the name NAME from START to END to the table of
+   regions to check against.  Before doing that, check for overlaps
+   with existing regions, unless FORCE is true.  */
+void loader_add_region (char *name, l4_word_t start, l4_word_t end, int force);
+
+
 /* Load the ELF images of the kernel and the initial servers into
    memory, checking for overlaps.  Update the start and end
    information with the information from the ELF program, and fill in
Index: hurd-l4/laden/loader.c
diff -u hurd-l4/laden/loader.c:1.2 hurd-l4/laden/loader.c:1.3
--- hurd-l4/laden/loader.c:1.2  Wed Sep  3 21:29:35 2003
+++ hurd-l4/laden/loader.c      Sun Sep  7 19:35:44 2003
@@ -107,14 +107,15 @@
 
 /* Add the region with the name NAME from START to END to the table of
    regions to check against.  Before doing that, check for overlaps
-   with existing regions.  */
-static void
-add_region (char *name, l4_word_t start, l4_word_t end)
+   with existing regions, unless FORCE is true.  */
+void
+loader_add_region (char *name, l4_word_t start, l4_word_t end, int force)
 {
   if (nr_regions == MAX_REGIONS)
     panic ("Too many memory regions, region %s doesn't fit", name);
 
-  check_region (name, start, end);
+  if (!force)
+    check_region (name, start, end);
 
   used_regions[nr_regions].name = name;
   used_regions[nr_regions].start = start;
@@ -204,7 +205,7 @@
 
   /* FIXME: Add this as a bootloader specific memory type to L4's
      memdesc list instead.  */
-  add_region (name, new_start, new_end);
+  loader_add_region (name, new_start, new_end, 0);
 
   if (new_start_p)
     *new_start_p = new_start;
@@ -224,18 +225,18 @@
 {
   if (!kernel.low)
     panic ("No L4 kernel found");
-  add_region ("kernel-mod", kernel.low, kernel.high);
+  loader_add_region ("kernel-mod", kernel.low, kernel.high, 0);
 
   if (!sigma0.low)
     panic ("No sigma0 server found");
-  add_region ("sigma0-mod", sigma0.low, sigma0.high);
+  loader_add_region ("sigma0-mod", sigma0.low, sigma0.high, 0);
 
   if (sigma1.low)
-    add_region ("sigma1-mod", sigma1.low, sigma1.high);
+    loader_add_region ("sigma1-mod", sigma1.low, sigma1.high, 0);
 
   if (!rootserver.low)
     panic ("No rootserver server found");
-  add_region ("rootserver-mod", rootserver.low, rootserver.high);
+  loader_add_region ("rootserver-mod", rootserver.low, rootserver.high, 0);
 
   elf_load ("kernel", kernel.low, kernel.high,
            &kernel.low, &kernel.high, &kernel.ip);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]