Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Oct 2002 22:21:27 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
Cc:        current@FreeBSD.ORG
Subject:   Re: [PATCH] Workaround for bogus INT 12H BIOS service implementation
Message-ID:  <20021002214819.W362-100000@gamplex.bde.org>
In-Reply-To: <20020930.234044.43000637.iwasaki@jp.FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 30 Sep 2002, Mitsuru IWASAKI wrote:

> > > Index: sys/i386/i386/machdep.c
> > > ===================================================================
> > > RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v
> > > retrieving revision 1.532
> > > diff -u -r1.532 machdep.c
> > > --- sys/i386/i386/machdep.c	7 Sep 2002 19:12:42 -0000	1.532
> > > +++ sys/i386/i386/machdep.c	29 Sep 2002 21:15:26 -0000
> > > @@ -1269,8 +1269,12 @@
> > >  	/*
> > >  	 * Perform "base memory" related probes & setup
> > >  	 */
> > > -	vm86_intcall(0x12, &vmf);
> > > -	basemem = vmf.vmf_ax;
> > > +	if (bootinfo.bi_basemem != 0) {
> > > +		basemem = bootinfo.bi_basemem;
> > > +	} else {
> > > +		vm86_intcall(0x12, &vmf);
> > > +		basemem = vmf.vmf_ax;
> > > +	}
> > >  	if (basemem > 640) {
> > >  		printf("Preposterous BIOS basemem of %uK, truncating to 640K\n",
> > >  			basemem);
> >
> > The kernel hasn't used bootinfo.bi_basemem for a long time and shouldn't
> > start using it again now.  It already uses the 0x15/0xe820 call for
> > everything except basemem (except when the this call fails, it falls
> > back to 0x15/0xe801).  Maybe the bug has something to do with the
> > kernel using the 0x12 call without checking whether the call succeeded.

I checked that a kernel boots fine when int 0x12 returns 0.   But there
would probably be problems if it returned a garbage value.

> > When both the 0x15/0xe820 and the 0x15/0xe801 calls fail, the kernel
> > falls back to an 0x15/0x88 call for determining extmem ... except this
> > is ifdefed out and replaced by looking at the rtc values.  Maybe the
> > unreliability of the 0x15/0x88 call has something to do with not
> > checking if the call succeeded.
>
> Yes, I think the best way to determine base mem size in getmemsize()
> is to try 0x15/0xe820 call first, then fall back to 0x12 call.  But
> I'm not sure whether it's OK to call vm86_datacall(0x15) before
> determining base mem size...
>
> > The patch makes no difference for booting directly from boot2 ... except
> > memsize() in boot2 also fails to check for errors, so it returns garbage
> > values.
>
> Yes I know that :-)
> But booting kernel directly from boot2 is not working at all for
> several years, so my understanding is that /boot/loader is necessary
> to boot kernel.

It mostly works.  I submitted patches in a PR many years ago and still use
them.

> > I think the basemem == 0 case should just work, so the systems with a
> > broken INT 0x12 should at worst lose 640K of memory, no matter whether
> > basemem is set to 0 because INT 0x12 fails or because it actually
> > returns 0.
>
> Hmmm, actually no.  I know that some machines get panic with fatal trap
> 12 if we do 0x12 call.  The worst case is getting panic, not losing
> 640K memory.

Where does the panic occur?  I checked that there is no problem here if
the result of INT 0x12 is ignored and basemem is set to 0.

> And it seems that today's Linux don't have 0x12 calling any more,
> so I didn't see any problem on the machines.
>
> Now I have some ideas on this issue;
>  - 0x15/0xe820 call in getmemsize() to determine base mem size. (But how?)
>  - 0x15/0xe820 call in locore.s before calling init386().
>  - specify the size by loader tunable (e.g. hw.basememsize).

I would first fix all the broken code that doesn't check for errors
and see if the problem goes away.  Then recover any low memory not
reported by int 0x12 in the int 0x15/0xe820 code in i386/machdep.c,
like libi386/biosmem.c does it (I think machdep.c intentionally skips
the low memory, while biosmem.c tries to find it).

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021002214819.W362-100000>