BUG: 9.0 stage 2 boot (/boot/boot)

rank1seeker at gmail.com rank1seeker at gmail.com
Sat Feb 25 14:41:51 UTC 2012


----- Original Message -----
From: John Baldwin <jhb at freebsd.org>
To: rank1seeker at gmail.com
Cc: hackers at freebsd.org, "Roman Divacky" <rdivacky at freebsd.org>
Date: Fri, 24 Feb 2012 15:31:11 -0500
Subject: Re: BUG: 9.0 stage 2 boot (/boot/boot)

> On Friday, February 24, 2012 2:11:52 pm rank1seeker at gmail.com wrote:
> > ----- Original Message -----
> > From: John Baldwin <jhb at freebsd.org>
> > To: rank1seeker at gmail.com
> > Cc: hackers at freebsd.org, "Roman Divacky" <rdivacky at freebsd.org>
> > Date: Fri, 24 Feb 2012 12:23:45 -0500
> > Subject: Re: BUG: 9.0 stage 2 boot (/boot/boot)
> > 
> > > On Friday, February 24, 2012 9:05:54 am rank1seeker at gmail.com wrote:
> > > > ----- Original Message -----
> > > > From: John Baldwin <jhb at freebsd.org>
> > > > To: freebsd-hackers at freebsd.org
> > > > Cc: rank1seeker at gmail.com, Roman Divacky <rdivacky at freebsd.org>
> > > > Date: Thu, 23 Feb 2012 08:02:04 -0500
> > > > Subject: Re: BUG: 9.0 stage 2 boot (/boot/boot)
> > > > 
> > > > > On Friday, February 17, 2012 2:43:55 am rank1seeker at gmail.com wrote:
> > > > > > Anyway, after upgrading to 9.0, my USB stick, when created, started 
> to 
> > > hang 
> > > > > at stage 2 boot.
> > > > > > I have a custom setup, where BSD label 'a', has a content of /boot/*
> > > > > > So when 'a' is being hit by stage 2 boot, there is boot.config 
> waiting 
> > > for 
> > > > > it.
> > > > > > After it reads it and displays it's content, it echos 'No' and 
> hangs.
> > > > > > 
> > > > > > I stare at it and can't believe as boot.config's information is 
> correct!
> > > > > > I hit '?' and it list all files in 'a'.
> > > > > > Then I simply RE-type what is displayed on screen (content of 
> > > boot.config -> 
> > > > > path to loader)
> > > > > > And loader kicks in!
> > > > > > 
> > > > > > I do this a few times more and EACH time I have to RE-type correct 
> info!
> > > > > > Tested on other machine, same thing.
> > > > > > 
> > > > > > However, this same custom layout works for HDD's, but NOT for USB 
> stick.
> > > > > > 
> > > > > > I've extracted binary installs of 8.2 and 9.0 R:
> > > > > > MD5 (8_boot) = adb1e84e96bd434e51cafaaa0ef22584
> > > > > > MD5 (9_boot) = 40f3f6403ebd5e131259d1336b4b50ad
> > > > > > 
> > > > > > Then:
> > > > > > # gpart bootcode -b 8_boot da0s2
> > > > > > And sudenly that USB stick boots, without ANY other change!
> > > > > > Just an "old" stage 2 boot code, from R8 was enough.
> > > > > 
> > > > > Looks like it is thinking that 'kname' is empty.  Ah, I think Roman 
> broke 
> > > this
> > > > > in 219186:
> > > > > 
> > > > >  @@ -474,11 +461,7 @@ parse()
> > > > >  			     ? DRV_HARD : 0) + drv;
> > > > >  		dsk_meta = 0;
> > > > >  	    }
> > > > > -	    if ((i = ep - arg)) {
> > > > > -		if ((size_t)i >= sizeof(kname))
> > > > > -		    return -1;
> > > > > -		memcpy(kname, arg, i + 1);
> > > > > -	    }
> > > > > +            kname = arg;
> > > > >  	}
> > > > >  	arg = p;
> > > > >      }
> > > > > 
> > > > > Before it only set kname if it wasn't an empty string.  Now it always 
> sets
> > > > > kname.  Try this change:
> > > > > 
> > > > > Index: boot2.c
> > > > > ===================================================================
> > > > > --- boot2.c	(revision 231983)
> > > > > +++ boot2.c	(working copy)
> > > > > @@ -457,7 +457,8 @@ parse()
> > > > >  			     ? DRV_HARD : 0) + drv;
> > > > >  		dsk_meta = 0;
> > > > >  	    }
> > > > > -            kname = arg;
> > > > > +	    if (*arg != '\0')
> > > > > +		    kname = arg;
> > > > >  	}
> > > > >  	arg = p;
> > > > >      }
> > > > > 
> > > > > -- 
> > > > > John Baldwin
> > > > > 
> > > > 
> > > > 
> > > > It still doesn't work!
> > > > 
> > > > And please, next time attach patch in a file (unified format), so I 
> would  
> > > have a less hassle (to avoid manuall patch application)
> 
> Hmm, our mailing lists each attachments, so you are less likely to get the
> patch that way.
> 
> > > Do you still get 'No ' with no other message before it breaks?
> > 
> > 
> > I get 'No ' with no other message before it HANGS waiting for manual input?
> > Manual input makes it work.
> > I simply RE-type outputed contest of boot.config file.
> > 
> > 
> > > Can you show me the contents of your /boot.config file via hd?
> > 
> > 
> > Both USB stick and HDD have a same boot.config file, contents:
> > ---
> > /loader
> > ---
> 
> Hmm, you didn't pass it to hd(1) like I asked.  Anyway, I hacked up a test
> program to run the parse() routine from boot2.c and it DTRT.


# hd boot.config
00000000  2f 6c 6f 61 64 65 72 0a                           |/loader.|
00000008


> Do you only see the "No " message?  Do you see the '/boot.config: /loader'
> message?  (Do you have RBX_QUIET enabled perhaps? (-q))  Do you get the actual
> boot2 prompt at all?

I don't have RBX_QUIET enabled nor any other flags

Let the pic tell a story:
http://www.starforce.biz/stage2boot.jpg

It is also valid for your latest patch


> Hmm, I think the problem is that 'opts' has garbage instead of being
> initialized to zero.
> 
> Try this (also at www.freebsd.org/~jhb/patches/boot2_opts.patch):


Patch eliminates possible error, of manual "intervention"
That is, a perfectly valid patch being classified as invalid.


> 
> Index: boot2.c
> ===================================================================
> --- boot2.c	(revision 231983)
> +++ boot2.c	(working copy)
> @@ -224,6 +224,7 @@
>      uint8_t autoboot;
>      ino_t ino;
>  
> +    opts = 0;
>      kname = NULL;
>      dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
>      v86.ctl = V86_FLAGS;
> 
> 
> -- 
> John Baldwin
> 


Domagoj Smolčić


More information about the freebsd-hackers mailing list