=== bsd-user: Upstreaming and Status Report

Links: +
link:https://qemu.org[QEMU Project] URL: link:https://qemu.org[] +
link:https://github.com/qemu-bsd-user/qemu-bsd-user[FreeBSD bsd-user qemu fork] URL: link:https://github.com/qemu-bsd-user/qemu-bsd-user[] +
link:https://gitlab.com/qemu-project/qemu[QEMU Project's gitlab mirror] URL: link:https://gitlab.com/qemu-project/qemu[]

Contact: Warner Losh <imp@FreeBSD.org>

In this quarter, Warner upstreamed two patch sets in the qemu-project repo (with a third pending).
Doug Rabson submitted some optimizations to save a handle to the qemu-user emulator in the kernel for future exec.
Contact has been made with some folks interested in getting bsd-user working on NetBSD.
Summer of Code project to upstream shows some interest.

==== Upstreaming Efforts

The sysctl system call was upstreamed this quarter.
Doug's changes were also upstreamed (see below).
Some cleanups around NetBSD and OpenBSD and to generate syscalls on the fly are pending.

==== Doug Rabson's Changes

As part of his container work, Doug submitted changes that allows the kernel to cache the emulator used to run programs.
This allows the kernel to directly exec the new binary with that cached emulator.
This simplifies bsd-user and removes one source of difference between it and linux-user.
Doug also provided an important fix that prevented aarch64 from running.

==== Bug Fixes and Improvements

In addition to Doug's fixes, Warner cleaned up things a bit this quarter.

* Warner removed the final bits of 'run on any BSD code' that was present in the emulator.
* While the basic system calls could be emulated between all the BSDs, their system call interface has diverged too much, and it is too feature rich for this to be feasible any time soon.
* Warner had planned to just remove the NetBSD and OpenBSD bits, but there is some interest from at least the NetBSD folks for making things build.
* Now that the NetBSD folks have contact information, and know direction, Warner hopes they will submit a pull request to build bsd-user on NetBSD for NetBSD.
* Warner added SIGSYS support so that we can catch unimplemented system calls sooner, and improved reporting of them to get more data about what fails.
* Warner cleaned up some code in the `blitz` branch.
* We're merged up to 8.0rc1 in upstream in the `blitz` branch we're using to stay current.

==== Summer of Code Projects

There's much interest in the bsd-user upstreaming task Warner added to Qemu's project list.
With luck, we'll have a student to fund to do the job of upstreaming all the system calls needed to run simple programs.
With a lot of luck, we'll be able to run any program that does the same thing(s) that clang does (one goal is to have it compile hello world).
Future quarterly reports will provide details, should we be fortunate enough to get a slot for this.

==== Help Needed

We can always use help with bsd-user.

* Pull requests for new system calls are welcome.
* Automation in generating many of the things we do by hand would be helpful (like system call argument tracing).
* Enthusiastic volunteers who want to help me with the upstreaming (many tasks are easy and quick if you don't want to commit).
* Coordination with the NetBSD folks and cleanup they come up with.
* Bug fixes (especially thread bugs) are needed.
