From af552644a7a2c5a4d57ae158d831bf8ef79d12dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 19 Nov 2020 17:17:07 +0100 Subject: [PATCH 01/13] linux-user/mips64: Restore setup_frame() for o32 ABI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 64-bit MIPS targets lost setup_frame() during the refactor in commit 8949bef18b9. Restore it declaring TARGET_ARCH_HAS_SETUP_FRAME, to be able to build the o32 ABI target. Fixes: 8949bef18b9 ("linux-user: move mips/mips64 signal.c parts to mips directory") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20201119161710.1985083-2-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/mips64/target_signal.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/mips64/target_signal.h b/linux-user/mips64/target_signal.h index 799f7a668c..f1f0ed7f70 100644 --- a/linux-user/mips64/target_signal.h +++ b/linux-user/mips64/target_signal.h @@ -67,4 +67,8 @@ typedef struct target_sigaltstack { #define TARGET_MINSIGSTKSZ 2048 #define TARGET_SIGSTKSZ 8192 +#if defined(TARGET_ABI_MIPSO32) +/* compare linux/arch/mips/kernel/signal.c:setup_frame() */ +#define TARGET_ARCH_HAS_SETUP_FRAME +#endif #endif /* MIPS64_TARGET_SIGNAL_H */ From 0b72da03001c8c9f077fc019b9651c19a32c4600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Thu, 19 Nov 2020 17:17:08 +0100 Subject: [PATCH 02/13] linux-user/mips64: Support o32 ABI syscalls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit o32 ABI syscalls start at offset 4000. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20201119161710.1985083-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/mips64/syscall_nr.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/linux-user/mips64/syscall_nr.h b/linux-user/mips64/syscall_nr.h index 672f2fa51c..6579421fa6 100644 --- a/linux-user/mips64/syscall_nr.h +++ b/linux-user/mips64/syscall_nr.h @@ -1,4 +1,7 @@ -#ifdef TARGET_ABI_MIPSN32 +#if defined(TARGET_ABI_MIPSO32) +#define TARGET_SYSCALL_OFFSET 4000 +#include "syscall_o32_nr.h" +#elif defined(TARGET_ABI_MIPSN32) #define TARGET_SYSCALL_OFFSET 6000 #include "syscall_n32_nr.h" #else From 1c3dfb506ea3decd17ec69ed6eaf611a885b9f59 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Tue, 19 Jan 2021 10:24:52 -0800 Subject: [PATCH 03/13] linux-user/signal: Decode waitid si_code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When mapping the host waitid status to the target status we previously just used decoding information in the status value. This doesn't follow what the waitid documentation describes, which instead suggests using the si_code value for the decoding. This results in the incorrect values seen when calling waitid. This is especially apparent on RV32 where all wait calls use waitid (see the bug case). This patch just passes the waitid status directly back to the guest. Buglink: https://bugs.launchpad.net/qemu/+bug/1906193 Signed-off-by: Alistair Francis Tested-by: Andreas K. Hüttel Reviewed-by: Laurent Vivier Message-Id: <1fb2d56aa23a81f4473e638abe9e2d78c09a3d5b.1611080607.git.alistair.francis@wdc.com> Signed-off-by: Laurent Vivier --- linux-user/signal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 73de934c65..7eecec46c4 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -349,8 +349,7 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, case TARGET_SIGCHLD: tinfo->_sifields._sigchld._pid = info->si_pid; tinfo->_sifields._sigchld._uid = info->si_uid; - tinfo->_sifields._sigchld._status - = host_to_target_waitstatus(info->si_status); + tinfo->_sifields._sigchld._status = info->si_status; tinfo->_sifields._sigchld._utime = info->si_utime; tinfo->_sifields._sigchld._stime = info->si_stime; si_type = QEMU_SI_CHLD; From 23b311155078bdd5bacc016ff3b3ebb5462b10c0 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Mon, 1 Feb 2021 16:59:22 +0100 Subject: [PATCH 04/13] linux-user: Add missing TARGET___O_TMPFILE for hppa and alpha The hppa and alpha targets miss the #define of the TARGET___O_TMPFILE and as such fail to run a trivial symlink command like ln -s /bin/bash /tmp which results in an -EINVAL return code. Adding the define fixes the problem. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20210201155922.GA18291@ls3530.fritz.box> Signed-off-by: Laurent Vivier --- linux-user/alpha/target_fcntl.h | 1 + linux-user/hppa/target_fcntl.h | 1 + 2 files changed, 2 insertions(+) diff --git a/linux-user/alpha/target_fcntl.h b/linux-user/alpha/target_fcntl.h index e16ed1d415..99774d7317 100644 --- a/linux-user/alpha/target_fcntl.h +++ b/linux-user/alpha/target_fcntl.h @@ -23,6 +23,7 @@ #define TARGET_O_CLOEXEC 010000000 #define TARGET___O_SYNC 020000000 #define TARGET_O_PATH 040000000 +#define TARGET___O_TMPFILE 0100000000 #define TARGET_F_GETLK 7 #define TARGET_F_SETLK 8 diff --git a/linux-user/hppa/target_fcntl.h b/linux-user/hppa/target_fcntl.h index bd966a59b8..9eaeef9d8e 100644 --- a/linux-user/hppa/target_fcntl.h +++ b/linux-user/hppa/target_fcntl.h @@ -21,6 +21,7 @@ #define TARGET_O_CLOEXEC 010000000 #define TARGET___O_SYNC 000100000 #define TARGET_O_PATH 020000000 +#define TARGET___O_TMPFILE 040000000 #define TARGET_F_RDLCK 1 #define TARGET_F_WRLCK 2 From 2bdc74f3d7c4cacb65dbde910471c62992640275 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Mon, 1 Feb 2021 23:05:51 +0100 Subject: [PATCH 05/13] linux-user: fix O_NONBLOCK usage for hppa target Historically the parisc linux port tried to be compatible with HP-UX userspace and as such defined the O_NONBLOCK constant to 0200004 to emulate separate NDELAY & NONBLOCK values. Since parisc was the only Linux platform which had two bits set, this produced various userspace issues. Finally it was decided to drop the (never completed) HP-UX compatibilty, which is why O_NONBLOCK was changed upstream to only have one bit set in future with this commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=75ae04206a4d0e4f541c1d692b7febd1c0fdb814 This patch simply adjusts the value for qemu-user too. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20210201220551.GA8015@ls3530.fritz.box> Signed-off-by: Laurent Vivier --- linux-user/hppa/target_fcntl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/hppa/target_fcntl.h b/linux-user/hppa/target_fcntl.h index 9eaeef9d8e..08e3a4fcb0 100644 --- a/linux-user/hppa/target_fcntl.h +++ b/linux-user/hppa/target_fcntl.h @@ -8,7 +8,7 @@ #ifndef HPPA_TARGET_FCNTL_H #define HPPA_TARGET_FCNTL_H -#define TARGET_O_NONBLOCK 000200004 /* HPUX has separate NDELAY & NONBLOCK */ +#define TARGET_O_NONBLOCK 000200000 #define TARGET_O_APPEND 000000010 #define TARGET_O_CREAT 000000400 /* not fcntl */ #define TARGET_O_EXCL 000002000 /* not fcntl */ From 78721301138114cf37fb179a6cf73a27c1b3a927 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Wed, 10 Feb 2021 07:12:14 +0100 Subject: [PATCH 06/13] linux-user: fix O_NONBLOCK in signalfd4() and eventfd2() syscalls On the hppa target userspace binaries may call signalfd4() and eventfd2() with an old TARGET_O_NONBLOCK value of 000200004 instead of 000200000 for the "mask" syscall parameter, in which case the current emulation doesn't handle the translation to the native O_NONBLOCK value correctly. The 0x04 bit is not masked out before the new O_NONBLOCK bit is set and as such when calling the native syscall errors out with EINVAL. Fix this by introducing TARGET_O_NONBLOCK_MASK which is used to mask off all possible bits. This define defaults to TARGET_O_NONBLOCK when not defined otherwise, so for all other targets the implementation will behave as before. This patch needs to be applied on top of my previous two patches. Bug was found and patch was verified by using qemu-hppa as debian buildd server on x86_64. Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier Message-Id: <20210210061214.GA221322@ls3530.fritz.box> Signed-off-by: Laurent Vivier --- linux-user/hppa/target_fcntl.h | 1 + linux-user/syscall.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/linux-user/hppa/target_fcntl.h b/linux-user/hppa/target_fcntl.h index 08e3a4fcb0..4eb0ec98e2 100644 --- a/linux-user/hppa/target_fcntl.h +++ b/linux-user/hppa/target_fcntl.h @@ -9,6 +9,7 @@ #define HPPA_TARGET_FCNTL_H #define TARGET_O_NONBLOCK 000200000 +#define TARGET_O_NONBLOCK_MASK 000200004 /* includes old HP-UX NDELAY flag */ #define TARGET_O_APPEND 000000010 #define TARGET_O_CREAT 000000400 /* not fcntl */ #define TARGET_O_EXCL 000002000 /* not fcntl */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 34760779c8..dcb4009e2f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -277,6 +277,11 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define TARGET_NR__llseek TARGET_NR_llseek #endif +/* some platforms need to mask more bits than just TARGET_O_NONBLOCK */ +#ifndef TARGET_O_NONBLOCK_MASK +#define TARGET_O_NONBLOCK_MASK TARGET_O_NONBLOCK +#endif + #define __NR_sys_gettid __NR_gettid _syscall0(int, sys_gettid) @@ -7777,7 +7782,7 @@ static abi_long do_signalfd4(int fd, abi_long mask, int flags) sigset_t host_mask; abi_long ret; - if (flags & ~(TARGET_O_NONBLOCK | TARGET_O_CLOEXEC)) { + if (flags & ~(TARGET_O_NONBLOCK_MASK | TARGET_O_CLOEXEC)) { return -TARGET_EINVAL; } if (!lock_user_struct(VERIFY_READ, target_mask, mask, 1)) { @@ -12566,7 +12571,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_eventfd2) case TARGET_NR_eventfd2: { - int host_flags = arg2 & (~(TARGET_O_NONBLOCK | TARGET_O_CLOEXEC)); + int host_flags = arg2 & (~(TARGET_O_NONBLOCK_MASK | TARGET_O_CLOEXEC)); if (arg2 & TARGET_O_NONBLOCK) { host_flags |= O_NONBLOCK; } From 22d113b52f410d345c3a50a00d2eafa64138e427 Mon Sep 17 00:00:00 2001 From: Giuseppe Musacchio Date: Thu, 17 Dec 2020 11:17:40 +0100 Subject: [PATCH 07/13] linux-user: Fix loading of BSS segments Some ELF binaries encode the .bss section as an extension of the data ones by setting the segment p_memsz > p_filesz. Some other binaries take a different route and encode it as a stand-alone PT_LOAD segment with p_filesz = 0 and p_memsz > 0. Both the encodings are actually correct per ELF specification but the ELF loader had some troubles in handling the former: with the old logic it was very likely to get Qemu to crash in zero_bss when trying to access unmapped memory. zero_bss isn't meant to allocate whole zero-filled segments but to "complete" a previously mapped segment with the needed zero bits. The fix is pretty simple, if the segment is completely zero-filled we simply allocate one or more pages (according to p_memsz) and avoid calling zero_bss altogether. Signed-off-by: Giuseppe Musacchio Message-Id: Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index a64050713f..f5bd4076fc 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2805,14 +2805,16 @@ static void load_elf_image(const char *image_name, int image_fd, vaddr = load_bias + eppnt->p_vaddr; vaddr_po = TARGET_ELF_PAGEOFFSET(vaddr); vaddr_ps = TARGET_ELF_PAGESTART(vaddr); - vaddr_len = TARGET_ELF_PAGELENGTH(eppnt->p_filesz + vaddr_po); + + vaddr_ef = vaddr + eppnt->p_filesz; + vaddr_em = vaddr + eppnt->p_memsz; /* - * Some segments may be completely empty without any backing file - * segment, in that case just let zero_bss allocate an empty buffer - * for it. + * Some segments may be completely empty, with a non-zero p_memsz + * but no backing file segment. */ if (eppnt->p_filesz != 0) { + vaddr_len = TARGET_ELF_PAGELENGTH(eppnt->p_filesz + vaddr_po); error = target_mmap(vaddr_ps, vaddr_len, elf_prot, MAP_PRIVATE | MAP_FIXED, image_fd, eppnt->p_offset - vaddr_po); @@ -2820,14 +2822,22 @@ static void load_elf_image(const char *image_name, int image_fd, if (error == -1) { goto exit_mmap; } - } - vaddr_ef = vaddr + eppnt->p_filesz; - vaddr_em = vaddr + eppnt->p_memsz; + /* + * If the load segment requests extra zeros (e.g. bss), map it. + */ + if (eppnt->p_filesz < eppnt->p_memsz) { + zero_bss(vaddr_ef, vaddr_em, elf_prot); + } + } else if (eppnt->p_memsz != 0) { + vaddr_len = TARGET_ELF_PAGELENGTH(eppnt->p_memsz + vaddr_po); + error = target_mmap(vaddr_ps, vaddr_len, elf_prot, + MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, + -1, 0); - /* If the load segment requests extra zeros (e.g. bss), map it. */ - if (vaddr_ef < vaddr_em) { - zero_bss(vaddr_ef, vaddr_em, elf_prot); + if (error == -1) { + goto exit_mmap; + } } /* Find the full program boundaries. */ From ccc5ccc17f8cfbfd87d9aede5d12a2d47c56e712 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 8 Jan 2021 17:42:12 +0000 Subject: [PATCH 08/13] linux-user/mmap: Avoid asserts for out of range mremap calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If mremap() is called without the MREMAP_MAYMOVE flag with a start address just before the end of memory (reserved_va) where new_size would exceed it (and GUEST_ADDR_MAX), the assert(end - 1 <= GUEST_ADDR_MAX) in  page_set_flags() would trigger. Add an extra guard to the guest_range_valid() checks to prevent this and avoid asserting binaries when reserved_va is set. This meant a bug I was seeing locally now gives the same behaviour  regardless of whether reserved_va is set or not. Signed-off-by: Richard Purdie Message-Id: <70c46e7b999bafbb01d54bfafd44b420d0b782e9.camel@linuxfoundation.org> Signed-off-by: Laurent Vivier --- linux-user/mmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 810653c503..1c9faef476 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -724,7 +724,9 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, if (!guest_range_valid(old_addr, old_size) || ((flags & MREMAP_FIXED) && - !guest_range_valid(new_addr, new_size))) { + !guest_range_valid(new_addr, new_size)) || + ((flags & MREMAP_MAYMOVE) == 0 && + !guest_range_valid(old_addr, new_size))) { errno = ENOMEM; return -1; } From 4df7b7fac84ba570bb33970659296555896232b6 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 9 Jan 2021 19:59:42 +0100 Subject: [PATCH 09/13] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit targets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sizeof(struct ifreq) is 40 for 64 bit and 32 for 32 bit architectures. This structure contains a union of other structures, of which struct ifmap is the biggest for 64 bit architectures. Calling ioclt(…, SIOCGIFCONF, …) fills a struct sockaddr of that union, and do_ioctl_ifconf() only considered that struct sockaddr for the size of the union, which has the same size as struct ifmap on 32 bit architectures. So do_ioctl_ifconf() assumed a wrong size of 32 for struct ifreq instead of the correct size of 40 on 64 bit architectures. The fix makes do_ioctl_ifconf() handle struct ifmap as the biggest part of the union, treating struct ifreq with the correct size. Signed-off-by: Stefan Message-Id: <60AA0765-53DD-43D1-A3D2-75F1778526F6@vodafonemail.de> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dcb4009e2f..6fea00869e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4914,6 +4914,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, struct ifconf *host_ifconf; uint32_t outbufsz; const argtype ifreq_arg_type[] = { MK_STRUCT(STRUCT_sockaddr_ifreq) }; + const argtype ifreq_max_type[] = { MK_STRUCT(STRUCT_ifmap_ifreq) }; int target_ifreq_size; int nb_ifreq; int free_buf = 0; @@ -4937,7 +4938,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, host_ifconf = (struct ifconf *)(unsigned long)buf_temp; target_ifc_buf = (abi_long)(unsigned long)host_ifconf->ifc_buf; - target_ifreq_size = thunk_type_size(ifreq_arg_type, 0); + target_ifreq_size = thunk_type_size(ifreq_max_type, 0); if (target_ifc_buf != 0) { target_ifc_len = host_ifconf->ifc_len; From ec63e06ef7edd8fb048fe41b901d68c888df9e6c Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 4 Feb 2021 16:39:25 +0100 Subject: [PATCH 10/13] linux-user: add TARGET_SO_{DOMAIN,PROTOCOL} These were defined for other platforms but mistakenly left out of mips and generic, so this commit adds them to the places missing. Then it makes them be translated in getsockopt. Signed-off-by: Jason A. Donenfeld Reviewed-by: Laurent Vivier Message-Id: <20210204153925.2030606-1-Jason@zx2c4.com> Signed-off-by: Laurent Vivier --- linux-user/generic/sockbits.h | 3 +++ linux-user/mips/sockbits.h | 2 ++ linux-user/syscall.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/linux-user/generic/sockbits.h b/linux-user/generic/sockbits.h index e44733c601..b3b4a8e44c 100644 --- a/linux-user/generic/sockbits.h +++ b/linux-user/generic/sockbits.h @@ -55,4 +55,7 @@ #define TARGET_SO_ACCEPTCONN 30 #define TARGET_SO_PEERSEC 31 + +#define TARGET_SO_PROTOCOL 38 +#define TARGET_SO_DOMAIN 39 #endif diff --git a/linux-user/mips/sockbits.h b/linux-user/mips/sockbits.h index 0f022cd598..562cad88e2 100644 --- a/linux-user/mips/sockbits.h +++ b/linux-user/mips/sockbits.h @@ -40,6 +40,8 @@ #define TARGET_SO_SNDTIMEO 0x1005 /* send timeout */ #define TARGET_SO_RCVTIMEO 0x1006 /* receive timeout */ #define TARGET_SO_ACCEPTCONN 0x1009 +#define TARGET_SO_PROTOCOL 0x1028 /* protocol type */ +#define TARGET_SO_DOMAIN 0x1029 /* domain/socket family */ /* linux-specific, might as well be the same as on i386 */ #define TARGET_SO_NO_CHECK 11 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6fea00869e..36b0901055 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2837,6 +2837,12 @@ get_timeout: case TARGET_SO_ACCEPTCONN: optname = SO_ACCEPTCONN; goto int_case; + case TARGET_SO_PROTOCOL: + optname = SO_PROTOCOL; + goto int_case; + case TARGET_SO_DOMAIN: + optname = SO_DOMAIN; + goto int_case; default: goto int_case; } From fba087458d3ca6f5470e0cdec82aaefe0854ddb2 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Thu, 8 Oct 2020 12:31:05 +0800 Subject: [PATCH 11/13] linux-user: target: signal: Support TARGET_SS_AUTODISARM Add definitions to pass building. Signed-off-by: Chen Gang Message-Id: <20201008043105.21058-1-chengang@emindsoft.com.cn> [lv: added the definitions in linux-user/generic/signal.h too] Signed-off-by: Laurent Vivier --- linux-user/alpha/target_signal.h | 6 ++++++ linux-user/generic/signal.h | 6 ++++++ linux-user/hppa/target_signal.h | 5 +++++ linux-user/mips/target_signal.h | 6 ++++++ linux-user/mips64/target_signal.h | 5 +++++ linux-user/sparc/target_signal.h | 6 ++++++ 6 files changed, 34 insertions(+) diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index b83797281c..0b90d3a897 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -92,4 +92,10 @@ typedef struct target_sigaltstack { #define TARGET_GEN_SUBRNG7 -25 #define TARGET_ARCH_HAS_SETUP_FRAME + +/* bit-flags */ +#define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ +/* mask for all SS_xxx flags */ +#define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM + #endif /* ALPHA_TARGET_SIGNAL_H */ diff --git a/linux-user/generic/signal.h b/linux-user/generic/signal.h index e1083f8fba..943bc1a1e2 100644 --- a/linux-user/generic/signal.h +++ b/linux-user/generic/signal.h @@ -54,4 +54,10 @@ #define TARGET_SIG_BLOCK 0 /* for blocking signals */ #define TARGET_SIG_UNBLOCK 1 /* for unblocking signals */ #define TARGET_SIG_SETMASK 2 /* for setting the signal mask */ + +/* bit-flags */ +#define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ +/* mask for all SS_xxx flags */ +#define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM + #endif diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signal.h index c52a3ea579..7f525362e9 100644 --- a/linux-user/hppa/target_signal.h +++ b/linux-user/hppa/target_signal.h @@ -66,4 +66,9 @@ typedef struct target_sigaltstack { #define TARGET_MINSIGSTKSZ 2048 #define TARGET_SIGSTKSZ 8192 +/* bit-flags */ +#define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ +/* mask for all SS_xxx flags */ +#define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM + #endif /* HPPA_TARGET_SIGNAL_H */ diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signal.h index fa4084a99d..d521765f6b 100644 --- a/linux-user/mips/target_signal.h +++ b/linux-user/mips/target_signal.h @@ -73,4 +73,10 @@ typedef struct target_sigaltstack { /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME #endif + +/* bit-flags */ +#define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ +/* mask for all SS_xxx flags */ +#define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM + #endif /* MIPS_TARGET_SIGNAL_H */ diff --git a/linux-user/mips64/target_signal.h b/linux-user/mips64/target_signal.h index f1f0ed7f70..d857c55e4c 100644 --- a/linux-user/mips64/target_signal.h +++ b/linux-user/mips64/target_signal.h @@ -67,6 +67,11 @@ typedef struct target_sigaltstack { #define TARGET_MINSIGSTKSZ 2048 #define TARGET_SIGSTKSZ 8192 +/* bit-flags */ +#define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ +/* mask for all SS_xxx flags */ +#define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM + #if defined(TARGET_ABI_MIPSO32) /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.h index 1b10d1490f..911a3f5af5 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -68,4 +68,10 @@ typedef struct target_sigaltstack { #define TARGET_SIGSTKSZ 16384 #define TARGET_ARCH_HAS_SETUP_FRAME + +/* bit-flags */ +#define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ +/* mask for all SS_xxx flags */ +#define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM + #endif /* SPARC_TARGET_SIGNAL_H */ From 5b30c53041d8f4c26ed3cf8434c08cdc9858ec87 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sun, 22 Nov 2020 00:01:31 +0000 Subject: [PATCH 12/13] docs/user: Remove outdated 'Quick Start' section The 'Quick Start' section of the userspace emulator documentation is very old and outdated. In particular: - it suggests running x86-on-x86 emulation, which is the least interesting possible use case - it recommends that users download tarballs of guest binaries from the QEMU web page which we no longer provide there There's nothing salvageable here; delete it all. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Acked-by: Laurent Vivier Message-Id: <20201122000131.18487-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- docs/user/main.rst | 61 ---------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/docs/user/main.rst b/docs/user/main.rst index 8dfe232a3a..e08d4be63b 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -45,67 +45,6 @@ emulator. Linux User space emulator ------------------------- -Quick Start -~~~~~~~~~~~ - -In order to launch a Linux process, QEMU needs the process executable -itself and all the target (x86) dynamic libraries used by it. - -- On x86, you can just try to launch any process by using the native - libraries:: - - qemu-i386 -L / /bin/ls - - ``-L /`` tells that the x86 dynamic linker must be searched with a - ``/`` prefix. - -- Since QEMU is also a linux process, you can launch QEMU with QEMU - (NOTE: you can only do that if you compiled QEMU from the sources):: - - qemu-i386 -L / qemu-i386 -L / /bin/ls - -- On non x86 CPUs, you need first to download at least an x86 glibc - (``qemu-runtime-i386-XXX-.tar.gz`` on the QEMU web page). Ensure that - ``LD_LIBRARY_PATH`` is not set:: - - unset LD_LIBRARY_PATH - - Then you can launch the precompiled ``ls`` x86 executable:: - - qemu-i386 tests/i386/ls - - You can look at ``scripts/qemu-binfmt-conf.sh`` so that QEMU is - automatically launched by the Linux kernel when you try to launch x86 - executables. It requires the ``binfmt_misc`` module in the Linux - kernel. - -- The x86 version of QEMU is also included. You can try weird things - such as:: - - qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 \ - /usr/local/qemu-i386/bin/ls-i386 - -Wine launch -~~~~~~~~~~~ - -- Ensure that you have a working QEMU with the x86 glibc distribution - (see previous section). In order to verify it, you must be able to - do:: - - qemu-i386 /usr/local/qemu-i386/bin/ls-i386 - -- Download the binary x86 Wine install (``qemu-XXX-i386-wine.tar.gz`` - on the QEMU web page). - -- Configure Wine on your account. Look at the provided script - ``/usr/local/qemu-i386/bin/wine-conf.sh``. Your previous - ``${HOME}/.wine`` directory is saved to ``${HOME}/.wine.org``. - -- Then you can try the example ``putty.exe``:: - - qemu-i386 /usr/local/qemu-i386/wine/bin/wine \ - /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe - Command line options ~~~~~~~~~~~~~~~~~~~~ From b8f91fd49c5c6993e06f0cd7bf024d176051320e Mon Sep 17 00:00:00 2001 From: Fredrik Noring Date: Thu, 8 Nov 2018 19:43:07 +0100 Subject: [PATCH 13/13] linux-user/mips: Support the n32 ABI for the R5900 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recognise the R5900, which reports itself as MIPS III, as a 64-bit CPU supporting the n32 ABI. Signed-off-by: Fredrik Noring Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <5bea109f0c140da6a821aa7f9705d4b3717e86dc.1541701393.git.noring@nocrew.org> Signed-off-by: Laurent Vivier --- linux-user/mips64/target_elf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h index ec55d8542a..5f2f2df29f 100644 --- a/linux-user/mips64/target_elf.h +++ b/linux-user/mips64/target_elf.h @@ -12,6 +12,9 @@ static inline const char *cpu_get_model(uint32_t eflags) if ((eflags & EF_MIPS_ARCH) == EF_MIPS_ARCH_64R6) { return "I6400"; } + if ((eflags & EF_MIPS_MACH) == EF_MIPS_MACH_5900) { + return "R5900"; + } return "5KEf"; } #endif