Michal Suchanek ff6bd7
From 718aae916fa6619c57c348beaedd675835cf1aa1 Mon Sep 17 00:00:00 2001
Michal Suchanek ff6bd7
From: Ananth N Mavinakayanahalli <ananth@linux.ibm.com>
Michal Suchanek ff6bd7
Date: Mon, 25 Jan 2021 18:36:43 +0530
Michal Suchanek ff6bd7
Subject: [PATCH] powerpc/sstep: Fix incorrect return from analyze_instr()
Michal Suchanek ff6bd7
Michal Suchanek ff6bd7
References: bsc#1156395
Michal Suchanek ff6bd7
Patch-mainline: v5.12-rc1
Michal Suchanek ff6bd7
Git-commit: 718aae916fa6619c57c348beaedd675835cf1aa1
Michal Suchanek ff6bd7
Michal Suchanek ff6bd7
We currently just percolate the return value from analyze_instr()
Michal Suchanek ff6bd7
to the caller of emulate_step(), especially if it is a -1.
Michal Suchanek ff6bd7
Michal Suchanek ff6bd7
For one particular case (opcode = 4) for instructions that aren't
Michal Suchanek ff6bd7
currently emulated, we are returning 'should not be single-stepped'
Michal Suchanek ff6bd7
while we should have returned 0 which says 'did not emulate, may
Michal Suchanek ff6bd7
have to single-step'.
Michal Suchanek ff6bd7
Michal Suchanek ff6bd7
Fixes: 930d6288a26787 ("powerpc: sstep: Add support for maddhd, maddhdu, maddld instructions")
Michal Suchanek ff6bd7
Signed-off-by: Ananth N Mavinakayanahalli <ananth@linux.ibm.com>
Michal Suchanek ff6bd7
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Michal Suchanek ff6bd7
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Michal Suchanek ff6bd7
Reviewed-by: Sandipan Das <sandipan@linux.ibm.com>
Michal Suchanek ff6bd7
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Michal Suchanek ff6bd7
Link: https://lore.kernel.org/r/161157999039.64773.14950289716779364766.stgit@thinktux.local
Michal Suchanek ff6bd7
Acked-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek ff6bd7
---
Michal Suchanek ff6bd7
 arch/powerpc/lib/sstep.c | 7 ++++++-
Michal Suchanek ff6bd7
 1 file changed, 6 insertions(+), 1 deletion(-)
Michal Suchanek ff6bd7
Michal Suchanek ff6bd7
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
Michal Suchanek ff6bd7
index f859cbbb6375..e96cff845ef7 100644
Michal Suchanek ff6bd7
--- a/arch/powerpc/lib/sstep.c
Michal Suchanek ff6bd7
+++ b/arch/powerpc/lib/sstep.c
Michal Suchanek ff6bd7
@@ -1445,6 +1445,11 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
Michal Suchanek ff6bd7
 
Michal Suchanek ff6bd7
 #ifdef __powerpc64__
Michal Suchanek ff6bd7
 	case 4:
Michal Suchanek ff6bd7
+		/*
Michal Suchanek ff6bd7
+		 * There are very many instructions with this primary opcode
Michal Suchanek ff6bd7
+		 * introduced in the ISA as early as v2.03. However, the ones
Michal Suchanek ff6bd7
+		 * we currently emulate were all introduced with ISA 3.0
Michal Suchanek ff6bd7
+		 */
Michal Suchanek ff6bd7
 		if (!cpu_has_feature(CPU_FTR_ARCH_300))
Michal Suchanek ff6bd7
 			goto unknown_opcode;
Michal Suchanek ff6bd7
 
Michal Suchanek ff6bd7
@@ -1472,7 +1477,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
Michal Suchanek ff6bd7
 		 * There are other instructions from ISA 3.0 with the same
Michal Suchanek ff6bd7
 		 * primary opcode which do not have emulation support yet.
Michal Suchanek ff6bd7
 		 */
Michal Suchanek ff6bd7
-		return -1;
Michal Suchanek ff6bd7
+		goto unknown_opcode;
Michal Suchanek ff6bd7
 #endif
Michal Suchanek ff6bd7
 
Michal Suchanek ff6bd7
 	case 7:		/* mulli */
Michal Suchanek ff6bd7
-- 
Michal Suchanek ff6bd7
2.26.2
Michal Suchanek ff6bd7