105a24871SPaolo Bonzini /*
205a24871SPaolo Bonzini * host-signal.h: signal info dependent on the host architecture
305a24871SPaolo Bonzini *
405a24871SPaolo Bonzini * Copyright (c) 2003-2005 Fabrice Bellard
505a24871SPaolo Bonzini * Copyright (c) 2021 Linaro Limited
605a24871SPaolo Bonzini *
705a24871SPaolo Bonzini * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
805a24871SPaolo Bonzini * See the COPYING file in the top-level directory.
905a24871SPaolo Bonzini */
1005a24871SPaolo Bonzini
1105a24871SPaolo Bonzini #ifndef ARM_HOST_SIGNAL_H
1205a24871SPaolo Bonzini #define ARM_HOST_SIGNAL_H
1305a24871SPaolo Bonzini
14*9940799bSRichard Henderson /* The third argument to a SA_SIGINFO handler is ucontext_t. */
15*9940799bSRichard Henderson typedef ucontext_t host_sigcontext;
16*9940799bSRichard Henderson
host_signal_pc(host_sigcontext * uc)17*9940799bSRichard Henderson static inline uintptr_t host_signal_pc(host_sigcontext *uc)
1805a24871SPaolo Bonzini {
1905a24871SPaolo Bonzini return uc->uc_mcontext.arm_pc;
2005a24871SPaolo Bonzini }
2105a24871SPaolo Bonzini
host_signal_set_pc(host_sigcontext * uc,uintptr_t pc)22*9940799bSRichard Henderson static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
2305a24871SPaolo Bonzini {
2405a24871SPaolo Bonzini uc->uc_mcontext.arm_pc = pc;
2505a24871SPaolo Bonzini }
2605a24871SPaolo Bonzini
host_signal_mask(host_sigcontext * uc)27*9940799bSRichard Henderson static inline void *host_signal_mask(host_sigcontext *uc)
28c8c89a6aSRichard Henderson {
29c8c89a6aSRichard Henderson return &uc->uc_sigmask;
30c8c89a6aSRichard Henderson }
31c8c89a6aSRichard Henderson
host_signal_write(siginfo_t * info,host_sigcontext * uc)32*9940799bSRichard Henderson static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
3305a24871SPaolo Bonzini {
3405a24871SPaolo Bonzini /*
3505a24871SPaolo Bonzini * In the FSR, bit 11 is WnR, assuming a v6 or
3605a24871SPaolo Bonzini * later processor. On v5 we will always report
3705a24871SPaolo Bonzini * this as a read, which will fail later.
3805a24871SPaolo Bonzini */
3905a24871SPaolo Bonzini uint32_t fsr = uc->uc_mcontext.error_code;
4005a24871SPaolo Bonzini return extract32(fsr, 11, 1);
4105a24871SPaolo Bonzini }
4205a24871SPaolo Bonzini
4305a24871SPaolo Bonzini #endif
44