From 1129dd712157b42397275681e6397bf2d6bdfa0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 4 Jun 2018 12:37:21 -0300 Subject: [PATCH 1/8] linux-user: Export use is_error(), use it to avoid warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes: linux-user/flatload.c:740:9: warning: Loss of sign in implicit conversion if (res > (unsigned long)-4096) ^~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20180604153722.24956-2-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 5 +++++ linux-user/syscall.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 6fa1e968db..793cd4df04 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -618,6 +618,11 @@ static inline void *lock_user_string(abi_ulong guest_addr) #include +static inline int is_error(abi_long ret) +{ + return (abi_ulong)ret >= (abi_ulong)(-4096); +} + /* Include target-specific struct and function definitions; * they may need access to the target-independent structures * above, so include them last. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7b9ac3b408..2117fb13b4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -906,11 +906,6 @@ static inline abi_long get_errno(abi_long ret) return ret; } -static inline int is_error(abi_long ret) -{ - return (abi_ulong)ret >= (abi_ulong)(-4096); -} - const char *target_strerror(int err) { if (err == TARGET_ERESTARTSYS) { From 71987b125ba49314b631f81a4f221e010fa9be48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 4 Jun 2018 12:37:22 -0300 Subject: [PATCH 2/8] linux-user: Use is_error() to avoid warnings and make the code clearer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes: linux-user/flatload.c:740:9: warning: Loss of sign in implicit conversion if (res > (unsigned long)-4096) ^~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20180604153722.24956-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/flatload.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/linux-user/flatload.c b/linux-user/flatload.c index a35a560904..10c529910f 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -224,8 +224,9 @@ static int decompress_exec( ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos); if (ret <= 0) break; - if (ret >= (unsigned long) -4096) + if (is_error(ret)) { break; + } len -= ret; strm.next_in = buf; @@ -283,8 +284,7 @@ calc_reloc(abi_ulong r, struct lib_info *p, int curid, int internalp) "in same module (%d != %d)\n", (unsigned) r, curid, id); goto failed; - } else if ( ! p[id].loaded && - load_flat_shared_library(id, p) > (unsigned long) -4096) { + } else if (!p[id].loaded && is_error(load_flat_shared_library(id, p))) { fprintf(stderr, "BINFMT_FLAT: failed to load library %d\n", id); goto failed; } @@ -523,9 +523,10 @@ static int load_flat_file(struct linux_binprm * bprm, fpos = 0; result = bprm->file->f_op->read(bprm->file, (char *) textpos, text_len, &fpos); - if (result < (unsigned long) -4096) + if (!is_error(result)) { result = decompress_exec(bprm, text_len, (char *) datapos, data_len + (relocs * sizeof(unsigned long)), 0); + } } else #endif @@ -693,8 +694,9 @@ static int load_flat_shared_library(int id, struct lib_info *libs) res = prepare_binprm(&bprm); - if (res <= (unsigned long)-4096) + if (!is_error(res)) { res = load_flat_file(&bprm, libs, id, NULL); + } if (bprm.file) { allow_write_access(bprm.file); fput(bprm.file); @@ -737,8 +739,9 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info) res = load_flat_file(bprm, libinfo, 0, &stack_len); - if (res > (unsigned long)-4096) + if (is_error(res)) { return res; + } /* Update data segment pointers for all libraries */ for (i=0; i Date: Tue, 5 Jun 2018 18:09:58 +0200 Subject: [PATCH 3/8] linux-user: disable qemu-bridge-helper and socket_scm_helper build linux-user targets don't need them, and if we ask to build statically linked binaries, some static libraries they need are not available. Signed-off-by: Laurent Vivier Reviewed-by: Peter Maydell Message-Id: <20180605160958.5434-1-laurent@vivier.eu> --- Makefile | 2 +- tests/Makefile.include | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 023b3437ec..e4bc34a1cb 100644 --- a/Makefile +++ b/Makefile @@ -351,7 +351,7 @@ $(call set-vpath, $(SRC_PATH)) LIBS+=-lz $(LIBS_TOOLS) -HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF) +HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF) ifdef BUILD_DOCS DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 diff --git a/tests/Makefile.include b/tests/Makefile.include index d098a104bb..10397ed159 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -930,7 +930,7 @@ check-report.html: check-report.xml # Other tests -QEMU_IOTESTS_HELPERS-$(CONFIG_LINUX) = tests/qemu-iotests/socket_scm_helper$(EXESUF) +QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = tests/qemu-iotests/socket_scm_helper$(EXESUF) .PHONY: check-tests/qemu-iotests-quick.sh check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) From daf238dcd54fc80c0a83e289574ed5bb66eaa125 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Tue, 5 Jun 2018 21:47:25 +0200 Subject: [PATCH 4/8] qemu-binfmt-conf.sh: ignore the OS/ABI field Most of the binaries have a value of "UNIX - System V" for the OS/ABI. But cc1 has a value of "UNIX - GNU", and if we don't update the binfmt mask to ignore the OS/ABI field, gcc fails to execute it: gcc: error trying to exec '/usr/lib/gcc/m68k-linux-gnu/7/cc1': execv: Exec format error Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20180605194725.8585-1-laurent@vivier.eu> --- scripts/qemu-binfmt-conf.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 7ab7435fbd..d7eefda0b8 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -7,15 +7,15 @@ mips mipsel mipsn32 mipsn32el mips64 mips64el \ sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb microblaze microblazeel" i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00' -i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' +i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' i386_family=i386 i486_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00' -i486_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' +i486_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' i486_family=i386 alpha_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90' -alpha_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' +alpha_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' alpha_family=alpha arm_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00' @@ -27,11 +27,11 @@ armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff armeb_family=armeb sparc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02' -sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +sparc_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' sparc_family=sparc sparc32plus_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12' -sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' sparc32plus_family=sparc ppc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14' @@ -47,7 +47,7 @@ ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\x ppc64le_family=ppcle m68k_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04' -m68k_mask='\xff\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +m68k_mask='\xff\xff\xff\xff\xff\xff\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' m68k_family=m68k # FIXME: We could use the other endianness on a MIPS host. @@ -77,15 +77,15 @@ mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\ mips64el_family=mips sh4_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00' -sh4_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' +sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' sh4_family=sh4 sh4eb_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a' -sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' sh4eb_family=sh4 s390x_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16' -s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +s390x_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' s390x_family=s390x aarch64_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00' From b7bf79ccddcf9fec49da0536bfd23093a929056a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 7 Jun 2018 11:48:41 -0700 Subject: [PATCH 5/8] linux-user/alpha: Fix epoll syscalls These were named incorrectly, going so far as to invade strace.list. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20180607184844.30126-2-richard.henderson@linaro.org> [lv: replace tabs by spaces] Signed-off-by: Laurent Vivier --- linux-user/alpha/syscall_nr.h | 6 +++--- linux-user/strace.list | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/linux-user/alpha/syscall_nr.h b/linux-user/alpha/syscall_nr.h index 00e14bb6b3..fbb1ed288b 100644 --- a/linux-user/alpha/syscall_nr.h +++ b/linux-user/alpha/syscall_nr.h @@ -343,9 +343,9 @@ #define TARGET_NR_io_cancel 402 #define TARGET_NR_exit_group 405 #define TARGET_NR_lookup_dcookie 406 -#define TARGET_NR_sys_epoll_create 407 -#define TARGET_NR_sys_epoll_ctl 408 -#define TARGET_NR_sys_epoll_wait 409 +#define TARGET_NR_epoll_create 407 +#define TARGET_NR_epoll_ctl 408 +#define TARGET_NR_epoll_wait 409 #define TARGET_NR_remap_file_pages 410 #define TARGET_NR_set_tid_address 411 #define TARGET_NR_restart_syscall 412 diff --git a/linux-user/strace.list b/linux-user/strace.list index a91e33f7e5..2bc5ba04d4 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1467,15 +1467,6 @@ #ifdef TARGET_NR__sysctl { TARGET_NR__sysctl, "_sysctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sys_epoll_create -{ TARGET_NR_sys_epoll_create, "sys_epoll_create" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_sys_epoll_ctl -{ TARGET_NR_sys_epoll_ctl, "sys_epoll_ctl" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_sys_epoll_wait -{ TARGET_NR_sys_epoll_wait, "sys_epoll_wait" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sysfs { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL }, #endif From 58c9d45a1d754879316258c843d247ce3c540d72 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 7 Jun 2018 11:48:42 -0700 Subject: [PATCH 6/8] linux-user/hppa: Fix typo in mknodat syscall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20180607184844.30126-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/hppa/syscall_nr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/hppa/syscall_nr.h b/linux-user/hppa/syscall_nr.h index 55bdf71d50..9c1d0a195d 100644 --- a/linux-user/hppa/syscall_nr.h +++ b/linux-user/hppa/syscall_nr.h @@ -279,7 +279,7 @@ #define TARGET_NR_ppoll 274 #define TARGET_NR_openat 275 #define TARGET_NR_mkdirat 276 -#define TARGET_NR_mknotat 277 +#define TARGET_NR_mknodat 277 #define TARGET_NR_fchownat 278 #define TARGET_NR_futimesat 279 #define TARGET_NR_fstatat64 280 From 966a6356b7281cc2f82533210c23bd786734762b Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 7 Jun 2018 11:48:43 -0700 Subject: [PATCH 7/8] linux-user/microblaze: Fix typo in accept4 syscall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20180607184844.30126-4-richard.henderson@linaro.org> [lv: replace tabs by spaces] Signed-off-by: Laurent Vivier --- linux-user/microblaze/syscall_nr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/microblaze/syscall_nr.h b/linux-user/microblaze/syscall_nr.h index 0704449bae..5d1a47a9a9 100644 --- a/linux-user/microblaze/syscall_nr.h +++ b/linux-user/microblaze/syscall_nr.h @@ -363,7 +363,7 @@ #define TARGET_NR_shutdown 359 /* new */ #define TARGET_NR_sendmsg 360 /* new */ #define TARGET_NR_recvmsg 361 /* new */ -#define TARGET_NR_accept04 362 /* new */ +#define TARGET_NR_accept4 362 /* new */ #define TARGET_NR_preadv 363 /* new */ #define TARGET_NR_pwritev 364 /* new */ #define TARGET_NR_rt_tgsigqueueinfo 365 /* new */ From dec1c928494f76ddd1484a7a4584ec18b1900a7a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 7 Jun 2018 11:48:44 -0700 Subject: [PATCH 8/8] linux-user/sparc64: Add inotify_rm_watch and tee syscalls Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20180607184844.30126-5-richard.henderson@linaro.org> --- linux-user/sparc64/syscall_nr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/sparc64/syscall_nr.h b/linux-user/sparc64/syscall_nr.h index 9391645598..0b91b896da 100644 --- a/linux-user/sparc64/syscall_nr.h +++ b/linux-user/sparc64/syscall_nr.h @@ -154,7 +154,7 @@ #define TARGET_NR_poll 153 /* Common */ #define TARGET_NR_getdents64 154 /* Linux specific */ #define TARGET_NR_fcntl64 155 /* Linux sparc32 Specific */ -/* #define TARGET_NR_getdirentries 156 SunOS Specific */ +#define TARGET_NR_inotify_rm_watch 156 /* Linux specific */ #define TARGET_NR_statfs 157 /* Common */ #define TARGET_NR_fstatfs 158 /* Common */ #define TARGET_NR_umount 159 /* Common */ @@ -278,7 +278,7 @@ #define TARGET_NR_mq_notify 277 #define TARGET_NR_mq_getsetattr 278 #define TARGET_NR_waitid 279 -/*#define TARGET_NR_sys_setaltroot 280 available (was setaltroot) */ +#define TARGET_NR_tee 280 #define TARGET_NR_add_key 281 #define TARGET_NR_request_key 282 #define TARGET_NR_keyctl 283