Linux user for upstream patches
The following changes since commit 5dae13cd71f0755a1395b5a4cde635b8a6ee3f58:
Merge remote-tracking branch 'remotes/rth/tags/pull-or-20170214' into staging (2017-02-14 09:55:48 +0000)
are available in the git repository at:
git://github.com/vivier/qemu.git tags/linux-user-for-upstream-pull-request
for you to fetch changes up to b4e74f188b2a50a25bc8d43894c36ea98b1d51a8:
linux-user: Add FICLONE and FICLONERANGE ioctls (2017-02-14 18:31:50 +0100)
----------------------------------------------------------------
To help Riku in his maintainer role of linux-user, I've proposed to help him to manage this pull request.
This series is based on his branch linux-user-for-upstream at:
https://git.linaro.org/people/riku.voipio/qemu.git
I have added some reviewed patches from the mailing list since the last pull request.
I have tested this series by creating some containers:
ppc64 fedora-21
ppc debian-8
aarch64 centos-7.2
All these containers can boot and run as expected
(create an user, log in as this user, install packages with yum/dnf/apt-get using sudo)
I have tested the LTP-20170116 in the ppc container (big-endian 32bit) on an x86_64 host (little-endian 64bit). The result is:
Total Tests: 1111
Total Skipped Tests: 174
Total Failures: 68
Kernel Version: 4.9.5-200.fc25.x86_64
Machine Architecture: ppc
Hostname: debian-8-ppc
----------------------------------------------------------------
Adrian Glaubitz (2):
linux-user: Update sh4 syscall definitions to match Linux 4.8
linux-user: Update m68k syscall definitions to match Linux 4.6
Helge Deller (1):
linux-user: Add FICLONE and FICLONERANGE ioctls
Jose Ricardo Ziviani (1):
linux-user: fill target sigcontext struct accordingly
Laurent Vivier (1):
linux-user: manage two new IFLA host message types
Lena Djokic (3):
linux-user: Fix inotify_init1 support
linux-user: Fix readahead
linux-user: Fix mq_open
Marc-André Lureau (2):
linux-user: fix settime old value location
linux-user: fix tcg/mmap test
Peter Maydell (1):
linux-user: Use correct types in load_symbols()
Richard Henderson (1):
linux-user: Fix s390x safe-syscall for z900
Riku Voipio (2):
linux-user: remove ifdef __USER_MISC
linux-user: drop __cygwin__ ifdef
linux-user/elfload.c | 22 +++++++++++++++------- linux-user/host/s390x/safe-syscall.inc.S | 2 +- linux-user/ioctls.h | 5 +++++ linux-user/m68k/syscall_nr.h | 3 +++ linux-user/mmap.c | 9 +++------ linux-user/sh4/syscall_nr.h | 14 ++++++++++++++ linux-user/signal.c | 5 +++++ linux-user/strace.c | 2 -- linux-user/syscall.c | 26 +++++++++++++++++++------- linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 6 ++++++ 11 files changed, 75 insertions(+), 23 deletions(-)
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 13/14] linux-user: Use correct types in load_symbols()
From: Peter Maydell <[email protected]>
Coverity doesn't like the code in load_symbols() which assumes it can use 'int' for a variable that might hold an offset into the guest ELF file, because in a 64-bit guest that could overflow. Guest binaries with 2GB sections aren't very likely and this isn't a security issue because we fully trust the guest linux-user binary anyway, but we might as well use the right types, which will placate Coverity. Use uint64_t to hold section sizes, and bail out if the symbol table is too large rather than just overflowing an int.
(Coverity issue CID1005776)
Message-Id: <[email protected]>
--- linux-user/elfload.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
linux-user/elfload.c +15 -7
@@ -2262,6 +2262,7 @@ static int symcmp(const void *s0, const void *s1)static void load_symbols (struct elfhdr *hdr,int fd,abi_ulong load_bias) {int i, shnum, nsyms, sym_idx =0 , str_idx =0 ; +uint64_t segsz;struct elf_shdr *shdr;char *strings =NULL ;struct syminfo *s =NULL ;
@@ -2293,19 +2294,26 @@ static void load_symbols(struct elfhdr *hdr, int fd, abi_ulong load_bias) goto give_up; } - i = shdr[str_idx].sh_size; - s->disas_strtab = strings =g_try_malloc (i); -if (!strings ||pread (fd, strings, i, shdr[str_idx].sh_offset) != i) { + segsz = shdr[str_idx].sh_size; + s->disas_strtab = strings =g_try_malloc (segsz); +if (!strings || +pread (fd, strings, segsz, shdr[str_idx].sh_offset) != segsz) { goto give_up; } - i = shdr[sym_idx].sh_size; - syms =g_try_malloc (i); -if (!syms ||pread (fd, syms, i, shdr[sym_idx].sh_offset) != i) { + segsz = shdr[sym_idx].sh_size; + syms =g_try_malloc (segsz); +if (!syms ||pread (fd, syms, segsz, shdr[sym_idx].sh_offset) != segsz) { goto give_up; } - nsyms = i /sizeof (struct elf_sym ); +if (segsz /sizeof (struct elf_sym ) >INT_MAX ) { +/* Implausibly large symbol table: give up rather than ploughing +* on with the number of symbols calculation overflowing +*/ + goto give_up; + } + nsyms = segsz /sizeof (struct elf_sym );for (i =0 ; i < nsyms; ) {bswap_sym (syms + i);/* Throw away entries which we do not need. */
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 01/14] linux-user: remove ifdef __USER_MISC
In reply to Laurent VivierFrom: Riku Voipio <[email protected]>
This preprocessor macro isn't set anywhere. Remove the check so -strace can show these options.
--- linux-user/strace.c | 2 -- 1 file changed, 2 deletions(-)
linux-user/strace.c +0 -2
@@ -90,10 +90,8 @@ if( cmd == val ) { \output_cmd (IPC_STAT );output_cmd (IPC_INFO );/* msgctl() commands */ -#ifdef __USER_MISCoutput_cmd (MSG_STAT );output_cmd (MSG_INFO ); -#endif /* shmctl() commands */ output_cmd (SHM_LOCK );output_cmd (SHM_UNLOCK );
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 07/14] linux-user: manage two new IFLA host message types
In reply to Laurent VivierAdd QEMU_IFLA_GSO_MAX_SEGS and QEMU_IFLA_GSO_MAX_SIZE in host_to_target_data_link_rtattr().
These two messages are sent by the host kernel when we use "sudo".
Found with qemu-m68k and Debian etch-m68k (sudo 1.6.8p12-4) and host kernel 4.7.6-200.fc24.x86_64
Message-Id: <[email protected]>
--- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+)
linux-user/syscall.c +2 -0
@@ -2326,6 +2326,8 @@ static abi_long host_to_target_data_link_rtattr(struct rtattr *rtattr)case QEMU_IFLA_GROUP :case QEMU_IFLA_MASTER :case QEMU_IFLA_NUM_VF : +case QEMU_IFLA_GSO_MAX_SEGS : +case QEMU_IFLA_GSO_MAX_SIZE : u32 =RTA_DATA (rtattr); *u32 =tswap32 (*u32);break ;
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 09/14] linux-user: Update m68k syscall definitions to match Linux 4.6
In reply to Laurent VivierFrom: Adrian Glaubitz <[email protected]>
Message-Id: <[email protected]>
--- linux-user/m68k/syscall_nr.h | 3 +++ 1 file changed, 3 insertions(+)
linux-user/m68k/syscall_nr.h +3 -0
@@ -376,3 +376,6 @@#define TARGET_NR_userfaultfd 373#define TARGET_NR_membarrier 374#define TARGET_NR_mlock2 375 +#define TARGET_NR_copy_file_range 376 +#define TARGET_NR_preadv2 377 +#define TARGET_NR_pwritev2 378
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PULL 09/14] linux-user: Update m68k syscall definitions to match Linux 4.6
Patchwork has cut off my name again!
Could you please override that?
It's "John Paul Adrian Glaubitz".
Thanks!
Quoted 25 lines · Laurent Vivier
From: Adrian Glaubitz <[email protected]>
Signed-off-by John Paul Adrian Glaubitz <[email protected]>Reviewed-by Laurent Vivier <[email protected]>Message-Id: <[email protected]>
Signed-off-by Laurent Vivier <[email protected]>---
linux-user/m68k/syscall_nr.h| 3 +++1 file changed, 3 insertions(+)linux-user/m68k/syscall_nr.h +3
-0@@ -376,3 +376,6 @@#define TARGET_NR_userfaultfd 373#define TARGET_NR_membarrier 374#define TARGET_NR_mlock2 375 +#define TARGET_NR_copy_file_range 376 +#define TARGET_NR_preadv2 377 +#define TARGET_NR_pwritev2 378Signature · 1 line
2.9.3
Re: [Qemu-devel] [PULL 09/14] linux-user: Update m68k syscall definitions to match Linux 4.6
Quoted 5 lines · John Paul Adrian Glaubitz
Patchwork has cut off my name again!
Could you please override that?
It's "John Paul Adrian Glaubitz".
Ok, I'm going to send a v2 with your name corrected.
Laurent
[Qemu-devel] [PULL 10/14] linux-user: fix settime old value location
In reply to Laurent VivierFrom: Marc-André Lureau <[email protected]>
old_value is the 4th argument of timer_settime(), not the 2nd.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
linux-user/syscall.c +6 -2
@@ -12043,10 +12043,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,timer_t htimer = g_posix_timers[timerid];struct itimerspec hspec_new = {{0 },}, hspec_old = {{0 },}; -target_to_host_itimerspec (&hspec_new, arg3); +if (target_to_host_itimerspec (&hspec_new, arg3)) { + goto efault; + } ret =get_errno (timer_settime (htimer, arg2, &hspec_new, &hspec_old)); -host_to_target_itimerspec (arg2, &hspec_old); +if (arg4 &&host_to_target_itimerspec (arg4, &hspec_old)) { + goto efault; + } }break ; }
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 12/14] linux-user: fill target sigcontext struct accordingly
In reply to Laurent VivierFrom: Jose Ricardo Ziviani <[email protected]>
A segfault is noticed when an emulated program uses any of ucontext regs fields. Risu detected this issue in the following operation when handling a signal:
ucontext_t *uc = (ucontext_t*)uc; uc->uc_mcontext.regs->nip += 4;
but this works fine:
uc->uc_mcontext.gp_regs[PT_NIP] += 4;
This patch set regs to a valid location as well as other sigcontext fields.
Message-Id: <[email protected]>
--- linux-user/signal.c | 5 +++++ 1 file changed, 5 insertions(+)
linux-user/signal.c +5 -0
@@ -5155,6 +5155,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,target_ulong rt_sf_addr, newsp =0 ;int i, err =0 ;#if defined(TARGET_PPC64 ) +struct target_sigcontext *sc =0 ;struct image_info *image = ((TaskState *)thread_cpu->opaque)->info;#endif
@@ -5183,6 +5184,10 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,#if defined(TARGET_PPC64 ) mctx = &rt_sf->uc.tuc_sigcontext.mcontext; trampptr = &rt_sf->trampoline[0 ]; + + sc = &rt_sf->uc.tuc_sigcontext; +__put_user (h2g (mctx), &sc->regs); +__put_user (sig, &sc->signal);#else mctx = &rt_sf->uc.tuc_mcontext; trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp;
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 08/14] linux-user: Update sh4 syscall definitions to match Linux 4.8
In reply to Laurent VivierFrom: Adrian Glaubitz <[email protected]>
Message-Id: <[email protected]>
--- linux-user/sh4/syscall_nr.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
linux-user/sh4/syscall_nr.h +14 -0
@@ -372,3 +372,17 @@#define TARGET_NR_process_vm_writev 366#define TARGET_NR_kcmp 367#define TARGET_NR_finit_module 368 +#define TARGET_NR_sched_getattr 369 +#define TARGET_NR_sched_setattr 370 +#define TARGET_NR_renameat2 371 +#define TARGET_NR_seccomp 372 +#define TARGET_NR_getrandom 373 +#define TARGET_NR_memfd_create 374 +#define TARGET_NR_bpf 375 +#define TARGET_NR_execveat 376 +#define TARGET_NR_userfaultfd 377 +#define TARGET_NR_membarrier 378 +#define TARGET_NR_mlock2 379 +#define TARGET_NR_copy_file_range 380 +#define TARGET_NR_preadv2 381 +#define TARGET_NR_pwritev2 382
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 11/14] linux-user: fix tcg/mmap test
In reply to Laurent VivierFrom: Marc-André Lureau <[email protected]>
tests/tcg/mmap test fails with values other than default target page size. When creating a map beyond EOF, extra anonymous pages are added up to the target page boundary. Currently, this operation is performed only when qemu_real_host_page_size < TARGET_PAGE_SIZE, but it should be performed if the configured page size (qemu -p) is larger than qemu_real_host_page_size too.
Message-Id: <[email protected]>
--- linux-user/mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/mmap.c +3 -3
@@ -426,9 +426,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,may need to truncate file maps at EOF and add extra anonymous pages up to the targets page boundary. */ -if ((qemu_real_host_page_size <TARGET_PAGE_SIZE ) - && !(flags &MAP_ANONYMOUS )) { -struct stat sb; +if ((qemu_real_host_page_size < qemu_host_page_size) && + !(flags &MAP_ANONYMOUS )) { +struct stat sb;if (fstat (fd, &sb) ==-1 ) goto fail;
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 04/14] linux-user: Fix inotify_init1 support
In reply to Laurent VivierFrom: Lena Djokic <[email protected]>
This commit adds necessary conversion of argument passed to inotify_init1. inotify_init1 flags can be IN_NONBLOCK and IN_CLOEXEC which rely on O_NONBLOCK and O_CLOEXEC and those can have different values on different platforms.
--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -1
@@ -11561,7 +11561,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)case TARGET_NR_inotify_init1: - ret =get_errno (sys_inotify_init1 (arg1)); + ret =get_errno (sys_inotify_init1 (target_to_host_bitmask (arg1, + fcntl_flags_tbl)));break ;#endif #endif
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 02/14] linux-user: drop __cygwin__ ifdef
In reply to Laurent VivierFrom: Riku Voipio <[email protected]>
linux-user doesn't work on cygwin anyways.
--- linux-user/mmap.c | 3 --- 1 file changed, 3 deletions(-)
linux-user/mmap.c +0 -3
@@ -193,9 +193,6 @@ static int mmap_frag(abi_ulong real_start,#if HOST_LONG_BITS ==64 &&TARGET_ABI_BITS ==64 # define TASK_UNMAPPED_BASE (1ul << 38) -#elif defined(__CYGWIN__) -/* Cygwin doesn't have a whole lot of address space. */ -# define TASK_UNMAPPED_BASE 0x18000000#else # define TASK_UNMAPPED_BASE 0x40000000#endif
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 03/14] linux-user: Fix s390x safe-syscall for z900
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
The LT instruction was added in the extended immediate facility introduced with the z9-109 processor.
--- linux-user/host/s390x/safe-syscall.inc.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/host/s390x/safe-syscall.inc.S +1 -1
@@ -72,7 +72,7 @@ safe_syscall_base: */ safe_syscall_start: /* if signal_pending is non-zero, don't do the call */ - lt %r0,0(%r8) + icm %r0,15,0(%r8) jne 2f svc 0 safe_syscall_end:
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 05/14] linux-user: Fix readahead
In reply to Laurent VivierFrom: Lena Djokic <[email protected]>
Calculation of 64-bit offset was not correct for all cases.
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -11228,7 +11228,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg3 = arg4; arg4 = arg5; } - ret =get_errno (readahead (arg1, ((off64_t )arg3 <<32 ) | arg2, arg4)); + ret =get_errno (readahead (arg1,target_offset64 (arg2, arg3) , arg4));#else ret =get_errno (readahead (arg1, arg2, arg3));#endif
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 14/14] linux-user: Add FICLONE and FICLONERANGE ioctls
In reply to Laurent VivierFrom: Helge Deller <[email protected]>
Add missing FICLONE and FICLONERANGE ioctls.
Message-Id: <[email protected]>
--- linux-user/ioctls.h | 5 +++++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 6 ++++++ 3 files changed, 15 insertions(+)
linux-user/ioctls.h +5 -0
@@ -112,6 +112,11 @@#ifdef FIBMAP IOCTL(FIBMAP, IOC_W | IOC_R, MK_PTR(TYPE_LONG))#endif +#ifdef FICLONE + IOCTL(FICLONE, IOC_W, TYPE_INT) + IOCTL(FICLONERANGE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_file_clone_range))) +#endif +#ifdef FIGETBSZ IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG))#endif
linux-user/syscall_defs.h +4 -0
@@ -1086,6 +1086,10 @@ struct target_pollfd {#define TARGET_FIBMAP TARGET_IO(0x00,1)/* bmap access */ #define TARGET_FIGETBSZ TARGET_IO(0x00,2)/* get the block size used for bmap */ + +#define TARGET_FICLONE TARGET_IOW(0x94, 9, int) +#define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range) +/* Note that the ioctl numbers claim type "long" but the actual type * used by the kernel is "int". */
linux-user/syscall_types.h +6 -0
@@ -232,6 +232,12 @@ STRUCT(dm_target_versions,STRUCT (dm_target_msg, TYPE_ULONGLONG) /* sector */ +STRUCT (file_clone_range, +TYPE_LONGLONG ,/* src_fd */ +TYPE_ULONGLONG ,/* src_offset */ +TYPE_ULONGLONG ,/* src_length */ + TYPE_ULONGLONG) /* dest_offset */ + STRUCT(fiemap_extent, TYPE_ULONGLONG, /* fe_logical */ TYPE_ULONGLONG, /* fe_physical */
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 06/14] linux-user: Fix mq_open
In reply to Laurent VivierFrom: Lena Djokic <[email protected]>
If fourth argument is NULL it should be passed without using lock_user function which would, in that case, return EFAULT, and system call supports passing NULL as fourth argument.
--- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
linux-user/syscall.c +8 -3
@@ -11583,17 +11583,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_mq_open: {struct mq_attr posix_mq_attr; +struct mq_attr *pposix_mq_attr;int host_flags; host_flags =target_to_host_bitmask (arg2, fcntl_flags_tbl); -if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { - goto efault; + pposix_mq_attr =NULL ; +if (arg4) { +if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { + goto efault; + } + pposix_mq_attr = &posix_mq_attr; } p =lock_user_string (arg1 -1 );if (!p) { goto efault; } - ret =get_errno (mq_open (p, host_flags, arg3, &posix_mq_attr)); + ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 ); }break ;
Signature · 1 line
2.9.3