summaryrefslogtreecommitdiffstats
path: root/linux-user/hppa
Commit message (Collapse)AuthorAgeFilesLines
* linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handlerHelge Deller2022-11-021-5/+14
| | | | | | | | | | | | | | | | | | | | The glibc on the hppa platform uses the "iitlbp %r0,(%sr0, %r0)" assembler instruction as ABORT_INSTRUCTION. If this (in userspace context) illegal assembler statement is found, dump the registers and report the failure to userspace the same way as the Linux kernel on physical hardware. For other illegal instructions report TARGET_ILL_ILLOPC instead of TARGET_ILL_ILLOPN as si_code. Additionally add the missing EXCP_BREAK exception handler which occurs when the "break x,y" assembler instruction is executed and report EXCP_ASSIST traps. Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <Y1osHVsylkuZNUnY@p100> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user/hppa: Fix setup_sigcontext()Helge Deller2022-09-271-13/+3Star
| | | | | | | | | | | 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>
* linux-user/hppa: Increase guest stack size to 80MB for hppa targetHelge Deller2022-09-271-0/+2
| | | | | | | | | | | | | | | | | 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>
* linux-user/hppa: Add signal trampoline for hppa targetHelge Deller2022-09-272-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>
* linux-user: Provide MADV_* definitionsIlya Leoshkevich2022-09-271-0/+15
| | | | | | | | | | | 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>
* linux-user/hppa: Use EXCP_DUMP() to show enhanced debug infoHelge Deller2022-09-271-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>
* linux-user/hppa: Fix segfaults on page zeroHelge Deller2022-07-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | This program: int main(void) { asm("bv %r0(%r0)"); return 0; } produces on real hppa hardware the expected segfault: SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x3} --- killed by SIGSEGV +++ Segmentation fault But when run on linux-user you get instead internal qemu errors: ERROR: linux-user/hppa/cpu_loop.c:172:cpu_loop: code should not be reached Bail out! ERROR: linux-user/hppa/cpu_loop.c:172:cpu_loop: code should not be reached ERROR: accel/tcg/cpu-exec.c:933:cpu_exec: assertion failed: (cpu == current_cpu) Bail out! ERROR: accel/tcg/cpu-exec.c:933:cpu_exec: assertion failed: (cpu == current_cpu) Fix it by adding the missing case for the EXCP_IMP trap in cpu_loop() and raise a segfault. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <YtWNC56seiV6VenA@p100> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Move generic TARGET_RLIMIT* definitions to generic/target_resource.hSerge Belyshev2022-02-011-0/+1
| | | | | | Signed-off-by: Serge Belyshev <belyshev@depni.sinp.msu.ru> Message-Id: <87ee4ql3yk.fsf_-_@depni.sinp.msu.ru> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user/hppa: Set FPE_CONDTRAP for CONDRichard Henderson2022-01-111-0/+2
| | | | | | | | | This si_code was changed in 75abf64287cab, for linux 4.17. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220107213243.212806-9-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user/hppa: Use the proper si_code for PRIV_OPR, PRIV_REG, OVERFLOWRichard Henderson2022-01-111-1/+7
| | | | | | | | | These si_codes have been properly set by the kernel since the beginning. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220107213243.212806-7-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user/hppa: Use force_sig_faultRichard Henderson2022-01-111-15/+3Star
| | | | | | | | | | | Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP and missing si_code for SIGBUS. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220107213243.212806-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* target/hppa: Implement prctl_unalign_sigbusRichard Henderson2022-01-061-1/+1
| | | | | | | | | | | Leave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20211227150127.2659293-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Split out do_prctl and subroutinesRichard Henderson2022-01-061-0/+1
| | | | | | | | | | | | | | | | Since the prctl constants are supposed to be generic, supply any that are not provided by the host. Split out subroutines for PR_GET_FP_MODE, PR_SET_FP_MODE, PR_GET_VL, PR_SET_VL, PR_RESET_KEYS, PR_SET_TAGGED_ADDR_CTRL, PR_GET_TAGGED_ADDR_CTRL. Return EINVAL for guests that do not support these options rather than pass them on to the host. Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20211227150127.2659293-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Remove TARGET_SIGSTKSZSong Gao2022-01-061-1/+0Star
| | | | | | | | | TARGET_SIGSTKSZ is not used, we should remove it. Signed-off-by: Song Gao <gaosong@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <1637893388-10282-4-git-send-email-gaosong@loongson.cn> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: target_syscall.h remove definition TARGET_MINSIGSTKSZSong Gao2022-01-061-1/+0Star
| | | | | | | | | | | | TARGET_MINSIGSTKSZ has been defined in generic/signal.h or target_signal.h, We don't need to define it again. Signed-off-by: Song Gao <gaosong@loongson.cn> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <1637893388-10282-3-git-send-email-gaosong@loongson.cn> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURNRichard Henderson2021-12-202-3/+3
| | | | | | | | This value is fully internal to qemu, and so is not a TARGET define. Reviewed-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
* linux-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYSRichard Henderson2021-12-201-1/+1
| | | | | | | | | This value is fully internal to qemu, and so is not a TARGET define. We use this as an extra marker for both host and target errno. Reviewed-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
* linux-user/hppa: Remove EXCP_UNALIGN handlingRichard Henderson2021-11-021-7/+0Star
| | | | | | | We will raise SIGBUS directly from cpu_loop_exit_sigbus. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
* target/hppa: Make hppa_cpu_tlb_fill sysemu onlyRichard Henderson2021-11-021-16/+0Star
| | | | | | | | | | | | The fallback code in cpu_loop_exit_sigsegv is sufficient for hppa linux-user. Remove the code from cpu_loop that raised SIGSEGV. This makes all of the code in mem_helper.c sysemu only, so remove the ifdefs and move the file to hppa_softmmu_ss. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
* linux-user/hppa: Document non-use of setup_sigtrampRichard Henderson2021-10-011-0/+14
| | | | | | | | | | | We cannot use a raw sigtramp page for hppa, but must wait for full vdso support. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210929130553.121567-10-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Split linux-user internals out of qemu.hPeter Maydell2021-09-132-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | qemu.h is included in various non-linux-user files (which mostly want the TaskState struct and the functions for doing usermode access to guest addresses like lock_user(), unlock_user(), get_user*(), etc). Split out the parts that are only used in linux-user itself into a new user-internals.h. This leaves qemu.h with basically three things: * the definition of the TaskState struct * the user-access functions and macros * do_brk() all of which are needed by code outside linux-user that includes qemu.h. The addition of all the extra #include lines was done with sed -i '/include.*qemu\.h/a #include "user-internals.h"' $(git grep -l 'include.*qemu\.h' linux-user) (and then undoing the change to fpa11.h). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210908154405.15417-8-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Split signal-related prototypes into signal-common.hPeter Maydell2021-09-131-0/+1
| | | | | | | | | | | Split the signal related prototypes into the existing header file signal-common.h, and include it in those places that now require it. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210908154405.15417-4-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* qemu/atomic: Add aligned_{int64,uint64}_t typesRichard Henderson2021-07-211-1/+1
| | | | | | | | | | | Use it to avoid some clang-12 -Watomic-alignment errors, forcing some structures to be aligned and as a pointer when we have ensured that the address is aligned. Tested-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
* linux-user: update syscall.tbl to Linux v5.13Laurent Vivier2021-07-131-12/+19
| | | | | | | | Updated running scripts/update-syscalltbl.sh Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20210708215756.268805-4-laurent@vivier.eu> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user/hppa: Move errno definitions to 'target_errno_defs.h'Philippe Mathieu-Daudé2021-07-122-210/+214
| | | | | | | | Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20210708170550.1846343-6-f4bug@amsat.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Extract target errno to 'target_errno_defs.h'Philippe Mathieu-Daudé2021-07-121-0/+6
| | | | | | | | | | | | | | | We want to access the target errno indepently of the rest of the linux-user code. Move the header containing the generic errno definitions ('errno_defs.h') to 'generic/target_errno_defs.h', create a new 'target_errno_defs.h' in each target which itself includes 'generic/target_errno_defs.h'. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20210708170550.1846343-4-f4bug@amsat.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user/hppa: Handle TARGET_EWOULDBLOCK as TARGET_EAGAINPhilippe Mathieu-Daudé2021-07-071-0/+2
| | | | | | | | | Linux kernel defines EWOULDBLOCK as EAGAIN (since before v2.6.12-rc2). Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210704183755.655002-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Pass CPUArchState to target_restore_altstackRichard Henderson2021-05-151-1/+1
| | | | | | | | | | | | | In most cases we were already passing get_sp_from_cpustate directly to the function. In other cases, we were passing a local variable which already contained the same value. In the rest of the cases, we were passing the stack pointer out of env directly. Reviewed by: Warner Losh <imp@bsdimp.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210426025334.1168495-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Use target_restore_altstack in all sigreturnRichard Henderson2021-05-151-7/+1Star
| | | | | | | | | | | | Note that target_restore_altstack uses the host memory pointer that we have already verified, so TARGET_EFAULT is not a possible return value. Note that using -EFAULT was a bug. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210426025334.1168495-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Use cpu_untagged_addr in access_ok; split out *_untaggedRichard Henderson2021-02-161-4/+4
| | | | | | | | | | | Provide both tagged and untagged versions of access_ok. In a few places use thread_cpu, as the user is several callees removed from do_syscall1. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210212184902.1251044-17-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* exec: Use cpu_untagged_addr in g2h; split out g2h_untaggedRichard Henderson2021-02-161-15/+16
| | | | | | | | | | | | | | | | | | | | | | | Use g2h_untagged in contexts that have no cpu, e.g. the binary loaders that operate before the primary cpu is created. As a colollary, target_mmap and friends must use untagged addresses, since they are used by the loaders. Use g2h_untagged on values returned from target_mmap, as the kernel never applies a tag itself. Use g2h_untagged on all pc values. The only current user of tags, aarch64, removes tags from code addresses upon branch, so "pc" is always untagged. Use g2h with the cpu context on hand wherever possible. Use g2h_untagged in lock_user, which will be updated soon. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210212184902.1251044-13-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* linux-user: target: signal: Support TARGET_SS_AUTODISARMChen Gang2021-02-131-0/+5
| | | | | | | | | Add definitions to pass building. Signed-off-by: Chen Gang <chengang@emindsoft.com.cn> 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 <laurent@vivier.eu>
* linux-user: fix O_NONBLOCK in signalfd4() and eventfd2() syscallsHelge Deller2021-02-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20210210061214.GA221322@ls3530.fritz.box> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: fix O_NONBLOCK usage for hppa targetHelge Deller2021-02-131-1/+1
| | | | | | | | | | | | | | | | | | | 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 <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20210201220551.GA8015@ls3530.fritz.box> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Add missing TARGET___O_TMPFILE for hppa and alphaHelge Deller2021-02-131-0/+1
| | | | | | | | | | | | | | | | 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 <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20210201155922.GA18291@ls3530.fritz.box> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux user: Fix Lesser GPL version numberChetan Pant2020-11-152-2/+2
| | | | | | | | | | | | There is no "version 2" of the "Lesser" General Public License. It is either "GPL version 2.0" or "Lesser GPL version 2.1". This patch replaces all occurrences of "Lesser GPL version 2" with "Lesser GPL version 2.1" in comment section. Signed-off-by: Chetan Pant <chetan4windows@gmail.com> Message-Id: <20201023122455.19417-1-chetan4windows@gmail.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
* linux-user: Correct definition of stack_tLemonBoy2020-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Some platforms used the wrong definition of stack_t where the flags and size fields were swapped or where the flags field had type ulong instead of int. Due to the presence of padding space in the structure and the prevalence of little-endian machines this problem went unnoticed for a long time. The type definitions have been cross-checked with the ones defined in the Linux kernel v5.9, plus some older versions for a few architecture that have been removed and Xilinx's kernel fork for NiosII [1]. The bsd-user headers remain unchanged as I don't know if they are wrong or not. [1] https://github.com/Xilinx/linux-xlnx/blob/master/arch/nios2/include/uapi/asm/signal.h Signed-off-by: Giuseppe Musacchio <thatlemon@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <e9d47692-ee92-009f-6007-0abc3f502b97@gmail.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: update syscall.tbl to Linux 5.9-rc7Laurent Vivier2020-10-261-3/+5
| | | | | | | | | Updated running scripts/update-syscalltbl.sh Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20200930003033.554124-4-laurent@vivier.eu> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* qemu/atomic.h: rename atomic_ to qatomic_Stefan Hajnoczi2020-09-231-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang's C11 atomic_fetch_*() functions only take a C11 atomic type pointer argument. QEMU uses direct types (int, etc) and this causes a compiler error when a QEMU code calls these functions in a source file that also included <stdatomic.h> via a system header file: $ CC=clang CXX=clang++ ./configure ... && make ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid) Avoid using atomic_*() names in QEMU's atomic.h since that namespace is used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h and <stdatomic.h> can co-exist. I checked /usr/include on my machine and searched GitHub for existing "qatomic_" users but there seem to be none. This patch was generated using: $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \ sort -u >/tmp/changed_identifiers $ for identifier in $(</tmp/changed_identifiers); do sed -i "s%\<$identifier\>%q$identifier%g" \ $(git grep -I -l "\<$identifier\>") done I manually fixed line-wrap issues and misaligned rST tables. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
* linux-user: Add missing termbits types and values definitionsFilip Bozuta2020-08-271-6/+11
| | | | | | | | | | | | | | | | This patch introduces missing target types ('target_flag_t', 'target_cc_t', 'target_speed_t') in a few 'termibts.h' header files. Also, two missing values ('TARGET_IUTF8' and 'TARGET_EXTPROC') were also added. These values were also added in file 'syscall.c' in bitmask tables 'iflag_tbl[]' and 'lflag_tbl[]' which are used to convert values of 'struct termios' between target and host. Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com> Reviewed-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20200723210233.349690-3-Filip.Bozuta@syrmia.com> [lv: keep TARGET_NCCS definition in xtensa/termbits.h] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Add strace support for printing arguments of syscalls used to ↵Filip Bozuta2020-08-271-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lock and unlock memory This patch implements strace argument printing functionality for following syscalls: * mlock, munlock, mlockall, munlockall - lock and unlock memory int mlock(const void *addr, size_t len) int munlock(const void *addr, size_t len) int mlockall(int flags) int munlockall(void) man page: https://man7.org/linux/man-pages/man2/mlock.2.html Implementation notes: Syscall mlockall() takes an argument that is composed of predefined values which represent flags that determine the type of locking operation that is to be performed. For that reason, a printing function "print_mlockall" was stated in file "strace.list". This printing function uses an already existing function "print_flags()" to print the "flags" argument. These flags are stated inside an array "mlockall_flags" that contains values of type "struct flags". These values are instantiated using an existing macro "FLAG_TARGET()" that crates aproppriate target flag values based on those defined in files '/target_syscall.h'. These target flag values were changed from "TARGET_MLOCKALL_MCL*" to "TARGET_MCL_*" so that they can be aproppriately set and recognised in "strace.c" with "FLAG_TARGET()". Value for "MCL_ONFAULT" was added in this patch. This value was also added in "syscall.c" in function "target_to_host_mlockall_arg()". Because this flag value was added in kernel version 4.4, it is enwrapped in an #ifdef directive (both in "syscall.c" and in "strace.c") as to support older kernel versions. The other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Syscall mlock2() is not implemented in "syscall.c" and thus it's argument printing is not implemented in this patch. Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20200811164553.27713-4-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* meson: linux-userMarc-André Lureau2020-08-212-5/+5
| | | | | | | | | | | | | | The most interesting or most complicated part here is the syscall_nr.h generators. In order to keep the generation logic all in meson.build, I am adding to config_target the name of the .tbl file, and making the generated file syscall<SUFFIX>_nr.h for input file syscall<SUFFIX>.tbl. For architectures where the input file is not named syscall_nr.tbl, syscall_nr.h has to be a source file; it's just a forwarder for x86 (i386/x86_64), while for MIPS64 it chooses between N32 and N64 ABIs. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* linux-user: update syscall.tbl from linux 0bf999f9c5e7Laurent Vivier2020-03-201-0/+2
| | | | | | | | | Run scripts/update-syscalltbl.sh with linux commit 0bf999f9c5e7 Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> Message-Id: <20200310103403.3284090-20-laurent@vivier.eu> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user, hppa: add syscall table generation supportLaurent Vivier2020-03-204-358/+472
| | | | | | | | | | | Copy syscall.tbl and syscallhdr.sh from linux/arch/parisc/kernel/syscalls v5.5 Update syscallhdr.sh to generate QEMU syscall_nr.h Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20200310103403.3284090-4-laurent@vivier.eu> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: add missing TARGET_SIGRTMIN for hppaLaurent Vivier2020-02-121-0/+1
| | | | | | | | | | | | | | | | This signal is defined for all other targets and we will need it later Signed-off-by: Laurent Vivier <laurent@vivier.eu> [pm: that this was actually an ABI change in the hppa kernel (at kernel version 3.17, kernel commit 1f25df2eff5b25f52c139d). Before that SIGRTMIN was 37... All our other HPPA TARGET_SIG* values are for the updated ABI following that commit, so using 32 for SIGRTMIN is the right thing for us.] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Taylor Simpson <tsimpson@quicinc.com> Message-Id: <20200212125658.644558-2-laurent@vivier.eu> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Introduce cpu_clone_regs_parentRichard Henderson2019-11-061-0/+4
| | | | | | | | | | | | We will need a target-specific hook for adjusting registers in the parent during clone. Add an empty inline function for each target, and invoke it from the proper places. Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20191106113318.10226-11-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Rename cpu_clone_regs to cpu_clone_regs_childRichard Henderson2019-11-061-1/+2
| | | | | | | | | | | | | | | We will need a target-specific hook for adjusting registers in the parent during clone. To avoid confusion, rename the one we have to make it clear it affects the child. At the same time, pass in the flags from the clone syscall. We will need them for correct behaviour for Sparc. Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20191106113318.10226-10-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* linux-user: Make sigaltstack stacks per-threadPeter Maydell2019-07-261-1/+2
| | | | | | | | | | | | | | | | | | | | | The alternate signal stack set up by the sigaltstack syscall is supposed to be per-thread. We were incorrectly implementing it as process-wide. This causes problems for guest binaries that rely on this. Notably the Go runtime does, and so we were seeing crashes caused by races where two guest threads might incorrectly both execute on the same stack simultaneously. Replace the global target_sigaltstack_used with a field sigaltstack_used in the TaskState, and make all the references to the old global instead get a pointer to the TaskState and use the field. Fixes: https://bugs.launchpad.net/qemu/+bug/1696773 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Tested-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20190725131645.19501-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* Supply missing header guardsMarkus Armbruster2019-06-123-0/+15
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190604181618.19980-5-armbru@redhat.com>
* target/hppa: Use env_cpu, env_archcpuRichard Henderson2019-06-101-1/+1
| | | | | | | | | | | Cleanup in the boilerplate that each target must define. Replace hppa_env_get_cpu with env_archcpu. The combination CPU(hppa_env_get_cpu) should have used ENV_GET_CPU to begin; use env_cpu now. Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>