Skip to content

Commit

Permalink
powerpc/sstep: Introduce macros to retrieve Prefix instruction operands
Browse files Browse the repository at this point in the history
retrieve prefix instruction operands RA and pc relative bit R values
using macros and adopt it in sstep.c and test_emulate_step.c.

Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200626095158.1031507-4-bala24@linux.ibm.com
  • Loading branch information
Balamuruhan S authored and Michael Ellerman committed Jul 23, 2020
1 parent 7e67c73 commit 68a180a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions arch/powerpc/include/asm/sstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ enum instruction_type {

#define MKOP(t, f, s) ((t) | (f) | SIZE(s))

/* Prefix instruction operands */
#define GET_PREFIX_RA(i) (((i) >> 16) & 0x1f)
#define GET_PREFIX_R(i) ((i) & (1ul << 20))

struct instruction_op {
int type;
int reg;
Expand Down
12 changes: 6 additions & 6 deletions arch/powerpc/lib/sstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ static nokprobe_inline unsigned long mlsd_8lsd_ea(unsigned int instr,
unsigned int dd;
unsigned long ea, d0, d1, d;

prefix_r = instr & (1ul << 20);
ra = (suffix >> 16) & 0x1f;
prefix_r = GET_PREFIX_R(instr);
ra = GET_PREFIX_RA(suffix);

d0 = instr & 0x3ffff;
d1 = suffix & 0xffff;
Expand Down Expand Up @@ -1339,8 +1339,8 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
switch (opcode) {
#ifdef __powerpc64__
case 1:
prefix_r = word & (1ul << 20);
ra = (suffix >> 16) & 0x1f;
prefix_r = GET_PREFIX_R(word);
ra = GET_PREFIX_RA(suffix);
rd = (suffix >> 21) & 0x1f;
op->reg = rd;
op->val = regs->gpr[rd];
Expand Down Expand Up @@ -2715,8 +2715,8 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
}
break;
case 1: /* Prefixed instructions */
prefix_r = word & (1ul << 20);
ra = (suffix >> 16) & 0x1f;
prefix_r = GET_PREFIX_R(word);
ra = GET_PREFIX_RA(suffix);
op->update_reg = ra;
rd = (suffix >> 21) & 0x1f;
op->reg = rd;
Expand Down

0 comments on commit 68a180a

Please sign in to comment.