1
2
3
4
5
6
7
8
9
10
11#ifndef S390_HOST_SIGNAL_H
12#define S390_HOST_SIGNAL_H
13
14
15typedef ucontext_t host_sigcontext;
16
17static inline uintptr_t host_signal_pc(host_sigcontext *uc)
18{
19 return uc->uc_mcontext.psw.addr;
20}
21
22static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
23{
24 uc->uc_mcontext.psw.addr = pc;
25}
26
27static inline void *host_signal_mask(host_sigcontext *uc)
28{
29 return &uc->uc_sigmask;
30}
31
32static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
33{
34 uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 switch (pinsn[0] >> 8) {
50 case 0x50:
51 case 0x42:
52 case 0x40:
53 case 0x44:
54 case 0xba:
55 case 0xbb:
56 return true;
57 case 0xc4:
58 switch (pinsn[0] & 0xf) {
59 case 0xf:
60 case 0xb:
61 case 0x7:
62 return true;
63 }
64 break;
65 case 0xc6:
66 switch (pinsn[0] & 0xf) {
67 case 0x0:
68 return true;
69 }
70 break;
71 case 0xc8:
72 switch (pinsn[0] & 0xf) {
73 case 0x2:
74 return true;
75 }
76 break;
77 case 0xe3:
78 switch (pinsn[2] & 0xff) {
79 case 0x50:
80 case 0x24:
81 case 0x72:
82 case 0x70:
83 case 0x8e:
84 case 0x3f:
85 case 0x3e:
86 case 0x2f:
87 return true;
88 }
89 break;
90 case 0xeb:
91 switch (pinsn[2] & 0xff) {
92 case 0x14:
93 case 0x30:
94 case 0x31:
95 case 0x3e:
96 case 0xe4:
97 case 0xe6:
98 case 0xe7:
99 case 0xe8:
100 case 0xea:
101 case 0xf4:
102 case 0xf6:
103 case 0xf7:
104 case 0xfa:
105 case 0xf8:
106 return true;
107 }
108 break;
109 }
110 return false;
111}
112
113#endif
114