Page MenuHomeFreeBSD

Compile loader as Little-Endian on PPC64/POWER8
ClosedPublic

Authored by wma on Sep 20 2017, 11:05 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 9:01 PM
Unknown Object (File)
Mon, Nov 11, 8:17 PM
Unknown Object (File)
Oct 21 2024, 11:17 PM
Unknown Object (File)
Oct 20 2024, 6:45 AM
Unknown Object (File)
Oct 17 2024, 6:11 AM
Unknown Object (File)
Sep 28 2024, 6:07 AM
Unknown Object (File)
Sep 23 2024, 1:24 AM
Unknown Object (File)
Sep 23 2024, 1:23 AM

Details

Summary

Add flag to the makefile to allow loader compilation as
Little-Endian 32-bit executable. Having 32-bit LE
loader.kboot is necessary to work on the latest
petitboot on POWER8 systems.

Usage:
    
make LOADER_FORCE_LE=y -C sys/boot all

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/boot/Makefile.inc
25 ↗(On Diff #33236)

Too many blank lines.

27–28 ↗(On Diff #33236)

Either make it when defined, OR make it always defined and test for 'y'. Not both.

Along those lines, I'd add it as a WITH_LOADER_LE and test MK_LOADER_LE here.

How does this interact with the libstand build, which also needs to be little-endian? Is there a way to make the build system create both loader.kbootbe and loader.kbootle (or the like) by default, rather than relying on a custom build flag?

The Makefile.inc adds the -mlittle_endian flag to all dependencies automatically, including libstand32.

Regarding building of both loader.kboot and loader.kbootle the biggest problem is to provide two separate versions of libstand/libfdt/etc. I'm not sure how to do this with makefiles in elegant way... If you have no objections, I'd rather stick to WITH_LOADER_LE/MK_LOADER_LE as Warner suggested, since it's much simpler solution.

OK. That's a pain to deal with. However, I'm not sure how we would make, say, ppc64 install media that include a usable loader.kboot in this configuration along with other cis-endian loaders. Maybe the answer is that we don't, that we use direct kexec() of our kernel (from the powernv branch) on install media, and leave a usable loader.kboot as an optional feature that people have to set up by hand?

For future updates please include full context (e.g. git diff -U9999)

share/mk/src.opts.mk
180 ↗(On Diff #33313)

In alpha order please

Oh, I indeed forgot to add -U9999 to the format-patch, sorry.

As for the installation of fbsd on P8, I have a plan to investigate what can be done to make the petitboot running the freebsd kernel or loader netively.
I see two solutions - just ideas, I didn't check their feasibility yet:

  1. Modify kexec+petitboot to understand freebsd kernel. Right now it finds that the ELF is relocatable and refuses to go further. Most likely it would require porting loader.kboot into petitboot.
  2. Prepare boot1 or loader.powernv which could be started using generic kexec. Because we don't have an access to any disk in powernv low-level code (no bios or uefi-like calls available), it might be worth considering providing the kernel, or the complete /boot partition as initrd blob. The loader would then use it as a memory-backed filesystem.
share/mk/src.opts.mk
180 ↗(On Diff #33313)

Right, will fix prior committing.

I like this. I'll echo the concerns of how to build both in one tree, but this allows either/or choice which is the next best thing.

This revision is now accepted and ready to land.Sep 22 2017, 2:34 PM
In D12421#258230, @wma wrote:

Oh, I indeed forgot to add -U9999 to the format-patch, sorry.

As for the installation of fbsd on P8, I have a plan to investigate what can be done to make the petitboot running the freebsd kernel or loader netively.
I see two solutions - just ideas, I didn't check their feasibility yet:

  1. Modify kexec+petitboot to understand freebsd kernel. Right now it finds that the ELF is relocatable and refuses to go further. Most likely it would require porting loader.kboot into petitboot.

I just (two days ago) committed code to the powernv branch that allows this. It's missing one patch (to ignore r6) that requires a little work still (you can fake it by setting mdp = NULL early in powerpc_init() for testing). The downside is that the kernel has to be on a petitboot-readable filesystem and you can't load KLDs from loader. Maybe we can lean on the petitboot people to add read-only UFS to their images?

  1. Prepare boot1 or loader.powernv which could be started using generic kexec. Because we don't have an access to any disk in powernv low-level code (no bios or uefi-like calls available), it might be worth considering providing the kernel, or the complete /boot partition as initrd blob. The loader would then use it as a memory-backed filesystem.

I think this might be the harder option. Even aside from the initrd thing, there isn't an obvious way to provide a UI from loader. I guess you could do serial-only via OPAL?

In any case, patch looks good. Thanks for doing this!

This revision was automatically updated to reflect the committed changes.