From owner-freebsd-stable@FreeBSD.ORG Fri May 23 22:11:17 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA0D91065680 for ; Fri, 23 May 2008 22:11:17 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id A63A68FC13 for ; Fri, 23 May 2008 22:11:17 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (server.baldwin.cx [208.65.91.234]) by elvis.mu.org (Postfix) with ESMTP id 444B41A4D82; Fri, 23 May 2008 15:11:17 -0700 (PDT) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m4NMB8aI020304; Fri, 23 May 2008 18:11:09 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Kostik Belousov Date: Fri, 23 May 2008 18:11:01 -0400 User-Agent: KMail/1.9.7 References: <720051dc0805220159n23eb6205yfcf9450be7af5c77@mail.gmail.com> <200805230829.09524.jhb@freebsd.org> <20080523132645.GO29770@deviant.kiev.zoral.com.ua> In-Reply-To: <20080523132645.GO29770@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200805231811.01936.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Fri, 23 May 2008 18:11:09 -0400 (EDT) X-Virus-Scanned: ClamAV 0.91.2/7222/Fri May 23 08:53:12 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: freebsd-stable@freebsd.org, James Seward , Mark Kirkwood Subject: Re: BTX loader hangs after version info X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 May 2008 22:11:18 -0000 On Friday 23 May 2008 09:26:45 am Kostik Belousov wrote: > On Fri, May 23, 2008 at 08:29:09AM -0400, John Baldwin wrote: > > On Friday 23 May 2008 07:53:11 am Kostik Belousov wrote: > > > On Fri, May 23, 2008 at 01:22:55PM +1200, Mark Kirkwood wrote: > > > > James Seward wrote: > > > > >Hello, > > > > > > > > > >Two days ago I csup'd my desktop at home, which was running RELENG_7 > > > > >from about 7.0-RELEASE time, to bring it up-to-date (still on > > > > >RELENG_7). I followed my usual buildkernel/world procedure (the usual > > > > >one) which has worked fine all the way since 5.x. After installing > > > > >kernel and restarting in single user, it was working fine. However, > > > > >following installworld it will not boot. > > > > > > > > > >It stops immediately after "BTX loader 1.00 BTX version 1.02", but > > > > >with the cursor on the line *above* the first "B". Nothing futher > > > > >happens, but the system responds to Ctrl-Alt-Del. > > > > > > > > > >I have managed to start it using the install CD and csup'd back to a > > > > >version just before the commit to BTX that moved it to 1.02 (March > > > > >18th, I think). However, that version too hangs after "BTX loader 1.00 > > > > >BTX version 1.01". > > > > > > > > > >My desktop is currently building RELENG_7_0 to see if that will work, > > > > >but I won't know that until later as I'm at work and it is at home :) > > > > > > > > > >The install CD (BTX 1.00/1.01) boots fine. Nothing else changed on my > > > > >system between the last successful boot and the unsuccessful one. > > > > > > > > > >Any suggestions/advice for what I can try next, or what I can do to > > > > >help the troubleshooting process? > > > > > > > > > >My desktop is an Athlon64 but I am using i386, on an Asus A8V-E Deluxe > > > > >board. > > > > > > > > FWIW - I am seeing this too, on a Supermicro P3TDDE. 7-STABLE src from > > > > 28-Feb is fine, but Mar, Apr, May code all hangs after printing "loading > > > > /boot/defaults/loader.conf" - presumably reading my /boot/loader.conf? > > > > > > > > Interestingly I can usually get it to boot by escaping to the loader > > > > prompt and then just pressing return. > > > > > > > > Oddly some other machines (Supermicro P3TDER and Asus PRO31J Laptop) > > > > behave normally with src from Mar->May. > > > > > > > > In all cases the canonical procedure from UPDATING was used (buildworld, > > > > kernel, reboot single, mergemaster -p, installworld, delete-old, > > > > mergemaster, reboot). > > > > > > > > I happy to help collect some debug info (how do you switch this on for > > > > the loader?), tho the machine exhibiting the problem is my workstation > > > > (of course)! > > > > > > Try to install new bootblock. > > > > I would be wary of that as it might make things worse? These problems are all > > from starting /boot/loader. boot2 is still working fine and thus there is > > still the possiblity of using boot2 to load /boot/loader.old as a workaround. > > If you update boot2 and it breaks you can't fix that w/o booting off of some > > other media such as a CD. > > > > Debugging these hangs is not easy to do remotely. If you know assembly then > > there are some things you can play with. For example, in the case where it > > hangs after printing out the BTX version (from btxldr.S) you could start > > adding debugging to btx.S to print out '.' characters in various places and > > see how many get printed out before it hangs. However, doing this requires > > familiarity with assembly and is a lot easier with physical access to a box. > > When I worked on my version of the realbtx, I sometimes experienced hangs when > vm86 btx run before real-mode btx. I did not investigated it then, only noted > the issue. > Try this patch. I'm not 100% certain this will fix it as I can't reproduce the issue, but I think it might help. Specifically, when the boot code makes a v86 call, the loader/boot2/whatever swaps in/out a new set of registers via the v86 structure including the eflags register. However, none of the boot programs actually initialized the v86 structure. Thus, the BIOS routines would start off running with whatever garbage was in v86.efl when each boot program started. This meant that we could end up invoking BIOS routines with interrupts disabled, and I think this might explain a hard hang (if a BIOS routine was waiting for an interrupt the interrupt would never fire). The patch fixes all the boot programs to initialize v86 to a better known state. At the least it sets v86.efl to a sane value (0x202) rather than random. (The random might have always been 0x0 BTW, not sure on that one.) --- //depot/vendor/freebsd/src/sys/boot/i386/boot2/boot2.c 2008/02/28 17:10:57 +++ //depot/user/jhb/boot/sys/boot/i386/boot2/boot2.c 2008/05/23 21:59:59 @@ -24,6 +24,7 @@ #include #include +#include #include @@ -83,8 +84,8 @@ #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 -#define V86_CY(x) ((x) & 1) -#define V86_ZR(x) ((x) & 0x40) +#define V86_CY(x) ((x) & PSL_C) +#define V86_ZR(x) ((x) & PSL_Z) #define DRV_HARD 0x80 #define DRV_MASK 0x7f @@ -237,6 +238,7 @@ dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); v86.ctl = V86_FLAGS; + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; dsk.drive = *(uint8_t *)PTOV(ARGS); dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD; dsk.unit = dsk.drive & DRV_MASK; --- //depot/vendor/freebsd/src/sys/boot/i386/gptboot/gptboot.c 2008/02/28 17:10:57 +++ //depot/user/jhb/boot/sys/boot/i386/gptboot/gptboot.c 2008/05/23 21:59:59 @@ -23,6 +23,7 @@ #include #include +#include #include @@ -81,8 +82,8 @@ #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 -#define V86_CY(x) ((x) & 1) -#define V86_ZR(x) ((x) & 0x40) +#define V86_CY(x) ((x) & PSL_C) +#define V86_ZR(x) ((x) & PSL_Z) #define DRV_HARD 0x80 #define DRV_MASK 0x7f @@ -235,6 +236,7 @@ dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); v86.ctl = V86_FLAGS; + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; dsk.drive = *(uint8_t *)PTOV(ARGS); dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD; dsk.unit = dsk.drive & DRV_MASK; --- //depot/vendor/freebsd/src/sys/boot/i386/loader/main.c 2007/10/24 04:07:14 +++ //depot/user/jhb/boot/sys/boot/i386/loader/main.c 2008/05/23 21:59:59 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "bootstrap.h" @@ -86,6 +87,10 @@ initial_bootdev = kargs->bootdev; initial_bootinfo = kargs->bootinfo ? (struct bootinfo *)PTOV(kargs->bootinfo) : NULL; + /* Initialize the v86 register set to a known-good state. */ + bzero(&v86, sizeof(v86)); + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; + /* * Initialise the heap as early as possible. Once this is done, malloc() is usable. */ --- //depot/vendor/freebsd/src/sys/boot/pc98/loader/main.c 2007/10/24 11:57:58 +++ //depot/user/jhb/boot/sys/boot/pc98/loader/main.c 2008/05/23 22:03:45 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "bootstrap.h" @@ -86,6 +87,10 @@ initial_bootdev = kargs->bootdev; initial_bootinfo = kargs->bootinfo ? (struct bootinfo *)PTOV(kargs->bootinfo) : NULL; + /* Initialize the v86 register set to a known-good state. */ + bzero(&v86, sizeof(v86)); + v86.efl = PSL_RESERVED_DEFAULT | PSL_I; + /* * Initialise the heap as early as possible. Once this is done, malloc() is usable. */ -- John Baldwin