Commit 0b582db5 authored by Jordan Niethe's avatar Jordan Niethe Committed by Michael Ellerman

powerpc: Make test_translate_branch() independent of instruction length

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: default avatarJordan Niethe <jniethe5@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Reviewed-by: default avatarAlistair Popple <alistair@popple.id.au>
Link: https://lore.kernel.org/r/20200506034050.24806-21-jniethe5@gmail.com
parent 7fccfcfb
...@@ -572,7 +572,7 @@ static void __init test_branch_bform(void) ...@@ -572,7 +572,7 @@ static void __init test_branch_bform(void)
static void __init test_translate_branch(void) static void __init test_translate_branch(void)
{ {
unsigned long addr; unsigned long addr;
struct ppc_inst *p, *q; void *p, *q;
struct ppc_inst instr; struct ppc_inst instr;
void *buf; void *buf;
...@@ -586,7 +586,7 @@ static void __init test_translate_branch(void) ...@@ -586,7 +586,7 @@ static void __init test_translate_branch(void)
addr = (unsigned long)p; addr = (unsigned long)p;
patch_branch(p, addr, 0); patch_branch(p, addr, 0);
check(instr_is_branch_to_addr(p, addr)); check(instr_is_branch_to_addr(p, addr));
q = p + 1; q = p + 4;
translate_branch(&instr, q, p); translate_branch(&instr, q, p);
patch_instruction(q, instr); patch_instruction(q, instr);
check(instr_is_branch_to_addr(q, addr)); check(instr_is_branch_to_addr(q, addr));
...@@ -642,7 +642,7 @@ static void __init test_translate_branch(void) ...@@ -642,7 +642,7 @@ static void __init test_translate_branch(void)
create_cond_branch(&instr, p, addr, 0); create_cond_branch(&instr, p, addr, 0);
patch_instruction(p, instr); patch_instruction(p, instr);
check(instr_is_branch_to_addr(p, addr)); check(instr_is_branch_to_addr(p, addr));
q = p + 1; q = buf + 4;
translate_branch(&instr, q, p); translate_branch(&instr, q, p);
patch_instruction(q, instr); patch_instruction(q, instr);
check(instr_is_branch_to_addr(q, addr)); check(instr_is_branch_to_addr(q, addr));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment