Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Oct 2006 18:18:30 +0400
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        Bruce Evans <bde@zeta.org.au>, John Baldwin <jhb@FreeBSD.org>
Cc:        freebsd-stable@FreeBSD.org, Stefan Bethke <stb@lassitu.de>, John Baldwin <jhb@FreeBSD.org>, Bruce Evans <bde@FreeBSD.org>
Subject:   Re: Still possible to directly boot without loader?
Message-ID:  <20061026141830.GA790@rambler-co.ru>
In-Reply-To: <20061026222234.P2553@epsplex.bde.org>
References:  <3A8131D4-881E-4873-A682-543A1A88C063@lassitu.de> <20060911180915.GB33304@lor.one-eyed-alien.net> <20061026113922.GA932@rambler-co.ru> <20061026222234.P2553@epsplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--GvXjxJ+pjyke8COw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Oct 26, 2006 at 10:52:30PM +1000, Bruce Evans wrote:
> On Thu, 26 Oct 2006, Ruslan Ermilov wrote:
> >3)  It's currently broken even on i386; backing out
> >   rev. 1.71 of boot2.c by jhb@ fixes this for me.
> >
> >: revision 1.71
> >: date: 2004/09/18 02:07:00;  author: jhb;  state: Exp;  lines: +3 -3
> >: A long, long time ago in a CVS branch far away (specifically, HEAD pri=
or
> >: to 4.0 and RELENG_3), the BTX mini-kernel used paging rather than flat
> >: mode and clients were limited to a virtual address space of 16 megabyt=
es.
> >: Because of this limitation, boot2 silently masked all physical address=
es
> >: in any binaries it loaded so that they were always loaded into the fir=
st
> >: 16 Meg.  Since BTX no longer has this limitation (and hasn't for a long
> >: time), remove the masking from boot2.  This allows boot2 to load kerne=
ls
> >: larger than about 12 to 14 meg (12 for non-PAE, 14 for PAE).
> >:
> >: Submitted by:   Sergey Lyubka devnull at uptsoft dot com
> >: MFC after:      1 month
>=20
> The kernel is linked at 0xc0000000 but loade din low memory, so the high
> bits must be masked off like they used to be for the kernel to boot at al=
l.
> This has nothing to do with paging AFAIK.  Rev.1.71 makes no sense, since
> BTX isn't large, and large kernels are more unbootable than before with
> 1.71.
>=20
The real purpose of this commit was to allow to directly "load kernels
larger than about 12 to 14 meg (12 for non-PAE, 14 for PAE)".  (Old
version masked high 8 bits, leaving only 2^24=3D16MB for the kernel.)

I have compiled GENERIC and PAE kernels; objdump(1) reports that GENERIC
kernel has virtual "start address 0xc0449cb0", and PAE has virtual "start
address 0xc02458f0".

What happens here is that BTX now uses flat memory model, and by not
masking higher bits at all, BTX attempts to load kernels at above 3G,
which silently fails, and then jumps to the entry point located in
"no memory" unless the machine has enough memory.

If the machine has enough physical memory, e.g. 4G, then it works (I
think that was the case on the machine John tested this change), but
on my test machine I only have 3G of memory, so it fails.

My interim solution to the problem that would still allow booting
larger than 16MB kernels is to mask some of the higher bits.
Currently, I mask 28 bits that gives possible 256MB which is probably
practical.

%%%
Index: boot2.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/boot/i386/boot2/boot2.c,v
retrieving revision 1.72.2.4
diff -u -p -r1.72.2.4 boot2.c
--- boot2.c	15 Feb 2006 15:08:51 -0000	1.72.2.4
+++ boot2.c	26 Oct 2006 13:48:44 -0000
@@ -332,7 +332,7 @@ load(void)
 	return;
     }
     if (fmt =3D=3D 0) {
-	addr =3D hdr.ex.a_entry;
+	addr =3D hdr.ex.a_entry & 0x0fffffff;
 	p =3D PTOV(addr);
 	fs_off =3D PAGE_SIZE;
 	if (xfsread(ino, p, hdr.ex.a_text))
@@ -366,7 +366,7 @@ load(void)
 		j++;
 	}
 	for (i =3D 0; i < 2; i++) {
-	    p =3D PTOV(ep[i].p_paddr);
+	    p =3D PTOV(ep[i].p_paddr & 0x0fffffff);
 	    fs_off =3D ep[i].p_offset;
 	    if (xfsread(ino, p, ep[i].p_filesz))
 		return;
@@ -387,7 +387,7 @@ load(void)
 		p +=3D es[i].sh_size;
 	    }
 	}
-	addr =3D hdr.eh.e_entry;
+	addr =3D hdr.eh.e_entry & 0x0fffffff;
     }
     bootinfo.bi_esymtab =3D VTOP(p);
     bootinfo.bi_kernelname =3D VTOP(kname);
%%%

A more intelligent approach would be to use the size of available
memory.  I haven't yet looking at implementing this and I don't
know if this kind of information is available in boot2.

> There is an another PR about this.
>=20
I've already closed PR 104709 as a duplicate for PR 96430.
Are there any other PRs with the same subject?

> 4) Another rev. broke support for booting with -c and -d to save 4 bytes.
> -c is useful for RELENG_6 and -d is essential for debugging.  If you
> always use loader(8) then you would only notice this if you try to set
> these flags in boot2.
>=20
I'll fix that.


Cheers,
--=20
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

--GvXjxJ+pjyke8COw
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFQMO2qRfpzJluFF4RAnzZAJ9pPIp9HFTPQavpu9LaZZezMz98vQCfe5OC
xG1GOBdu4lP8bFw0fUy7eWA=
=t8ju
-----END PGP SIGNATURE-----

--GvXjxJ+pjyke8COw--



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