Skip to contentSkip to conversation

s390/probes: Various fixes

PATCH New Heiko Carstens 2 participants 7 messages Oct 12 s390

lore
Share & tools
lore

Heiko Carstens

author maintainer
#0 lore raw

cover s390/probes: Various fixes

Fix various bugs in uprobes/kprobes instruction fixup handling:

- For cgrb a wrong (non existing) opcode is used for comparison
- Handling for bctgr and bic instructions is missing
- Wrong comment for clgib

Thanks,
Heiko

Heiko Carstens (3):
s390/probes: Fix wrong opcode for cgrb fixup s390/probes: Add missing fixup for bctgr and bic s390/probes: Fix wrong mnemonic comment for clgib

 arch/s390/lib/probes.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/3 s390/probes: Fix wrong opcode for cgrb fixup

The last byte of the cgrb instruction is 0xe4, however the probes code compares against 0xe6. Fix it.

Fixes 6b169ac9b434 ("s390/kprobes: add support for compare and branch instructions")
---
 arch/s390/lib/probes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/lib/probes.c +1 -1
index 1e184a03442d..049300b68ddd 100644
@@ -99,8 +99,8 @@ int probe_get_fixup_type(u16 *insn)
 		break;
 	case 0xec:
 		switch (insn[2] & 0xff) {
+		case 0xe4: /* cgrb  */
 		case 0xe5: /* clgrb */
-		case 0xe6: /* cgrb  */
 		case 0xf6: /* crb   */
 		case 0xf7: /* clrb  */
 		case 0xfc: /* cgib  */
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH 2/3 s390/probes: Add missing fixup for bctgr and bic

In reply to Heiko Carstens

For the bctgr and bic instructions the probes fixup is missing. For both instructions the instruction address must only be fixed up if the branch is not taken. If the branch is taken the instruction address is already correct.

Return FIXUP_BRANCH_NOT_TAKEN instead of the default FIXUP_PSW_NORMAL to reflect that.

---
 arch/s390/lib/probes.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
arch/s390/lib/probes.c +12 -4
index 049300b68ddd..3e7654223b05 100644
@@ -77,6 +77,10 @@ int probe_get_fixup_type(u16 *insn)
 		if ((insn[0] & 0xff) == 0xb2)
 			fixup = FIXUP_NOT_REQUIRED;
 		break;
+	case 0xb9:	/* bctgr */
+		if ((insn[0] & 0xff) == 0x46)
+			fixup = FIXUP_BRANCH_NOT_TAKEN;
+		break;
 	case 0xa7:	/* bras	*/
 		if ((insn[0] & 0x0f) == 0x05)
 			fixup |= FIXUP_RETURN_REGISTER;
@@ -85,6 +89,14 @@ int probe_get_fixup_type(u16 *insn)
 		if ((insn[0] & 0x0f) == 0x05)	/* brasl */
 			fixup |= FIXUP_RETURN_REGISTER;
 		break;
+	case 0xe3:
+		switch (insn[2] & 0xff) {
+		case 0x46: /* bctg */
+		case 0x47: /* bic  */
+			fixup = FIXUP_BRANCH_NOT_TAKEN;
+			break;
+		}
+		break;
 	case 0xeb:
 		switch (insn[2] & 0xff) {
 		case 0x44: /* bxhg  */
@@ -93,10 +105,6 @@ int probe_get_fixup_type(u16 *insn)
 			break;
 		}
 		break;
-	case 0xe3:	/* bctg	*/
-		if ((insn[2] & 0xff) == 0x46)
-			fixup = FIXUP_BRANCH_NOT_TAKEN;
-		break;
 	case 0xec:
 		switch (insn[2] & 0xff) {
 		case 0xe4: /* cgrb  */
Signature · 1 line
2.53.0
author maintainer
#5 lore raw

PATCH 3/3 s390/probes: Fix wrong mnemonic comment for clgib

In reply to Heiko Carstens

There is no cglib instruction; the correct mnemonic is clgib. Fix the comment.

Fixes 6b169ac9b434 ("s390/kprobes: add support for compare and branch instructions")
---
 arch/s390/lib/probes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/lib/probes.c +1 -1
index 3e7654223b05..66221ec16822 100644
@@ -112,7 +112,7 @@ int probe_get_fixup_type(u16 *insn)
 		case 0xf6: /* crb   */
 		case 0xf7: /* clrb  */
 		case 0xfc: /* cgib  */
-		case 0xfd: /* cglib */
+		case 0xfd: /* clgib */
 		case 0xfe: /* cib   */
 		case 0xff: /* clib  */
 			fixup = FIXUP_BRANCH_NOT_TAKEN;
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH 3/3] s390/probes: Fix wrong mnemonic comment for clgib

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

There is no cglib instruction; the correct mnemonic is clgib. Fix the comment.

Fixes 6b169ac9b434 ("s390/kprobes: add support for compare and branch instructions")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#2 lore raw

Re: [PATCH 1/3] s390/probes: Fix wrong opcode for cgrb fixup

In reply to Heiko Carstens
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines

The last byte of the cgrb instruction is 0xe4, however the probes code compares against 0xe6. Fix it.

Fixes 6b169ac9b434 ("s390/kprobes: add support for compare and branch instructions")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#4 lore raw

Re: [PATCH 2/3] s390/probes: Add missing fixup for bctgr and bic

In reply to Heiko Carstens
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines

For the bctgr and bic instructions the probes fixup is missing. For both instructions the instruction address must only be fixed up if the branch is not taken. If the branch is taken the instruction address is already correct.

Return FIXUP_BRANCH_NOT_TAKEN instead of the default FIXUP_PSW_NORMAL to reflect that.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2