2 * Common helper functions for kprobes and uprobes
4 * Copyright IBM Corp. 2014
7 #include <asm/kprobes.h>
10 int probe_is_prohibited_opcode(u16 *insn)
12 if (!is_known_insn((unsigned char *)insn))
14 switch (insn[0] >> 8) {
15 case 0x0c: /* bassm */
19 case 0xac: /* stnsm */
20 case 0xad: /* stosm */
23 switch (insn[0] & 0x0f) {
30 case 0xb25a: /* bsa */
31 case 0xb240: /* bakr */
32 case 0xb258: /* bsg */
35 case 0xb98d: /* epsw */
36 case 0xe560: /* tbegin */
37 case 0xe561: /* tbeginc */
38 case 0xb2f8: /* tend */
44 int probe_get_fixup_type(u16 *insn)
46 /* default fixup method */
47 int fixup = FIXUP_PSW_NORMAL;
49 switch (insn[0] >> 8) {
52 fixup = FIXUP_RETURN_REGISTER;
53 /* if r2 = 0, no branch will be taken */
54 if ((insn[0] & 0x0f) == 0)
55 fixup |= FIXUP_BRANCH_NOT_TAKEN;
59 fixup = FIXUP_BRANCH_NOT_TAKEN;
63 fixup = FIXUP_RETURN_REGISTER;
69 fixup = FIXUP_BRANCH_NOT_TAKEN;
72 fixup = FIXUP_NOT_REQUIRED;
74 case 0xb2: /* lpswe */
75 if ((insn[0] & 0xff) == 0xb2)
76 fixup = FIXUP_NOT_REQUIRED;
79 if ((insn[0] & 0x0f) == 0x05)
80 fixup |= FIXUP_RETURN_REGISTER;
83 if ((insn[0] & 0x0f) == 0x05) /* brasl */
84 fixup |= FIXUP_RETURN_REGISTER;
87 switch (insn[2] & 0xff) {
89 case 0x45: /* bxleg */
90 fixup = FIXUP_BRANCH_NOT_TAKEN;
95 if ((insn[2] & 0xff) == 0x46)
96 fixup = FIXUP_BRANCH_NOT_TAKEN;
99 switch (insn[2] & 0xff) {
100 case 0xe5: /* clgrb */
101 case 0xe6: /* cgrb */
103 case 0xf7: /* clrb */
104 case 0xfc: /* cgib */
105 case 0xfd: /* cglib */
107 case 0xff: /* clib */
108 fixup = FIXUP_BRANCH_NOT_TAKEN;
116 int probe_is_insn_relative_long(u16 *insn)
118 /* Check if we have a RIL-b or RIL-c format instruction which
119 * we need to modify in order to avoid instruction emulation. */
120 switch (insn[0] >> 8) {
122 if ((insn[0] & 0x0f) == 0x00) /* larl */
126 switch (insn[0] & 0x0f) {
127 case 0x02: /* llhrl */
128 case 0x04: /* lghrl */
129 case 0x05: /* lhrl */
130 case 0x06: /* llghrl */
131 case 0x07: /* sthrl */
132 case 0x08: /* lgrl */
133 case 0x0b: /* stgrl */
134 case 0x0c: /* lgfrl */
136 case 0x0e: /* llgfrl */
137 case 0x0f: /* strl */
142 switch (insn[0] & 0x0f) {
143 case 0x02: /* pfdrl */
144 case 0x04: /* cghrl */
145 case 0x05: /* chrl */
146 case 0x06: /* clghrl */
147 case 0x07: /* clhrl */
148 case 0x08: /* cgrl */
149 case 0x0a: /* clgrl */
150 case 0x0c: /* cgfrl */
152 case 0x0e: /* clgfrl */
153 case 0x0f: /* clrl */