All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for 6.2 00/49] bsd-user updates to run hello world
@ 2021-08-07 21:41 Warner Losh
  2021-08-07 21:41 ` [PATCH for 6.2 01/49] bsd-user: remove sparc and sparc64 Warner Losh
                   ` (48 more replies)
  0 siblings, 49 replies; 123+ messages in thread
From: Warner Losh @ 2021-08-07 21:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: kevans, Warner Losh

This series of patches gets me to the point that I can run "Hello World" on i386
and x86_64. This is for static binaries only, that are relatively small, but
it's better than the 100% instant mmap failre that is the current state of all
things bsd-user in upstream qemu. Future patch sets will refine this, add
the missing system calls, fix bugs preventing more sophisticated programms
from running and add a bunch of new architecture support.

There's three large themes in these patches, though the changes that
represent them are interrelated making it hard to separate out further.
1. Reorganization to support multiple OS and architectures (though I've only
   tested FreeBSD, other BSDs might not even compile yet).
2. Diff reduction with the bsd-user fork for several files. These diffs include
   changes that borrowed from linux-user as well as changes to make things work
   on FreeBSD. The records keeping when this was done, however, was poor at
   best, so many of the specific borrowings are going unacknowledged here, apart
   from this general ack. These diffs also include some minor code shuffling.
   Some of the changes are done specifically to make it easier to rebase
   the bsd-user fork's changes when these land in the tree (a number of changes
   have been pushed there to make this more possible).
3. Filling in the missing pieces to make things work. There's many changes to
   elfload to make it load things in the right places, to find the interpreter
   better, etc. There's changes to mmap.c to make the mappings work better and
   there's changes to main.c that were inspired, at least, by now-ancient changes
   to linux-user's main.c.

I ran checkpatch.pl on this, and there's 350-odd errors it identifies (the vast
majoirty come from BSD's fetish for tabs), so there will need to be a V2 to fix
this at the very least. In addition, the change set is big (about +~4.5k/-~2.5k
lines), so I anticipate some iteration as well just based on its sheer
size. I've tried to keep each set small to make it easy to review in isolation,
but I've also allowed some interrelated ones to get a little bigger than I'd
normally like. I've not done the customary documentation of the expected
checkpatch.pl output because it is large, and because I wanted to get review
of the other parts rolling to get this project unstuck. Future versions of the
patch will document the expected output.

In addition, I noticed a number of places where I could modernize to make the
code match things like linux-user better. I've resisted the urge to do these at
this time, since it would complicate merging the other ~30k lines of diff that
remains after this batch. Future batches should generally be smaller once this
one has landed since they are, by and large, either a bunch of new files to
support armv7, aarch64, riscv64, mips, mipsel, mips64, ppc, ppc64 and ppc64le,
or are adding system calls, which can be done individually or small groups. I've
removed sparc and sparc64 support as they've been removed from FreeBSD and
have been near totally busted for years.

Stacey Son did the bulk of this work originally, but since I had to move things
around so much and/or retool that work in non-trivial ways, I've kept myself as
author, and added his signed-off-by line. I'm unsure of the qemu standard
practice for this, but am happy to learn if this is too far outside its current
mainstream. For a while Sean Bruno did the merges from upstream, and he's
credited using his signed-off-by in appropriate places, though for this patch
set there's only a few. I've tried to ensure that others who have work in
individual patches that I've aggregated together also are reflected in their
signed-off-by. Given the chaotic stat of the upstream repo for its early
history, this may be the best that can be reconstructed at this late date. Most
of these files are 'foundational' so have existed from the earliest days when
record keeping wasn't quite what I'd wish for in hindsight. There was only
really one change that I could easily cherry-pick (Colin's), so I did that.

Colin Percival (1):
  bsd-user: Add '-0 argv0' option to bsd-user/main.c

Warner Losh (48):
  bsd-user: remove sparc and sparc64
  bsd-user: add copyright header to elfload.c
  bsd-user: Add Stacey's copyright to main.c
  bsd-user: Remove all non-x86 code from elfload.c
  bsd-user: move arch specific defines out of elfload.c
  bsd-user: merge comments and guards from bsd-user fork
  bsd-user: style nits: apply qemu style to these files
  bsd-user: style nits: fix whitespace issues to be qemu standard
  bsd-user: add license
  bsd-user: pass the bsd_param into loader_exec
  bsd-user: Fix calculation of size to allocate
  bsd-user: implement path searching
  bsd-user: Eliminate elf personality
  bsd-user: remove a.out support
  bsd-user: TARGET_NGROUPS unused in this file, remove
  bsd-user: elfload: simplify bswap a bit.
  bsd-user: assume pthreads and support of __thread
  bsd-user: add host-os.h
  bsd-user: Include host-os.h from main
  bsd-user: save the path the qemu emulator
  bsd-user: start to move target CPU functions to target_arch*
  bsd-user: Move per-cpu code into target_arch_cpu.h
  bsd-user: pull in target_arch_thread.h update target_arch_elf.h
  bsd-user: Include more things in qemu.h
  bsd-user: define max args in terms of pages
  bsd-user: Create target specific vmparam.h
  bsd-user: Add architecture specific signal tramp code
  bsd-user: Move stack initializtion into a per-os file.
  bsd-user: Add system independent stack, data and text limiting
  bsd-user: elf cleanup
  bsd-user: Remove dead #ifdefs from elfload.c
  bsd-user: *BSD specific siginfo defintions
  bsd-user: Rewrite target system call definintion glue
  bsd-user: Fix initializtion of task state
  bsd-user: remove error_init
  bsd-user: Make cpu_model and cpu_type visible to all of main.c
  bsd-user: update debugging in mmap.c
  bsd-user: Update mapping to handle reserved and starting conditions
  bsd-user: Need to reset CPU after creation.
  bsd-user: Add target_arch_reg to describe a target's register set
  bsd-user: Add target_os_user.h to capture the user/kernel structures
  bsd-user: add stubbed out core dump support
  bsd-user: elfload.c style catch up patch
  bsd-user: Refactor load_elf_sections and is_target_elf_binary
  bsd-user: Make guest_base an unsigned long
  bsd-user: move qemu_log to later in the file
  bsd-user: Implement interlock for atomic operations
  bsd-user: Implement cpu_copy() helper routine

 bsd-user/bsd-mman.h                           |  121 --
 bsd-user/bsdload.c                            |  141 +-
 bsd-user/elfcore.c                            |   10 +
 bsd-user/elfload.c                            | 1464 +++++------------
 bsd-user/freebsd/host-os.h                    |   25 +
 bsd-user/freebsd/target_os_elf.h              |  149 ++
 bsd-user/freebsd/target_os_siginfo.h          |  145 ++
 bsd-user/freebsd/target_os_signal.h           |   78 +
 bsd-user/freebsd/target_os_stack.h            |  181 ++
 bsd-user/freebsd/target_os_thread.h           |   25 +
 bsd-user/freebsd/target_os_user.h             |  429 +++++
 bsd-user/freebsd/target_os_vmparam.h          |   38 +
 .../target_syscall.h => i386/target_arch.h}   |   27 +-
 bsd-user/i386/target_arch_cpu.c               |   76 +
 bsd-user/i386/target_arch_cpu.h               |  306 ++++
 .../target_arch_elf.h}                        |   30 +-
 bsd-user/i386/target_arch_reg.h               |   82 +
 bsd-user/i386/target_arch_signal.h            |   94 ++
 bsd-user/i386/target_arch_sigtramp.h          |   29 +
 bsd-user/i386/target_arch_thread.h            |   47 +
 bsd-user/i386/target_arch_vmparam.h           |   46 +
 bsd-user/main.c                               |  831 ++--------
 bsd-user/mmap.c                               |  421 ++++-
 bsd-user/netbsd/host-os.h                     |   25 +
 bsd-user/netbsd/target_os_elf.h               |  143 ++
 bsd-user/netbsd/target_os_siginfo.h           |   82 +
 bsd-user/netbsd/target_os_signal.h            |   70 +
 bsd-user/netbsd/target_os_stack.h             |   56 +
 bsd-user/netbsd/target_os_thread.h            |   25 +
 bsd-user/openbsd/host-os.h                    |   25 +
 bsd-user/openbsd/target_os_elf.h              |  143 ++
 bsd-user/openbsd/target_os_siginfo.h          |   82 +
 bsd-user/openbsd/target_os_signal.h           |   70 +
 bsd-user/openbsd/target_os_stack.h            |   56 +
 bsd-user/openbsd/target_os_thread.h           |   25 +
 bsd-user/qemu.h                               |   62 +-
 bsd-user/sparc/target_arch_sysarch.h          |   52 -
 bsd-user/sparc64/target_arch_sysarch.h        |   52 -
 bsd-user/syscall.c                            |   11 -
 bsd-user/syscall_defs.h                       |  255 +--
 bsd-user/x86_64/target_arch.h                 |   31 +
 bsd-user/x86_64/target_arch_cpu.c             |   76 +
 bsd-user/x86_64/target_arch_cpu.h             |  328 ++++
 bsd-user/x86_64/target_arch_elf.h             |   33 +
 bsd-user/x86_64/target_arch_reg.h             |   92 ++
 bsd-user/x86_64/target_arch_signal.h          |   94 ++
 bsd-user/x86_64/target_arch_sigtramp.h        |   29 +
 bsd-user/x86_64/target_arch_thread.h          |   40 +
 bsd-user/x86_64/target_arch_vmparam.h         |   46 +
 meson.build                                   |    8 +-
 50 files changed, 4555 insertions(+), 2251 deletions(-)
 delete mode 100644 bsd-user/bsd-mman.h
 create mode 100644 bsd-user/elfcore.c
 create mode 100644 bsd-user/freebsd/host-os.h
 create mode 100644 bsd-user/freebsd/target_os_elf.h
 create mode 100644 bsd-user/freebsd/target_os_siginfo.h
 create mode 100644 bsd-user/freebsd/target_os_signal.h
 create mode 100644 bsd-user/freebsd/target_os_stack.h
 create mode 100644 bsd-user/freebsd/target_os_thread.h
 create mode 100644 bsd-user/freebsd/target_os_user.h
 create mode 100644 bsd-user/freebsd/target_os_vmparam.h
 rename bsd-user/{sparc/target_syscall.h => i386/target_arch.h} (60%)
 create mode 100644 bsd-user/i386/target_arch_cpu.c
 create mode 100644 bsd-user/i386/target_arch_cpu.h
 rename bsd-user/{sparc64/target_syscall.h => i386/target_arch_elf.h} (59%)
 create mode 100644 bsd-user/i386/target_arch_reg.h
 create mode 100644 bsd-user/i386/target_arch_signal.h
 create mode 100644 bsd-user/i386/target_arch_sigtramp.h
 create mode 100644 bsd-user/i386/target_arch_thread.h
 create mode 100644 bsd-user/i386/target_arch_vmparam.h
 create mode 100644 bsd-user/netbsd/host-os.h
 create mode 100644 bsd-user/netbsd/target_os_elf.h
 create mode 100644 bsd-user/netbsd/target_os_siginfo.h
 create mode 100644 bsd-user/netbsd/target_os_signal.h
 create mode 100644 bsd-user/netbsd/target_os_stack.h
 create mode 100644 bsd-user/netbsd/target_os_thread.h
 create mode 100644 bsd-user/openbsd/host-os.h
 create mode 100644 bsd-user/openbsd/target_os_elf.h
 create mode 100644 bsd-user/openbsd/target_os_siginfo.h
 create mode 100644 bsd-user/openbsd/target_os_signal.h
 create mode 100644 bsd-user/openbsd/target_os_stack.h
 create mode 100644 bsd-user/openbsd/target_os_thread.h
 delete mode 100644 bsd-user/sparc/target_arch_sysarch.h
 delete mode 100644 bsd-user/sparc64/target_arch_sysarch.h
 create mode 100644 bsd-user/x86_64/target_arch.h
 create mode 100644 bsd-user/x86_64/target_arch_cpu.c
 create mode 100644 bsd-user/x86_64/target_arch_cpu.h
 create mode 100644 bsd-user/x86_64/target_arch_elf.h
 create mode 100644 bsd-user/x86_64/target_arch_reg.h
 create mode 100644 bsd-user/x86_64/target_arch_signal.h
 create mode 100644 bsd-user/x86_64/target_arch_sigtramp.h
 create mode 100644 bsd-user/x86_64/target_arch_thread.h
 create mode 100644 bsd-user/x86_64/target_arch_vmparam.h

-- 
2.32.0



^ permalink raw reply	[flat|nested] 123+ messages in thread

end of thread, other threads:[~2021-08-20 23:37 UTC | newest]

Thread overview: 123+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-07 21:41 [PATCH for 6.2 00/49] bsd-user updates to run hello world Warner Losh
2021-08-07 21:41 ` [PATCH for 6.2 01/49] bsd-user: remove sparc and sparc64 Warner Losh
2021-08-08  4:28   ` Richard Henderson
2021-08-07 21:41 ` [PATCH for 6.2 02/49] bsd-user: add copyright header to elfload.c Warner Losh
2021-08-08  4:29   ` Richard Henderson
2021-08-07 21:41 ` [PATCH for 6.2 03/49] bsd-user: Add Stacey's copyright to main.c Warner Losh
2021-08-08  4:30   ` Richard Henderson
2021-08-07 21:41 ` [PATCH for 6.2 04/49] bsd-user: Remove all non-x86 code from elfload.c Warner Losh
2021-08-08  4:30   ` Richard Henderson
2021-08-07 21:41 ` [PATCH for 6.2 05/49] bsd-user: move arch specific defines out of elfload.c Warner Losh
2021-08-08  4:35   ` Richard Henderson
2021-08-07 21:41 ` [PATCH for 6.2 06/49] bsd-user: merge comments and guards from bsd-user fork Warner Losh
2021-08-08  4:37   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 07/49] bsd-user: style nits: apply qemu style to these files Warner Losh
2021-08-08  4:38   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 08/49] bsd-user: style nits: fix whitespace issues to be qemu standard Warner Losh
2021-08-08  4:38   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 09/49] bsd-user: add license Warner Losh
2021-08-08  4:39   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 10/49] bsd-user: pass the bsd_param into loader_exec Warner Losh
2021-08-08  4:48   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 11/49] bsd-user: Fix calculation of size to allocate Warner Losh
2021-08-08  4:49   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 12/49] bsd-user: implement path searching Warner Losh
2021-08-08  5:11   ` Richard Henderson
2021-08-08  5:48     ` Kyle Evans
2021-08-08 17:22       ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 13/49] bsd-user: Eliminate elf personality Warner Losh
2021-08-08  5:12   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 14/49] bsd-user: remove a.out support Warner Losh
2021-08-08  5:14   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 15/49] bsd-user: TARGET_NGROUPS unused in this file, remove Warner Losh
2021-08-08  5:15   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 16/49] bsd-user: elfload: simplify bswap a bit Warner Losh
2021-08-08  5:17   ` Richard Henderson
2021-08-10 18:19   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 17/49] bsd-user: assume pthreads and support of __thread Warner Losh
2021-08-08  5:18   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 18/49] bsd-user: add host-os.h Warner Losh
2021-08-08  5:19   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 19/49] bsd-user: Include host-os.h from main Warner Losh
2021-08-08  5:20   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 20/49] bsd-user: save the path the qemu emulator Warner Losh
2021-08-08  5:24   ` Richard Henderson
2021-08-08 16:44     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 21/49] bsd-user: start to move target CPU functions to target_arch* Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 22/49] bsd-user: Move per-cpu code into target_arch_cpu.h Warner Losh
2021-08-08  5:35   ` Richard Henderson
2021-08-08  6:03     ` Warner Losh
2021-08-08  6:16       ` Richard Henderson
2021-08-08 17:38         ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 23/49] bsd-user: pull in target_arch_thread.h update target_arch_elf.h Warner Losh
2021-08-08  6:24   ` Richard Henderson
2021-08-08 21:43     ` Warner Losh
2021-08-08 22:56       ` Warner Losh
2021-08-09 17:53       ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 24/49] bsd-user: Include more things in qemu.h Warner Losh
2021-08-09 20:31   ` Richard Henderson
2021-08-10  2:35     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 25/49] bsd-user: define max args in terms of pages Warner Losh
2021-08-09 20:33   ` Richard Henderson
2021-08-10  2:38     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 26/49] bsd-user: Create target specific vmparam.h Warner Losh
2021-08-09 20:39   ` Richard Henderson
2021-08-10  2:44     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 27/49] bsd-user: Add architecture specific signal tramp code Warner Losh
2021-08-09 20:39   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 28/49] bsd-user: Move stack initializtion into a per-os file Warner Losh
2021-08-09 21:00   ` Richard Henderson
2021-08-20  3:48     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 29/49] bsd-user: Add system independent stack, data and text limiting Warner Losh
2021-08-09 21:05   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 30/49] bsd-user: elf cleanup Warner Losh
2021-08-09 23:47   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 31/49] bsd-user: Remove dead #ifdefs from elfload.c Warner Losh
2021-08-10  4:21   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 32/49] bsd-user: *BSD specific siginfo defintions Warner Losh
2021-08-10  4:26   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 33/49] bsd-user: Rewrite target system call definintion glue Warner Losh
2021-08-10 15:18   ` Richard Henderson
2021-08-20  1:10     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 34/49] bsd-user: Fix initializtion of task state Warner Losh
2021-08-10 15:02   ` Richard Henderson
2021-08-10 22:28     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 35/49] bsd-user: remove error_init Warner Losh
2021-08-10 15:07   ` Richard Henderson
2021-08-10 22:29     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 36/49] bsd-user: Make cpu_model and cpu_type visible to all of main.c Warner Losh
2021-08-10 15:08   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 37/49] bsd-user: update debugging in mmap.c Warner Losh
2021-08-10 16:18   ` Richard Henderson
2021-08-10 22:34     ` Warner Losh
2021-08-10 23:36       ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 38/49] bsd-user: Update mapping to handle reserved and starting conditions Warner Losh
2021-08-10 16:27   ` Richard Henderson
2021-08-10 22:38     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 39/49] bsd-user: Need to reset CPU after creation Warner Losh
2021-08-10 16:32   ` Richard Henderson
2021-08-10 22:40     ` Warner Losh
2021-08-10 23:39       ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 40/49] bsd-user: Add target_arch_reg to describe a target's register set Warner Losh
2021-08-10 16:44   ` Richard Henderson
2021-08-20 23:36     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 41/49] bsd-user: Add target_os_user.h to capture the user/kernel structures Warner Losh
2021-08-10 16:46   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 42/49] bsd-user: add stubbed out core dump support Warner Losh
2021-08-10 17:27   ` Richard Henderson
2021-08-20  3:16     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 43/49] bsd-user: elfload.c style catch up patch Warner Losh
2021-08-10 17:36   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 44/49] bsd-user: Refactor load_elf_sections and is_target_elf_binary Warner Losh
2021-08-10 17:55   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 45/49] bsd-user: Make guest_base an unsigned long Warner Losh
2021-08-10 17:58   ` Richard Henderson
2021-08-10 18:04     ` Warner Losh
2021-08-07 21:42 ` [PATCH for 6.2 46/49] bsd-user: move qemu_log to later in the file Warner Losh
2021-08-10 17:59   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 47/49] bsd-user: Implement interlock for atomic operations Warner Losh
2021-08-10 18:03   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 48/49] bsd-user: Implement cpu_copy() helper routine Warner Losh
2021-08-10 18:06   ` Richard Henderson
2021-08-07 21:42 ` [PATCH for 6.2 49/49] bsd-user: Add '-0 argv0' option to bsd-user/main.c Warner Losh
2021-08-10 18:08   ` Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.