[PATCH v2 0/9] linux-user: split internals out of qemu.h

Peter Maydell posted 9 patches 2 years, 6 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210908154405.15417-1-peter.maydell@linaro.org
Maintainers: Laurent Vivier <laurent@vivier.eu>, Taylor Simpson <tsimpson@quicinc.com>
linux-user/loader.h              |  59 +++++
linux-user/qemu.h                | 429 ++-----------------------------
linux-user/safe-syscall.h        | 154 +++++++++++
linux-user/signal-common.h       |  36 +++
linux-user/strace.h              |  38 +++
linux-user/user-internals.h      | 186 ++++++++++++++
linux-user/user-mmap.h           |  34 +++
gdbstub.c                        |   2 +-
linux-user/aarch64/cpu_loop.c    |   2 +
linux-user/aarch64/signal.c      |   1 +
linux-user/alpha/cpu_loop.c      |   2 +
linux-user/alpha/signal.c        |   1 +
linux-user/arm/cpu_loop.c        |   2 +
linux-user/arm/signal.c          |   1 +
linux-user/cris/cpu_loop.c       |   2 +
linux-user/cris/signal.c         |   1 +
linux-user/elfload.c             |   3 +
linux-user/exit.c                |   2 +
linux-user/fd-trans.c            |   2 +
linux-user/flatload.c            |   3 +
linux-user/hexagon/cpu_loop.c    |   2 +
linux-user/hexagon/signal.c      |   1 +
linux-user/hppa/cpu_loop.c       |   2 +
linux-user/hppa/signal.c         |   1 +
linux-user/i386/cpu_loop.c       |   3 +
linux-user/i386/signal.c         |   1 +
linux-user/linuxload.c           |   2 +
linux-user/m68k/cpu_loop.c       |   2 +
linux-user/m68k/signal.c         |   1 +
linux-user/main.c                |   5 +
linux-user/microblaze/cpu_loop.c |   2 +
linux-user/microblaze/signal.c   |   1 +
linux-user/mips/cpu_loop.c       |   2 +
linux-user/mips/signal.c         |   1 +
linux-user/mmap.c                |   2 +
linux-user/nios2/cpu_loop.c      |   2 +
linux-user/nios2/signal.c        |   1 +
linux-user/openrisc/cpu_loop.c   |   2 +
linux-user/openrisc/signal.c     |   1 +
linux-user/ppc/cpu_loop.c        |   2 +
linux-user/ppc/signal.c          |   1 +
linux-user/riscv/cpu_loop.c      |   2 +
linux-user/riscv/signal.c        |   1 +
linux-user/s390x/cpu_loop.c      |   2 +
linux-user/s390x/signal.c        |   1 +
linux-user/semihost.c            |   1 +
linux-user/sh4/cpu_loop.c        |   2 +
linux-user/sh4/signal.c          |   1 +
linux-user/signal.c              |   5 +
linux-user/sparc/cpu_loop.c      |   2 +
linux-user/sparc/signal.c        |   1 +
linux-user/strace.c              |   3 +
linux-user/syscall.c             |   6 +
linux-user/uaccess.c             |   1 +
linux-user/uname.c               |   1 +
linux-user/vm86.c                |   1 +
linux-user/xtensa/cpu_loop.c     |   2 +
linux-user/xtensa/signal.c       |   1 +
semihosting/arm-compat-semi.c    |   2 +-
target/m68k/m68k-semi.c          |   2 +-
target/nios2/nios2-semi.c        |   2 +-
thunk.c                          |   1 +
62 files changed, 620 insertions(+), 417 deletions(-)
create mode 100644 linux-user/loader.h
create mode 100644 linux-user/safe-syscall.h
create mode 100644 linux-user/strace.h
create mode 100644 linux-user/user-internals.h
create mode 100644 linux-user/user-mmap.h
[PATCH v2 0/9] linux-user: split internals out of qemu.h
Posted by Peter Maydell 2 years, 6 months ago
linux-user/qemu.h is an awkward header, for two reasons:
 (1) its name suggests it's a rather common generic header,
     but it's actually specific to the usermode emulators
 (2) it is a mix of:
   * lots of things internal to the implementation of linux-user
   * functions that a few files outside linux-user want
     (mostly the user-access functions like lock_user,
     get/put_user_*, etc, and also the TaskStruct definition)

This patchset tries to clean it up a bit by at least splitting
most of the "just internal to linux-user" parts out of qemu.h
and putting them in a handful of different .h files that are
then included by the linux-user files that need them.

I think the ideal would probably be to eventually junk
qemu.h entirely and have a few separate headers specifically
for the bits that non-linux-user code needs (eg a 'user-access.h'
for the get/put_user stuff), perhaps located somewhere that
means we don't need to put linux-user/ on the include path.
But that's awkward as it needs interaction with bsd-user too.
So this much cleanup seemed like a reasonable start...

Changes v1->v2:
 * rebased
 * fixed a few minor niggles spotted in v1 during review
 * use existing signal-common.h rather than creating a new
   header for signal-related functions

Patches still needing review: 3, 4, 5, 7

thanks
-- PMM

Peter Maydell (9):
  linux-user: Fix coding style nits in qemu.h
  linux-user: Split strace prototypes into strace.h
  linux-user: Split signal-related prototypes into signal-common.h
  linux-user: Split loader-related prototypes into loader.h
  linux-user: Split mmap prototypes into user-mmap.h
  linux-user: Split safe-syscall macro into its own header
  linux-user: Split linux-user internals out of qemu.h
  linux-user: Don't include gdbstub.h in qemu.h
  linux-user: Drop unneeded includes from qemu.h

 linux-user/loader.h              |  59 +++++
 linux-user/qemu.h                | 429 ++-----------------------------
 linux-user/safe-syscall.h        | 154 +++++++++++
 linux-user/signal-common.h       |  36 +++
 linux-user/strace.h              |  38 +++
 linux-user/user-internals.h      | 186 ++++++++++++++
 linux-user/user-mmap.h           |  34 +++
 gdbstub.c                        |   2 +-
 linux-user/aarch64/cpu_loop.c    |   2 +
 linux-user/aarch64/signal.c      |   1 +
 linux-user/alpha/cpu_loop.c      |   2 +
 linux-user/alpha/signal.c        |   1 +
 linux-user/arm/cpu_loop.c        |   2 +
 linux-user/arm/signal.c          |   1 +
 linux-user/cris/cpu_loop.c       |   2 +
 linux-user/cris/signal.c         |   1 +
 linux-user/elfload.c             |   3 +
 linux-user/exit.c                |   2 +
 linux-user/fd-trans.c            |   2 +
 linux-user/flatload.c            |   3 +
 linux-user/hexagon/cpu_loop.c    |   2 +
 linux-user/hexagon/signal.c      |   1 +
 linux-user/hppa/cpu_loop.c       |   2 +
 linux-user/hppa/signal.c         |   1 +
 linux-user/i386/cpu_loop.c       |   3 +
 linux-user/i386/signal.c         |   1 +
 linux-user/linuxload.c           |   2 +
 linux-user/m68k/cpu_loop.c       |   2 +
 linux-user/m68k/signal.c         |   1 +
 linux-user/main.c                |   5 +
 linux-user/microblaze/cpu_loop.c |   2 +
 linux-user/microblaze/signal.c   |   1 +
 linux-user/mips/cpu_loop.c       |   2 +
 linux-user/mips/signal.c         |   1 +
 linux-user/mmap.c                |   2 +
 linux-user/nios2/cpu_loop.c      |   2 +
 linux-user/nios2/signal.c        |   1 +
 linux-user/openrisc/cpu_loop.c   |   2 +
 linux-user/openrisc/signal.c     |   1 +
 linux-user/ppc/cpu_loop.c        |   2 +
 linux-user/ppc/signal.c          |   1 +
 linux-user/riscv/cpu_loop.c      |   2 +
 linux-user/riscv/signal.c        |   1 +
 linux-user/s390x/cpu_loop.c      |   2 +
 linux-user/s390x/signal.c        |   1 +
 linux-user/semihost.c            |   1 +
 linux-user/sh4/cpu_loop.c        |   2 +
 linux-user/sh4/signal.c          |   1 +
 linux-user/signal.c              |   5 +
 linux-user/sparc/cpu_loop.c      |   2 +
 linux-user/sparc/signal.c        |   1 +
 linux-user/strace.c              |   3 +
 linux-user/syscall.c             |   6 +
 linux-user/uaccess.c             |   1 +
 linux-user/uname.c               |   1 +
 linux-user/vm86.c                |   1 +
 linux-user/xtensa/cpu_loop.c     |   2 +
 linux-user/xtensa/signal.c       |   1 +
 semihosting/arm-compat-semi.c    |   2 +-
 target/m68k/m68k-semi.c          |   2 +-
 target/nios2/nios2-semi.c        |   2 +-
 thunk.c                          |   1 +
 62 files changed, 620 insertions(+), 417 deletions(-)
 create mode 100644 linux-user/loader.h
 create mode 100644 linux-user/safe-syscall.h
 create mode 100644 linux-user/strace.h
 create mode 100644 linux-user/user-internals.h
 create mode 100644 linux-user/user-mmap.h

-- 
2.20.1


Re: [PATCH v2 0/9] linux-user: split internals out of qemu.h
Posted by Laurent Vivier 2 years, 6 months ago
Le 08/09/2021 à 17:43, Peter Maydell a écrit :
> linux-user/qemu.h is an awkward header, for two reasons:
>  (1) its name suggests it's a rather common generic header,
>      but it's actually specific to the usermode emulators
>  (2) it is a mix of:
>    * lots of things internal to the implementation of linux-user
>    * functions that a few files outside linux-user want
>      (mostly the user-access functions like lock_user,
>      get/put_user_*, etc, and also the TaskStruct definition)
> 
> This patchset tries to clean it up a bit by at least splitting
> most of the "just internal to linux-user" parts out of qemu.h
> and putting them in a handful of different .h files that are
> then included by the linux-user files that need them.
> 
> I think the ideal would probably be to eventually junk
> qemu.h entirely and have a few separate headers specifically
> for the bits that non-linux-user code needs (eg a 'user-access.h'
> for the get/put_user stuff), perhaps located somewhere that
> means we don't need to put linux-user/ on the include path.
> But that's awkward as it needs interaction with bsd-user too.
> So this much cleanup seemed like a reasonable start...
> 
> Changes v1->v2:
>  * rebased
>  * fixed a few minor niggles spotted in v1 during review
>  * use existing signal-common.h rather than creating a new
>    header for signal-related functions
> 
> Patches still needing review: 3, 4, 5, 7
> 
> thanks
> -- PMM
> 
> Peter Maydell (9):
>   linux-user: Fix coding style nits in qemu.h
>   linux-user: Split strace prototypes into strace.h
>   linux-user: Split signal-related prototypes into signal-common.h
>   linux-user: Split loader-related prototypes into loader.h
>   linux-user: Split mmap prototypes into user-mmap.h
>   linux-user: Split safe-syscall macro into its own header
>   linux-user: Split linux-user internals out of qemu.h
>   linux-user: Don't include gdbstub.h in qemu.h
>   linux-user: Drop unneeded includes from qemu.h
> 
>  linux-user/loader.h              |  59 +++++
>  linux-user/qemu.h                | 429 ++-----------------------------
>  linux-user/safe-syscall.h        | 154 +++++++++++
>  linux-user/signal-common.h       |  36 +++
>  linux-user/strace.h              |  38 +++
>  linux-user/user-internals.h      | 186 ++++++++++++++
>  linux-user/user-mmap.h           |  34 +++
>  gdbstub.c                        |   2 +-
>  linux-user/aarch64/cpu_loop.c    |   2 +
>  linux-user/aarch64/signal.c      |   1 +
>  linux-user/alpha/cpu_loop.c      |   2 +
>  linux-user/alpha/signal.c        |   1 +
>  linux-user/arm/cpu_loop.c        |   2 +
>  linux-user/arm/signal.c          |   1 +
>  linux-user/cris/cpu_loop.c       |   2 +
>  linux-user/cris/signal.c         |   1 +
>  linux-user/elfload.c             |   3 +
>  linux-user/exit.c                |   2 +
>  linux-user/fd-trans.c            |   2 +
>  linux-user/flatload.c            |   3 +
>  linux-user/hexagon/cpu_loop.c    |   2 +
>  linux-user/hexagon/signal.c      |   1 +
>  linux-user/hppa/cpu_loop.c       |   2 +
>  linux-user/hppa/signal.c         |   1 +
>  linux-user/i386/cpu_loop.c       |   3 +
>  linux-user/i386/signal.c         |   1 +
>  linux-user/linuxload.c           |   2 +
>  linux-user/m68k/cpu_loop.c       |   2 +
>  linux-user/m68k/signal.c         |   1 +
>  linux-user/main.c                |   5 +
>  linux-user/microblaze/cpu_loop.c |   2 +
>  linux-user/microblaze/signal.c   |   1 +
>  linux-user/mips/cpu_loop.c       |   2 +
>  linux-user/mips/signal.c         |   1 +
>  linux-user/mmap.c                |   2 +
>  linux-user/nios2/cpu_loop.c      |   2 +
>  linux-user/nios2/signal.c        |   1 +
>  linux-user/openrisc/cpu_loop.c   |   2 +
>  linux-user/openrisc/signal.c     |   1 +
>  linux-user/ppc/cpu_loop.c        |   2 +
>  linux-user/ppc/signal.c          |   1 +
>  linux-user/riscv/cpu_loop.c      |   2 +
>  linux-user/riscv/signal.c        |   1 +
>  linux-user/s390x/cpu_loop.c      |   2 +
>  linux-user/s390x/signal.c        |   1 +
>  linux-user/semihost.c            |   1 +
>  linux-user/sh4/cpu_loop.c        |   2 +
>  linux-user/sh4/signal.c          |   1 +
>  linux-user/signal.c              |   5 +
>  linux-user/sparc/cpu_loop.c      |   2 +
>  linux-user/sparc/signal.c        |   1 +
>  linux-user/strace.c              |   3 +
>  linux-user/syscall.c             |   6 +
>  linux-user/uaccess.c             |   1 +
>  linux-user/uname.c               |   1 +
>  linux-user/vm86.c                |   1 +
>  linux-user/xtensa/cpu_loop.c     |   2 +
>  linux-user/xtensa/signal.c       |   1 +
>  semihosting/arm-compat-semi.c    |   2 +-
>  target/m68k/m68k-semi.c          |   2 +-
>  target/nios2/nios2-semi.c        |   2 +-
>  thunk.c                          |   1 +
>  62 files changed, 620 insertions(+), 417 deletions(-)
>  create mode 100644 linux-user/loader.h
>  create mode 100644 linux-user/safe-syscall.h
>  create mode 100644 linux-user/strace.h
>  create mode 100644 linux-user/user-internals.h
>  create mode 100644 linux-user/user-mmap.h
> 

Applied to my linux-user-for-6.2 branch.

Thanks,
Laurent