aboutsummaryrefslogtreecommitdiff
path: root/linux-user
AgeCommit message (Collapse)AuthorFilesLines
2022-09-27linux-user: Implement PI futexesRichard Henderson2-0/+13
Define the missing FUTEX_* constants in syscall_defs.h Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220829021006.67305-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Convert signal number for FUTEX_FDRichard Henderson1-0/+1
The val argument to FUTEX_FD is a signal number. Convert to match the host, as it will be converted back when the signal is delivered. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220829021006.67305-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Implement FUTEX_WAKE_BITSETRichard Henderson1-0/+1
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220829021006.67305-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Sink call to do_safe_futexRichard Henderson1-29/+31
Leave only the argument adjustments within the shift, and sink the actual syscall to the end. Sink the timespec conversion as well, as there will be more users. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220829021006.67305-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Combine do_futex and do_futex_time64Richard Henderson1-56/+11
Pass a boolean to select between time32 and time64. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220829021006.67305-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Set ELF_BASE_PLATFORM for MIPSJiaxun Yang1-0/+31
Match most appropriate base platform string based on insn_flags. Logic is aligned with aligned with set_isa() from arch/mips/kernel/cpu-probe.c in Linux kernel. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220803103009.95972-3-jiaxun.yang@flygoat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Introduce stubs for ELF AT_BASE_PLATFORMJiaxun Yang1-2/+27
AT_BASE_PLATFORM is a elf auxiliary vector pointing to a string to pass some architecture information. See getauxval(3) man-page. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220803103009.95972-2-jiaxun.yang@flygoat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/s390x: Save/restore fpc when handling a signalIlya Leoshkevich1-0/+2
Linux kernel does this in fpregs_store() and fpregs_load(), so qemu-user should do this as well. Found by running valgrind's none/tests/s390x/test_sig. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220817123902.585623-1-iii@linux.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Don't assume 0 is not a valid host timer_t valuePeter Maydell1-8/+16
For handling guest POSIX timers, we currently use an array g_posix_timers[], whose entries are a host timer_t value, or 0 for "this slot is unused". When the guest calls the timer_create syscall we look through the array for a slot containing 0, and use that for the new timer. This scheme assumes that host timer_t values can never be zero. This is unfortunately not a valid assumption -- for some host libc versions, timer_t values are simply indexes starting at 0. When using this kind of host libc, the effect is that the first and second timers end up sharing a slot, and so when the guest tries to operate on the first timer it changes the second timer instead. Rework the timer allocation code, so that: * the 'slot in use' indication uses a separate array from the host timer_t array * we grab the free slot atomically, to avoid races when multiple threads call timer_create simultaneously * releasing an allocated slot is abstracted out into a new free_host_timer_slot() function called in the correct places This fixes: * problems on hosts where timer_t 0 is valid * the FIXME in next_free_host_timer() about locking * bugs in the error paths in timer_create where we forgot to release the slot we grabbed, or forgot to free the host timer Reported-by: Jon Alduan <jon.alduan@gmail.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220725110035.1273441-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: fix bug about missing signum convert of sigqueuefanwenjie1-2/+2
Fixes: 66fb9763af ("basic signal handling") Fixes: cf8b8bfc50 ("linux-user: add support for rt_tgsigqueueinfo() system call") Signed-off-by: fanwenjie <fanwj@mail.ustc.edu.cn> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/hppa: Fix setup_sigcontext()Helge Deller1-13/+3
We don't emulate a preemptive kernel on this level, and the hppa architecture doesn't allow context switches on the gateway page. So we always have to return to sc_iaoq[] and not to gr[31]. This fixes the remaining random segfaults which still occured. Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20220924114501.21767-8-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/hppa: Allow PROT_GROWSUP and PROT_GROWSDOWN in mprotect()Helge Deller1-0/+2
The hppa platform uses an upwards-growing stack and required in Linux kernels < 5.18 an executable stack for signal processing. For that some executables and libraries are marked to have an executable stack, for which glibc uses the mprotect() syscall to mark the stack like this: mprotect(xfa000000,4096,PROT_EXEC|PROT_READ|PROT_WRITE|PROT_GROWSUP). Currently qemu will return -TARGET_EINVAL for this syscall because of the checks in validate_prot_to_pageflags(), which doesn't allow the PROT_GROWSUP or PROT_GROWSDOWN flags and thus triggers this error in the guest: error while loading shared libraries: libc.so.6: cannot enable executable stack as shared object requires: Invalid argument Allow mprotect() to handle both flags and thus fix the guest. The glibc tst-execstack testcase can be used to reproduce the issue. Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20220924114501.21767-7-deller@gmx.de> [lvivier: s/elif TARGET_HPPA/elif defined(TARGET_HPPA)/] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/hppa: Increase guest stack size to 80MB for hppa targetHelge Deller3-2/+13
The hppa target requires a much bigger stack than many other targets, and the Linux kernel allocates 80 MB by default for it. This patch increases the guest stack for hppa to 80MB, and prevents that this default stack size gets reduced by a lower stack limit on the host. Since the stack grows upwards on hppa, the stack_limit value marks the upper boundary of the stack. Fix the output of /proc/self/maps (in the guest) to show the [stack] marker on the correct memory area. Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20220924114501.21767-6-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/hppa: Drop stack guard page on hppa targetHelge Deller1-4/+9
The stack-overflow check when building the "grep" debian package fails on the debian hppa target. Reason is, that the guard page at the top of the stack (which is added by qemu) prevents the fault handler in the grep program to properly detect the stack overflow. The Linux kernel on a physical machine doesn't install a guard page either, so drop it and as such fix the build of "grep". Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20220924114501.21767-5-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/hppa: Add signal trampoline for hppa targetHelge Deller2-23/+32
In Linux kernel v5.18 the vDSO for signal trampoline was added. This code mimiks the bare minimum of this vDSO and thus avoids that the parisc emulation needs executable stacks. Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20220924114501.21767-4-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Add proper strace format strings for getdents()/getdents64()Helge Deller1-2/+2
Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20220924114501.21767-3-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Fix TARGET_PROT_SEM for XTENSAHelge Deller1-1/+1
The xtensa platform has a value of 0x10 for PROT_SEM. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220924114501.21767-2-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Passthrough MADV_DONTNEED for certain file mappingsIlya Leoshkevich1-5/+22
This is a follow-up for commit 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED"), which added passthrough for anonymous mappings. File mappings can be handled in a similar manner. In order to do that, mark pages, for which mmap() was passed through, with PAGE_PASSTHROUGH, and then allow madvise() passthrough for these pages. Drop the explicit PAGE_ANON check, since anonymous mappings are expected to have PAGE_PASSTHROUGH anyway. Add PAGE_PASSTHROUGH to PAGE_STICKY in order to keep it on mprotect(). Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220725125043.43048-1-iii@linux.ibm.com> Message-Id: <20220906000839.1672934-5-iii@linux.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Implement stracing madvise()Ilya Leoshkevich2-1/+42
The default implementation has several problems: the first argument is not displayed as a pointer, making it harder to grep; the third argument is not symbolized; and there are several extra unused arguments. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220906000839.1672934-4-iii@linux.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Fix madvise(MADV_DONTNEED) on alphaIlya Leoshkevich1-1/+2
MADV_DONTNEED has a different value on alpha, compared to all the other architectures. Fix by using TARGET_MADV_DONTNEED instead of MADV_DONTNEED. Fixes: 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220906000839.1672934-3-iii@linux.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Provide MADV_* definitionsIlya Leoshkevich22-0/+134
Provide MADV_* definitions using target_mman.h header, similar to what kernel does. Most architectures use the same values, with the exception of alpha and hppa. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220906000839.1672934-2-iii@linux.ibm.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Show timespec on strace for futex()Helge Deller1-1/+10
Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220918194555.83535-11-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Add strace for clock_nanosleep()Helge Deller2-1/+17
Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220918194555.83535-10-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa archHelge Deller1-0/+4
On the parisc architecture the stack grows upwards. Move the TASK_UNMAPPED_BASE to high memory area as it's done by the kernel on physical machines. Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20220918194555.83535-9-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Fix strace of chmod() if mode == 0Helge Deller1-0/+5
If the mode parameter of chmod() is zero, this value isn't shown when stracing a program: chmod("filename",) This patch fixes it up to show the zero-value as well: chmod("filename",000) Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220918194555.83535-8-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user/hppa: Use EXCP_DUMP() to show enhanced debug infoHelge Deller1-1/+5
Enhance the hppa linux-user cpu_loop() to show more debugging info on hard errors. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220918194555.83535-6-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Log failing executable in EXCP_DUMP()Helge Deller1-0/+2
Enhance the EXCP_DUMP() macro to print out the failing program too. During debugging it's sometimes hard to track down the actual failing program if you are e.g. building a whole debian package. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220918194555.83535-5-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscallsHelge Deller3-0/+71
I noticed those were missing when running the glib2.0 testsuite. Add the syscalls including the strace output. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220918194555.83535-4-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Add missing clock_gettime64() syscall straceHelge Deller2-0/+57
Allow linux-user to strace the clock_gettime64() syscall. This syscall is used a lot on 32-bit guest architectures which use newer glibc versions. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220918194555.83535-3-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-27linux-user: Add missing signals in strace outputHelge Deller3-53/+60
Some of the guest signal numbers are currently not converted to their representative names in the strace output, e.g. SIGVTALRM. This patch introduces a smart way to generate and keep in sync the host-to-guest and guest-to-host signal conversion tables for usage in the qemu signal and strace code. This ensures that any signals will now show up in both tables. There is no functional change in this patch - with the exception that yet missing signal names now show up in the strace code too. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220918194555.83535-2-deller@gmx.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-23linux-user: fix readlinkat handling with magic exe symlinkJameson Nash1-2/+13
Exactly the same as f17f4989fa193fa8279474c5462289a3cfe69aea before was for readlink. I suppose this was simply missed at the time. Signed-off-by: Jameson Nash <vtjnash@gmail.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220808190727.875155-1-vtjnash@gmail.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-23linux-user: use 'max' instead of 'qemu32' / 'qemu64' by defaultDaniel P. Berrangé2-2/+2
The 'qemu64' CPU model implements the least featureful x86_64 CPU that's possible. Historically this hasn't been an issue since it was rare for OS distros to build with a higher mandatory CPU baseline. With RHEL-9, however, the entire distro is built for the x86_64-v2 ABI baseline: https://developers.redhat.com/blog/2021/01/05/building-red-hat-enterprise-linux-9-for-the-x86-64-v2-microarchitecture-level It is likely that other distros may take similar steps in the not too distant future. For example, it has been suggested for Fedora on a number of occasions. This new baseline is not compatible with the qemu64 CPU model though. While it is possible to pass a '-cpu xxx' flag to qemu-x86_64, the usage of QEMU doesn't always allow for this. For example, the args are typically controlled via binfmt rules that the user has no ability to change. This impacts users who are trying to use podman on aarch64 platforms, to run containers with x86_64 content. There's no arg to podman that can be used to change the qemu-x86_64 args, and a non-root user of podman can not change binfmt rules without elevating privileges: https://github.com/containers/podman/issues/15456#issuecomment-1228210973 Changing to the 'max' CPU model gives 'qemu-x86_64' maximum compatibility with binaries it is likely to encounter in the wild, and not likely to have a significant downside for existing usage. Most other architectures already use an 'any' CPU model, which is often mapped to 'max' (or similar) already, rather than the oldest possible CPU model. For the sake of consistency the 'i386' architecture is also changed from using 'qemu32' to 'max'. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20220923110413.70593-1-berrange@redhat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-09-06linux-user: Clear translations on mprotect()Ilya Leoshkevich1-2/+4
Currently it's possible to execute pages that do not have PAGE_EXEC if there is an existing translation block. Fix by invalidating TBs that touch the affected pages. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20220817150506.592862-2-iii@linux.ibm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-09-06linux-user: Honor PT_GNU_STACKRichard Henderson2-1/+19
Map the stack executable if required by default or on demand. Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-09-06linux-user/x86_64: Allocate vsyscall page as a commpageRichard Henderson1-0/+23
We're about to start validating PAGE_EXEC, which means that we've got to mark the vsyscall page executable. We had been special casing this entirely within translate. Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-09-06linux-user/hppa: Allocate page zero as a commpageRichard Henderson1-3/+31
We're about to start validating PAGE_EXEC, which means that we've got to mark page zero executable. We had been special casing this entirely within translate. Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-09-06linux-user/arm: Mark the commpage executableRichard Henderson2-3/+7
We're about to start validating PAGE_EXEC, which means that we've got to mark the commpage executable. We had been placing the commpage outside of reserved_va, which was incorrect and lead to an abort. Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-08-18Revert "linux-user: un-parent OBJECT(cpu) when closing thread"Richard Henderson1-7/+6
This reverts commit 52f0c1607671293afcdb2acc2f83e9bccbfa74bb. This caused a regression in arm/aarch64. We are hard-coding ARMCPRegInfo pointers into TranslationBlocks, for calling into helper_{get,set}cp_reg{,64}. So we have a race condition between whichever cpu thread translates the code first (encoding the pointer), and that cpu thread exiting, so that the next execution of the TB references a freed data structure. Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-08-16linux-user: un-parent OBJECT(cpu) when closing threadAlex Bennée1-6/+7
While forcing the CPU to unrealize by hand does trigger the clean-up code we never fully free resources because refcount never reaches zero. This is because QOM automatically added objects without an explicit parent to /unattached/, incrementing the refcount. Instead of manually triggering unrealization just unparent the object and let the device machinery deal with that for us. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/866 Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220811151413.3350684-2-alex.bennee@linaro.org>
2022-08-11linux-user/aarch64: Reset target data on MADV_DONTNEEDVitaly Buka1-0/+3
aarch64 stores MTE tags in target_date, and they should be reset by MADV_DONTNEED. Signed-off-by: Vitaly Buka <vitalybuka@google.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220711220028.2467290-1-vitalybuka@google.com> [lv: fix code style issues] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-08-10linux-user: fix compat with glibc >= 2.36 sys/mount.hDaniel P. Berrangé1-0/+18
The latest glibc 2.36 has extended sys/mount.h so that it defines the FSCONFIG_* enum constants. These are historically defined in linux/mount.h, and thus if you include both headers the compiler complains: In file included from /usr/include/linux/fs.h:19, from ../linux-user/syscall.c:98: /usr/include/linux/mount.h:95:6: error: redeclaration of 'enum fsconfig_command' 95 | enum fsconfig_command { | ^~~~~~~~~~~~~~~~ In file included from ../linux-user/syscall.c:31: /usr/include/sys/mount.h:189:6: note: originally defined here 189 | enum fsconfig_command | ^~~~~~~~~~~~~~~~ /usr/include/linux/mount.h:96:9: error: redeclaration of enumerator 'FSCONFIG_SET_FLAG' 96 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | ^~~~~~~~~~~~~~~~~ /usr/include/sys/mount.h:191:3: note: previous definition of 'FSCONFIG_SET_FLAG' with type 'enum fsconfig_command' 191 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ | ^~~~~~~~~~~~~~~~~ ...snip... QEMU doesn't include linux/mount.h, but it does use linux/fs.h and thus gets linux/mount.h indirectly. glibc acknowledges this problem but does not appear to be intending to fix it in the forseeable future, simply documenting it as a known incompatibility with no workaround: https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E https://sourceware.org/glibc/wiki/Synchronizing_Headers To address this requires either removing use of sys/mount.h or linux/fs.h, despite QEMU needing declarations from both. This patch removes linux/fs.h, meaning we have to define various FS_IOC constants that are now unavailable. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Tested-by: Richard W.M. Jones <rjones@redhat.com> Message-Id: <20220802164134.1851910-1-berrange@redhat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-08-05target/loongarch: Update gdb_set_fpu() and gdb_get_fpu()Song Gao1-22/+2
GDB LoongArch fpu use fcc register, update gdb_set_fpu() and gdb_get_fpu() to match it. Signed-off-by: Song Gao <gaosong@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Acked-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220805033523.1416837-6-gaosong@loongson.cn>
2022-08-03Merge tag 'linux-user-for-7.1-pull-request' of ↵Richard Henderson3-10/+16
https://gitlab.com/laurent_vivier/qemu into staging Pull request linux-user 20220803 # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmLqjIMSHGxhdXJlbnRA # dml2aWVyLmV1AAoJEPMMOL0/L748bpAP/1HW4wQztNCDL2epXGtDMTHFIjsLlc05 # h/3BwnXXXbRv/m4+IEJLITI5WpyZ24CGgA5kIFPRDxLCIHxcTo5etzqkJzxhnRvU # MNP3m8L5gSAUUZhD8Xw2b95V8vOv4cu8J+sgub8ZaRXJpcHK1cuCF43OeI3bBuoz # HNVY8XHl0E46JyXQmK9/phBRSK8INhlMIORd+k/GzSx7+9/UdIqTj1kVpdgbQ8we # GqrnVW9hYA2T2vUL3SEV8t6GE6lSGRr9bvsyRRfLxJanUEQbGmbJPvqBwjamRwUF # xZOBou/cYQOoI9AVku9bL+h2ITGfrfNZ8Oo7r7oOrz+ZjBfL9hUQqhFhI/oI265n # 4ivzdOcsXH6OT7X+JdZRvyv6pxVL7ycu2KCKvmnNvQSocGHT1OvFqIHAWd+NAdEr # c4q1ob1QdUfZjrzjzLR/qY2NPZat1Ge5lSIXOwC1G3T5umuw8cV7BV9KJJRoQXfE # AWeXsLKqqByQ59z+qObnFIkUXLaUOzKMjHNFpDGSqk+dzXxQYJtBn+b8ZLoL9MLa # miIN9imVzI2gzolIBz9Za2pnBw72bIR2PdXd3zfKH0cqmytOhKlMIEK4KJcB6kMB # CNAbszUwrmBSopGGryf+hLMk9VsPLVUg+Yqnc6/GLY8LF9d8Xr5rd8UzelYowBuh # 3UR/V06U2Skv # =41sQ # -----END PGP SIGNATURE----- # gpg: Signature made Wed 03 Aug 2022 07:56:03 AM PDT # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [undefined] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [undefined] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * tag 'linux-user-for-7.1-pull-request' of https://gitlab.com/laurent_vivier/qemu: linux-user: Use memfd for open syscall emulation linux-user: Do not treat madvise()'s advice as a bitmask linux-user/flatload.c: Fix setting of image_info::end_code Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-08-02linux-user: Use memfd for open syscall emulationRainer Müller1-8/+14
For certain paths in /proc, the open syscall is intercepted and the returned file descriptor points to a temporary file with emulated contents. If TMPDIR is not accessible or writable for the current user (for example in a read-only mounted chroot or container) tools such as ps from procps may fail unexpectedly. Trying to read one of these paths such as /proc/self/stat would return an error such as ENOENT or EROFS. To relax the requirement on a writable TMPDIR, use memfd_create() instead to create an anonymous file and return its file descriptor. Signed-off-by: Rainer Müller <raimue@codingfarm.de> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220729154951.76268-1-raimue@codingfarm.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-08-02linux-user/riscv: Align signal frame to 16 bytesRichard Henderson1-3/+1
Follow the kernel's alignment, as we already noted. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1093 Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220729201942.30738-1-richard.henderson@linaro.org> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2022-08-01misc: fix commonly doubled up wordsDaniel P. Berrangé1-1/+1
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20220707163720.1421716-5-berrange@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com>
2022-07-29linux-user: Do not treat madvise()'s advice as a bitmaskIlya Leoshkevich1-1/+1
Advice is enum, not flags. Doing (advice & MADV_DONTNEED) also matches e.g. MADV_MERGEABLE. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220725134100.128035-1-iii@linux.ibm.com> Fixes: 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED") Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-07-28linux-user/flatload.c: Fix setting of image_info::end_codePeter Maydell1-1/+1
The flatload loader sets the end_code field in the image_info struct incorrectly, due to a typo. This is a very long-standing bug (dating all the way back to when the bFLT loader was added in 2006), but has gone unnoticed because (a) most people don't use bFLT binaries (b) we don't actually do anything with the end_code field, except print it in debugging traces and pass it to TCG plugins Fix the typo. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1119 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220728151406.2262862-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-07-25linux-user: Use target abi_int type for pipefd[1] in pipe()Helge Deller1-1/+1
When writing back the fd[1] pipe file handle to emulated userspace memory, use sizeof(abi_int) as offset insted of the hosts's int type. There is no functional change in this patch. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <YtQ3Id6z8slpVr7r@p100> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-07-25linux-user: Unconditionally use pipe2() syscallHelge Deller1-10/+1
The pipe2() syscall is available on all Linux platforms since kernel 2.6.27, so use it unconditionally to emulate pipe() and pipe2(). Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <YtbZ2ojisTnzxN9Y@p100> Signed-off-by: Laurent Vivier <laurent@vivier.eu>