[PATCH 1/6] powerpc test_emulate_step: update nip with patched instruction address
Jordan Niethe
jniethe5 at gmail.com
Tue Jun 23 09:41:58 AEST 2020
On Mon, Jun 22, 2020 at 5:10 PM Balamuruhan S <bala24 at linux.ibm.com> wrote:
>
> pt_regs are initialized to zero in the test infrastructure, R bit
> in prefixed instruction form is used to specify whether the effective
> address of the storage operand is computed relative to the address
> of the instruction.
>
> If R = 1 and RA = R0|0, the sum of the address of the instruction
> and the value SI is placed into register RT. So to assert the emulated
> instruction with executed instruction, update nip of emulated pt_regs.
>
> Signed-off-by: Balamuruhan S <bala24 at linux.ibm.com>
> ---
> arch/powerpc/lib/test_emulate_step.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/lib/test_emulate_step.c b/arch/powerpc/lib/test_emulate_step.c
> index 33a72b7d2764..d5902b7b4e5c 100644
> --- a/arch/powerpc/lib/test_emulate_step.c
> +++ b/arch/powerpc/lib/test_emulate_step.c
> @@ -1204,13 +1204,24 @@ static struct compute_test compute_tests[] = {
> static int __init emulate_compute_instr(struct pt_regs *regs,
> struct ppc_inst instr)
> {
> + int prefix_r, ra;
> extern s32 patch__exec_instr;
> struct instruction_op op;
>
> if (!regs || !ppc_inst_val(instr))
> return -EINVAL;
>
> - regs->nip = patch_site_addr(&patch__exec_instr);
Is there any harm in just always setting the NIP like this instead of
only setting it for relative prefixed instructions?
> + /*
> + * If R=1 and RA=0 in Prefixed instruction form, calculate the address
> + * of the instruction and update nip to assert with executed
> + * instruction
> + */
> + if (ppc_inst_prefixed(instr)) {
> + prefix_r = ppc_inst_val(instr) & (1UL << 20);
> + ra = (ppc_inst_suffix(instr) >> 16) & 0x1f;
> + if (prefix_r && !ra)
> + regs->nip = patch_site_addr(&patch__exec_instr);
> + }
>
> if (analyse_instr(&op, regs, instr) != 1 ||
> GETTYPE(op.type) != COMPUTE) {
> --
> 2.24.1
>
More information about the Linuxppc-dev
mailing list