All of lore.kernel.org
 help / color / mirror / Atom feed
* UFS (FFS) support seems broken in grub2
@ 2008-01-19 17:01 jakllsch
  2008-01-19 18:27 ` walt
  0 siblings, 1 reply; 46+ messages in thread
From: jakllsch @ 2008-01-19 17:01 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 698 bytes --]

Hi,

The UFS (or FFS as it's known to NetBSD)
support in grub2 does not seem to work for me.

I've tried multiple configurations of partitioning
(MBR, MBR & BSD disklabel, and even no partitioning),
the best I get is "Unknown filesystem".
This happens with either [UF]FSv[12].

Judging by some printfs i added, it is seeing the
correct magic in the superblock, but tracking down
the location it's actually bailing out is a bit
more eluding to me.

I'm using a checkout of grub2 CVS from today,
compiling on Debian GNU/Linux (etch).

The newfs(8) is from NetBSD 4.99.34,
if that makes any difference.

At the very least some tips on tracking this
down would be helpful.

Thanks,

	Jonathan Kollasch

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-19 17:01 UFS (FFS) support seems broken in grub2 jakllsch
@ 2008-01-19 18:27 ` walt
  2008-01-22 18:58   ` Bean
  0 siblings, 1 reply; 46+ messages in thread
From: walt @ 2008-01-19 18:27 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 389 bytes --]

jakllsch@kollasch.net wrote:
> Hi,
>
> The UFS (or FFS as it's known to NetBSD)
> support in grub2 does not seem to work for me.

There was an interesting but strangely incomplete discussion of
UFS back in April 2007.  Hitoshi Ozeki posted the attached patch,
which lets me list UFS filesystems but not read from them.

If you can use his patch to devise a real fix, I'd be very happy.




[-- Attachment #2: ufs.patch --]
[-- Type: text/x-patch, Size: 2960 bytes --]

--- grub-1.95/fs/ufs.c	2006-06-04 17:55:56.000000000 +0900
+++ grub-1.95-new/fs/ufs.c	2007-04-12 08:05:09.698149332 +0900
@@ -394,16 +394,13 @@
 static grub_err_t
 grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
 {
-  char fpath[grub_strlen (path)];
-  char *name = fpath;
-  char *next;
+  const char *name = path;
+  const char *next;
   unsigned int pos = 0;
   int dirino;
   
-  grub_strncpy (fpath, path, grub_strlen (path));
-  
   /* Skip the first slash.  */
-  if (name[0] == '/')
+  if (*name == '/')
     {
       name++;
       if (!*name)
@@ -412,17 +409,14 @@
 
   /* Extract the actual part from the pathname.  */
   next = grub_strchr (name, '/');
-  if (next)
-    {
-      next[0] = '\0';
-      next++;
-    }
+  if (!next)
+    next = &name[grub_strlen(name)];
   
   do
     {
       struct grub_ufs_dirent dirent;
       
-      if (grub_strlen (name) == 0)
+      if (next <= name)
 	return GRUB_ERR_NONE;
       
       if (grub_ufs_read_file (data, 0, pos, sizeof (dirent),
@@ -430,15 +424,13 @@
 	return grub_errno;
       
       {
-	char filename[dirent.namelen + 1];
+	char filename[dirent.namelen];
 
 	if (grub_ufs_read_file (data, 0, pos + sizeof (dirent),
 				dirent.namelen, filename) < 0)
 	  return grub_errno;
 	
-	filename[dirent.namelen] = '\0';
-	
-	if (!grub_strcmp (name, filename))
+	if ((&name[dirent.namelen] == next) && !grub_strncmp (name, filename, dirent.namelen))
 	  {
 	    dirino = data->ino;
 	    grub_ufs_read_inode (data, grub_le_to_cpu32 (dirent.ino));
@@ -450,18 +442,15 @@
 		  return grub_errno;
 	      }
 
-	    if (!next)
+	    if (!*next)
 	      return 0;
 
 	    pos = 0;
 
-	    name = next;
-	    next = grub_strchr (name, '/');
-	    if (next)
-	      {
-		next[0] = '\0';
-		next++;
-	      }
+	    name = next + 1;
+            next = grub_strchr (name, '/');
+            if (!next)
+              next = &name[grub_strlen(name)];
 	    
 	    if (!(dirent.filetype & GRUB_UFS_FILETYPE_DIR))
 	      return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
@@ -599,34 +588,43 @@
 grub_ufs_open (struct grub_file *file, const char *name)
 {
   struct grub_ufs_data *data;
+
+#ifndef GRUB_UTIL
+  grub_dl_ref (my_mod);
+#endif
+  
   data = grub_ufs_mount (file->device->disk);
   if (!data)
     return grub_errno;
   
   grub_ufs_read_inode (data, 2);
   if (grub_errno)
-    {
-      grub_free (data);
-      return grub_errno;
-    }
+    goto fail;
     
   if (!name || name[0] != '/')
     {
       grub_error (GRUB_ERR_BAD_FILENAME, "bad filename");
-      return grub_errno;
+      goto fail;
     }
   
   grub_ufs_find_file (data, name);
   if (grub_errno)
-    {
-      grub_free (data);
-      return grub_errno;
-    }
+    goto fail;
   
   file->data = data;
   file->size = INODE_SIZE (data);
 
   return GRUB_ERR_NONE;
+
+ fail:
+  
+  grub_free (data);
+  
+#ifndef GRUB_UTIL
+  grub_dl_unref (my_mod);
+#endif
+  
+  return grub_errno;
 }
 
 

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-19 18:27 ` walt
@ 2008-01-22 18:58   ` Bean
  2008-01-22 20:04     ` Robert Millan
  2008-01-23 16:15     ` walt
  0 siblings, 2 replies; 46+ messages in thread
From: Bean @ 2008-01-22 18:58 UTC (permalink / raw)
  To: The development of GRUB 2

This patch should fix the problem.

diff --git a/fs/ufs.c b/fs/ufs.c
index 917d9a2..bef19e6 100644
--- a/fs/ufs.c
+++ b/fs/ufs.c
@@ -38,6 +38,8 @@

 #define GRUB_UFS_ATTR_DIR	040000

+#define GRUB_UFS_MAX_VOLLEN	32
+
 /* Calculate in which group the inode can be found.  */
 #define inode_group(inode,sblock) ()

@@ -86,7 +88,12 @@ struct grub_ufs_sblock
   /* The frags per cylinder group.  */
   grub_uint32_t frags_per_group;

-  grub_uint8_t unused7[1180];
+  grub_uint8_t unused7[488];
+
+  /* Volume name for UFS2.  */
+  grub_uint8_t volume_name[GRUB_UFS_MAX_VOLLEN];
+
+  grub_uint8_t unused8[660];

   /* Magic value to check if this is really a UFS filesystem.  */
   grub_uint32_t magic;
@@ -393,13 +400,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data
*data, int ino)
 static grub_err_t
 grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
 {
-  char fpath[grub_strlen (path)];
+  char fpath[grub_strlen (path) + 1];
   char *name = fpath;
   char *next;
   unsigned int pos = 0;
   int dirino;

-  grub_strncpy (fpath, path, grub_strlen (path));
+  grub_strcpy (fpath, path);

   /* Skip the first slash.  */
   if (name[0] == '/')
@@ -649,10 +656,30 @@ grub_ufs_close (grub_file_t file)


 static grub_err_t
-grub_ufs_label (grub_device_t device __attribute ((unused)),
-		char **label __attribute ((unused)))
+grub_ufs_label (grub_device_t device,char **label)
 {
-  return GRUB_ERR_NONE;
+  struct grub_ufs_data *data = 0;
+
+#ifndef GRUB_UTIL
+  grub_dl_ref (my_mod);
+#endif
+
+  *label = 0;
+
+  data = grub_ufs_mount (device->disk);
+  if (data)
+    {
+      if (data->ufs_type == UFS2)
+        *label = grub_strdup ((char *) data->sblock.volume_name);
+    }
+
+#ifndef GRUB_UTIL
+  grub_dl_unref (my_mod);
+#endif
+
+  grub_free (data);
+
+  return grub_errno;
 }

 \f


-- 
Bean



^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-22 18:58   ` Bean
@ 2008-01-22 20:04     ` Robert Millan
  2008-01-23  9:02       ` Marco Gerards
  2008-01-23 16:15     ` walt
  1 sibling, 1 reply; 46+ messages in thread
From: Robert Millan @ 2008-01-22 20:04 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, Jan 23, 2008 at 02:58:02AM +0800, Bean wrote:
> This patch should fix the problem.

Nice!

> -grub_ufs_label (grub_device_t device __attribute ((unused)),
> -		char **label __attribute ((unused)))
> +grub_ufs_label (grub_device_t device,char **label)

Please add a space after the comma ;-)

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-22 20:04     ` Robert Millan
@ 2008-01-23  9:02       ` Marco Gerards
  0 siblings, 0 replies; 46+ messages in thread
From: Marco Gerards @ 2008-01-23  9:02 UTC (permalink / raw)
  To: The development of GRUB 2

Robert Millan <rmh@aybabtu.com> writes:

> On Wed, Jan 23, 2008 at 02:58:02AM +0800, Bean wrote:
>> This patch should fix the problem.
>
> Nice!
>
>> -grub_ufs_label (grub_device_t device __attribute ((unused)),
>> -		char **label __attribute ((unused)))
>> +grub_ufs_label (grub_device_t device,char **label)
>
> Please add a space after the comma ;-)

And a changelog entry ;-)

--
Marco




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-22 18:58   ` Bean
  2008-01-22 20:04     ` Robert Millan
@ 2008-01-23 16:15     ` walt
  2008-01-23 16:31       ` Bean
  1 sibling, 1 reply; 46+ messages in thread
From: walt @ 2008-01-23 16:15 UTC (permalink / raw)
  To: grub-devel

Bean wrote:
> This patch should fix the problem...

Yes, thanks!  I had to use the -l flag before patch would use it,
and even then the last hunk needed increased fuzz.

Are you going to commit it today?




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-23 16:15     ` walt
@ 2008-01-23 16:31       ` Bean
  2008-01-23 19:21         ` Marco Gerards
  2008-01-23 22:49         ` walt
  0 siblings, 2 replies; 46+ messages in thread
From: Bean @ 2008-01-23 16:31 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 24, 2008 12:15 AM, walt <wa1ter@myrealbox.com> wrote:
> Bean wrote:
> > This patch should fix the problem...
>
> Yes, thanks!  I had to use the -l flag before patch would use it,
> and even then the last hunk needed increased fuzz.
>
> Are you going to commit it today?

thanks for the testing, if you have ufs2, please check it as well.

this is the new patch after adding changelog:


	* fs/ufs.c (GRUB_UFS_MAX_VOLLEN) : New constant.
	(grub_ufs_sblock) : New member volume name.
	(grub_ufs_find_file) : Fix string copy bug.
	(grub_ufs_label) : Implement this function properly.


diff --git a/fs/ufs.c b/fs/ufs.c
index 917d9a2..a1fdcda 100644
--- a/fs/ufs.c
+++ b/fs/ufs.c
@@ -38,6 +38,8 @@

 #define GRUB_UFS_ATTR_DIR	040000

+#define GRUB_UFS_MAX_VOLLEN	32
+
 /* Calculate in which group the inode can be found.  */
 #define inode_group(inode,sblock) ()

@@ -86,7 +88,12 @@ struct grub_ufs_sblock
   /* The frags per cylinder group.  */
   grub_uint32_t frags_per_group;

-  grub_uint8_t unused7[1180];
+  grub_uint8_t unused7[488];
+
+  /* Volume name for UFS2.  */
+  grub_uint8_t volume_name[GRUB_UFS_MAX_VOLLEN];
+
+  grub_uint8_t unused8[660];

   /* Magic value to check if this is really a UFS filesystem.  */
   grub_uint32_t magic;
@@ -393,13 +400,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data
*data, int ino)
 static grub_err_t
 grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
 {
-  char fpath[grub_strlen (path)];
+  char fpath[grub_strlen (path) + 1];
   char *name = fpath;
   char *next;
   unsigned int pos = 0;
   int dirino;

-  grub_strncpy (fpath, path, grub_strlen (path));
+  grub_strcpy (fpath, path);

   /* Skip the first slash.  */
   if (name[0] == '/')
@@ -649,10 +656,30 @@ grub_ufs_close (grub_file_t file)


 static grub_err_t
-grub_ufs_label (grub_device_t device __attribute ((unused)),
-		char **label __attribute ((unused)))
+grub_ufs_label (grub_device_t device, char **label)
 {
-  return GRUB_ERR_NONE;
+  struct grub_ufs_data *data = 0;
+
+#ifndef GRUB_UTIL
+  grub_dl_ref (my_mod);
+#endif
+
+  *label = 0;
+
+  data = grub_ufs_mount (device->disk);
+  if (data)
+    {
+      if (data->ufs_type == UFS2)
+        *label = grub_strdup ((char *) data->sblock.volume_name);
+    }
+
+#ifndef GRUB_UTIL
+  grub_dl_unref (my_mod);
+#endif
+
+  grub_free (data);
+
+  return grub_errno;
 }

 \f



-- 
Bean



^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-23 16:31       ` Bean
@ 2008-01-23 19:21         ` Marco Gerards
  2008-01-23 20:26           ` Bean
  2008-01-23 22:49         ` walt
  1 sibling, 1 reply; 46+ messages in thread
From: Marco Gerards @ 2008-01-23 19:21 UTC (permalink / raw)
  To: The development of GRUB 2

Bean <bean123ch@gmail.com> writes:

> On Jan 24, 2008 12:15 AM, walt <wa1ter@myrealbox.com> wrote:
>> Bean wrote:
>> > This patch should fix the problem...
>>
>> Yes, thanks!  I had to use the -l flag before patch would use it,
>> and even then the last hunk needed increased fuzz.
>>
>> Are you going to commit it today?
>
> thanks for the testing, if you have ufs2, please check it as well.

Hopefully it can be tested.

> this is the new patch after adding changelog:
>
>
> 	* fs/ufs.c (GRUB_UFS_MAX_VOLLEN) : New constant.

s/constant/macro/

VOLNAME_LEN would be better, I think

> 	(grub_ufs_sblock) : New member volume name.
> 	(grub_ufs_find_file) : Fix string copy bug.
> 	(grub_ufs_label) : Implement this function properly.

If you can make these changes, feel free to commit the patch.

--
Marco




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-23 19:21         ` Marco Gerards
@ 2008-01-23 20:26           ` Bean
  0 siblings, 0 replies; 46+ messages in thread
From: Bean @ 2008-01-23 20:26 UTC (permalink / raw)
  To: The development of GRUB 2

Committed.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-23 16:31       ` Bean
  2008-01-23 19:21         ` Marco Gerards
@ 2008-01-23 22:49         ` walt
  2008-01-23 23:53           ` Robert Millan
  2008-01-24  8:33           ` UFS (FFS) support seems broken in grub2 Marco Gerards
  1 sibling, 2 replies; 46+ messages in thread
From: walt @ 2008-01-23 22:49 UTC (permalink / raw)
  To: grub-devel

Bean wrote:
> On Jan 24, 2008 12:15 AM, walt<wa1ter@myrealbox.com>  wrote:
>> Bean wrote:
>>> This patch should fix the problem...
>> Yes, thanks!  I had to use the -l flag before patch would use it,
>> and even then the last hunk needed increased fuzz.
>>
>> Are you going to commit it today?
>
> thanks for the testing, if you have ufs2, please check it as well...

I see you have already commited, thank you!  I did test both UFS1/2
and both work nicely.  I can list and cat any files on a UFS fs now.

Unfortunately, I don't know how to boot any of the BSD kernels with
grub2 :o(

I recompiled my NetBSD kernel with the MULTIBOOT option enabled, but
I still get a 'magic broken' error when doing 'multiboot /netbsd'.

On FreeBSD I use grub0.95 to load /boot/loader as 'the kernel' and
everything just works.  Using grub2, I can't tell exactly what I am
supposed to use, e.g. insmod, module, or [whatever].  There is no
'kernel' command any more, right?

I can use 'linux' to boot linux with no problems, which is the easy
part.

I can use chainload on any BSD as long as the boot record is installed
properly (which is a bit tricky and dangerous for the BSD newbie).

Any hints would be most welcome, and thanks again.




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-23 22:49         ` walt
@ 2008-01-23 23:53           ` Robert Millan
  2008-01-24  1:21             ` walt
  2008-01-24  8:33           ` UFS (FFS) support seems broken in grub2 Marco Gerards
  1 sibling, 1 reply; 46+ messages in thread
From: Robert Millan @ 2008-01-23 23:53 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, Jan 23, 2008 at 02:49:55PM -0800, walt wrote:
> 
> I recompiled my NetBSD kernel with the MULTIBOOT option enabled, but
> I still get a 'magic broken' error when doing 'multiboot /netbsd'.

The kernel of NetBSD supports multiboot now?  Or maybe it's referring to
something else?

What's the exact error message?

> On FreeBSD I use grub0.95 to load /boot/loader as 'the kernel' and
> everything just works.  Using grub2, I can't tell exactly what I am
> supposed to use, e.g. insmod, module, or [whatever].  There is no
> 'kernel' command any more, right?

Someone should write a new loader for that.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-23 23:53           ` Robert Millan
@ 2008-01-24  1:21             ` walt
  2008-01-24 12:30               ` booting *BSD kernels (Re: UFS (FFS) support seems broken in grub2) Robert Millan
  0 siblings, 1 reply; 46+ messages in thread
From: walt @ 2008-01-24  1:21 UTC (permalink / raw)
  To: grub-devel

Robert Millan wrote:
> On Wed, Jan 23, 2008 at 02:49:55PM -0800, walt wrote:
>> I recompiled my NetBSD kernel with the MULTIBOOT option enabled, but
>> I still get a 'magic broken' error when doing 'multiboot /netbsd'.
>
> The kernel of NetBSD supports multiboot now?  Or maybe it's referring to
> something else?

I'm referring to NetBSD-HEAD, not RELEASE.  I'm sure you will understand
the commit messages better than I do (search for multiboot):

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/i386/conf/GENERIC

> What's the exact error message?

free magic is broken at 0x5cb60: 0xbb<etc>

>
>> On FreeBSD I use grub0.95 to load /boot/loader as 'the kernel' and
>> everything just works.  Using grub2, I can't tell exactly what I am
>> supposed to use, e.g. insmod, module, or [whatever].  There is no
>> 'kernel' command any more, right?
>
> Someone should write a new loader for that.

Would it be better to add multiboot support to the kernel and eliminate
/boot/loader?






^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-23 22:49         ` walt
  2008-01-23 23:53           ` Robert Millan
@ 2008-01-24  8:33           ` Marco Gerards
  2008-01-24 14:20             ` walt
  1 sibling, 1 reply; 46+ messages in thread
From: Marco Gerards @ 2008-01-24  8:33 UTC (permalink / raw)
  To: The development of GRUB 2

walt <wa1ter@myrealbox.com> writes:

> Bean wrote:
>> On Jan 24, 2008 12:15 AM, walt<wa1ter@myrealbox.com>  wrote:
>>> Bean wrote:
>>>> This patch should fix the problem...
>>> Yes, thanks!  I had to use the -l flag before patch would use it,
>>> and even then the last hunk needed increased fuzz.
>>>
>>> Are you going to commit it today?
>>
>> thanks for the testing, if you have ufs2, please check it as well...
>
> I see you have already commited, thank you!  I did test both UFS1/2
> and both work nicely.  I can list and cat any files on a UFS fs now.
>
> Unfortunately, I don't know how to boot any of the BSD kernels with
> grub2 :o(

I am not sure about BSD, one way is to load the BSD loader.  But a
more direct approach (as in loading the BSD kernel) would be nice.  Do
you want to work on this?

> I recompiled my NetBSD kernel with the MULTIBOOT option enabled, but
> I still get a 'magic broken' error when doing 'multiboot /netbsd'.

Can it be loaded from GRUB Legacy using its multiboot capabilities?

> On FreeBSD I use grub0.95 to load /boot/loader as 'the kernel' and
> everything just works.  Using grub2, I can't tell exactly what I am
> supposed to use, e.g. insmod, module, or [whatever].  There is no
> 'kernel' command any more, right?

No.  I think there is no loader yet for BSD.

> I can use 'linux' to boot linux with no problems, which is the easy
> part.
>
> I can use chainload on any BSD as long as the boot record is installed
> properly (which is a bit tricky and dangerous for the BSD newbie).
>
> Any hints would be most welcome, and thanks again.

Do you want to work on a loader for BSD?  That would be the ideal
solution and a nice opportunity for you to learn :-)

--
Marco




^ permalink raw reply	[flat|nested] 46+ messages in thread

* booting *BSD kernels (Re: UFS (FFS) support seems broken in grub2)
  2008-01-24  1:21             ` walt
@ 2008-01-24 12:30               ` Robert Millan
  0 siblings, 0 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-24 12:30 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, Jan 23, 2008 at 05:21:26PM -0800, walt wrote:
> Robert Millan wrote:
> >On Wed, Jan 23, 2008 at 02:49:55PM -0800, walt wrote:
> >>I recompiled my NetBSD kernel with the MULTIBOOT option enabled, but
> >>I still get a 'magic broken' error when doing 'multiboot /netbsd'.
> >
> >The kernel of NetBSD supports multiboot now?  Or maybe it's referring to
> >something else?
> 
> I'm referring to NetBSD-HEAD, not RELEASE.  I'm sure you will understand
> the commit messages better than I do (search for multiboot):
> 
> http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/i386/conf/GENERIC

Really nice.  Does this work with GRUB Legacy?

> >What's the exact error message?
> 
> free magic is broken at 0x5cb60: 0xbb<etc>

That means memory corruption.  Can have a variety of causes :-/

> >>On FreeBSD I use grub0.95 to load /boot/loader as 'the kernel' and
> >>everything just works.  Using grub2, I can't tell exactly what I am
> >>supposed to use, e.g. insmod, module, or [whatever].  There is no
> >>'kernel' command any more, right?
> >
> >Someone should write a new loader for that.
> 
> Would it be better to add multiboot support to the kernel and eliminate
> /boot/loader?

Of course.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-24  8:33           ` UFS (FFS) support seems broken in grub2 Marco Gerards
@ 2008-01-24 14:20             ` walt
  2008-01-24 14:33               ` booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2) Robert Millan
  2008-01-24 18:16               ` UFS (FFS) support seems broken in grub2 Marco Gerards
  0 siblings, 2 replies; 46+ messages in thread
From: walt @ 2008-01-24 14:20 UTC (permalink / raw)
  To: grub-devel

Marco Gerards wrote:
> walt<wa1ter@myrealbox.com>  writes:
>
...
>> I recompiled my NetBSD kernel with the MULTIBOOT option enabled, but
>> I still get a 'magic broken' error when doing 'multiboot /netbsd'.

> Can it be loaded from GRUB Legacy using its multiboot capabilities?

Yes!

> Do you want to work on a loader for BSD?  That would be the ideal
> solution and a nice opportunity for you to learn :-)

Sure, but don't expect very much :o)  We know that grub legacy can
boot NetBSD, so maybe I can get grub2 to do the same.  Debugging
a free-standing program like grub is something I've never tried.
How would you approach the problem if you were going to do it
yourself?




^ permalink raw reply	[flat|nested] 46+ messages in thread

* booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-24 14:20             ` walt
@ 2008-01-24 14:33               ` Robert Millan
  2008-01-24 14:53                 ` Robert Millan
  2008-01-24 18:16               ` UFS (FFS) support seems broken in grub2 Marco Gerards
  1 sibling, 1 reply; 46+ messages in thread
From: Robert Millan @ 2008-01-24 14:33 UTC (permalink / raw)
  To: The development of GRUB 2

On Thu, Jan 24, 2008 at 06:20:07AM -0800, walt wrote:
> >Do you want to work on a loader for BSD?  That would be the ideal
> >solution and a nice opportunity for you to learn :-)
> 
> Sure, but don't expect very much :o)  We know that grub legacy can
> boot NetBSD, so maybe I can get grub2 to do the same.  Debugging
> a free-standing program like grub is something I've never tried.
> How would you approach the problem if you were going to do it
> yourself?

I was afraid too, but if you're used to debugging normal programs it's not
so difficult.  GRUB is just like a big, single-threaded C program really.

I usually just turn on debugging output to grasp where things start to go
ill, and add lots printfs to figure out what lines of code are reached,
at which point a value is corrupted, etc.

When I reach a cpu fault, I tend to put a "while (1);" loop someplace and
start moving it forward till I find the last point where runtime is still
"sane".

Also, if you're familiar with an emulator that supports debugging (I think
both qemu and bochs do), you can use that (but without direct debugging symbol
support, of course).

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-24 14:33               ` booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2) Robert Millan
@ 2008-01-24 14:53                 ` Robert Millan
  2008-01-24 16:47                   ` walt
  0 siblings, 1 reply; 46+ messages in thread
From: Robert Millan @ 2008-01-24 14:53 UTC (permalink / raw)
  To: The development of GRUB 2


Btw, if you put that kernel image somewhere, chances are higher that someone
gives it a try.  Setting up a NetBSD system (and figuring out how to play with
kernel options) just to test that can be too much of a hassle for most of us.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-24 14:53                 ` Robert Millan
@ 2008-01-24 16:47                   ` walt
  2008-01-24 17:12                     ` Robert Millan
  0 siblings, 1 reply; 46+ messages in thread
From: walt @ 2008-01-24 16:47 UTC (permalink / raw)
  To: grub-devel


On Thu, 2008-01-24 at 15:53 +0100, Robert Millan wrote:
> Btw, if you put that kernel image somewhere, chances are higher that someone
> gives it a try...

http://rapidshare.com/files/86269193/netbsd.html

grub2 will certainly get fixed faster if one of you does the fixing :o)






^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-24 16:47                   ` walt
@ 2008-01-24 17:12                     ` Robert Millan
  2008-01-26 15:01                       ` Bean
  0 siblings, 1 reply; 46+ messages in thread
From: Robert Millan @ 2008-01-24 17:12 UTC (permalink / raw)
  To: The development of GRUB 2

On Thu, Jan 24, 2008 at 08:47:52AM -0800, walt wrote:
> 
> On Thu, 2008-01-24 at 15:53 +0100, Robert Millan wrote:
> > Btw, if you put that kernel image somewhere, chances are higher that someone
> > gives it a try...
> 
> http://rapidshare.com/files/86269193/netbsd.html

Ouch, what an horrid download site :-)

Here, I put it at debian webserver for the convenience of others:

  http://people.debian.org/~rmh/grub/multiboot_netbsd.gz

> grub2 will certainly get fixed faster if one of you does the fixing :o)

This issue in particular is not very high priority for me.  I'd like to look
at it, but other things go first in my list.  If noone else picks this up, it
means the fastest way is if you help us by providing a patch ;-)

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-24 14:20             ` walt
  2008-01-24 14:33               ` booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2) Robert Millan
@ 2008-01-24 18:16               ` Marco Gerards
  2008-01-24 18:19                 ` Robert Millan
  1 sibling, 1 reply; 46+ messages in thread
From: Marco Gerards @ 2008-01-24 18:16 UTC (permalink / raw)
  To: The development of GRUB 2

walt <wa1ter@myrealbox.com> writes:

> Marco Gerards wrote:
>> walt<wa1ter@myrealbox.com>  writes:
>>
> ...
>>> I recompiled my NetBSD kernel with the MULTIBOOT option enabled, but
>>> I still get a 'magic broken' error when doing 'multiboot /netbsd'.
>
>> Can it be loaded from GRUB Legacy using its multiboot capabilities?
>
> Yes!

The error cannot be found in the sourcecode.  Can you provide the
*exact* error?  Providing a kernel might help as well.

>> Do you want to work on a loader for BSD?  That would be the ideal
>> solution and a nice opportunity for you to learn :-)
>
> Sure, but don't expect very much :o)  We know that grub legacy can
> boot NetBSD, so maybe I can get grub2 to do the same.  Debugging
> a free-standing program like grub is something I've never tried.
> How would you approach the problem if you were going to do it
> yourself?

Read how the loader should work (*BSD documents), get a test kernel,
write a loader and see if it works.  Possibly on qemu, dprintf helps a
lot for debugging.

--
Marco




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: UFS (FFS) support seems broken in grub2
  2008-01-24 18:16               ` UFS (FFS) support seems broken in grub2 Marco Gerards
@ 2008-01-24 18:19                 ` Robert Millan
  0 siblings, 0 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-24 18:19 UTC (permalink / raw)
  To: The development of GRUB 2

On Thu, Jan 24, 2008 at 07:16:06PM +0100, Marco Gerards wrote:
> 
> The error cannot be found in the sourcecode.  Can you provide the
> *exact* error?  Providing a kernel might help as well.

He did:  "free magic is broken at 0x5cb60: 0xbb<etc>"

Memory corruption, it seems.

> Read how the loader should work (*BSD documents), get a test kernel,
> write a loader and see if it works.  Possibly on qemu, dprintf helps a
> lot for debugging.

Actually, it's a multiboot image.  I tested it with GRUB Legacy:

  http://people.debian.org/~rmh/grub/multiboot_netbsd.gz

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-24 17:12                     ` Robert Millan
@ 2008-01-26 15:01                       ` Bean
  2008-01-26 17:24                         ` Robert Millan
                                           ` (2 more replies)
  0 siblings, 3 replies; 46+ messages in thread
From: Bean @ 2008-01-26 15:01 UTC (permalink / raw)
  To: The development of GRUB 2

this is the patch, problems found:

1, the mbi structure is not initialized to all zeros, this means some
important member, like mods_count, will contain trash.
2, the entry point in the header is virtual address, we need to
translate it to physical address.

	* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
	address of entry.
	(grub_multiboot_load_elf64): Likewise.
	(grub_multiboot): Initialize mbi structure.


diff --git a/loader/i386/pc/multiboot.c b/loader/i386/pc/multiboot.c
index fa6346e..2fd2b24 100644
--- a/loader/i386/pc/multiboot.c
+++ b/loader/i386/pc/multiboot.c
@@ -96,6 +96,7 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer)
 {
   Elf32_Ehdr *ehdr = (Elf32_Ehdr *) buffer;
   Elf32_Phdr *phdr;
+  grub_addr_t real_entry = 0;
   int i;

   if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
@@ -144,9 +145,16 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer)
           if (phdr->p_filesz < phdr->p_memsz)
             grub_memset ((char *) phdr->p_paddr + phdr->p_filesz, 0,
 			 phdr->p_memsz - phdr->p_filesz);
+
+          if ((entry >= phdr->p_vaddr) &&
+	      (entry < phdr->p_vaddr + phdr->p_memsz))
+	    real_entry = entry + phdr->p_paddr - phdr->p_vaddr;
         }
     }
-
+
+  if (real_entry)
+    entry = real_entry;
+
   return grub_errno;
 }

@@ -164,6 +172,7 @@ grub_multiboot_load_elf64 (grub_file_t file, void *buffer)
 {
   Elf64_Ehdr *ehdr = (Elf64_Ehdr *) buffer;
   Elf64_Phdr *phdr;
+  grub_addr_t real_entry = 0;
   int i;

   if (ehdr->e_ident[EI_CLASS] != ELFCLASS64)
@@ -226,9 +235,16 @@ grub_multiboot_load_elf64 (grub_file_t file, void *buffer)
 			  + phdr->p_filesz),
 			 0,
 			 phdr->p_memsz - phdr->p_filesz);
+
+	  if ((entry >= phdr->p_vaddr) &&
+	      (entry < phdr->p_vaddr + phdr->p_memsz))
+	    real_entry = entry + phdr->p_paddr - phdr->p_vaddr;
         }
     }
-
+
+  if (real_entry)
+    entry = real_entry;
+
   return grub_errno;
 }

@@ -306,6 +322,8 @@ grub_multiboot (int argc, char *argv[])
   if (! mbi)
     goto fail;

+  grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));
+
   mbi->flags = MULTIBOOT_INFO_MEMORY;

   /* Convert from bytes to kilobytes.  */

-- 
Bean



^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 15:01                       ` Bean
@ 2008-01-26 17:24                         ` Robert Millan
  2008-01-26 18:19                           ` walt
  2008-01-26 21:24                         ` walt
  2008-02-06 15:32                         ` Robert Millan
  2 siblings, 1 reply; 46+ messages in thread
From: Robert Millan @ 2008-01-26 17:24 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote:
> this is the patch, problems found:
> 
> 1, the mbi structure is not initialized to all zeros, this means some
> important member, like mods_count, will contain trash.
> 2, the entry point in the header is virtual address, we need to
> translate it to physical address.
> 
> 	* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
> 	address of entry.
> 	(grub_multiboot_load_elf64): Likewise.
> 	(grub_multiboot): Initialize mbi structure.

Wow, you're inexhaustible :-)

Btw it won't apply to CVS head; maybe it was scrambled when sending it?

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 17:24                         ` Robert Millan
@ 2008-01-26 18:19                           ` walt
  2008-01-26 18:24                             ` Bean
  2008-01-26 19:57                             ` Robert Millan
  0 siblings, 2 replies; 46+ messages in thread
From: walt @ 2008-01-26 18:19 UTC (permalink / raw)
  To: grub-devel


On Sat, 2008-01-26 at 18:24 +0100, Robert Millan wrote:
> On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote:
> > this is the patch, problems found:
> > 
> > 1, the mbi structure is not initialized to all zeros, this means some
> > important member, like mods_count, will contain trash.
> > 2, the entry point in the header is virtual address, we need to
> > translate it to physical address.
> > 
> > 	* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
> > 	address of entry.
> > 	(grub_multiboot_load_elf64): Likewise.
> > 	(grub_multiboot): Initialize mbi structure.
> 
> Wow, you're inexhaustible :-)

Indeed!  Unfortunately I still get the same free magic is broken :o(
As an experiment, I g-zipped the kernel and now grub2 just reboots
without printing anything when I do multiboot /netbsd.gz.  (The same
kernel still boots normally with legacy grub.)
 

> Btw it won't apply to CVS head; maybe it was scrambled when sending it?

I had to use the -l flag to get it to apply, but it did apply okay.







^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 18:19                           ` walt
@ 2008-01-26 18:24                             ` Bean
  2008-01-26 18:31                               ` Bean
  2008-01-26 19:57                               ` Robert Millan
  2008-01-26 19:57                             ` Robert Millan
  1 sibling, 2 replies; 46+ messages in thread
From: Bean @ 2008-01-26 18:24 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 27, 2008 2:19 AM, walt <wa1ter@myrealbox.com> wrote:
>
> On Sat, 2008-01-26 at 18:24 +0100, Robert Millan wrote:
> > On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote:
> > > this is the patch, problems found:
> > >
> > > 1, the mbi structure is not initialized to all zeros, this means some
> > > important member, like mods_count, will contain trash.
> > > 2, the entry point in the header is virtual address, we need to
> > > translate it to physical address.
> > >
> > >     * loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
> > >     address of entry.
> > >     (grub_multiboot_load_elf64): Likewise.
> > >     (grub_multiboot): Initialize mbi structure.
> >
> > Wow, you're inexhaustible :-)
>
> Indeed!  Unfortunately I still get the same free magic is broken :o(
> As an experiment, I g-zipped the kernel and now grub2 just reboots
> without printing anything when I do multiboot /netbsd.gz.  (The same
> kernel still boots normally with legacy grub.)

don't gzip it, grub2 doesn't support auto decompression like grub legacy.

>
>
> > Btw it won't apply to CVS head; maybe it was scrambled when sending it?
>
> I had to use the -l flag to get it to apply, but it did apply okay.

maybe blank line problem.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 18:24                             ` Bean
@ 2008-01-26 18:31                               ` Bean
  2008-01-26 19:57                               ` Robert Millan
  1 sibling, 0 replies; 46+ messages in thread
From: Bean @ 2008-01-26 18:31 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 27, 2008 2:24 AM, Bean <bean123ch@gmail.com> wrote:
> On Jan 27, 2008 2:19 AM, walt <wa1ter@myrealbox.com> wrote:
> >
> > On Sat, 2008-01-26 at 18:24 +0100, Robert Millan wrote:
> > > On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote:
> > > > this is the patch, problems found:
> > > >
> > > > 1, the mbi structure is not initialized to all zeros, this means some
> > > > important member, like mods_count, will contain trash.
> > > > 2, the entry point in the header is virtual address, we need to
> > > > translate it to physical address.
> > > >
> > > >     * loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
> > > >     address of entry.
> > > >     (grub_multiboot_load_elf64): Likewise.
> > > >     (grub_multiboot): Initialize mbi structure.
> > >
> > > Wow, you're inexhaustible :-)
> >
> > Indeed!  Unfortunately I still get the same free magic is broken :o(
> > As an experiment, I g-zipped the kernel and now grub2 just reboots
> > without printing anything when I do multiboot /netbsd.gz.  (The same
> > kernel still boots normally with legacy grub.)
>
> don't gzip it, grub2 doesn't support auto decompression like grub legacy.

i just try multiboot_netbsd.gz, i boot ok. maybe you send netbsd.gz
somewhere for me to test.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 18:24                             ` Bean
  2008-01-26 18:31                               ` Bean
@ 2008-01-26 19:57                               ` Robert Millan
  1 sibling, 0 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-26 19:57 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Jan 27, 2008 at 02:24:16AM +0800, Bean wrote:
> >
> > Indeed!  Unfortunately I still get the same free magic is broken :o(
> > As an experiment, I g-zipped the kernel and now grub2 just reboots
> > without printing anything when I do multiboot /netbsd.gz.  (The same
> > kernel still boots normally with legacy grub.)
> 
> don't gzip it, grub2 doesn't support auto decompression like grub legacy.

I thought it was supported at user interface level.  Was this what you were
trying to fix before?  I recall some thread about it.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 18:19                           ` walt
  2008-01-26 18:24                             ` Bean
@ 2008-01-26 19:57                             ` Robert Millan
  1 sibling, 0 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-26 19:57 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Jan 26, 2008 at 10:19:36AM -0800, walt wrote:
> > Btw it won't apply to CVS head; maybe it was scrambled when sending it?
> 
> I had to use the -l flag to get it to apply, but it did apply okay.

Ah, didn't know about this flag.  Sounds useful!

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 15:01                       ` Bean
  2008-01-26 17:24                         ` Robert Millan
@ 2008-01-26 21:24                         ` walt
  2008-01-27  1:35                           ` Bean
  2008-01-27  8:53                           ` Robert Millan
  2008-02-06 15:32                         ` Robert Millan
  2 siblings, 2 replies; 46+ messages in thread
From: walt @ 2008-01-26 21:24 UTC (permalink / raw)
  To: grub-devel


On Sat, 2008-01-26 at 23:01 +0800, Bean wrote:
> this is the patch, problems found:
> 
> 1, the mbi structure is not initialized to all zeros, this means some
> important member, like mods_count, will contain trash.
> 2, the entry point in the header is virtual address, we need to
> translate it to physical address...

Yes!  I just discovered that I can multiboot the netbsd kernel off
of a FAT32 fs or even an NTFS fs, but *not* off of a UFS fs :o/

Apparently "something bad" happens to the kernel in the process of
reading or loading it from the UFS fs.  I can read small text files
from a UFS fs, however, so I'm thinking maybe this has something to
do with the size of the netbsd kernel?

BTW, I've tried booting the netbsd kernel off of a FreeBSD UFS1 fs
but I can't tell if my NetBSD partition is UFS1 or UFS2 -- dumpfs
doesn't say which kind it is.  I confess I really don't remember if
I have any UFS2 partitions or not.

Excellent work so far in just one day!  Got any other tricks? :o)





^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 21:24                         ` walt
@ 2008-01-27  1:35                           ` Bean
  2008-01-27 20:13                             ` walt
  2008-01-27  8:53                           ` Robert Millan
  1 sibling, 1 reply; 46+ messages in thread
From: Bean @ 2008-01-27  1:35 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 27, 2008 5:24 AM, walt <wa1ter@myrealbox.com> wrote:
>
> On Sat, 2008-01-26 at 23:01 +0800, Bean wrote:
> > this is the patch, problems found:
> >
> > 1, the mbi structure is not initialized to all zeros, this means some
> > important member, like mods_count, will contain trash.
> > 2, the entry point in the header is virtual address, we need to
> > translate it to physical address...
>
> Yes!  I just discovered that I can multiboot the netbsd kernel off
> of a FAT32 fs or even an NTFS fs, but *not* off of a UFS fs :o/
>
> Apparently "something bad" happens to the kernel in the process of
> reading or loading it from the UFS fs.  I can read small text files
> from a UFS fs, however, so I'm thinking maybe this has something to
> do with the size of the netbsd kernel?
>
> BTW, I've tried booting the netbsd kernel off of a FreeBSD UFS1 fs
> but I can't tell if my NetBSD partition is UFS1 or UFS2 -- dumpfs
> doesn't say which kind it is.  I confess I really don't remember if
> I have any UFS2 partitions or not.
>
> Excellent work so far in just one day!  Got any other tricks? :o)

please make a small ufs image containing the netbsd kernel, i don't a
a bsd system at hand.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 21:24                         ` walt
  2008-01-27  1:35                           ` Bean
@ 2008-01-27  8:53                           ` Robert Millan
  2008-01-27 20:09                             ` walt
  2008-01-28  8:57                             ` Marco Gerards
  1 sibling, 2 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-27  8:53 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Jan 26, 2008 at 01:24:57PM -0800, walt wrote:
> 
> Yes!  I just discovered that I can multiboot the netbsd kernel off
> of a FAT32 fs or even an NTFS fs, but *not* off of a UFS fs :o/
> 
> Apparently "something bad" happens to the kernel in the process of
> reading or loading it from the UFS fs.  I can read small text files
> from a UFS fs, however, so I'm thinking maybe this has something to
> do with the size of the netbsd kernel?

I just committed a check in grub-probe that attempts to read and verify files
using GRUB filesystems and compares them with output from your system.  E.g.
if you do:  grub-probe -t fs /full/path/to/file it will compare and verify it
using fs/ufs.c.

Bean, IIRC you planned add something similar.  Is this feature useful to you?

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-27  8:53                           ` Robert Millan
@ 2008-01-27 20:09                             ` walt
  2008-01-27 22:11                               ` Robert Millan
  2008-01-28  8:57                             ` Marco Gerards
  1 sibling, 1 reply; 46+ messages in thread
From: walt @ 2008-01-27 20:09 UTC (permalink / raw)
  To: grub-devel


On Sun, 2008-01-27 at 09:53 +0100, Robert Millan wrote:

> I just committed a check in grub-probe that attempts to read and verify files
> using GRUB filesystems and compares them with output from your system.  E.g.
> if you do:  grub-probe -t fs /full/path/to/file it will compare and verify it
> using fs/ufs.c.

A few problems.  grub-mkdevicemap generates an incomplete file 
containing only a very long list of (hd0), (hd1) ... (hd35) with
no matching device names.  I edited the file by hand to this:
(hd0)   /dev/ad0
(hd1)   /dev/ad1

# grub-probe /           
grub-probe: error: cannot find a device for /.

# grub-probe -t fs /kernel
grub-probe: error: cannot find a device for /kernel.

It seems that grub2 doesn't detect the existing devices including (fd0)
on a *BSD system, though it works great on linux.  Oh, and I have a
FAT32 fs mounted on /c and grub-probe still gives me the same error,
so it seems device related rather than fs related.

I still have some ideas to try on the different BSD's to see if they
all act the same.

BTW, gcc on NetBSD *does* support -fstack-protector :o/







^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-27  1:35                           ` Bean
@ 2008-01-27 20:13                             ` walt
  2008-01-27 20:25                               ` Bean
  0 siblings, 1 reply; 46+ messages in thread
From: walt @ 2008-01-27 20:13 UTC (permalink / raw)
  To: grub-devel


On Sun, 2008-01-27 at 09:35 +0800, Bean wrote:
> On Jan 27, 2008 5:24 AM, walt <wa1ter@myrealbox.com> wrote:
> >
> > Apparently "something bad" happens to the kernel in the process of
> > reading or loading it from the UFS fs.  I can read small text files
> > from a UFS fs, however, so I'm thinking maybe this has something to
> > do with the size of the netbsd kernel?

> please make a small ufs image containing the netbsd kernel, i don't a
> a bsd system at hand.

I can use dd to copy a UFS fs to a file.  Is that what you mean?  Are
you planning to use the loopback feature in grub2 to use the image?
(I want to test the image before I send it to you.)






^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-27 20:13                             ` walt
@ 2008-01-27 20:25                               ` Bean
  2008-01-28  1:54                                 ` walt
  0 siblings, 1 reply; 46+ messages in thread
From: Bean @ 2008-01-27 20:25 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 28, 2008 4:13 AM, walt <wa1ter@myrealbox.com> wrote:
>
> On Sun, 2008-01-27 at 09:35 +0800, Bean wrote:
> > On Jan 27, 2008 5:24 AM, walt <wa1ter@myrealbox.com> wrote:
> > >
> > > Apparently "something bad" happens to the kernel in the process of
> > > reading or loading it from the UFS fs.  I can read small text files
> > > from a UFS fs, however, so I'm thinking maybe this has something to
> > > do with the size of the netbsd kernel?
>
> > please make a small ufs image containing the netbsd kernel, i don't a
> > a bsd system at hand.
>
> I can use dd to copy a UFS fs to a file.  Is that what you mean?  Are
> you planning to use the loopback feature in grub2 to use the image?
> (I want to test the image before I send it to you.)

yes, thanks.

btw, if you have time, please try the a.out loader, it should be able
to boot /boot/loader of freebsd, i don't know if openbsd and netbsd
use the same booting method.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-27 20:09                             ` walt
@ 2008-01-27 22:11                               ` Robert Millan
  0 siblings, 0 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-27 22:11 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Jan 27, 2008 at 12:09:20PM -0800, walt wrote:
> 
> On Sun, 2008-01-27 at 09:53 +0100, Robert Millan wrote:
> 
> > I just committed a check in grub-probe that attempts to read and verify files
> > using GRUB filesystems and compares them with output from your system.  E.g.
> > if you do:  grub-probe -t fs /full/path/to/file it will compare and verify it
> > using fs/ufs.c.
> 
> A few problems.  grub-mkdevicemap generates an incomplete file 
> containing only a very long list of (hd0), (hd1) ... (hd35) with
> no matching device names.  I edited the file by hand to this:
> (hd0)   /dev/ad0
> (hd1)   /dev/ad1
> 
> # grub-probe /           
> grub-probe: error: cannot find a device for /.
> 
> # grub-probe -t fs /kernel
> grub-probe: error: cannot find a device for /kernel.

Someone sent a patch for this, search for "[PATCH] grub-probe && FreeBSD".

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-27 20:25                               ` Bean
@ 2008-01-28  1:54                                 ` walt
  2008-01-28  8:52                                   ` Robert Millan
  2008-01-28 10:02                                   ` Bean
  0 siblings, 2 replies; 46+ messages in thread
From: walt @ 2008-01-28  1:54 UTC (permalink / raw)
  To: grub-devel


On Mon, 2008-01-28 at 04:25 +0800, Bean wrote:
...
> > > please make a small ufs image containing the netbsd kernel, i don't a
> > > a bsd system at hand

http://leaf.dragonflybsd.org/~wa1ter/ufs.gz

I included a small text file (motd) to demonstrate that you can cat it
okay, but when you try 'multiboot /netbsd' you should get the same error
I've been describing.


> btw, if you have time, please try the a.out loader, it should be able
> to boot /boot/loader of freebsd, i don't know if openbsd and netbsd
> use the same booting method.

diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk

Heh.  I'm assuming an .rmk file involves ruby somehow?  The bonehead
build process that I'm using doesn't turn an .rmk into a .mk AFAICT,
but I'd like to know how to do it.






^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-28  1:54                                 ` walt
@ 2008-01-28  8:52                                   ` Robert Millan
  2008-01-28 10:02                                   ` Bean
  1 sibling, 0 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-28  8:52 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Jan 27, 2008 at 05:54:26PM -0800, walt wrote:
> 
> Heh.  I'm assuming an .rmk file involves ruby somehow?  The bonehead
> build process that I'm using doesn't turn an .rmk into a .mk AFAICT,
> but I'd like to know how to do it.

Try ./autogen.sh

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-27  8:53                           ` Robert Millan
  2008-01-27 20:09                             ` walt
@ 2008-01-28  8:57                             ` Marco Gerards
  2008-01-28 10:06                               ` Bean
  1 sibling, 1 reply; 46+ messages in thread
From: Marco Gerards @ 2008-01-28  8:57 UTC (permalink / raw)
  To: The development of GRUB 2

Robert Millan <rmh@aybabtu.com> writes:

> On Sat, Jan 26, 2008 at 01:24:57PM -0800, walt wrote:
>> 
>> Yes!  I just discovered that I can multiboot the netbsd kernel off
>> of a FAT32 fs or even an NTFS fs, but *not* off of a UFS fs :o/
>> 
>> Apparently "something bad" happens to the kernel in the process of
>> reading or loading it from the UFS fs.  I can read small text files
>> from a UFS fs, however, so I'm thinking maybe this has something to
>> do with the size of the netbsd kernel?
>
> I just committed a check in grub-probe that attempts to read and verify files
> using GRUB filesystems and compares them with output from your system.  E.g.
> if you do:  grub-probe -t fs /full/path/to/file it will compare and verify it
> using fs/ufs.c.
>
> Bean, IIRC you planned add something similar.  Is this feature useful to you?

It's at least useful to me :-)

--
Marco




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-28  1:54                                 ` walt
  2008-01-28  8:52                                   ` Robert Millan
@ 2008-01-28 10:02                                   ` Bean
  2008-01-28 13:00                                     ` Marco Gerards
  1 sibling, 1 reply; 46+ messages in thread
From: Bean @ 2008-01-28 10:02 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 28, 2008 9:54 AM, walt <wa1ter@myrealbox.com> wrote:
>
> On Mon, 2008-01-28 at 04:25 +0800, Bean wrote:
> ...
> > > > please make a small ufs image containing the netbsd kernel, i don't a
> > > > a bsd system at hand
>
> http://leaf.dragonflybsd.org/~wa1ter/ufs.gz
>
> I included a small text file (motd) to demonstrate that you can cat it
> okay, but when you try 'multiboot /netbsd' you should get the same error
> I've been describing.
>
>
> > btw, if you have time, please try the a.out loader, it should be able
> > to boot /boot/loader of freebsd, i don't know if openbsd and netbsd
> > use the same booting method.
>
> diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
>
> Heh.  I'm assuming an .rmk file involves ruby somehow?  The bonehead
> build process that I'm using doesn't turn an .rmk into a .mk AFAICT,
> but I'd like to know how to do it.

all you need to do is do install ruby.

here is a patch for ufs, it fix the indirect block calculation problem.

	* fs/ufs.c (INODE_BLKSZ): Fix incorrect value.
	(grub_ufs_get_file_block): Fix indirect block calculation problem.


diff --git a/fs/ufs.c b/fs/ufs.c
index 25cd1fa..ebb7198 100644
--- a/fs/ufs.c
+++ b/fs/ufs.c
@@ -52,7 +52,7 @@
                            grub_le_to_cpu##bits2 (data->inode2.field))
 #define INODE_SIZE(data) INODE_ENDIAN (data,size,32,64)
 #define INODE_MODE(data) INODE_ENDIAN (data,mode,16,16)
-#define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 32 : 64)
+#define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 4 : 8)
 #define INODE_DIRBLOCKS(data,blk) INODE_ENDIAN \
                                    (data,blocks.dir_blocks[blk],32,64)
 #define INODE_INDIRBLOCKS(data,blk) INODE_ENDIAN \
@@ -205,35 +205,41 @@ grub_ufs_get_file_block (struct grub_ufs_data
*data, unsigned int blk)
 {
   struct grub_ufs_sblock *sblock = &data->sblock;
   unsigned int indirsz;
+  int log2_blksz;

   /* Direct.  */
   if (blk < GRUB_UFS_DIRBLKS)
     return INODE_DIRBLOCKS (data, blk);

+  log2_blksz = grub_le_to_cpu32 (data->sblock.log2_blksz);
+
   blk -= GRUB_UFS_DIRBLKS;

   indirsz = UFS_BLKSZ (sblock) / INODE_BLKSZ (data);
   /* Single indirect block.  */
   if (blk < indirsz)
     {
-      grub_uint32_t indir[UFS_BLKSZ (sblock)];
-      grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 0),
+      grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2];
+      grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 0) << log2_blksz,
 		      0, sizeof (indir), (char *) indir);
-      return indir[blk];
+      return (data->ufs_type == UFS1) ? indir[blk] : indir[blk << 1];
     }
   blk -= indirsz;

   /* Double indirect block.  */
   if (blk < UFS_BLKSZ (sblock) / indirsz)
     {
-      grub_uint32_t indir[UFS_BLKSZ (sblock)];
+      grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2];

-      grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1),
+      grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1) << log2_blksz,
 		      0, sizeof (indir), (char *) indir);
-      grub_disk_read (data->disk,  indir[blk / indirsz],
+      grub_disk_read (data->disk,
+      		      (data->ufs_type == UFS1) ?
+		      indir[blk / indirsz] : indir [(blk / indirsz) << 1],
 		      0, sizeof (indir), (char *) indir);

-      return indir[blk % indirsz];
+      return (data->ufs_type == UFS1) ?
+	     indir[blk % indirsz] : indir[(blk % indirsz) << 1];
     }



-- 
Bean



^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-28  8:57                             ` Marco Gerards
@ 2008-01-28 10:06                               ` Bean
  2008-01-28 10:41                                 ` Robert Millan
  0 siblings, 1 reply; 46+ messages in thread
From: Bean @ 2008-01-28 10:06 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 28, 2008 4:57 PM, Marco Gerards <mgerards@xs4all.nl> wrote:
> Robert Millan <rmh@aybabtu.com> writes:
>
> > On Sat, Jan 26, 2008 at 01:24:57PM -0800, walt wrote:
> >>
> >> Yes!  I just discovered that I can multiboot the netbsd kernel off
> >> of a FAT32 fs or even an NTFS fs, but *not* off of a UFS fs :o/
> >>
> >> Apparently "something bad" happens to the kernel in the process of
> >> reading or loading it from the UFS fs.  I can read small text files
> >> from a UFS fs, however, so I'm thinking maybe this has something to
> >> do with the size of the netbsd kernel?
> >
> > I just committed a check in grub-probe that attempts to read and verify files
> > using GRUB filesystems and compares them with output from your system.  E.g.
> > if you do:  grub-probe -t fs /full/path/to/file it will compare and verify it
> > using fs/ufs.c.
> >
> > Bean, IIRC you planned add something similar.  Is this feature useful to you?
>
> It's at least useful to me :-)

grub-probe is nice, but i normally use grub-fstest to debug fs
problem, because it have more options.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-28 10:06                               ` Bean
@ 2008-01-28 10:41                                 ` Robert Millan
  0 siblings, 0 replies; 46+ messages in thread
From: Robert Millan @ 2008-01-28 10:41 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Jan 28, 2008 at 06:06:51PM +0800, Bean wrote:
> 
> grub-probe is nice, but i normally use grub-fstest to debug fs
> problem, because it have more options.

Ah, I noticed grub-fstest is not in CVS yet.  I'll comment on your patch now..

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-28 10:02                                   ` Bean
@ 2008-01-28 13:00                                     ` Marco Gerards
  2008-01-28 13:02                                       ` Bean
  0 siblings, 1 reply; 46+ messages in thread
From: Marco Gerards @ 2008-01-28 13:00 UTC (permalink / raw)
  To: The development of GRUB 2

Bean <bean123ch@gmail.com> writes:

> On Jan 28, 2008 9:54 AM, walt <wa1ter@myrealbox.com> wrote:
>>
>> On Mon, 2008-01-28 at 04:25 +0800, Bean wrote:
>> ...
>> > > > please make a small ufs image containing the netbsd kernel, i don't a
>> > > > a bsd system at hand
>>
>> http://leaf.dragonflybsd.org/~wa1ter/ufs.gz
>>
>> I included a small text file (motd) to demonstrate that you can cat it
>> okay, but when you try 'multiboot /netbsd' you should get the same error
>> I've been describing.
>>
>>
>> > btw, if you have time, please try the a.out loader, it should be able
>> > to boot /boot/loader of freebsd, i don't know if openbsd and netbsd
>> > use the same booting method.
>>
>> diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
>>
>> Heh.  I'm assuming an .rmk file involves ruby somehow?  The bonehead
>> build process that I'm using doesn't turn an .rmk into a .mk AFAICT,
>> but I'd like to know how to do it.
>
> all you need to do is do install ruby.
>
> here is a patch for ufs, it fix the indirect block calculation problem.
>
> 	* fs/ufs.c (INODE_BLKSZ): Fix incorrect value.
> 	(grub_ufs_get_file_block): Fix indirect block calculation problem.

Fine for me, if you tested this.

This patch fixes this specific problem regarding loading this
multiboot kernel from UFS?

--
Marco




^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-28 13:00                                     ` Marco Gerards
@ 2008-01-28 13:02                                       ` Bean
  2008-02-02 14:16                                         ` Bean
  0 siblings, 1 reply; 46+ messages in thread
From: Bean @ 2008-01-28 13:02 UTC (permalink / raw)
  To: The development of GRUB 2

On Jan 28, 2008 9:00 PM, Marco Gerards <mgerards@xs4all.nl> wrote:
> Bean <bean123ch@gmail.com> writes:
>
> > On Jan 28, 2008 9:54 AM, walt <wa1ter@myrealbox.com> wrote:
> >>
> >> On Mon, 2008-01-28 at 04:25 +0800, Bean wrote:
> >> ...
> >> > > > please make a small ufs image containing the netbsd kernel, i don't a
> >> > > > a bsd system at hand
> >>
> >> http://leaf.dragonflybsd.org/~wa1ter/ufs.gz
> >>
> >> I included a small text file (motd) to demonstrate that you can cat it
> >> okay, but when you try 'multiboot /netbsd' you should get the same error
> >> I've been describing.
> >>
> >>
> >> > btw, if you have time, please try the a.out loader, it should be able
> >> > to boot /boot/loader of freebsd, i don't know if openbsd and netbsd
> >> > use the same booting method.
> >>
> >> diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
> >>
> >> Heh.  I'm assuming an .rmk file involves ruby somehow?  The bonehead
> >> build process that I'm using doesn't turn an .rmk into a .mk AFAICT,
> >> but I'd like to know how to do it.
> >
> > all you need to do is do install ruby.
> >
> > here is a patch for ufs, it fix the indirect block calculation problem.
> >
> >       * fs/ufs.c (INODE_BLKSZ): Fix incorrect value.
> >       (grub_ufs_get_file_block): Fix indirect block calculation problem.
>
> Fine for me, if you tested this.
>
> This patch fixes this specific problem regarding loading this
> multiboot kernel from UFS?

yes, it works for me.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-28 13:02                                       ` Bean
@ 2008-02-02 14:16                                         ` Bean
  0 siblings, 0 replies; 46+ messages in thread
From: Bean @ 2008-02-02 14:16 UTC (permalink / raw)
  To: The development of GRUB 2

Committed.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-01-26 15:01                       ` Bean
  2008-01-26 17:24                         ` Robert Millan
  2008-01-26 21:24                         ` walt
@ 2008-02-06 15:32                         ` Robert Millan
  2008-02-06 16:03                           ` Bean
  2 siblings, 1 reply; 46+ messages in thread
From: Robert Millan @ 2008-02-06 15:32 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote:
> 
> 	* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
> 	address of entry.
> 	(grub_multiboot_load_elf64): Likewise.
> 	(grub_multiboot): Initialize mbi structure.
> 
> 
> diff --git a/loader/i386/pc/multiboot.c b/loader/i386/pc/multiboot.c
> index fa6346e..2fd2b24 100644
> --- a/loader/i386/pc/multiboot.c
> +++ b/loader/i386/pc/multiboot.c
> @@ -96,6 +96,7 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer)
>  {
>    Elf32_Ehdr *ehdr = (Elf32_Ehdr *) buffer;
>    Elf32_Phdr *phdr;
> +  grub_addr_t real_entry = 0;

I would suggest a more explicit name, like physical_entry_addr or so.  That'd
make it easier to understand without the context of your mail and changelog
entry.

> +  grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));

I wonder if it'd make sense to do this in grub_malloc().  This would save us
from similar bugs in the future (and have the advantage that memory handling
bugs would be exposed earlier).  What do you think, is this idea too crazy? :-)

(I would still add grub_memset here for now, though; makes no sense to delay
it)

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
  2008-02-06 15:32                         ` Robert Millan
@ 2008-02-06 16:03                           ` Bean
  0 siblings, 0 replies; 46+ messages in thread
From: Bean @ 2008-02-06 16:03 UTC (permalink / raw)
  To: The development of GRUB 2

On Feb 6, 2008 11:32 PM, Robert Millan <rmh@aybabtu.com> wrote:
> On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote:
> >
> >       * loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
> >       address of entry.
> >       (grub_multiboot_load_elf64): Likewise.
> >       (grub_multiboot): Initialize mbi structure.
> >
> >
> > diff --git a/loader/i386/pc/multiboot.c b/loader/i386/pc/multiboot.c
> > index fa6346e..2fd2b24 100644
> > --- a/loader/i386/pc/multiboot.c
> > +++ b/loader/i386/pc/multiboot.c
> > @@ -96,6 +96,7 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer)
> >  {
> >    Elf32_Ehdr *ehdr = (Elf32_Ehdr *) buffer;
> >    Elf32_Phdr *phdr;
> > +  grub_addr_t real_entry = 0;
>
> I would suggest a more explicit name, like physical_entry_addr or so.  That'd
> make it easier to understand without the context of your mail and changelog
> entry.
>
> > +  grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));
>
> I wonder if it'd make sense to do this in grub_malloc().  This would save us
> from similar bugs in the future (and have the advantage that memory handling
> bugs would be exposed earlier).  What do you think, is this idea too crazy? :-)
>
> (I would still add grub_memset here for now, though; makes no sense to delay
> it)

thanks for your advise, fix and committed.

-- 
Bean



^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2008-02-06 16:04 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-19 17:01 UFS (FFS) support seems broken in grub2 jakllsch
2008-01-19 18:27 ` walt
2008-01-22 18:58   ` Bean
2008-01-22 20:04     ` Robert Millan
2008-01-23  9:02       ` Marco Gerards
2008-01-23 16:15     ` walt
2008-01-23 16:31       ` Bean
2008-01-23 19:21         ` Marco Gerards
2008-01-23 20:26           ` Bean
2008-01-23 22:49         ` walt
2008-01-23 23:53           ` Robert Millan
2008-01-24  1:21             ` walt
2008-01-24 12:30               ` booting *BSD kernels (Re: UFS (FFS) support seems broken in grub2) Robert Millan
2008-01-24  8:33           ` UFS (FFS) support seems broken in grub2 Marco Gerards
2008-01-24 14:20             ` walt
2008-01-24 14:33               ` booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2) Robert Millan
2008-01-24 14:53                 ` Robert Millan
2008-01-24 16:47                   ` walt
2008-01-24 17:12                     ` Robert Millan
2008-01-26 15:01                       ` Bean
2008-01-26 17:24                         ` Robert Millan
2008-01-26 18:19                           ` walt
2008-01-26 18:24                             ` Bean
2008-01-26 18:31                               ` Bean
2008-01-26 19:57                               ` Robert Millan
2008-01-26 19:57                             ` Robert Millan
2008-01-26 21:24                         ` walt
2008-01-27  1:35                           ` Bean
2008-01-27 20:13                             ` walt
2008-01-27 20:25                               ` Bean
2008-01-28  1:54                                 ` walt
2008-01-28  8:52                                   ` Robert Millan
2008-01-28 10:02                                   ` Bean
2008-01-28 13:00                                     ` Marco Gerards
2008-01-28 13:02                                       ` Bean
2008-02-02 14:16                                         ` Bean
2008-01-27  8:53                           ` Robert Millan
2008-01-27 20:09                             ` walt
2008-01-27 22:11                               ` Robert Millan
2008-01-28  8:57                             ` Marco Gerards
2008-01-28 10:06                               ` Bean
2008-01-28 10:41                                 ` Robert Millan
2008-02-06 15:32                         ` Robert Millan
2008-02-06 16:03                           ` Bean
2008-01-24 18:16               ` UFS (FFS) support seems broken in grub2 Marco Gerards
2008-01-24 18:19                 ` Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.