]>
git.proxmox.com Git - mirror_qemu.git/blob - linux-user/host/aarch64/host-signal.h
9770b36dc10fa882c07b8a548944437cd3a4a506
2 * host-signal.h: signal info dependent on the host architecture
4 * Copyright (c) 2003-2005 Fabrice Bellard
5 * Copyright (c) 2021 Linaro Limited
7 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
8 * See the COPYING file in the top-level directory.
11 #ifndef AARCH64_HOST_SIGNAL_H
12 #define AARCH64_HOST_SIGNAL_H
14 /* Pre-3.16 kernel headers don't have these, so provide fallback definitions */
16 #define ESR_MAGIC 0x45535201
18 struct _aarch64_ctx head
;
23 static inline struct _aarch64_ctx
*first_ctx(ucontext_t
*uc
)
25 return (struct _aarch64_ctx
*)&uc
->uc_mcontext
.__reserved
;
28 static inline struct _aarch64_ctx
*next_ctx(struct _aarch64_ctx
*hdr
)
30 return (struct _aarch64_ctx
*)((char *)hdr
+ hdr
->size
);
33 static inline uintptr_t host_signal_pc(ucontext_t
*uc
)
35 return uc
->uc_mcontext
.pc
;
38 static inline void host_signal_set_pc(ucontext_t
*uc
, uintptr_t pc
)
40 uc
->uc_mcontext
.pc
= pc
;
43 static inline bool host_signal_write(siginfo_t
*info
, ucontext_t
*uc
)
45 struct _aarch64_ctx
*hdr
;
48 /* Find the esr_context, which has the WnR bit in it */
49 for (hdr
= first_ctx(uc
); hdr
->magic
; hdr
= next_ctx(hdr
)) {
50 if (hdr
->magic
== ESR_MAGIC
) {
51 struct esr_context
const *ec
= (struct esr_context
const *)hdr
;
52 uint64_t esr
= ec
->esr
;
54 /* For data aborts ESR.EC is 0b10010x: then bit 6 is the WnR bit */
55 return extract32(esr
, 27, 5) == 0x12 && extract32(esr
, 6, 1) == 1;
60 * Fall back to parsing instructions; will only be needed
61 * for really ancient (pre-3.16) kernels.
63 insn
= *(uint32_t *)host_signal_pc(uc
);
65 return (insn
& 0xbfff0000) == 0x0c000000 /* C3.3.1 */
66 || (insn
& 0xbfe00000) == 0x0c800000 /* C3.3.2 */
67 || (insn
& 0xbfdf0000) == 0x0d000000 /* C3.3.3 */
68 || (insn
& 0xbfc00000) == 0x0d800000 /* C3.3.4 */
69 || (insn
& 0x3f400000) == 0x08000000 /* C3.3.6 */
70 || (insn
& 0x3bc00000) == 0x39000000 /* C3.3.13 */
71 || (insn
& 0x3fc00000) == 0x3d800000 /* ... 128bit */
72 /* Ignore bits 10, 11 & 21, controlling indexing. */
73 || (insn
& 0x3bc00000) == 0x38000000 /* C3.3.8-12 */
74 || (insn
& 0x3fe00000) == 0x3c800000 /* ... 128bit */
75 /* Ignore bits 23 & 24, controlling indexing. */
76 || (insn
& 0x3a400000) == 0x28000000; /* C3.3.7,14-16 */