]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/powerpc/lib/code-patching.c
powerpc: Avoid code patching freed init sections
[mirror_ubuntu-bionic-kernel.git] / arch / powerpc / lib / code-patching.c
1 /*
2 * Copyright 2008 Michael Ellerman, IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10 #include <linux/kernel.h>
11 #include <linux/kprobes.h>
12 #include <linux/vmalloc.h>
13 #include <linux/init.h>
14 #include <linux/mm.h>
15 #include <linux/cpuhotplug.h>
16 #include <linux/slab.h>
17 #include <linux/uaccess.h>
18 #include <linux/kprobes.h>
19
20 #include <asm/pgtable.h>
21 #include <asm/tlbflush.h>
22 #include <asm/page.h>
23 #include <asm/code-patching.h>
24 #include <asm/sections.h>
25 #include <asm/setup.h>
26
27 static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,
28 unsigned int *patch_addr)
29 {
30 int err;
31
32 /* Make sure we aren't patching a freed init section */
33 if (init_mem_is_free && init_section_contains(exec_addr, 4)) {
34 pr_debug("Skipping init section patching addr: 0x%px\n", exec_addr);
35 return 0;
36 }
37
38 __put_user_size(instr, patch_addr, 4, err);
39 if (err)
40 return err;
41
42 asm ("dcbst 0, %0; sync; icbi 0,%1; sync; isync" :: "r" (patch_addr),
43 "r" (exec_addr));
44
45 return 0;
46 }
47
48 int raw_patch_instruction(unsigned int *addr, unsigned int instr)
49 {
50 return __patch_instruction(addr, instr, addr);
51 }
52
53 #ifdef CONFIG_STRICT_KERNEL_RWX
54 static DEFINE_PER_CPU(struct vm_struct *, text_poke_area);
55
56 static int text_area_cpu_up(unsigned int cpu)
57 {
58 struct vm_struct *area;
59
60 area = get_vm_area(PAGE_SIZE, VM_ALLOC);
61 if (!area) {
62 WARN_ONCE(1, "Failed to create text area for cpu %d\n",
63 cpu);
64 return -1;
65 }
66 this_cpu_write(text_poke_area, area);
67
68 return 0;
69 }
70
71 static int text_area_cpu_down(unsigned int cpu)
72 {
73 free_vm_area(this_cpu_read(text_poke_area));
74 return 0;
75 }
76
77 /*
78 * Run as a late init call. This allows all the boot time patching to be done
79 * simply by patching the code, and then we're called here prior to
80 * mark_rodata_ro(), which happens after all init calls are run. Although
81 * BUG_ON() is rude, in this case it should only happen if ENOMEM, and we judge
82 * it as being preferable to a kernel that will crash later when someone tries
83 * to use patch_instruction().
84 */
85 static int __init setup_text_poke_area(void)
86 {
87 BUG_ON(!cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
88 "powerpc/text_poke:online", text_area_cpu_up,
89 text_area_cpu_down));
90
91 return 0;
92 }
93 late_initcall(setup_text_poke_area);
94
95 /*
96 * This can be called for kernel text or a module.
97 */
98 static int map_patch_area(void *addr, unsigned long text_poke_addr)
99 {
100 unsigned long pfn;
101 int err;
102
103 if (is_vmalloc_addr(addr))
104 pfn = vmalloc_to_pfn(addr);
105 else
106 pfn = __pa_symbol(addr) >> PAGE_SHIFT;
107
108 err = map_kernel_page(text_poke_addr, (pfn << PAGE_SHIFT),
109 pgprot_val(PAGE_KERNEL));
110
111 pr_devel("Mapped addr %lx with pfn %lx:%d\n", text_poke_addr, pfn, err);
112 if (err)
113 return -1;
114
115 return 0;
116 }
117
118 static inline int unmap_patch_area(unsigned long addr)
119 {
120 pte_t *ptep;
121 pmd_t *pmdp;
122 pud_t *pudp;
123 pgd_t *pgdp;
124
125 pgdp = pgd_offset_k(addr);
126 if (unlikely(!pgdp))
127 return -EINVAL;
128
129 pudp = pud_offset(pgdp, addr);
130 if (unlikely(!pudp))
131 return -EINVAL;
132
133 pmdp = pmd_offset(pudp, addr);
134 if (unlikely(!pmdp))
135 return -EINVAL;
136
137 ptep = pte_offset_kernel(pmdp, addr);
138 if (unlikely(!ptep))
139 return -EINVAL;
140
141 pr_devel("clearing mm %p, pte %p, addr %lx\n", &init_mm, ptep, addr);
142
143 /*
144 * In hash, pte_clear flushes the tlb, in radix, we have to
145 */
146 pte_clear(&init_mm, addr, ptep);
147 flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
148
149 return 0;
150 }
151
152 int patch_instruction(unsigned int *addr, unsigned int instr)
153 {
154 int err;
155 unsigned int *patch_addr = NULL;
156 unsigned long flags;
157 unsigned long text_poke_addr;
158 unsigned long kaddr = (unsigned long)addr;
159
160 /*
161 * During early early boot patch_instruction is called
162 * when text_poke_area is not ready, but we still need
163 * to allow patching. We just do the plain old patching
164 */
165 if (!this_cpu_read(text_poke_area))
166 return raw_patch_instruction(addr, instr);
167
168 local_irq_save(flags);
169
170 text_poke_addr = (unsigned long)__this_cpu_read(text_poke_area)->addr;
171 if (map_patch_area(addr, text_poke_addr)) {
172 err = -1;
173 goto out;
174 }
175
176 patch_addr = (unsigned int *)(text_poke_addr) +
177 ((kaddr & ~PAGE_MASK) / sizeof(unsigned int));
178
179 __patch_instruction(addr, instr, patch_addr);
180
181 err = unmap_patch_area(text_poke_addr);
182 if (err)
183 pr_warn("failed to unmap %lx\n", text_poke_addr);
184
185 out:
186 local_irq_restore(flags);
187
188 return err;
189 }
190 #else /* !CONFIG_STRICT_KERNEL_RWX */
191
192 int patch_instruction(unsigned int *addr, unsigned int instr)
193 {
194 return raw_patch_instruction(addr, instr);
195 }
196
197 #endif /* CONFIG_STRICT_KERNEL_RWX */
198 NOKPROBE_SYMBOL(patch_instruction);
199
200 int patch_branch(unsigned int *addr, unsigned long target, int flags)
201 {
202 return patch_instruction(addr, create_branch(addr, target, flags));
203 }
204
205 int patch_branch_site(s32 *site, unsigned long target, int flags)
206 {
207 unsigned int *addr;
208
209 addr = (unsigned int *)((unsigned long)site + *site);
210 return patch_instruction(addr, create_branch(addr, target, flags));
211 }
212
213 int patch_instruction_site(s32 *site, unsigned int instr)
214 {
215 unsigned int *addr;
216
217 addr = (unsigned int *)((unsigned long)site + *site);
218 return patch_instruction(addr, instr);
219 }
220
221 bool is_offset_in_branch_range(long offset)
222 {
223 /*
224 * Powerpc branch instruction is :
225 *
226 * 0 6 30 31
227 * +---------+----------------+---+---+
228 * | opcode | LI |AA |LK |
229 * +---------+----------------+---+---+
230 * Where AA = 0 and LK = 0
231 *
232 * LI is a signed 24 bits integer. The real branch offset is computed
233 * by: imm32 = SignExtend(LI:'0b00', 32);
234 *
235 * So the maximum forward branch should be:
236 * (0x007fffff << 2) = 0x01fffffc = 0x1fffffc
237 * The maximum backward branch should be:
238 * (0xff800000 << 2) = 0xfe000000 = -0x2000000
239 */
240 return (offset >= -0x2000000 && offset <= 0x1fffffc && !(offset & 0x3));
241 }
242
243 /*
244 * Helper to check if a given instruction is a conditional branch
245 * Derived from the conditional checks in analyse_instr()
246 */
247 bool is_conditional_branch(unsigned int instr)
248 {
249 unsigned int opcode = instr >> 26;
250
251 if (opcode == 16) /* bc, bca, bcl, bcla */
252 return true;
253 if (opcode == 19) {
254 switch ((instr >> 1) & 0x3ff) {
255 case 16: /* bclr, bclrl */
256 case 528: /* bcctr, bcctrl */
257 case 560: /* bctar, bctarl */
258 return true;
259 }
260 }
261 return false;
262 }
263 NOKPROBE_SYMBOL(is_conditional_branch);
264
265 unsigned int create_branch(const unsigned int *addr,
266 unsigned long target, int flags)
267 {
268 unsigned int instruction;
269 long offset;
270
271 offset = target;
272 if (! (flags & BRANCH_ABSOLUTE))
273 offset = offset - (unsigned long)addr;
274
275 /* Check we can represent the target in the instruction format */
276 if (!is_offset_in_branch_range(offset))
277 return 0;
278
279 /* Mask out the flags and target, so they don't step on each other. */
280 instruction = 0x48000000 | (flags & 0x3) | (offset & 0x03FFFFFC);
281
282 return instruction;
283 }
284
285 unsigned int create_cond_branch(const unsigned int *addr,
286 unsigned long target, int flags)
287 {
288 unsigned int instruction;
289 long offset;
290
291 offset = target;
292 if (! (flags & BRANCH_ABSOLUTE))
293 offset = offset - (unsigned long)addr;
294
295 /* Check we can represent the target in the instruction format */
296 if (offset < -0x8000 || offset > 0x7FFF || offset & 0x3)
297 return 0;
298
299 /* Mask out the flags and target, so they don't step on each other. */
300 instruction = 0x40000000 | (flags & 0x3FF0003) | (offset & 0xFFFC);
301
302 return instruction;
303 }
304
305 static unsigned int branch_opcode(unsigned int instr)
306 {
307 return (instr >> 26) & 0x3F;
308 }
309
310 static int instr_is_branch_iform(unsigned int instr)
311 {
312 return branch_opcode(instr) == 18;
313 }
314
315 static int instr_is_branch_bform(unsigned int instr)
316 {
317 return branch_opcode(instr) == 16;
318 }
319
320 int instr_is_relative_branch(unsigned int instr)
321 {
322 if (instr & BRANCH_ABSOLUTE)
323 return 0;
324
325 return instr_is_branch_iform(instr) || instr_is_branch_bform(instr);
326 }
327
328 int instr_is_relative_link_branch(unsigned int instr)
329 {
330 return instr_is_relative_branch(instr) && (instr & BRANCH_SET_LINK);
331 }
332
333 static unsigned long branch_iform_target(const unsigned int *instr)
334 {
335 signed long imm;
336
337 imm = *instr & 0x3FFFFFC;
338
339 /* If the top bit of the immediate value is set this is negative */
340 if (imm & 0x2000000)
341 imm -= 0x4000000;
342
343 if ((*instr & BRANCH_ABSOLUTE) == 0)
344 imm += (unsigned long)instr;
345
346 return (unsigned long)imm;
347 }
348
349 static unsigned long branch_bform_target(const unsigned int *instr)
350 {
351 signed long imm;
352
353 imm = *instr & 0xFFFC;
354
355 /* If the top bit of the immediate value is set this is negative */
356 if (imm & 0x8000)
357 imm -= 0x10000;
358
359 if ((*instr & BRANCH_ABSOLUTE) == 0)
360 imm += (unsigned long)instr;
361
362 return (unsigned long)imm;
363 }
364
365 unsigned long branch_target(const unsigned int *instr)
366 {
367 if (instr_is_branch_iform(*instr))
368 return branch_iform_target(instr);
369 else if (instr_is_branch_bform(*instr))
370 return branch_bform_target(instr);
371
372 return 0;
373 }
374
375 int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr)
376 {
377 if (instr_is_branch_iform(*instr) || instr_is_branch_bform(*instr))
378 return branch_target(instr) == addr;
379
380 return 0;
381 }
382
383 unsigned int translate_branch(const unsigned int *dest, const unsigned int *src)
384 {
385 unsigned long target;
386
387 target = branch_target(src);
388
389 if (instr_is_branch_iform(*src))
390 return create_branch(dest, target, *src);
391 else if (instr_is_branch_bform(*src))
392 return create_cond_branch(dest, target, *src);
393
394 return 0;
395 }
396
397 #ifdef CONFIG_PPC_BOOK3E_64
398 void __patch_exception(int exc, unsigned long addr)
399 {
400 extern unsigned int interrupt_base_book3e;
401 unsigned int *ibase = &interrupt_base_book3e;
402
403 /* Our exceptions vectors start with a NOP and -then- a branch
404 * to deal with single stepping from userspace which stops on
405 * the second instruction. Thus we need to patch the second
406 * instruction of the exception, not the first one
407 */
408
409 patch_branch(ibase + (exc / 4) + 1, addr, 0);
410 }
411 #endif
412
413 #ifdef CONFIG_CODE_PATCHING_SELFTEST
414
415 static void __init test_trampoline(void)
416 {
417 asm ("nop;\n");
418 }
419
420 #define check(x) \
421 if (!(x)) printk("code-patching: test failed at line %d\n", __LINE__);
422
423 static void __init test_branch_iform(void)
424 {
425 unsigned int instr;
426 unsigned long addr;
427
428 addr = (unsigned long)&instr;
429
430 /* The simplest case, branch to self, no flags */
431 check(instr_is_branch_iform(0x48000000));
432 /* All bits of target set, and flags */
433 check(instr_is_branch_iform(0x4bffffff));
434 /* High bit of opcode set, which is wrong */
435 check(!instr_is_branch_iform(0xcbffffff));
436 /* Middle bits of opcode set, which is wrong */
437 check(!instr_is_branch_iform(0x7bffffff));
438
439 /* Simplest case, branch to self with link */
440 check(instr_is_branch_iform(0x48000001));
441 /* All bits of targets set */
442 check(instr_is_branch_iform(0x4bfffffd));
443 /* Some bits of targets set */
444 check(instr_is_branch_iform(0x4bff00fd));
445 /* Must be a valid branch to start with */
446 check(!instr_is_branch_iform(0x7bfffffd));
447
448 /* Absolute branch to 0x100 */
449 instr = 0x48000103;
450 check(instr_is_branch_to_addr(&instr, 0x100));
451 /* Absolute branch to 0x420fc */
452 instr = 0x480420ff;
453 check(instr_is_branch_to_addr(&instr, 0x420fc));
454 /* Maximum positive relative branch, + 20MB - 4B */
455 instr = 0x49fffffc;
456 check(instr_is_branch_to_addr(&instr, addr + 0x1FFFFFC));
457 /* Smallest negative relative branch, - 4B */
458 instr = 0x4bfffffc;
459 check(instr_is_branch_to_addr(&instr, addr - 4));
460 /* Largest negative relative branch, - 32 MB */
461 instr = 0x4a000000;
462 check(instr_is_branch_to_addr(&instr, addr - 0x2000000));
463
464 /* Branch to self, with link */
465 instr = create_branch(&instr, addr, BRANCH_SET_LINK);
466 check(instr_is_branch_to_addr(&instr, addr));
467
468 /* Branch to self - 0x100, with link */
469 instr = create_branch(&instr, addr - 0x100, BRANCH_SET_LINK);
470 check(instr_is_branch_to_addr(&instr, addr - 0x100));
471
472 /* Branch to self + 0x100, no link */
473 instr = create_branch(&instr, addr + 0x100, 0);
474 check(instr_is_branch_to_addr(&instr, addr + 0x100));
475
476 /* Maximum relative negative offset, - 32 MB */
477 instr = create_branch(&instr, addr - 0x2000000, BRANCH_SET_LINK);
478 check(instr_is_branch_to_addr(&instr, addr - 0x2000000));
479
480 /* Out of range relative negative offset, - 32 MB + 4*/
481 instr = create_branch(&instr, addr - 0x2000004, BRANCH_SET_LINK);
482 check(instr == 0);
483
484 /* Out of range relative positive offset, + 32 MB */
485 instr = create_branch(&instr, addr + 0x2000000, BRANCH_SET_LINK);
486 check(instr == 0);
487
488 /* Unaligned target */
489 instr = create_branch(&instr, addr + 3, BRANCH_SET_LINK);
490 check(instr == 0);
491
492 /* Check flags are masked correctly */
493 instr = create_branch(&instr, addr, 0xFFFFFFFC);
494 check(instr_is_branch_to_addr(&instr, addr));
495 check(instr == 0x48000000);
496 }
497
498 static void __init test_create_function_call(void)
499 {
500 unsigned int *iptr;
501 unsigned long dest;
502
503 /* Check we can create a function call */
504 iptr = (unsigned int *)ppc_function_entry(test_trampoline);
505 dest = ppc_function_entry(test_create_function_call);
506 patch_instruction(iptr, create_branch(iptr, dest, BRANCH_SET_LINK));
507 check(instr_is_branch_to_addr(iptr, dest));
508 }
509
510 static void __init test_branch_bform(void)
511 {
512 unsigned long addr;
513 unsigned int *iptr, instr, flags;
514
515 iptr = &instr;
516 addr = (unsigned long)iptr;
517
518 /* The simplest case, branch to self, no flags */
519 check(instr_is_branch_bform(0x40000000));
520 /* All bits of target set, and flags */
521 check(instr_is_branch_bform(0x43ffffff));
522 /* High bit of opcode set, which is wrong */
523 check(!instr_is_branch_bform(0xc3ffffff));
524 /* Middle bits of opcode set, which is wrong */
525 check(!instr_is_branch_bform(0x7bffffff));
526
527 /* Absolute conditional branch to 0x100 */
528 instr = 0x43ff0103;
529 check(instr_is_branch_to_addr(&instr, 0x100));
530 /* Absolute conditional branch to 0x20fc */
531 instr = 0x43ff20ff;
532 check(instr_is_branch_to_addr(&instr, 0x20fc));
533 /* Maximum positive relative conditional branch, + 32 KB - 4B */
534 instr = 0x43ff7ffc;
535 check(instr_is_branch_to_addr(&instr, addr + 0x7FFC));
536 /* Smallest negative relative conditional branch, - 4B */
537 instr = 0x43fffffc;
538 check(instr_is_branch_to_addr(&instr, addr - 4));
539 /* Largest negative relative conditional branch, - 32 KB */
540 instr = 0x43ff8000;
541 check(instr_is_branch_to_addr(&instr, addr - 0x8000));
542
543 /* All condition code bits set & link */
544 flags = 0x3ff000 | BRANCH_SET_LINK;
545
546 /* Branch to self */
547 instr = create_cond_branch(iptr, addr, flags);
548 check(instr_is_branch_to_addr(&instr, addr));
549
550 /* Branch to self - 0x100 */
551 instr = create_cond_branch(iptr, addr - 0x100, flags);
552 check(instr_is_branch_to_addr(&instr, addr - 0x100));
553
554 /* Branch to self + 0x100 */
555 instr = create_cond_branch(iptr, addr + 0x100, flags);
556 check(instr_is_branch_to_addr(&instr, addr + 0x100));
557
558 /* Maximum relative negative offset, - 32 KB */
559 instr = create_cond_branch(iptr, addr - 0x8000, flags);
560 check(instr_is_branch_to_addr(&instr, addr - 0x8000));
561
562 /* Out of range relative negative offset, - 32 KB + 4*/
563 instr = create_cond_branch(iptr, addr - 0x8004, flags);
564 check(instr == 0);
565
566 /* Out of range relative positive offset, + 32 KB */
567 instr = create_cond_branch(iptr, addr + 0x8000, flags);
568 check(instr == 0);
569
570 /* Unaligned target */
571 instr = create_cond_branch(iptr, addr + 3, flags);
572 check(instr == 0);
573
574 /* Check flags are masked correctly */
575 instr = create_cond_branch(iptr, addr, 0xFFFFFFFC);
576 check(instr_is_branch_to_addr(&instr, addr));
577 check(instr == 0x43FF0000);
578 }
579
580 static void __init test_translate_branch(void)
581 {
582 unsigned long addr;
583 unsigned int *p, *q;
584 void *buf;
585
586 buf = vmalloc(PAGE_ALIGN(0x2000000 + 1));
587 check(buf);
588 if (!buf)
589 return;
590
591 /* Simple case, branch to self moved a little */
592 p = buf;
593 addr = (unsigned long)p;
594 patch_branch(p, addr, 0);
595 check(instr_is_branch_to_addr(p, addr));
596 q = p + 1;
597 patch_instruction(q, translate_branch(q, p));
598 check(instr_is_branch_to_addr(q, addr));
599
600 /* Maximum negative case, move b . to addr + 32 MB */
601 p = buf;
602 addr = (unsigned long)p;
603 patch_branch(p, addr, 0);
604 q = buf + 0x2000000;
605 patch_instruction(q, translate_branch(q, p));
606 check(instr_is_branch_to_addr(p, addr));
607 check(instr_is_branch_to_addr(q, addr));
608 check(*q == 0x4a000000);
609
610 /* Maximum positive case, move x to x - 32 MB + 4 */
611 p = buf + 0x2000000;
612 addr = (unsigned long)p;
613 patch_branch(p, addr, 0);
614 q = buf + 4;
615 patch_instruction(q, translate_branch(q, p));
616 check(instr_is_branch_to_addr(p, addr));
617 check(instr_is_branch_to_addr(q, addr));
618 check(*q == 0x49fffffc);
619
620 /* Jump to x + 16 MB moved to x + 20 MB */
621 p = buf;
622 addr = 0x1000000 + (unsigned long)buf;
623 patch_branch(p, addr, BRANCH_SET_LINK);
624 q = buf + 0x1400000;
625 patch_instruction(q, translate_branch(q, p));
626 check(instr_is_branch_to_addr(p, addr));
627 check(instr_is_branch_to_addr(q, addr));
628
629 /* Jump to x + 16 MB moved to x - 16 MB + 4 */
630 p = buf + 0x1000000;
631 addr = 0x2000000 + (unsigned long)buf;
632 patch_branch(p, addr, 0);
633 q = buf + 4;
634 patch_instruction(q, translate_branch(q, p));
635 check(instr_is_branch_to_addr(p, addr));
636 check(instr_is_branch_to_addr(q, addr));
637
638
639 /* Conditional branch tests */
640
641 /* Simple case, branch to self moved a little */
642 p = buf;
643 addr = (unsigned long)p;
644 patch_instruction(p, create_cond_branch(p, addr, 0));
645 check(instr_is_branch_to_addr(p, addr));
646 q = p + 1;
647 patch_instruction(q, translate_branch(q, p));
648 check(instr_is_branch_to_addr(q, addr));
649
650 /* Maximum negative case, move b . to addr + 32 KB */
651 p = buf;
652 addr = (unsigned long)p;
653 patch_instruction(p, create_cond_branch(p, addr, 0xFFFFFFFC));
654 q = buf + 0x8000;
655 patch_instruction(q, translate_branch(q, p));
656 check(instr_is_branch_to_addr(p, addr));
657 check(instr_is_branch_to_addr(q, addr));
658 check(*q == 0x43ff8000);
659
660 /* Maximum positive case, move x to x - 32 KB + 4 */
661 p = buf + 0x8000;
662 addr = (unsigned long)p;
663 patch_instruction(p, create_cond_branch(p, addr, 0xFFFFFFFC));
664 q = buf + 4;
665 patch_instruction(q, translate_branch(q, p));
666 check(instr_is_branch_to_addr(p, addr));
667 check(instr_is_branch_to_addr(q, addr));
668 check(*q == 0x43ff7ffc);
669
670 /* Jump to x + 12 KB moved to x + 20 KB */
671 p = buf;
672 addr = 0x3000 + (unsigned long)buf;
673 patch_instruction(p, create_cond_branch(p, addr, BRANCH_SET_LINK));
674 q = buf + 0x5000;
675 patch_instruction(q, translate_branch(q, p));
676 check(instr_is_branch_to_addr(p, addr));
677 check(instr_is_branch_to_addr(q, addr));
678
679 /* Jump to x + 8 KB moved to x - 8 KB + 4 */
680 p = buf + 0x2000;
681 addr = 0x4000 + (unsigned long)buf;
682 patch_instruction(p, create_cond_branch(p, addr, 0));
683 q = buf + 4;
684 patch_instruction(q, translate_branch(q, p));
685 check(instr_is_branch_to_addr(p, addr));
686 check(instr_is_branch_to_addr(q, addr));
687
688 /* Free the buffer we were using */
689 vfree(buf);
690 }
691
692 static int __init test_code_patching(void)
693 {
694 printk(KERN_DEBUG "Running code patching self-tests ...\n");
695
696 test_branch_iform();
697 test_branch_bform();
698 test_create_function_call();
699 test_translate_branch();
700
701 return 0;
702 }
703 late_initcall(test_code_patching);
704
705 #endif /* CONFIG_CODE_PATCHING_SELFTEST */