Skip to content

Commit 68a180a

Browse files
balamuruhansmpe
authored andcommitted
powerpc/sstep: Introduce macros to retrieve Prefix instruction operands
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7e67c73 commit 68a180a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

arch/powerpc/include/asm/sstep.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ enum instruction_type {
104104

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

107+
/* Prefix instruction operands */
108+
#define GET_PREFIX_RA(i) (((i) >> 16) & 0x1f)
109+
#define GET_PREFIX_R(i) ((i) & (1ul << 20))
110+
107111
struct instruction_op {
108112
int type;
109113
int reg;

arch/powerpc/lib/sstep.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ static nokprobe_inline unsigned long mlsd_8lsd_ea(unsigned int instr,
200200
unsigned int dd;
201201
unsigned long ea, d0, d1, d;
202202

203-
prefix_r = instr & (1ul << 20);
204-
ra = (suffix >> 16) & 0x1f;
203+
prefix_r = GET_PREFIX_R(instr);
204+
ra = GET_PREFIX_RA(suffix);
205205

206206
d0 = instr & 0x3ffff;
207207
d1 = suffix & 0xffff;
@@ -1339,8 +1339,8 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
13391339
switch (opcode) {
13401340
#ifdef __powerpc64__
13411341
case 1:
1342-
prefix_r = word & (1ul << 20);
1343-
ra = (suffix >> 16) & 0x1f;
1342+
prefix_r = GET_PREFIX_R(word);
1343+
ra = GET_PREFIX_RA(suffix);
13441344
rd = (suffix >> 21) & 0x1f;
13451345
op->reg = rd;
13461346
op->val = regs->gpr[rd];
@@ -2715,8 +2715,8 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
27152715
}
27162716
break;
27172717
case 1: /* Prefixed instructions */
2718-
prefix_r = word & (1ul << 20);
2719-
ra = (suffix >> 16) & 0x1f;
2718+
prefix_r = GET_PREFIX_R(word);
2719+
ra = GET_PREFIX_RA(suffix);
27202720
op->update_reg = ra;
27212721
rd = (suffix >> 21) & 0x1f;
27222722
op->reg = rd;

0 commit comments

Comments
 (0)