Page MenuHomeFreeBSD

[PowerPC] Fix kboot bootloader
Needs ReviewPublic

Authored by bdragon on Mar 28 2021, 1:18 AM.
Referenced Files
Unknown Object (File)
Thu, Apr 18, 9:05 PM
Unknown Object (File)
Mon, Apr 8, 8:59 AM
Unknown Object (File)
Sat, Mar 30, 1:38 PM
Unknown Object (File)
Jan 19 2024, 5:04 AM
Unknown Object (File)
Dec 23 2023, 1:37 AM
Unknown Object (File)
Nov 8 2023, 11:50 AM
Unknown Object (File)
Oct 7 2023, 10:44 AM
Unknown Object (File)
Sep 18 2023, 3:36 PM
Subscribers

Details

Reviewers
nwhitehorn
Summary

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

Repository
rG FreeBSD src repository
Lint
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.

stand/powerpc/kboot/host_syscall.S
51

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.

stand/powerpc/kboot/ldscript.powerpc
54

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