Page MenuHomeFreeBSD

powerpc64le: stand fixes

Authored by luporl on Sep 27 2021, 5:37 PM.
Referenced Files
Unknown Object (File)
Sun, Nov 26, 7:29 PM
Unknown Object (File)
Sun, Nov 26, 7:29 PM
Unknown Object (File)
Thu, Nov 23, 3:35 PM
Unknown Object (File)
Oct 21 2023, 4:27 PM
Unknown Object (File)
Oct 9 2023, 1:26 PM
Unknown Object (File)
Sep 26 2023, 6:34 PM
Unknown Object (File)
Sep 23 2023, 12:12 AM
Unknown Object (File)
Sep 23 2023, 12:12 AM



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

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline


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


Same here


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


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.

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.