diff mbox series

[3/5] powerpc sstep: Set NIP in instruction emulation tests

Message ID 20200525025923.19843-3-jniethe5@gmail.com (mailing list archive)
State Accepted
Commit 1c89cf7fbed36f078b20fd47d308b4fc6dbff5f6
Headers show
Series [1/5] powerpc sstep: Add tests for prefixed integer load/stores | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (1ef93962cf4293ec9e1bb3163cc4b7dcfc3de84f)
snowpatch_ozlabs/checkpatch warning total: 0 errors, 1 warnings, 0 checks, 14 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Jordan Niethe May 25, 2020, 2:59 a.m. UTC
The tests for emulation of compute instructions execute and
emulate an instruction and then compare the results to verify the
emulation. In ISA v3.1 there are instructions that operate relative to
the NIP. Therefore set the NIP in the regs used for the emulated
instruction to the location of the executed instruction so they will
give the same result.

This is a rework of a patch by Balamuruhan S.

Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
---
 arch/powerpc/lib/test_emulate_step.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/arch/powerpc/lib/test_emulate_step.c b/arch/powerpc/lib/test_emulate_step.c
index 9599f3a03ca1..427c2ca8191e 100644
--- a/arch/powerpc/lib/test_emulate_step.c
+++ b/arch/powerpc/lib/test_emulate_step.c
@@ -1076,11 +1076,14 @@  static struct compute_test compute_tests[] = {
 static int __init emulate_compute_instr(struct pt_regs *regs,
 					struct ppc_inst instr)
 {
+	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);
+
 	if (analyse_instr(&op, regs, instr) != 1 ||
 	    GETTYPE(op.type) != COMPUTE) {
 		pr_info("emulation failed, instruction = 0x%08x\n", ppc_inst_val(instr));