diff mbox series

[v4,10/16] powerpc: Make test_translate_branch() independent of instruction length

Message ID 20200320051809.24332-11-jniethe5@gmail.com (mailing list archive)
State Superseded
Headers show
Series Initial Prefixed Instruction support | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (8a445cbcb9f5090cb07ec6cbb89a8a1fc99a0ff7)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (59ed2adf393109c56d383e568f2e57bb5ad6d901)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (6c90b86a745a446717fdf408c4a8a4631a5e8ee3)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (af3d0a68698c7e5df8b72267086b23422a3954bb)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (aff7e57f8266549245eb4a272ce149b752dfce77)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Jordan Niethe March 20, 2020, 5:18 a.m. UTC
test_translate_branch() uses two pointers to instructions within a
buffer, p and q, to test patch_branch(). The pointer arithmetic done on
them assumes a size of 4. This will not work if the instruction length
changes. Instead do the arithmetic relative to the void * to the buffer.

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

Patch

diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index 88ee03ff55f1..fa7f32adf029 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -563,7 +563,7 @@  static void __init test_branch_bform(void)
 static void __init test_translate_branch(void)
 {
 	unsigned long addr;
-	ppc_inst *p, *q;
+	void *p, *q;
 	void *buf;
 
 	buf = vmalloc(PAGE_ALIGN(0x2000000 + 1));
@@ -576,7 +576,7 @@  static void __init test_translate_branch(void)
 	addr = (unsigned long)p;
 	patch_branch(p, addr, 0);
 	check(instr_is_branch_to_addr(p, addr));
-	q = p + 1;
+	q = buf + 4;
 	patch_instruction(q, translate_branch(q, p));
 	check(instr_is_branch_to_addr(q, addr));
 
@@ -626,7 +626,7 @@  static void __init test_translate_branch(void)
 	addr = (unsigned long)p;
 	patch_instruction(p, create_cond_branch(p, addr, 0));
 	check(instr_is_branch_to_addr(p, addr));
-	q = p + 1;
+	q = buf + 4;
 	patch_instruction(q, translate_branch(q, p));
 	check(instr_is_branch_to_addr(q, addr));