File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING
1616CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING
1717endif
1818
19- obj-y += alloc.o code-patching.o feature-fixups.o pmem.o inst.o
19+ obj-y += alloc.o code-patching.o feature-fixups.o pmem.o inst.o test_code-patching.o
2020
2121ifndef CONFIG_KASAN
2222obj-y += string.o memcmp_$(BITS ) .o
Original file line number Diff line number Diff line change @@ -708,6 +708,26 @@ static void __init test_translate_branch(void)
708708 vfree (buf );
709709}
710710
711+ #ifdef CONFIG_PPC64
712+ static void __init test_prefixed_patching (void )
713+ {
714+ extern unsigned int code_patching_test1 [];
715+ extern unsigned int code_patching_test1_expected [];
716+ extern unsigned int end_code_patching_test1 [];
717+
718+ __patch_instruction ((struct ppc_inst * )code_patching_test1 ,
719+ ppc_inst_prefix (OP_PREFIX << 26 , 0x00000000 ),
720+ (struct ppc_inst * )code_patching_test1 );
721+
722+ check (!memcmp (code_patching_test1 ,
723+ code_patching_test1_expected ,
724+ sizeof (unsigned int ) *
725+ (end_code_patching_test1 - code_patching_test1 )));
726+ }
727+ #else
728+ static inline void test_prefixed_patching (void ) {}
729+ #endif
730+
711731static int __init test_code_patching (void )
712732{
713733 printk (KERN_DEBUG "Running code patching self-tests ...\n" );
@@ -716,6 +736,7 @@ static int __init test_code_patching(void)
716736 test_branch_bform ();
717737 test_create_function_call ();
718738 test_translate_branch ();
739+ test_prefixed_patching ();
719740
720741 return 0 ;
721742}
Original file line number Diff line number Diff line change 1+ /* SPDX-License-Identifier: GPL-2.0 */
2+ /*
3+ * Copyright (C) 2020 IBM Corporation
4+ */
5+ #include <asm/ppc-opcode.h>
6+
7+ .text
8+
9+ #define globl(x) \
10+ .globl x; \
11+ x:
12+
13+ globl(code_patching_test1)
14+ nop
15+ nop
16+ globl(end_code_patching_test1)
17+
18+ globl(code_patching_test1_expected)
19+ .long OP_PREFIX << 26
20+ .long 0x0000000
You can’t perform that action at this time.
0 commit comments