bug-hurd
[Top][All Lists]
Advanced

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

Re: Getting rid of serverboot


From: Neal H Walfield
Subject: Re: Getting rid of serverboot
Date: Sun, 19 Aug 2001 16:03:51 +0200
User-agent: Mutt/1.3.18i

> > Second, struct multiboot_module.  I do not know if this works under OSKit
> > Mach, however, this was the root of all my trouble in GNUMach.
> > Basically, this does not work at all.  
> 
> Can you try to get some more information about this?

Here is a fix.  Basically, the problem was lack of type checking and the
use of physical, not kernel mapped addresses.

Additionally, booting from the kernel does not set MULTIBOOT_CMDLINE
which means that the user ends up in single user mode.  I.e. take a look
at /libexec/runsystem lines 66-67.

Anyway, here is the patch:

2001-08-19  Neal H Walfield  <neal@cs.uml.edu>

        * bootstrap.c [!OSKIT_MACH]: boot_info is a pointer, not a
        structure.
        [!OSKIT_MACH] FUBAR: New macro.
        [!OSKIT_MACH] boot_info: New macro.  Munge the variable
        boot_info into a structure.

        (bootstrap_create): Pass the module structure to
        bootstrap_exec_compat, not the start of the module.

        (boot_read): Use virtual, not physical addresses.
        (read_exec): Likewise.

        (boot_script_exec_cmd): Use MOD, not HOOK.
        Do not just fall off the end of the function; return something.

        (user_bootstrap): The event that our parent thread is waiting on
        is INFO, not &INFO.

        (boot_script_task_create): Add a new line to the error message.
        (boot_script_task_resume): Likewise.

        (bootstrap_create) [OSKIT_MACH]: The code mark as GNUMach
        specific isn't.
        Reported by Jeroen Dekkers <jeroen@dekkers.cx>.


Index: bootstrap.c
===================================================================
RCS file: /cvsroot/hurd/gnumach/kern/bootstrap.c,v
retrieving revision 1.3.2.6
diff -u -p -r1.3.2.6 bootstrap.c
--- bootstrap.c 2001/08/17 10:26:11     1.3.2.6
+++ bootstrap.c 2001/08/19 13:55:54
@@ -67,7 +67,14 @@
 static mach_port_t     boot_device_port;       /* local name */
 static mach_port_t     boot_host_port;         /* local name */
 
+#if OSKIT_MACH
 extern struct multiboot_info boot_info;
+#else
+extern struct multiboot_info *boot_info;
+#define FUBAR (*boot_info)
+#define boot_info FUBAR
+#endif
+
 extern char *kernel_cmdline;
 
 static void user_bootstrap();  /* forward */
@@ -109,7 +116,7 @@ void bootstrap_create()
     {
       printf("Loading single multiboot module in compat mode: %s\n",
             (char*)phystokv(bmods[0].string));
-      bootstrap_exec_compat((void*)phystokv(bmods[0].mod_start));
+      bootstrap_exec_compat((void *) &bmods[0]);
     }
   else
     {
@@ -156,7 +163,7 @@ void bootstrap_create()
                     var, boot_script_error_string (losers));
          }
       }
-#else  /* GNUmach, not oskit-mach */
+#endif
       {
        char *flag_string = alloca(1024);
        char *root_string = alloca(1024);
@@ -177,7 +184,6 @@ void bootstrap_create()
          panic ("cannot set boot-script variable %s: %s",
                 "root-device", boot_script_error_string (losers));
       }
-#endif
 
       for (i = 0; i < boot_info.mods_count; ++i)
        {
@@ -345,10 +351,11 @@ boot_read(void *handle, vm_offset_t file
 {
   struct multiboot_module *mod = handle;
 
-  if (mod->mod_start + file_ofs + size > mod->mod_end)
+  if ((void *) phystokv (mod->mod_start) + file_ofs + size
+      > (void *) phystokv (mod->mod_end))
     return -1;
 
-  memcpy(buf, (const char*)mod->mod_start + file_ofs, size);
+  memcpy(buf, (const char*)phystokv (mod->mod_start) + file_ofs, size);
   *out_actual = size;
   return 0;
 }
@@ -365,8 +372,9 @@ read_exec(void *handle, vm_offset_t file
        vm_prot_t mem_prot = sec_type & EXEC_SECTYPE_PROT_MASK;
        int err;
 
-       if (mod->mod_start + file_ofs + file_size > mod->mod_end)
-         return -1;
+       if ((void *) phystokv (mod->mod_start) + file_ofs + file_size
+           > (void *) phystokv(mod->mod_end))
+         return -2;
 
        if (!(sec_type & EXEC_SECTYPE_ALLOC))
                return 0;
@@ -388,7 +396,7 @@ read_exec(void *handle, vm_offset_t file
 
        if (file_size > 0)
        {
-               err = copyout((char *)mod->mod_start + file_ofs,
+               err = copyout((char *)phystokv (mod->mod_start) + file_ofs,
                              mem_addr, file_size);
                assert(err == 0);
        }
@@ -655,7 +663,7 @@ boot_script_exec_cmd (void *hook, task_t
   if (task != MACH_PORT_NULL)
     {
       thread_t thread;
-      struct user_bootstrap_info info = { hook, argv, 0, };
+      struct user_bootstrap_info info = { mod, argv, 0, };
       simple_lock_init (&info.lock);
       simple_lock (&info.lock);
 
@@ -673,6 +681,7 @@ boot_script_exec_cmd (void *hook, task_t
          simple_lock (&info.lock);
        }
     }
+  return 0;
 }
 
 static void user_bootstrap()
@@ -697,7 +706,7 @@ static void user_bootstrap()
   simple_lock (&info.lock);
   assert (!info->done);
   info->done = 1;
-  thread_wakeup ((event_t) &info);
+  thread_wakeup ((event_t) info);
 
   /*
    * Exit to user thread.
@@ -726,7 +735,7 @@ boot_script_task_create (struct cmd *cmd
   kern_return_t rc = task_create(TASK_NULL, FALSE, &cmd->task);
   if (rc)
     {
-      printf("boot_script_task_create failed with %x", rc);
+      printf("boot_script_task_create failed with %x\n", rc);
       return BOOT_SCRIPT_MACH_ERROR;
     }
   return 0;
@@ -738,7 +747,7 @@ boot_script_task_resume (struct cmd *cmd
   kern_return_t rc = task_resume (cmd->task);
   if (rc)
     {
-      printf("boot_script_task_resume failed with %x", rc);
+      printf("boot_script_task_resume failed with %x\n", rc);
       return BOOT_SCRIPT_MACH_ERROR;
     }
   return 0;

Attachment: pgpj66CG8EZL5.pgp
Description: PGP signature


reply via email to

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