Page MenuHomeFreeBSD

powerpc: Add first Linuxulator support (ELFv1, BE, powerpc64)
Needs ReviewPublic

Authored by jhibbits on Dec 9 2023, 2:57 AM.
Tags
None
Referenced Files
F89280109: D42982.id139960.diff
Fri, Jul 26, 2:03 AM
Unknown Object (File)
Sun, Jun 30, 10:26 AM
Unknown Object (File)
Sun, Jun 30, 9:08 AM
Unknown Object (File)
Jun 25 2024, 8:28 AM
Unknown Object (File)
Jun 3 2024, 6:40 AM
Unknown Object (File)
May 12 2024, 4:58 PM
Unknown Object (File)
May 8 2024, 6:19 PM
Unknown Object (File)
May 8 2024, 1:23 PM
Subscribers

Details

Reviewers
dchagin
brooks
Group Reviewers
Linux Emulation
PowerPC
Summary

Introduce the first cut of the Linuxulator for powerpc64. This was a
GSoC project for 2022, and consists of the following:

  • Big-endian powerpc64
  • ELFv1
  • Limited shared page (no timekeep)
  • Most, if not all, syscalls are implemented, all common ones, no arch-specific ones.

At completion of the GSoC period this was able to run through the LTP
test suite, with a very high pass rate. More work remains, as always,
and will be done as needed.

Further work is still necessary, but this lays the groundwork. Expected
future work includes:

  • ELFv2
  • powerpc64le
  • 32-bit support (running legacy Linux applications)

Sponsored by: Google Summer of Code
MFC after: 2 months

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 58223
Build 55111: arc lint + arc unit

Event Timeline

sys/compat/linux/linux_file.c
319

should this change apply to COMPAT_LINUX32 only, as with amd64?

sys/compat/linux/linux_ioctl.h
38

curious why this is needed now

335

curious about why these are excluded from __powerpc64__, perhaps a comment in the src

402

this should probably be a separate commit with a stated rationale

sys/conf/files.powerpc
380 ↗(On Diff #131200)

undo this

sys/modules/linux64/Makefile
73–74

?

105–108

?

sys/compat/linux/linux_file.c
319

According to Linux's arch/powerpc/kernel/syscalls/syscall.tbl llseek is common. This really should be powerpc, not powerpc64, on the off-chance I add 32-bit compat.

sys/compat/linux/linux_ioctl.h
335

Curious. I didn't know, so just checked Linux. powerpc seems to be the *only* arch that uses lowercase 't'. I'll add a comment for it. This is also the case for TCSETS, etc., so all of these should be in one block, not sprinkled like this.

402

I'll have to rework this.

sys/conf/files.powerpc
380 ↗(On Diff #131200)

That's an odd one, don't know how it snuck in here.

sys/modules/linux64/Makefile
73–74

My fault. My GSoC student (last year) had made some changes to this file that I didn't want to fully revert while I was doing the final merge. I forgot to remove this and below before submitting the review.

105–108

As above.

I didn't have time for this whole thing.

sys/compat/linux/linux_ioctl.h
335

I know that PowerPC is the odd-man out for ABI issues, encoding, termios definitions, etc. All the others platforms we support on Linux use the common ABI stuff (by and large, there's interesting exceptions for i386 sometimes, but the common stuff often is the i386 stuff given Linux's development history).

When I did similar things for kboot, I created a per-arch .h file for this stuff as well as a common .h file that most things use. This ifdef soup is crazy and avoided that way.

sys/powerpc/linux/linux_genassym.c
3

This is bogus. Drop it. :)

sys/powerpc/linux/linux_locore.asm
3

The -FreeBSD SPDX identifier is obsolete and shouldn't be used at all.

sys/powerpc/linux/linux_machdep.c
33

Here and everywhere else: remove $FreeBSD$ and #include <sys/cdefs.h>

63

Should we return an error instead?

sys/compat/linux/linux_ioctl.h
402

It's even weirder than I thought. The powerpc ioctl list breaks the linuxulator ioctl registration code. There are two groups of terminal ioctls for powerpc: those that are formed via the macros, and those that match the rest (0x54xx). So in order to do this right, I'll need to break up the existing ioctl list into two lists, and register them separately.

sys/compat/linux/linux_ioctl.h
335

Interestingly, the powerpc ioctls here match the FreeBSD ioctls perfectly in many cases. Since our ABIs aren't changing... ever... I can just use our ioctl definitions for many of these in the powerpc case, and even use the _IOC() macros to generate them.

jhibbits added inline comments.
sys/compat/linux/linux_ioctl.h
38

Linux on powerpc defines LINUX_IOC_VOID as 0x20000000 (same as IOC_VOID on FreeBSD), all other archs FreeBSD runs on, Linux defines it as 0.

sys/powerpc/linux/linux_machdep.c
63

It's a trivial function, so implementing it.

Address feedback. Add new linux_ioctl_handler for powerpc-specific TTY ioctls.

Cleanup:

  • Remove unnecessary code
    • linux_exec_setregs() is identical to exec_setregs(), so dedup. Could dedup even more, too.
  • style(9) some bits