PPC: sstep.c: Add modsw, moduw instruction emulation
PATCH 1/1 PPC: sstep.c: Add modsw, moduw instruction emulation
Add modsw and moduw instruction emulation support to analyse_instr.
--- arch/powerpc/lib/sstep.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/powerpc/lib/sstep.c +9 -0
@@ -1148,6 +1148,15 @@ int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, (int ) regs->gpr[rb]; goto arith_done; +case 779 :/* modsw */ + regs->gpr[rd] = (int ) regs->gpr[ra] % + (int ) regs->gpr[rb]; + goto arith_done; + +case 267 :/* moduw */ + regs->gpr[rd] = (unsigned int ) regs->gpr[ra] % + (unsigned int ) regs->gpr[rb]; + goto arith_done;/* * Logical instructions
Signature · 1 line
2.9.3
Quoted 3 lines · PrasannaKumar Muralidharan
Add modsw and moduw instruction emulation support to
analyse_instr.Signed-off-by PrasannaKumar Muralidharan <[email protected]>
Hi Prasanna,
Thanks for the patch! A few minor comments below...
Quoted 9 lines
--- arch/powerpc/lib/sstep.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/powerpc/lib/sstep.c +0
-0
arch/powerpc/lib/sstep.c int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, · line 1154
Quoted 7 lines
arch/powerpc/lib/sstep.c +4
-0@@ -1148,6 +1148,15 @@ int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, (int ) regs->gpr[rb]; goto arith_done; +case 779 :/* modsw */ + regs->gpr[rd] = (int ) regs->gpr[ra] % + (int ) regs->gpr[rb]; + goto arith_done;
Since these instructions don't update CR, you can directly goto instr_done.
arch/powerpc/lib/sstep.c int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, · line 1156
Quoted 2 lines
arch/powerpc/lib/sstep.c +2
-0+ +case 267 :/* moduw */
Please move this case further up so that the extended opcodes are in numerical order.
- Naveen
Hi Naveen,
Thanks for the review.
Quoted 12 lines
Quoted 12 lines
--- arch/powerpc/lib/sstep.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/powerpc/lib/sstep.c +0
-0@@ -1148,6 +1148,15 @@ int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, (int ) regs->gpr[rb]; goto arith_done;
Quoted 7 lines
arch/powerpc/lib/sstep.c int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, · line 1154
Quoted 4 lines
arch/powerpc/lib/sstep.c +4
-0+case 779 :/* modsw */ + regs->gpr[rd] = (int ) regs->gpr[ra] % + (int ) regs->gpr[rb]; + goto arith_done;Since these instructions don't update CR, you can directly goto
instr_done.
Sure. Will use that.
Quoted 5 lines
arch/powerpc/lib/sstep.c int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, · line 1156
Quoted 2 lines
arch/powerpc/lib/sstep.c +2
-0+ +case 267 :/* moduw */ Please move this case further up so that the extended opcodes are in numerical order.
Placed it after divide instruction as it appeared logical. Also placed 267 below 779 as it is the order in which the instructions are documented in the ISA book. This may help in finding related instructions together. If this style is not preferred I can arrange it in numerical order.
Regards,
PrasannaKumar
Quoted 11 lines · PrasannaKumar Muralidharan
Quoted 5 lines
arch/powerpc/lib/sstep.c int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs, · line 1156
Quoted 2 lines
arch/powerpc/lib/sstep.c +2
-0+ +case 267 :/* moduw */ Please move this case further up so that the extended opcodes are in numerical order.
Placed it after divide instruction as it appeared logical. Also placed 267 below 779 as it is the order in which the instructions are documented in the ISA book. This may help in finding related instructions together. If this style is not preferred I can arrange it in numerical order.
I guessed as much, but if you look at the existing function, you'll see that things have been arranged in numerical order. As such, it's best to stick to that convention.
- Naveen
By the way, I missed mentioning previously: please use 'powerpc: ' prefix for the subject, rather than PPC.
Quoted 1 line · PrasannaKumar Muralidharan
Add modsw and moduw instruction emulation support to
analyse_instr.
And, it will be better if you can briefly describe what these functions do for the benefit of others.
- Naveen
Quoted 3 lines
I guessed as much, but if you look at the existing function, you'll see that things have been arranged in numerical order. As such, it's best to stick to that convention.
Makes sense. Will do.
Quoted 2 lines
By the way, I missed mentioning previously: please use 'powerpc: ' prefix for the subject, rather than PPC.
I will change it. Wondering how they are different.
Quoted 4 lines
Quoted 1 line
Add modsw and moduw instruction emulation support to
analyse_instr.And, it will be better if you can briefly describe what these functions do for the benefit of others.
Sure. I will add description.
Quoted 4 lines · PrasannaKumar Muralidharan
Quoted 2 lines
By the way, I missed mentioning previously: please use 'powerpc: ' prefix for the subject, rather than PPC.
I will change it. Wondering how they are different.
It's by convention. Maintainers are picky ;)
- Naveen