Page MenuHomeFreeBSD

[PowerPC] Fix kboot bootloader
Needs ReviewPublic

Authored by bdragon on Mar 28 2021, 1:18 AM.



The kboot bootloader has been broken since the clang transition, due to it
using GCC specific features like explicit register variables.

Write an actual startup routine that properly calls into main() using a
Linux initial stack.

This also fixes the environment, which was previously broken.

Test Plan

I verified that this makes kboot stop crashing on Playstation 3. I did not test actual loading though, as I'm not yet fully set up for doing kernel testing on my PS3 yet.

Diff Detail

rG FreeBSD src repository
Lint Skipped
Unit Tests Skipped

Event Timeline

Thanks! This looks basically sane. I'll try to smoke-test it in the next few days; if I don't report back by Wednesday, treat this comment as approval.

I should also mention: one other path here is just to delete loader.kboot, since I'm not really sure it's useful. Even my PS3 loads the kernel directly from petitboot these days.

  • Fix bug in host_open error path
  • Fix linker script problems

I can now successfully load the kernel. It loses when jumping to it though, I think I might need to do some entry point fixes.

I haven't had any luck doing raw kernel loads on mine. Are you trying with ELFv1 or ELFv2 kernels? I can't get either 12.2 or -current kernels to load properly, is there some special petitboot version you are using with yours?

FWIW my goal in fixing this is to readd netbooting support. I have a not-quite-working-yet net driver using linux raw sockets that is built on top of this stuff.

BTW I got a second PS3 in the mail today so I now have the ability to test both a modern OtherOS++ (Rebug 4.86.1) setup and a classic OtherOS on OFW 2.80 setup.


BTW this bug also affects FreeBSD 12's loader.kboot -- it would try and open fd 0 and read from it, causing the console to go crazy.


This one confused the hell out of me until I realized Linux was being extra stupid and ignoring the section alignment constraints.