summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-03-20 16:00:21 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-03-20 16:00:21 +0000
commit52a96afaa23d883d281bc7b95b9e69db7d6d3d3f (patch)
tree88d08bbf48bb4581ed85fdbca48f129211af8f7f /scripts
parent3d0ac346032a1fa9afafcaedc979a99f670e077e (diff)
parenta64ddbb03acf1ee916c826ae89e0e1aa6500d5ae (diff)
downloadqemu-52a96afaa23d883d281bc7b95b9e69db7d6d3d3f.zip
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-5.0-pull-request' into staging
update syscall numbers to linux 5.5 (with scripts) add clock_gettime64/clock_settime64 add AT_EXECFN v4: restore syscall.tbl series but remove vsyscall series v3: remove syscall.tbl series v2: guard copy_to_user_timezone() with TARGET_NR_gettimeofday remove "Support futex_time64" patch guard sys_futex with TARGET_NR_exit # gpg: Signature made Fri 20 Mar 2020 15:23:29 GMT # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [full] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier2/tags/linux-user-for-5.0-pull-request: (32 commits) linux-user, openrisc: sync syscall numbers with kernel v5.5 linux-user, nios2: sync syscall numbers with kernel v5.5 linux-user, aarch64: sync syscall numbers with kernel v5.5 scripts: add a script to generate syscall_nr.h linux-user,mips: update syscall-args-o32.c.inc linux-user,mips: move content of mips_syscall_args linux-user: update syscall.tbl from linux 0bf999f9c5e7 linux-user, scripts: add a script to update syscall.tbl linux-user, mips64: add syscall table generation support linux-user, mips: add syscall table generation support linux-user, x86_64: add syscall table generation support linux-user, i386: add syscall table generation support linux-user, x86_64, i386: cleanup TARGET_NR_arch_prctl linux-user, sparc, sparc64: add syscall table generation support linux-user, s390x: add syscall table generation support linux-user, s390x: remove syscall definitions for !TARGET_S390X linux-user, ppc: add syscall table generation support linux-user, arm: add syscall table generation support linux-user, microblaze: add syscall table generation support linux-user, sh4: add syscall table generation support ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gensyscalls.sh102
-rwxr-xr-xscripts/update-mips-syscall-args.sh57
-rwxr-xr-xscripts/update-syscalltbl.sh49
3 files changed, 208 insertions, 0 deletions
diff --git a/scripts/gensyscalls.sh b/scripts/gensyscalls.sh
new file mode 100755
index 0000000000..b7b8456f63
--- /dev/null
+++ b/scripts/gensyscalls.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# Update syscall_nr.h files from linux headers asm-generic/unistd.h
+#
+# This code is licensed under the GPL version 2 or later. See
+# the COPYING file in the top-level directory.
+#
+
+linux="$1"
+output="$2"
+
+TMP=$(mktemp -d)
+
+if [ "$linux" = "" ] ; then
+ echo "Needs path to linux source tree" 1>&2
+ exit 1
+fi
+
+if [ "$output" = "" ] ; then
+ output="$PWD"
+fi
+
+upper()
+{
+ echo "$1" | tr "[:lower:]" "[:upper:]" | tr "[:punct:]" "_"
+}
+
+qemu_arch()
+{
+ case "$1" in
+ arm64)
+ echo "aarch64"
+ ;;
+ *)
+ echo "$1"
+ ;;
+ esac
+}
+
+read_includes()
+{
+ arch=$1
+ bits=$2
+
+ cpp -P -nostdinc -fdirectives-only \
+ -D_UAPI_ASM_$(upper ${arch})_BITSPERLONG_H \
+ -D__BITS_PER_LONG=${bits} \
+ -I${linux}/arch/${arch}/include/uapi/ \
+ -I${linux}/include/uapi \
+ -I${TMP} \
+ "${linux}/arch/${arch}/include/uapi/asm/unistd.h"
+}
+
+filter_defines()
+{
+ grep -e "#define __NR_" -e "#define __NR3264"
+}
+
+rename_defines()
+{
+ sed "s/ __NR_/ TARGET_NR_/g;s/(__NR_/(TARGET_NR_/g"
+}
+
+evaluate_values()
+{
+ sed "s/#define TARGET_NR_/QEMU TARGET_NR_/" | \
+ cpp -P -nostdinc | \
+ sed "s/^QEMU /#define /"
+}
+
+generate_syscall_nr()
+{
+ arch=$1
+ bits=$2
+ file="$3"
+ guard="$(upper LINUX_USER_$(qemu_arch $arch)_$(basename "$file"))"
+
+ (echo "/*"
+ echo " * This file contains the system call numbers."
+ echo " * Do not modify."
+ echo " * This file is generated by scripts/gensyscalls.sh"
+ echo " */"
+ echo "#ifndef ${guard}"
+ echo "#define ${guard}"
+ echo
+ read_includes $arch $bits | filter_defines | rename_defines | \
+ evaluate_values | sort -n -k 3
+ echo
+ echo "#endif /* ${guard} */"
+ echo) > "$file"
+}
+
+mkdir "$TMP/asm"
+> "$TMP/asm/bitsperlong.h"
+
+generate_syscall_nr arm64 64 "$output/linux-user/aarch64/syscall_nr.h"
+generate_syscall_nr nios2 32 "$output/linux-user/nios2/syscall_nr.h"
+generate_syscall_nr openrisc 32 "$output/linux-user/openrisc/syscall_nr.h"
+
+generate_syscall_nr riscv 32 "$output/linux-user/riscv/syscall32_nr.h"
+generate_syscall_nr riscv 64 "$output/linux-user/riscv/syscall64_nr.h"
+rm -fr "$TMP"
diff --git a/scripts/update-mips-syscall-args.sh b/scripts/update-mips-syscall-args.sh
new file mode 100755
index 0000000000..4f0dda4b83
--- /dev/null
+++ b/scripts/update-mips-syscall-args.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+URL=https://raw.githubusercontent.com/strace/strace/master
+FILES="sysent.h sysent_shorthand_defs.h linux/mips/syscallent-compat.h \
+ linux/mips/syscallent-o32.h linux/syscallent-common-32.h \
+ linux/syscallent-common.h"
+
+output="$1"
+if [ "$output" = "" ] ; then
+ output="$PWD"
+fi
+
+INC=linux-user/mips/syscall-args-o32.c.inc
+
+TMP=$(mktemp -d)
+cd $TMP
+
+for file in $FILES; do
+ curl -O $URL/$file
+done
+
+> subcall32.h
+
+cat > gen_mips_o32.c <<EOF
+#include <stdio.h>
+
+#define LINUX_MIPSO32
+#define MAX_ARGS 7
+
+#include "sysent.h"
+#include "sysent_shorthand_defs.h"
+
+#define SEN(syscall_name) 0,0
+const struct_sysent sysent0[] = {
+#include "syscallent-o32.h"
+};
+
+int main(void)
+{
+ int i;
+
+ for (i = 4000; i < sizeof(sysent0) / sizeof(struct_sysent); i++) {
+ if (sysent0[i].sys_name == NULL) {
+ printf(" [% 4d] = MIPS_SYSCALL_NUMBER_UNUSED,\n", i - 4000);
+ } else {
+ printf(" [% 4d] = %d, /* %s */\n", i - 4000,
+ sysent0[i].nargs, sysent0[i].sys_name);
+ }
+ }
+
+ return 0;
+}
+EOF
+
+cc -o gen_mips_o32 gen_mips_o32.c && ./gen_mips_o32 > "$output/$INC"
+
+rm -fr "$TMP"
diff --git a/scripts/update-syscalltbl.sh b/scripts/update-syscalltbl.sh
new file mode 100755
index 0000000000..2d23e56800
--- /dev/null
+++ b/scripts/update-syscalltbl.sh
@@ -0,0 +1,49 @@
+TBL_LIST="\
+arch/alpha/kernel/syscalls/syscall.tbl,linux-user/alpha/syscall.tbl \
+arch/arm/tools/syscall.tbl,linux-user/arm/syscall.tbl \
+arch/m68k/kernel/syscalls/syscall.tbl,linux-user/m68k/syscall.tbl \
+arch/microblaze/kernel/syscalls/syscall.tbl,linux-user/microblaze/syscall.tbl \
+arch/mips/kernel/syscalls/syscall_n32.tbl,linux-user/mips64/syscall_n32.tbl \
+arch/mips/kernel/syscalls/syscall_n64.tbl,linux-user/mips64/syscall_n64.tbl \
+arch/mips/kernel/syscalls/syscall_o32.tbl,linux-user/mips/syscall_o32.tbl \
+arch/parisc/kernel/syscalls/syscall.tbl,linux-user/hppa/syscall.tbl \
+arch/powerpc/kernel/syscalls/syscall.tbl,linux-user/ppc/syscall.tbl \
+arch/s390/kernel/syscalls/syscall.tbl,linux-user/s390x/syscall.tbl \
+arch/sh/kernel/syscalls/syscall.tbl,linux-user/sh4/syscall.tbl \
+arch/sparc/kernel/syscalls/syscall.tbl,linux-user/sparc64/syscall.tbl \
+arch/sparc/kernel/syscalls/syscall.tbl,linux-user/sparc/syscall.tbl \
+arch/x86/entry/syscalls/syscall_32.tbl,linux-user/i386/syscall_32.tbl \
+arch/x86/entry/syscalls/syscall_64.tbl,linux-user/x86_64/syscall_64.tbl \
+arch/xtensa/kernel/syscalls/syscall.tbl,linux-user/xtensa/syscall.tbl\
+"
+
+linux="$1"
+output="$2"
+
+if [ -z "$linux" ] || ! [ -d "$linux" ]; then
+ cat << EOF
+usage: update-syscalltbl.sh LINUX_PATH [OUTPUT_PATH]
+
+LINUX_PATH Linux kernel directory to obtain the syscall.tbl from
+OUTPUT_PATH output directory, usually the qemu source tree (default: $PWD)
+EOF
+ exit 1
+fi
+
+if [ -z "$output" ]; then
+ output="$PWD"
+fi
+
+for entry in $TBL_LIST; do
+ OFS="$IFS"
+ IFS=,
+ set $entry
+ src=$1
+ dst=$2
+ IFS="$OFS"
+ if ! cp "$linux/$src" "$output/$dst" ; then
+ echo "Cannot copy $linux/$src to $output/$dst" 1>&2
+ exit 1
+ fi
+done
+