[PATCH v2 00/20] linux-user: generate syscall_nr.sh

Laurent Vivier posted 20 patches 4 years, 2 months ago
Test docker-quick@centos7 passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200219220333.1411905-1-laurent@vivier.eu
Maintainers: Aleksandar Markovic <amarkovic@wavecomp.com>, Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>, Aurelien Jarno <aurelien@aurel32.net>, Laurent Vivier <laurent@vivier.eu>, Riku Voipio <riku.voipio@iki.fi>
There is a newer version of this series
MAINTAINERS                            |   1 +
Makefile.target                        |   3 +-
configure                              |  35 ++
linux-user/Makefile.objs               |  19 +-
linux-user/alpha/Makefile.objs         |   5 +
linux-user/alpha/syscall.tbl           | 479 ++++++++++++++++
linux-user/alpha/syscall_nr.h          | 492 -----------------
linux-user/alpha/syscallhdr.sh         |  32 ++
linux-user/arm/Makefile.objs           |   8 +
linux-user/arm/syscall.tbl             | 453 +++++++++++++++
linux-user/arm/syscall_nr.h            | 447 ---------------
linux-user/arm/syscallhdr.sh           |  31 ++
linux-user/hppa/Makefile.objs          |   5 +
linux-user/hppa/syscall.tbl            | 437 +++++++++++++++
linux-user/hppa/syscall_nr.h           | 358 ------------
linux-user/hppa/syscallhdr.sh          |  32 ++
linux-user/i386/Makefile.objs          |   5 +
linux-user/i386/syscall_32.tbl         | 444 +++++++++++++++
linux-user/i386/syscall_nr.h           | 387 -------------
linux-user/i386/syscallhdr.sh          |  28 +
linux-user/m68k/Makefile.objs          |   5 +
linux-user/m68k/syscall.tbl            | 439 +++++++++++++++
linux-user/m68k/syscall_nr.h           | 434 ---------------
linux-user/m68k/syscallhdr.sh          |  32 ++
linux-user/microblaze/Makefile.objs    |   5 +
linux-user/microblaze/syscall.tbl      | 445 +++++++++++++++
linux-user/microblaze/syscall_nr.h     | 442 ---------------
linux-user/microblaze/syscallhdr.sh    |  32 ++
linux-user/mips/Makefile.objs          |   5 +
linux-user/mips/cpu_loop.c             | 440 +--------------
linux-user/mips/syscall-args-o32.c.inc | 436 +++++++++++++++
linux-user/mips/syscall_nr.h           | 425 ---------------
linux-user/mips/syscall_o32.tbl        | 427 +++++++++++++++
linux-user/mips/syscallhdr.sh          |  36 ++
linux-user/mips64/Makefile.objs        |  12 +
linux-user/mips64/syscall_n32.tbl      | 378 +++++++++++++
linux-user/mips64/syscall_n64.tbl      | 354 ++++++++++++
linux-user/mips64/syscall_nr.h         | 725 -------------------------
linux-user/mips64/syscallhdr.sh        |  33 ++
linux-user/ppc/Makefile.objs           |   6 +
linux-user/ppc/signal.c                |   2 +-
linux-user/ppc/syscall.tbl             | 521 ++++++++++++++++++
linux-user/ppc/syscall_nr.h            | 402 --------------
linux-user/ppc/syscallhdr.sh           |  34 ++
linux-user/s390x/Makefile.objs         |   5 +
linux-user/s390x/syscall.tbl           | 442 +++++++++++++++
linux-user/s390x/syscall_nr.h          | 398 --------------
linux-user/s390x/syscallhdr.sh         |  32 ++
linux-user/sh4/Makefile.objs           |   5 +
linux-user/sh4/syscall.tbl             | 442 +++++++++++++++
linux-user/sh4/syscall_nr.h            | 441 ---------------
linux-user/sh4/syscallhdr.sh           |  32 ++
linux-user/sparc/Makefile.objs         |   5 +
linux-user/sparc/syscall.tbl           | 485 +++++++++++++++++
linux-user/sparc/syscall_nr.h          | 363 -------------
linux-user/sparc/syscallhdr.sh         |  32 ++
linux-user/sparc64/Makefile.objs       |   5 +
linux-user/sparc64/syscall.tbl         | 485 +++++++++++++++++
linux-user/sparc64/syscall_nr.h        | 366 -------------
linux-user/sparc64/syscallhdr.sh       |  32 ++
linux-user/syscall.c                   |   6 +
linux-user/x86_64/Makefile.objs        |   5 +
linux-user/x86_64/syscall_64.tbl       | 404 ++++++++++++++
linux-user/x86_64/syscall_nr.h         | 356 ------------
linux-user/x86_64/syscallhdr.sh        |  28 +
linux-user/xtensa/Makefile.objs        |   5 +
linux-user/xtensa/syscall.tbl          | 410 ++++++++++++++
linux-user/xtensa/syscall_nr.h         | 469 ----------------
linux-user/xtensa/syscallhdr.sh        |  32 ++
scripts/update-mips-syscall-args.sh    |  57 ++
scripts/update-syscalltbl.sh           |  49 ++
71 files changed, 8214 insertions(+), 6948 deletions(-)
create mode 100644 linux-user/alpha/Makefile.objs
create mode 100644 linux-user/alpha/syscall.tbl
delete mode 100644 linux-user/alpha/syscall_nr.h
create mode 100644 linux-user/alpha/syscallhdr.sh
create mode 100644 linux-user/arm/Makefile.objs
create mode 100644 linux-user/arm/syscall.tbl
delete mode 100644 linux-user/arm/syscall_nr.h
create mode 100644 linux-user/arm/syscallhdr.sh
create mode 100644 linux-user/hppa/Makefile.objs
create mode 100644 linux-user/hppa/syscall.tbl
delete mode 100644 linux-user/hppa/syscall_nr.h
create mode 100644 linux-user/hppa/syscallhdr.sh
create mode 100644 linux-user/i386/Makefile.objs
create mode 100644 linux-user/i386/syscall_32.tbl
delete mode 100644 linux-user/i386/syscall_nr.h
create mode 100644 linux-user/i386/syscallhdr.sh
create mode 100644 linux-user/m68k/Makefile.objs
create mode 100644 linux-user/m68k/syscall.tbl
delete mode 100644 linux-user/m68k/syscall_nr.h
create mode 100644 linux-user/m68k/syscallhdr.sh
create mode 100644 linux-user/microblaze/Makefile.objs
create mode 100644 linux-user/microblaze/syscall.tbl
delete mode 100644 linux-user/microblaze/syscall_nr.h
create mode 100644 linux-user/microblaze/syscallhdr.sh
create mode 100644 linux-user/mips/Makefile.objs
create mode 100644 linux-user/mips/syscall-args-o32.c.inc
delete mode 100644 linux-user/mips/syscall_nr.h
create mode 100644 linux-user/mips/syscall_o32.tbl
create mode 100644 linux-user/mips/syscallhdr.sh
create mode 100644 linux-user/mips64/Makefile.objs
create mode 100644 linux-user/mips64/syscall_n32.tbl
create mode 100644 linux-user/mips64/syscall_n64.tbl
delete mode 100644 linux-user/mips64/syscall_nr.h
create mode 100644 linux-user/mips64/syscallhdr.sh
create mode 100644 linux-user/ppc/Makefile.objs
create mode 100644 linux-user/ppc/syscall.tbl
delete mode 100644 linux-user/ppc/syscall_nr.h
create mode 100644 linux-user/ppc/syscallhdr.sh
create mode 100644 linux-user/s390x/Makefile.objs
create mode 100644 linux-user/s390x/syscall.tbl
delete mode 100644 linux-user/s390x/syscall_nr.h
create mode 100755 linux-user/s390x/syscallhdr.sh
create mode 100644 linux-user/sh4/Makefile.objs
create mode 100644 linux-user/sh4/syscall.tbl
delete mode 100644 linux-user/sh4/syscall_nr.h
create mode 100644 linux-user/sh4/syscallhdr.sh
create mode 100644 linux-user/sparc/Makefile.objs
create mode 100644 linux-user/sparc/syscall.tbl
delete mode 100644 linux-user/sparc/syscall_nr.h
create mode 100644 linux-user/sparc/syscallhdr.sh
create mode 100644 linux-user/sparc64/Makefile.objs
create mode 100644 linux-user/sparc64/syscall.tbl
delete mode 100644 linux-user/sparc64/syscall_nr.h
create mode 100644 linux-user/sparc64/syscallhdr.sh
create mode 100644 linux-user/x86_64/Makefile.objs
create mode 100644 linux-user/x86_64/syscall_64.tbl
delete mode 100644 linux-user/x86_64/syscall_nr.h
create mode 100644 linux-user/x86_64/syscallhdr.sh
create mode 100644 linux-user/xtensa/Makefile.objs
create mode 100644 linux-user/xtensa/syscall.tbl
delete mode 100644 linux-user/xtensa/syscall_nr.h
create mode 100644 linux-user/xtensa/syscallhdr.sh
create mode 100755 scripts/update-mips-syscall-args.sh
create mode 100755 scripts/update-syscalltbl.sh
[PATCH v2 00/20] linux-user: generate syscall_nr.sh
Posted by Laurent Vivier 4 years, 2 months ago
This series copies the files syscall.tbl from linux v5.5 and generates
the file syscall_nr.h from them.

This is done for all the QEMU targets that have a syscall.tbl
in the linux source tree: mips, mips64, i386, x86_64, sparc, s390x,
ppc, arm, microblaze, sh4, xtensa, m68k, hppa and alpha.

tilegx and cris are depecrated in linux (tilegx has no maintainer in QEMU)

aarch64, nios2, openrisc and riscv have no syscall.tbl in linux.

It seems there is a bug in QEMU that forces to disable manually arch_prctl
with i386 target: do_arch_prctl() is only defined with TARGET_ABI32 but
TARGET_ABI32 is never defined with TARGET_I386 (nor TARGET_X86_64).

I have also removed all syscalls in s390x/syscall_nr.h defined for
!defined(TARGET_S390X).

I have added a script to copy all these files from linux and updated
them at the end of the series with their latest version for today.

The two last patches manage the special case for mips O32 that needs
to know the number of arguments. We find them in strace sources.

v2:
    fix a typo (double comma) in $(call quiet-command)
    add a script to remove dependencies to syscall_nr.h in source directory

ppc, mips64:

        we don't need to split syscall_nr.h as it is generated
        according TARGET_SYSTBL_ABI to TARGET_ABI_DIR
        and generated values are incorrect according to the file name.

arm:

        manage TARGET_NR_arm_sync_file_range

Once the syscall_nr.h are built in the build directory, the following script
allows to compare them with the original one (first argument is the path
to build directory), it must be run from the source directory:

cat > check_syscall_nr.sh <<EOF
BUILD="$1"

ARCHS="i386 alpha arm hppa i386 m68k microblaze s390x sh4 sparc sparc64 xtensa ppc"

syscall_nr_diff()
{
        arch=$1
        target=$2
        syscall_nr=linux-user/$arch/syscall_nr.h
        offset=$3
        REFERENCE=$(git log -1 --format=format:%h -- $syscall_nr)^
        if [ "$offset" = "" ] ; then
                git show $REFERENCE:$syscall_nr | \
                        sed 's/[[:blank:]]\/\*[^*]*\*\///' | \
                        sed 's/(\([^)]*\))/\1/'  > /tmp/old
        else
                git show $REFERENCE:$syscall_nr | \
                        sed 's/[[:blank:]]\/\*[^*]*\*\///' | \
                        sed "s/TARGET_NR_Linux/$offset/" > /tmp/old
        fi
        diff -wu --color=always /tmp/old \
                                $BUILD/$target/$syscall_nr | less -R
}

for arch in $ARCHS ; do
        syscall_nr_diff $arch $arch-linux-user
done

syscall_nr_diff ppc    ppc64-linux-user

syscall_nr_diff mips   mips-linux-user    4000
syscall_nr_diff mips64 mips64-linux-user  5000
syscall_nr_diff mips64 mipsn32-linux-user 6000
EOF

Laurent Vivier (20):
  linux-user: introduce parameters to generate syscall_nr.h
  linux-user,alpha: add syscall table generation support
  linux-user,hppa: add syscall table generation support
  linux-user,m68k: add syscall table generation support
  linux-user,xtensa: add syscall table generation support
  linux-user,sh4: add syscall table generation support
  linux-user,microblaze: add syscall table generation support
  linux-user,arm: add syscall table generation support
  linux-user,ppc: add syscall table generation support
  linux-user,s390x: remove syscall definitions for !TARGET_S390X
  linux-user,s390x: add syscall table generation support
  linux-user,sparc,sparc64: add syscall table generation support
  linux-user,i386: add syscall table generation support
  linux-user,x86_64: add syscall table generation support
  linux-user,mips: add syscall table generation support
  linux-user,mips64: add syscall table generation support
  linux-user,scripts: add a script to update syscall.tbl
  linux-user: update syscall.tbl from linux 0bf999f9c5e7
  linux-user,mips: move content of mips_syscall_args
  linux-user,mips: update syscall-args-o32.c.inc

 MAINTAINERS                            |   1 +
 Makefile.target                        |   3 +-
 configure                              |  35 ++
 linux-user/Makefile.objs               |  19 +-
 linux-user/alpha/Makefile.objs         |   5 +
 linux-user/alpha/syscall.tbl           | 479 ++++++++++++++++
 linux-user/alpha/syscall_nr.h          | 492 -----------------
 linux-user/alpha/syscallhdr.sh         |  32 ++
 linux-user/arm/Makefile.objs           |   8 +
 linux-user/arm/syscall.tbl             | 453 +++++++++++++++
 linux-user/arm/syscall_nr.h            | 447 ---------------
 linux-user/arm/syscallhdr.sh           |  31 ++
 linux-user/hppa/Makefile.objs          |   5 +
 linux-user/hppa/syscall.tbl            | 437 +++++++++++++++
 linux-user/hppa/syscall_nr.h           | 358 ------------
 linux-user/hppa/syscallhdr.sh          |  32 ++
 linux-user/i386/Makefile.objs          |   5 +
 linux-user/i386/syscall_32.tbl         | 444 +++++++++++++++
 linux-user/i386/syscall_nr.h           | 387 -------------
 linux-user/i386/syscallhdr.sh          |  28 +
 linux-user/m68k/Makefile.objs          |   5 +
 linux-user/m68k/syscall.tbl            | 439 +++++++++++++++
 linux-user/m68k/syscall_nr.h           | 434 ---------------
 linux-user/m68k/syscallhdr.sh          |  32 ++
 linux-user/microblaze/Makefile.objs    |   5 +
 linux-user/microblaze/syscall.tbl      | 445 +++++++++++++++
 linux-user/microblaze/syscall_nr.h     | 442 ---------------
 linux-user/microblaze/syscallhdr.sh    |  32 ++
 linux-user/mips/Makefile.objs          |   5 +
 linux-user/mips/cpu_loop.c             | 440 +--------------
 linux-user/mips/syscall-args-o32.c.inc | 436 +++++++++++++++
 linux-user/mips/syscall_nr.h           | 425 ---------------
 linux-user/mips/syscall_o32.tbl        | 427 +++++++++++++++
 linux-user/mips/syscallhdr.sh          |  36 ++
 linux-user/mips64/Makefile.objs        |  12 +
 linux-user/mips64/syscall_n32.tbl      | 378 +++++++++++++
 linux-user/mips64/syscall_n64.tbl      | 354 ++++++++++++
 linux-user/mips64/syscall_nr.h         | 725 -------------------------
 linux-user/mips64/syscallhdr.sh        |  33 ++
 linux-user/ppc/Makefile.objs           |   6 +
 linux-user/ppc/signal.c                |   2 +-
 linux-user/ppc/syscall.tbl             | 521 ++++++++++++++++++
 linux-user/ppc/syscall_nr.h            | 402 --------------
 linux-user/ppc/syscallhdr.sh           |  34 ++
 linux-user/s390x/Makefile.objs         |   5 +
 linux-user/s390x/syscall.tbl           | 442 +++++++++++++++
 linux-user/s390x/syscall_nr.h          | 398 --------------
 linux-user/s390x/syscallhdr.sh         |  32 ++
 linux-user/sh4/Makefile.objs           |   5 +
 linux-user/sh4/syscall.tbl             | 442 +++++++++++++++
 linux-user/sh4/syscall_nr.h            | 441 ---------------
 linux-user/sh4/syscallhdr.sh           |  32 ++
 linux-user/sparc/Makefile.objs         |   5 +
 linux-user/sparc/syscall.tbl           | 485 +++++++++++++++++
 linux-user/sparc/syscall_nr.h          | 363 -------------
 linux-user/sparc/syscallhdr.sh         |  32 ++
 linux-user/sparc64/Makefile.objs       |   5 +
 linux-user/sparc64/syscall.tbl         | 485 +++++++++++++++++
 linux-user/sparc64/syscall_nr.h        | 366 -------------
 linux-user/sparc64/syscallhdr.sh       |  32 ++
 linux-user/syscall.c                   |   6 +
 linux-user/x86_64/Makefile.objs        |   5 +
 linux-user/x86_64/syscall_64.tbl       | 404 ++++++++++++++
 linux-user/x86_64/syscall_nr.h         | 356 ------------
 linux-user/x86_64/syscallhdr.sh        |  28 +
 linux-user/xtensa/Makefile.objs        |   5 +
 linux-user/xtensa/syscall.tbl          | 410 ++++++++++++++
 linux-user/xtensa/syscall_nr.h         | 469 ----------------
 linux-user/xtensa/syscallhdr.sh        |  32 ++
 scripts/update-mips-syscall-args.sh    |  57 ++
 scripts/update-syscalltbl.sh           |  49 ++
 71 files changed, 8214 insertions(+), 6948 deletions(-)
 create mode 100644 linux-user/alpha/Makefile.objs
 create mode 100644 linux-user/alpha/syscall.tbl
 delete mode 100644 linux-user/alpha/syscall_nr.h
 create mode 100644 linux-user/alpha/syscallhdr.sh
 create mode 100644 linux-user/arm/Makefile.objs
 create mode 100644 linux-user/arm/syscall.tbl
 delete mode 100644 linux-user/arm/syscall_nr.h
 create mode 100644 linux-user/arm/syscallhdr.sh
 create mode 100644 linux-user/hppa/Makefile.objs
 create mode 100644 linux-user/hppa/syscall.tbl
 delete mode 100644 linux-user/hppa/syscall_nr.h
 create mode 100644 linux-user/hppa/syscallhdr.sh
 create mode 100644 linux-user/i386/Makefile.objs
 create mode 100644 linux-user/i386/syscall_32.tbl
 delete mode 100644 linux-user/i386/syscall_nr.h
 create mode 100644 linux-user/i386/syscallhdr.sh
 create mode 100644 linux-user/m68k/Makefile.objs
 create mode 100644 linux-user/m68k/syscall.tbl
 delete mode 100644 linux-user/m68k/syscall_nr.h
 create mode 100644 linux-user/m68k/syscallhdr.sh
 create mode 100644 linux-user/microblaze/Makefile.objs
 create mode 100644 linux-user/microblaze/syscall.tbl
 delete mode 100644 linux-user/microblaze/syscall_nr.h
 create mode 100644 linux-user/microblaze/syscallhdr.sh
 create mode 100644 linux-user/mips/Makefile.objs
 create mode 100644 linux-user/mips/syscall-args-o32.c.inc
 delete mode 100644 linux-user/mips/syscall_nr.h
 create mode 100644 linux-user/mips/syscall_o32.tbl
 create mode 100644 linux-user/mips/syscallhdr.sh
 create mode 100644 linux-user/mips64/Makefile.objs
 create mode 100644 linux-user/mips64/syscall_n32.tbl
 create mode 100644 linux-user/mips64/syscall_n64.tbl
 delete mode 100644 linux-user/mips64/syscall_nr.h
 create mode 100644 linux-user/mips64/syscallhdr.sh
 create mode 100644 linux-user/ppc/Makefile.objs
 create mode 100644 linux-user/ppc/syscall.tbl
 delete mode 100644 linux-user/ppc/syscall_nr.h
 create mode 100644 linux-user/ppc/syscallhdr.sh
 create mode 100644 linux-user/s390x/Makefile.objs
 create mode 100644 linux-user/s390x/syscall.tbl
 delete mode 100644 linux-user/s390x/syscall_nr.h
 create mode 100755 linux-user/s390x/syscallhdr.sh
 create mode 100644 linux-user/sh4/Makefile.objs
 create mode 100644 linux-user/sh4/syscall.tbl
 delete mode 100644 linux-user/sh4/syscall_nr.h
 create mode 100644 linux-user/sh4/syscallhdr.sh
 create mode 100644 linux-user/sparc/Makefile.objs
 create mode 100644 linux-user/sparc/syscall.tbl
 delete mode 100644 linux-user/sparc/syscall_nr.h
 create mode 100644 linux-user/sparc/syscallhdr.sh
 create mode 100644 linux-user/sparc64/Makefile.objs
 create mode 100644 linux-user/sparc64/syscall.tbl
 delete mode 100644 linux-user/sparc64/syscall_nr.h
 create mode 100644 linux-user/sparc64/syscallhdr.sh
 create mode 100644 linux-user/x86_64/Makefile.objs
 create mode 100644 linux-user/x86_64/syscall_64.tbl
 delete mode 100644 linux-user/x86_64/syscall_nr.h
 create mode 100644 linux-user/x86_64/syscallhdr.sh
 create mode 100644 linux-user/xtensa/Makefile.objs
 create mode 100644 linux-user/xtensa/syscall.tbl
 delete mode 100644 linux-user/xtensa/syscall_nr.h
 create mode 100644 linux-user/xtensa/syscallhdr.sh
 create mode 100755 scripts/update-mips-syscall-args.sh
 create mode 100755 scripts/update-syscalltbl.sh

-- 
2.24.1


Re: [PATCH v2 00/20] linux-user: generate syscall_nr.sh
Posted by Peter Maydell 4 years, 2 months ago
On Wed, 19 Feb 2020 at 22:07, Laurent Vivier <laurent@vivier.eu> wrote:
>
> This series copies the files syscall.tbl from linux v5.5 and generates
> the file syscall_nr.h from them.
>
> This is done for all the QEMU targets that have a syscall.tbl
> in the linux source tree: mips, mips64, i386, x86_64, sparc, s390x,
> ppc, arm, microblaze, sh4, xtensa, m68k, hppa and alpha.
>
> tilegx and cris are depecrated in linux (tilegx has no maintainer in QEMU)
>
> aarch64, nios2, openrisc and riscv have no syscall.tbl in linux.

Is it the case that all our architectures either:
 (1) have a syscall.tbl
 (2) are using the asm-generic common numbering system ?

Though even if they do use asm-generic there's awkwardness
still around whether they have extra arch-specific syscalls
and what features of the asm-generic/unistd.h they select,
so I'm not sure whether it helps us much to know that they're
sharing a basically common numbering system.

It does suggest that future architectures are unlikely to have
a syscall.tbl unless somebody pushes for one to be generated
for asm-generic users.

> It seems there is a bug in QEMU that forces to disable manually arch_prctl
> with i386 target: do_arch_prctl() is only defined with TARGET_ABI32 but
> TARGET_ABI32 is never defined with TARGET_I386 (nor TARGET_X86_64).

TARGET_ABI32 for x86 would mean the x32 "32-bit APIs
on a 64-bit CPU", which we don't implement. But the
guards on do_arch_prctl() are
#if defined(TARGET_I386) && !defined(TARGET_ABI32)

where the !TARGET_ABI32 check seems like it's unnecessary but
harmless (we never define it for x86), so what causes a problem?

thanks
-- PMM

Re: [PATCH v2 00/20] linux-user: generate syscall_nr.sh
Posted by Laurent Vivier 4 years, 2 months ago
Le 21/02/2020 à 14:45, Peter Maydell a écrit :
> On Wed, 19 Feb 2020 at 22:07, Laurent Vivier <laurent@vivier.eu> wrote:
>>
>> This series copies the files syscall.tbl from linux v5.5 and generates
>> the file syscall_nr.h from them.
>>
>> This is done for all the QEMU targets that have a syscall.tbl
>> in the linux source tree: mips, mips64, i386, x86_64, sparc, s390x,
>> ppc, arm, microblaze, sh4, xtensa, m68k, hppa and alpha.
>>
>> tilegx and cris are depecrated in linux (tilegx has no maintainer in QEMU)
>>
>> aarch64, nios2, openrisc and riscv have no syscall.tbl in linux.
> 
> Is it the case that all our architectures either:
>  (1) have a syscall.tbl
>  (2) are using the asm-generic common numbering system ?

Yes, for what I see archs that have not been converted to syscall.tbl
are the ones using asm-generic common numbering system.

> 
> Though even if they do use asm-generic there's awkwardness
> still around whether they have extra arch-specific syscalls
> and what features of the asm-generic/unistd.h they select,
> so I'm not sure whether it helps us much to know that they're
> sharing a basically common numbering system.
> 
> It does suggest that future architectures are unlikely to have
> a syscall.tbl unless somebody pushes for one to be generated
> for asm-generic users.

I agree.

> 
>> It seems there is a bug in QEMU that forces to disable manually arch_prctl
>> with i386 target: do_arch_prctl() is only defined with TARGET_ABI32 but
>> TARGET_ABI32 is never defined with TARGET_I386 (nor TARGET_X86_64).
> 
> TARGET_ABI32 for x86 would mean the x32 "32-bit APIs
> on a 64-bit CPU", which we don't implement. But the
> guards on do_arch_prctl() are
> #if defined(TARGET_I386) && !defined(TARGET_ABI32)
> 
> where the !TARGET_ABI32 check seems like it's unnecessary but
> harmless (we never define it for x86), so what causes a problem?

Yes, my conclusion was too quick.

The error is:

  CC      i386-linux-user/linux-user/syscall.o
linux-user/syscall.c: In function 'do_syscall1':
linux-user/syscall.c:10208:2: error: #error unreachable
10208 | #error unreachable
      |  ^~~~~

So something defines TARGET_ABI32:

include/exec/user/abitypes.h

 42 #ifdef TARGET_ABI32
...
 54 #else
...
 60 /* for consistency, define ABI32 too */
 61 #if TARGET_ABI_BITS == 32
 62 #define TARGET_ABI32 1
 63 #endif
...
 70 #endif

TARGET_ABI32 is always defined if TARGET_ABI_BITS is 32 (and i386 is 32bit)

An the problem is more complex.

do_arch_prctl() uses TARGET_ARCH_SET_GS, TARGET_ARCH_SET_FS,
TARGET_ARCH_GET_GS and TARGET_ARCH_GET_FS that are defined in
linux-user/x86_64/target_syscall.h and not in i386.

Thanks,
Laurent

Re: [PATCH v2 00/20] linux-user: generate syscall_nr.sh
Posted by Peter Maydell 4 years, 2 months ago
On Fri, 21 Feb 2020 at 13:45, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Wed, 19 Feb 2020 at 22:07, Laurent Vivier <laurent@vivier.eu> wrote:
> >
> > This series copies the files syscall.tbl from linux v5.5 and generates
> > the file syscall_nr.h from them.
> >
> > This is done for all the QEMU targets that have a syscall.tbl
> > in the linux source tree: mips, mips64, i386, x86_64, sparc, s390x,
> > ppc, arm, microblaze, sh4, xtensa, m68k, hppa and alpha.
> >
> > tilegx and cris are depecrated in linux (tilegx has no maintainer in QEMU)
> >
> > aarch64, nios2, openrisc and riscv have no syscall.tbl in linux.
>
> Is it the case that all our architectures either:
>  (1) have a syscall.tbl
>  (2) are using the asm-generic common numbering system ?

I think that for asm-generic we should be able to generate
the syscall_nr.h by suitably defining a __SYSCALL macro
before #including linux-headers/asm-whatever/unistd.h --
They basically define syscall numbers like this:
#define __NR_setxattr 5
__SYSCALL(__NR_setxattr, sys_setxattr)

so a C program that just did the autogeneration has the
info it needs.

thanks
-- PMM

Re: [PATCH v2 00/20] linux-user: generate syscall_nr.sh
Posted by Laurent Vivier 4 years, 2 months ago
Le 21/02/2020 à 14:56, Peter Maydell a écrit :
> On Fri, 21 Feb 2020 at 13:45, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> On Wed, 19 Feb 2020 at 22:07, Laurent Vivier <laurent@vivier.eu> wrote:
>>>
>>> This series copies the files syscall.tbl from linux v5.5 and generates
>>> the file syscall_nr.h from them.
>>>
>>> This is done for all the QEMU targets that have a syscall.tbl
>>> in the linux source tree: mips, mips64, i386, x86_64, sparc, s390x,
>>> ppc, arm, microblaze, sh4, xtensa, m68k, hppa and alpha.
>>>
>>> tilegx and cris are depecrated in linux (tilegx has no maintainer in QEMU)
>>>
>>> aarch64, nios2, openrisc and riscv have no syscall.tbl in linux.
>>
>> Is it the case that all our architectures either:
>>  (1) have a syscall.tbl
>>  (2) are using the asm-generic common numbering system ?
> 
> I think that for asm-generic we should be able to generate
> the syscall_nr.h by suitably defining a __SYSCALL macro
> before #including linux-headers/asm-whatever/unistd.h --
> They basically define syscall numbers like this:
> #define __NR_setxattr 5
> __SYSCALL(__NR_setxattr, sys_setxattr)
> 
> so a C program that just did the autogeneration has the
> info it needs.

Thank you for the hint. I will have a look.

Thanks,
Laurent