summaryrefslogtreecommitdiffstats
path: root/bsd-user
Commit message (Collapse)AuthorAgeFilesLines
* bsd-user/signal.c: Only copy the _capsicum for FreeBSD_version > 1400026Warner Losh2022-02-012-0/+10
| | | | | | | | | | The capsicum signal stuff is new with FreeBSD 14, rev 1400026, so only define QEMU_SI_CAPSICUM there. Only copy _capsicum when QEMU_SI_CAPSICUM is defined. Default to no info being passed for signals we make no guess about. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/freebsd/target_os_ucontext.h: Prefer env as arg name for ↵Warner Losh2022-01-311-3/+3
| | | | | | | CPUArchState args Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Rename arg name for target_cpu_reset to envWarner Losh2022-01-313-5/+5
| | | | | | | | Rename the parameter name for target_cpu_reset's CPUArchState * arg from cpu to env. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: do_sigaltstackWarner Losh2022-01-311-5/+67
| | | | | | | | | | | | Implement the meat of the sigaltstack(2) system call with do_sigaltstack. With that, all the stubbed out routines are complete, so remove now-incorrect comment. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: implement do_sigactionWarner Losh2022-01-312-0/+104
| | | | | | | | | | | Implement the meat of the sigaction(2) system call with do_sigaction and helper routiner block_signals (which is also used to implemement signal masking so it's global). Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: implement do_sigreturnWarner Losh2022-01-312-1/+57
| | | | | | | | | | | Implements the meat of a sigreturn(2) system call via do_sigreturn, and helper reset_signal_mask. Fix the prototype of do_sigreturn in qemu.h and remove do_rt_sigreturn since it's linux only. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: process_pending_signalsWarner Losh2022-01-281-1/+55
| | | | | | | | | Process the currently queued signals. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: tswap_siginfoWarner Losh2022-01-281-0/+53
| | | | | | | | | Convert siginfo from targer to host. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: handle_pending_signalWarner Losh2022-01-282-0/+94
| | | | | | | | | Handle a queued signal. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: setup_frameWarner Losh2022-01-283-1/+90
| | | | | | | | | | setup_frame sets up a signalled stack frame. Associated routines to extract the pointer to the stack frame and to support alternate stacks. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: sigset manipulation routines.Warner Losh2022-01-282-0/+76
| | | | | | | | | | | | | | | target_sigemptyset: resets a set to having no bits set target_sigaddset: adds a signal to a set target_sigismember: returns true when signal is a member host_to_target_sigset_internal: convert host sigset to target host_to_target_sigset: convert host sigset to target target_to_host_sigset_internal: convert target sigset to host target_to_host_sigset: convert target sigset to host Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: Fill in queue_signalWarner Losh2022-01-282-1/+17
| | | | | | | | | | Fill in queue signal implementation, as well as routines allocate and delete elements of the signal queue. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: Implement dump_core_and_abortWarner Losh2022-01-282-0/+77
| | | | | | | | | | Force delivering a signal and generating a core file. It's a global function for the moment... Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/strace.c: print_taken_signalWarner Losh2022-01-282-0/+107
| | | | | | | | | | print_taken_signal() prints signals when we're tracing signals. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: Implement host_signal_handlerWarner Losh2022-01-281-0/+105
| | | | | | | | | | Implement host_signal_handler to handle signals generated by the host and to do safe system calls. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: Implement rewind_if_in_safe_syscallWarner Losh2022-01-282-1/+14
| | | | | | | Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: host_to_target_siginfo_noswapWarner Losh2022-01-281-0/+113
| | | | | | | | | Implement conversion of host to target siginfo. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Add trace events for bsd-userWarner Losh2022-01-283-0/+13
| | | | | | | | | | | Add the bsd-user specific events and infrastructure. Only include the linux-user trace events for linux-user, not bsd-user. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Add host signals to the buildWarner Losh2022-01-281-0/+1
| | | | | | | | Start to add the host signal functionality to the build. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/host/x86_64/host-signal.h: Implement host_signal_*Warner Losh2022-01-281-0/+37
| | | | | | | | | | Implement host_signal_pc, host_signal_set_pc and host_signal_write for x86_64. Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/host/i386/host-signal.h: Implement host_signal_*Warner Losh2022-01-281-0/+37
| | | | | | | | | | Implement host_signal_pc, host_signal_set_pc and host_signal_write for i386. Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/host/arm/host-signal.h: Implement host_signal_*Warner Losh2022-01-281-0/+35
| | | | | | | | | Implement host_signal_pc, host_signal_set_pc and host_signal_write for arm. Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: Add si_type argument to queue_signalWarner Losh2022-01-282-3/+28
| | | | | | | | | | | | | | | | Mirror the linux-user practice and add a si_type argument to queue signal. This will be transported as the upper 8 bits in the si_type element of siginfo so that we know what bits of the structure are valid and so we can properly implement host_to_target_siginfo_noswap and tswap_siginfo. Adapt the one caller of queue_signal to the new interface. Use all the same names as Linux (except _RT which we don't treat differently, unlike Linux), though some are unused. Place this into signal-common.h since that's a better place given bsd-user's structure. Move prototype of queue_signal to signal-common.h to mirror linux-user's location. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: Implement signal_init()Warner Losh2022-01-282-0/+74
| | | | | | | | | | | | | Initialize the signal state for the emulator. Setup a set of sane default signal handlers, mirroring the host's signals. For fatal signals (those that exit by default), establish our own set of signal handlers. Stub out the actual signal handler we use for the moment. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> XXX SIGPROF PENDING
* bsd-user/signal.c: implement abstract target / host signal translationWarner Losh2022-01-282-0/+18
| | | | | | | | | | Implement host_to_target_signal and target_to_host_signal. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_cpu.h: Implement data faultsWarner Losh2022-01-281-10/+35
| | | | | | | | | Update for the richer set of data faults that are now possible. Copied largely from linux-user/arm/cpu_loop.c, with minor typo fixes. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_cpu.h: Use force_sig_fault for EXCP_UDEFWarner Losh2022-01-281-12/+13
| | | | | | | | | | | | Use force_sig_fault to implement unknown opcode. This just uninlines that function, so simplify things by using it. Fold in EXCP_NOCP and EXCP_INVSTATE, as is done in linux-user. Make a note about slight differences with FreeBSD in case any of them turn out to be important later. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_cpu.h: Correct code pointerWarner Losh2022-01-281-1/+1
| | | | | | | | | The code has moved in FreeBSD since the emulator was started, update the comment to reflect that change. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/arget_arch_cpu.h: Move EXCP_DEBUG and EXCP_BKPT togetherWarner Losh2022-01-281-20/+2Star
| | | | | | | | | | | | Implement EXCP_DEBUG and EXCP_BKPT the same, as is done in linux-user. The prior adjustment of register 15 isn't needed, so remove that. Remove a redunant comment (that code in FreeBSD never handled break points). It's unclear why BKPT was an alias for system calls, but FreeBSD doesn't do that today. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: implement cpu_loop_exit_sigbusWarner Losh2022-01-281-3/+9
| | | | | | | | | | | First attempt at implementing cpu_loop_exit_sigbus, mostly copied from linux-user version of this function. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: Implement cpu_loop_exit_sigsegvWarner Losh2022-01-281-3/+12
| | | | | | | | | | | First attempt at implementing cpu_loop_exit_sigsegv, mostly copied from linux-user version of this function. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal-common.h: Move signal functions prototypes to hereWarner Losh2022-01-285-8/+9
| | | | | Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/signal.c: implement force_sig_faultWarner Losh2022-01-282-0/+32
| | | | | | | | | | | | | Start to implement the force_sig_fault code. This currently just calls queue_signal(). The bsd-user fork version of that will handle this the synchronous nature of this call. Add signal-common.h to hold signal helper functions like force_sig_fault. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@freebsd.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_cpu.h: Move EXCP_ATOMIC to match linux-userWarner Losh2022-01-281-3/+3
| | | | | | | | | Move the EXCP_ATOMIC case to match linux-user/arm/cpu_loop.c:cpu_loop ordering. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Bring in docs from linux-user for signal_pendingWarner Losh2022-01-281-1/+8
| | | | | | | This is currently unused, so no code adjustments are needed. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Remove vestiges of signal queueing codeWarner Losh2022-01-282-20/+2Star
| | | | | | | | | | bsd-user was copied from linux-user at a time when it queued signals. Remove those vestiges of thse code. Retain the init function, even though it's now empty since other stuff will likely be added there. Make it static since it's not called from outside of main.c Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/signal.c: get_mcontext should zero vfp dataWarner Losh2022-01-281-0/+9
| | | | | | | | | | FreeBSD's get_mcontext doesn't return any vfp data. Instead, it zeros out the vfp feilds (and all the spare fields). Impelement this behavior. We're still missing the sysarch(ARM_GET_VFPCONTEXT) syscall, though. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/signal.c: Implement setup_sigframe_arch for armWarner Losh2022-01-281-17/+33
| | | | | | | | | | | Fix the broken context setting for arm. FreeBSD's get_mcontext does not fill in the vfp info. It's filled in in sigframe(). This corresponds to the new setup_sigframe_arch which fills in mcontext, then adjusts it to point to the vfp context in the sigframe and fills in that context as well. Add pointer to where this code is done. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Create setup_sigframe_arch to setup sigframe contextWarner Losh2022-01-283-0/+29
| | | | | | | | Define setup_sigframe_arch whose job it is to setup the mcontext for the sigframe. Implement for x86 to just call mcontext. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Complete FreeBSD siginfoWarner Losh2022-01-281-1/+14
| | | | | | | Fill in the missing FreeBSD siginfo fields, and add some comments. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* user: move common-user includes to a subdirectory of {bsd,linux}-user/Paolo Bonzini2022-01-122-1/+1
| | | | | | | | | | Avoid polluting the compilation of common-user/ with local include files; making an include file available to common-user/ should be a deliberate decision in order to keep a clear interface that can be used by both bsd-user/ and linux-user/. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* bsd-user/freebsd/target_os_ucontext.h: Require TARGET_*CONTEXT_SIZEWarner Losh2022-01-081-2/+0Star
| | | | | | | | | Now that all architecutres define TARGET_[MU]CONTEXT_SIZE, enforce requiring them and always check the sizeof target_{u,m}context_t sizes. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/signal.c: arm get_ucontext_sigreturnWarner Losh2022-01-081-0/+9
| | | | | | | | Update ucontext to implement sigreturn. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/signal.c: arm set_mcontextWarner Losh2022-01-081-0/+76
| | | | | | | | | Move the machine context to the CPU state. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/signal.c: arm get_mcontextWarner Losh2022-01-081-0/+51
| | | | | | | | | Get the machine context from the CPU state. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/signal.c: arm set_sigtramp_argsWarner Losh2022-01-081-0/+60
| | | | | | | | | Implement set_sigtramp_args to setup the arguments to the sigtramp calls. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_signal.h: Define size of *context_tWarner Losh2022-01-081-0/+3
| | | | | | | | | Define the native sizes of mcontext_t and ucontext_t so that the tests in target_os_ucontext.h ensure the size of arm's version of these structures is correct. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_signal.h: arm machine context and trapframe for signalsWarner Losh2022-01-081-0/+28
| | | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_signal.h: arm specific signal registers and stackWarner Losh2022-01-081-0/+57
| | | | | | | | | Defines for registers and stack layout related to signals. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Kyle Evans <kevans@FreeBSD.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/arm/target_arch_elf.h: arm get_hwcap2 implWarner Losh2022-01-081-0/+22
| | | | | | | | | Implement the extended HW capabilities for HWCAP2. Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Kyle Evans <kevans@FreeBSD.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>