Skip to content

Commit ff14a9c

Browse files
chleroympe
authored andcommitted
powerpc/code-patching: Use test_trampoline for prefixed patch test
Use the dedicated test_trampoline function for testing prefixed patching like other tests and remove the hand coded assembly stuff. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/a450ef3f8653f75e1bd9aaf7a3889d379752f33b.1638446239.git.christophe.leroy@csgroup.eu
1 parent d5937db commit ff14a9c

File tree

3 files changed

+10
-36
lines changed

3 files changed

+10
-36
lines changed

arch/powerpc/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING
1919
CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING
2020
endif
2121

22-
obj-y += alloc.o code-patching.o feature-fixups.o pmem.o test_code-patching.o
22+
obj-y += alloc.o code-patching.o feature-fixups.o pmem.o
2323

2424
ifndef CONFIG_KASAN
2525
obj-y += string.o memcmp_$(BITS).o

arch/powerpc/lib/code-patching.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static int __init instr_is_branch_to_addr(const u32 *instr, unsigned long addr)
399399

400400
static void __init test_trampoline(void)
401401
{
402-
asm ("nop;\n");
402+
asm ("nop;nop;\n");
403403
}
404404

405405
#define check(x) do { \
@@ -708,25 +708,19 @@ static void __init test_translate_branch(void)
708708
vfree(buf);
709709
}
710710

711-
#ifdef CONFIG_PPC64
712711
static void __init test_prefixed_patching(void)
713712
{
714-
extern unsigned int code_patching_test1[];
715-
extern unsigned int code_patching_test1_expected[];
716-
extern unsigned int end_code_patching_test1[];
713+
u32 *iptr = (u32 *)ppc_function_entry(test_trampoline);
714+
u32 expected[2] = {OP_PREFIX << 26, 0};
715+
ppc_inst_t inst = ppc_inst_prefix(OP_PREFIX << 26, 0);
717716

718-
__patch_instruction(code_patching_test1,
719-
ppc_inst_prefix(OP_PREFIX << 26, 0x00000000),
720-
code_patching_test1);
717+
if (!IS_ENABLED(CONFIG_PPC64))
718+
return;
719+
720+
patch_instruction(iptr, inst);
721721

722-
check(!memcmp(code_patching_test1,
723-
code_patching_test1_expected,
724-
sizeof(unsigned int) *
725-
(end_code_patching_test1 - code_patching_test1)));
722+
check(!memcmp(iptr, expected, sizeof(expected)));
726723
}
727-
#else
728-
static inline void test_prefixed_patching(void) {}
729-
#endif
730724

731725
static int __init test_code_patching(void)
732726
{

arch/powerpc/lib/test_code-patching.S

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)