[booke] preloading limited to initial mapping in kernel

Marcel Moolenaar marcel at xcllnt.net
Tue Sep 9 16:11:10 UTC 2014


All,

The kernel creates a single 16MB mapping in locore.S under the
assumption that what got preloaded fits that size. With the metadata
at the end of what's preloaded, the kernel will simply fail to boot
is the total amount preloaded is larger than the initial mapping.

Juniper fixed this problem by having the loader create the initial
mapping based on the total size preloaded and communicate this to
the kernel by virtue of the number of TLBs used. A change was made
in locore.S to detect Juniper's loader and skip over the entire
TLB1 fiddling.

Juniper is currently porting Junos onto the latest FreeBSD version
using mostly stock FreeBSD bits and problem described above is back
again. Juniper has 2 options:

1.  Make the same change to FreeBSD's loader as it did before. The
    problem with this approach is that newer U-Boot versions use
    the first few TLB1 entries for itself, meaning that the loader
    has to jump through a few hoops to make sure it can use the
    first N entries without destroying the entries used by U-Boot
    and itself.
2.  Change locore.S and map enough to cover all the preloaded bits.
    The problem here is that the kernel does not know how much is
    preloaded. While it's easy enough to tell the kernel that, the
    problem is that the kernel must have a reliable way to detect
    by which loader it was loaded so that it knows whether the size
    of preloading is in whatever register we dedicate for that.

Juniper's loader swizzled the registers so that the kernel can check
for this. To be precise: FreeBSD's loader passes the metadata pointer
(MDP) in r3. Juniper's loader sets r3 to 0 and passes the MDP in r4.

Note also that I added support for booting directly from U-Boot. I'd
like that to continue to work for as much as is possible.

I'd like suggestions as to what approach to use. I played with the
first (change the loader) and it can be made to work. It just doesn't
feel right. I attached the patch for reference.

Thanks,

-- 
Marcel Moolenaar
marcel at xcllnt.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: booke.diff
Type: application/octet-stream
Size: 9773 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-ppc/attachments/20140909/46c57368/attachment.obj>
-------------- next part --------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-ppc/attachments/20140909/46c57368/attachment.sig>


More information about the freebsd-ppc mailing list