Lines Matching refs:addr
42 int raw_patch_instruction(unsigned int *addr, unsigned int instr) in raw_patch_instruction() argument
44 return __patch_instruction(addr, instr, addr); in raw_patch_instruction()
92 static int map_patch_area(void *addr, unsigned long text_poke_addr) in map_patch_area() argument
97 if (is_vmalloc_addr(addr)) in map_patch_area()
98 pfn = vmalloc_to_pfn(addr); in map_patch_area()
100 pfn = __pa_symbol(addr) >> PAGE_SHIFT; in map_patch_area()
112 static inline int unmap_patch_area(unsigned long addr) in unmap_patch_area() argument
119 pgdp = pgd_offset_k(addr); in unmap_patch_area()
123 pudp = pud_offset(pgdp, addr); in unmap_patch_area()
127 pmdp = pmd_offset(pudp, addr); in unmap_patch_area()
131 ptep = pte_offset_kernel(pmdp, addr); in unmap_patch_area()
135 pr_devel("clearing mm %p, pte %p, addr %lx\n", &init_mm, ptep, addr); in unmap_patch_area()
140 pte_clear(&init_mm, addr, ptep); in unmap_patch_area()
141 flush_tlb_kernel_range(addr, addr + PAGE_SIZE); in unmap_patch_area()
146 static int do_patch_instruction(unsigned int *addr, unsigned int instr) in do_patch_instruction() argument
152 unsigned long kaddr = (unsigned long)addr; in do_patch_instruction()
160 return raw_patch_instruction(addr, instr); in do_patch_instruction()
164 text_poke_addr = (unsigned long)__this_cpu_read(text_poke_area)->addr; in do_patch_instruction()
165 if (map_patch_area(addr, text_poke_addr)) { in do_patch_instruction()
173 __patch_instruction(addr, instr, patch_addr); in do_patch_instruction()
186 static int do_patch_instruction(unsigned int *addr, unsigned int instr) in do_patch_instruction() argument
188 return raw_patch_instruction(addr, instr); in do_patch_instruction()
193 int patch_instruction(unsigned int *addr, unsigned int instr) in patch_instruction() argument
196 if (init_mem_is_free && init_section_contains(addr, 4)) { in patch_instruction()
197 pr_debug("Skipping init section patching addr: 0x%px\n", addr); in patch_instruction()
200 return do_patch_instruction(addr, instr); in patch_instruction()
204 int patch_branch(unsigned int *addr, unsigned long target, int flags) in patch_branch() argument
206 return patch_instruction(addr, create_branch(addr, target, flags)); in patch_branch()
211 unsigned int *addr; in patch_branch_site() local
213 addr = (unsigned int *)((unsigned long)site + *site); in patch_branch_site()
214 return patch_instruction(addr, create_branch(addr, target, flags)); in patch_branch_site()
219 unsigned int *addr; in patch_instruction_site() local
221 addr = (unsigned int *)((unsigned long)site + *site); in patch_instruction_site()
222 return patch_instruction(addr, instr); in patch_instruction_site()
269 unsigned int create_branch(const unsigned int *addr, in create_branch() argument
277 offset = offset - (unsigned long)addr; in create_branch()
289 unsigned int create_cond_branch(const unsigned int *addr, in create_cond_branch() argument
297 offset = offset - (unsigned long)addr; in create_cond_branch()
379 int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr) in instr_is_branch_to_addr() argument
382 return branch_target(instr) == addr; in instr_is_branch_to_addr()
402 void __patch_exception(int exc, unsigned long addr) in __patch_exception() argument
413 patch_branch(ibase + (exc / 4) + 1, addr, 0); in __patch_exception()
430 unsigned long addr; in test_branch_iform() local
432 addr = (unsigned long)&instr; in test_branch_iform()
460 check(instr_is_branch_to_addr(&instr, addr + 0x1FFFFFC)); in test_branch_iform()
463 check(instr_is_branch_to_addr(&instr, addr - 4)); in test_branch_iform()
466 check(instr_is_branch_to_addr(&instr, addr - 0x2000000)); in test_branch_iform()
469 instr = create_branch(&instr, addr, BRANCH_SET_LINK); in test_branch_iform()
470 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_iform()
473 instr = create_branch(&instr, addr - 0x100, BRANCH_SET_LINK); in test_branch_iform()
474 check(instr_is_branch_to_addr(&instr, addr - 0x100)); in test_branch_iform()
477 instr = create_branch(&instr, addr + 0x100, 0); in test_branch_iform()
478 check(instr_is_branch_to_addr(&instr, addr + 0x100)); in test_branch_iform()
481 instr = create_branch(&instr, addr - 0x2000000, BRANCH_SET_LINK); in test_branch_iform()
482 check(instr_is_branch_to_addr(&instr, addr - 0x2000000)); in test_branch_iform()
485 instr = create_branch(&instr, addr - 0x2000004, BRANCH_SET_LINK); in test_branch_iform()
489 instr = create_branch(&instr, addr + 0x2000000, BRANCH_SET_LINK); in test_branch_iform()
493 instr = create_branch(&instr, addr + 3, BRANCH_SET_LINK); in test_branch_iform()
497 instr = create_branch(&instr, addr, 0xFFFFFFFC); in test_branch_iform()
498 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_iform()
516 unsigned long addr; in test_branch_bform() local
520 addr = (unsigned long)iptr; in test_branch_bform()
539 check(instr_is_branch_to_addr(&instr, addr + 0x7FFC)); in test_branch_bform()
542 check(instr_is_branch_to_addr(&instr, addr - 4)); in test_branch_bform()
545 check(instr_is_branch_to_addr(&instr, addr - 0x8000)); in test_branch_bform()
551 instr = create_cond_branch(iptr, addr, flags); in test_branch_bform()
552 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_bform()
555 instr = create_cond_branch(iptr, addr - 0x100, flags); in test_branch_bform()
556 check(instr_is_branch_to_addr(&instr, addr - 0x100)); in test_branch_bform()
559 instr = create_cond_branch(iptr, addr + 0x100, flags); in test_branch_bform()
560 check(instr_is_branch_to_addr(&instr, addr + 0x100)); in test_branch_bform()
563 instr = create_cond_branch(iptr, addr - 0x8000, flags); in test_branch_bform()
564 check(instr_is_branch_to_addr(&instr, addr - 0x8000)); in test_branch_bform()
567 instr = create_cond_branch(iptr, addr - 0x8004, flags); in test_branch_bform()
571 instr = create_cond_branch(iptr, addr + 0x8000, flags); in test_branch_bform()
575 instr = create_cond_branch(iptr, addr + 3, flags); in test_branch_bform()
579 instr = create_cond_branch(iptr, addr, 0xFFFFFFFC); in test_branch_bform()
580 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_bform()
586 unsigned long addr; in test_translate_branch() local
597 addr = (unsigned long)p; in test_translate_branch()
598 patch_branch(p, addr, 0); in test_translate_branch()
599 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
602 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
606 addr = (unsigned long)p; in test_translate_branch()
607 patch_branch(p, addr, 0); in test_translate_branch()
610 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
611 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
616 addr = (unsigned long)p; in test_translate_branch()
617 patch_branch(p, addr, 0); in test_translate_branch()
620 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
621 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
626 addr = 0x1000000 + (unsigned long)buf; in test_translate_branch()
627 patch_branch(p, addr, BRANCH_SET_LINK); in test_translate_branch()
630 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
631 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
635 addr = 0x2000000 + (unsigned long)buf; in test_translate_branch()
636 patch_branch(p, addr, 0); in test_translate_branch()
639 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
640 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
647 addr = (unsigned long)p; in test_translate_branch()
648 patch_instruction(p, create_cond_branch(p, addr, 0)); in test_translate_branch()
649 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
652 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
656 addr = (unsigned long)p; in test_translate_branch()
657 patch_instruction(p, create_cond_branch(p, addr, 0xFFFFFFFC)); in test_translate_branch()
660 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
661 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
666 addr = (unsigned long)p; in test_translate_branch()
667 patch_instruction(p, create_cond_branch(p, addr, 0xFFFFFFFC)); in test_translate_branch()
670 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
671 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
676 addr = 0x3000 + (unsigned long)buf; in test_translate_branch()
677 patch_instruction(p, create_cond_branch(p, addr, BRANCH_SET_LINK)); in test_translate_branch()
680 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
681 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
685 addr = 0x4000 + (unsigned long)buf; in test_translate_branch()
686 patch_instruction(p, create_cond_branch(p, addr, 0)); in test_translate_branch()
689 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
690 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()