Page MenuHomeFreeBSD

powerpc64le: stand fixes
ClosedPublic

Authored by luporl on Sep 27 2021, 5:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 1:28 PM
Unknown Object (File)
Sun, Apr 14, 7:32 AM
Unknown Object (File)
Mar 1 2024, 5:47 AM
Unknown Object (File)
Feb 2 2024, 1:16 AM
Unknown Object (File)
Feb 2 2024, 1:16 AM
Unknown Object (File)
Feb 2 2024, 1:16 AM
Unknown Object (File)
Feb 2 2024, 1:16 AM
Unknown Object (File)
Feb 2 2024, 1:16 AM
Subscribers

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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 42141
Build 39029: arc lint + arc unit

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.