This patch adds emulation of the cmpb instruction, enabling xmon to
emulate this instruction.

Signed-off-by: Matt Brown <matthew.brown....@gmail.com>
---
 arch/powerpc/lib/sstep.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 33117f8..f3e9ba8 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -596,6 +596,23 @@ static nokprobe_inline void do_cmp_unsigned(struct pt_regs 
*regs, unsigned long
        regs->ccr = (regs->ccr & ~(0xf << shift)) | (crval << shift);
 }
 
+static nokprobe_inline void do_cmpb(struct pt_regs *regs, unsigned long v1,
+                               unsigned long v2, int rd)
+{
+       unsigned long out_val, mask;
+       int i;
+
+       out_val = 0;
+       for (i = 0; i < 8; i++) {
+               mask = 0xff << (i * 8);
+
+               if ((v1 & mask) == (v2 & mask))
+                       out_val |= mask;
+       }
+
+       regs->gpr[rd] = out_val;
+}
+
 static nokprobe_inline int trap_compare(long v1, long v2)
 {
        int ret = 0;
@@ -1049,6 +1066,13 @@ int analyse_instr(struct instruction_op *op, struct 
pt_regs *regs,
                        do_cmp_unsigned(regs, val, val2, rd >> 2);
                        goto instr_done;
 
+               case 19173952: /* cmpb */
+                       val = regs->gpr[rd];
+                       val2 = regs->gpr[rb];
+
+                       do_cmpb(regs, val, val2, ra);
+                       goto instr_done;
+
 /*
  * Arithmetic instructions
  */
-- 
2.9.3

Reply via email to