Page MenuHomeFreeBSD

powerpc64le: stand fixes
ClosedPublic

Authored by luporl on Sep 27 2021, 5:37 PM.

Details

Summary

Fix boot1 and loader on PowerPC64 little-endian (LE).

Due to endian issues, boot1 couldn't find the UFS boot partition
and loader wasn't able to load the kernel. Most of the issues
happened because boot1 and loader were BE binaries trying to access
LE UFS partitions and because loader expects the kernel ELF image
to use the same endian as itself.

To fix these issues, boot1 and loader are now built as LE binaries
on PPC64LE. To support this, the functions that call OpenFirmware
were enhanced to correctly perform endian conversion on its input
and output arguments and to change the CPU into BE mode before
making the calls, as OpenFirmware always runs in BE. Besides that,
some other small fixes were needed.

Most of the changes were done by @bdragon.

Test Plan

Tested on POWER9 VMs, with the following configurations:

  • BE Hash MMU
  • BE Radix MMU
  • LE Hash MMU
  • LE Radix MMU

Tested both boot from disk as well as netboot.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

stand/common/load_elf.c
752–753

Isn't this a NOP? htobe() on BIG_ENDIAN is a NOP.

797–798

Same here

stand/common/load_elf.c
752–753

Yes, I hadn't realized that. This part was causing the kernel to crash at boot on PPC64LE, so I supposed it should be a BE specific stuff.

After some digging, it seems it was added by D12421 and D12422, when booting on POWER8 was done with kboot running in LE and the kernel running in BE. The option to compile stand and kboot in LE was later removed with D26430.

As this is not the case anymore and the kernel may also be compiled in LE for PowerPC, this should be removed.

Remove obsolete endian conversions

stand/powerpc/Makefile
14

uboot is needed for ppc32, too, for the embedded platforms. Maybe an outside SUBDIR.${MK_FDT} for that?

Build uboot for ppc32 too

luporl added inline comments.
stand/powerpc/Makefile
14

Ok, it's now being built for all platforms but powerpc64le, keeping the original behavior.

Great job @bdragon and @luporl!
Tested a powerpc64 disc1.iso with this patch on QEMU6.0 and installation went fine. Also tested make buildkernel/installkernel with no issues.

This revision is now accepted and ready to land.Oct 14 2021, 6:06 PM
This revision was automatically updated to reflect the committed changes.
luporl marked an inline comment as done.