Lines Matching refs:addr
42 int raw_patch_instruction(u32 *addr, struct ppc_inst instr) in raw_patch_instruction() argument
44 return __patch_instruction(addr, instr, addr); in raw_patch_instruction()
86 static int map_patch_area(void *addr, unsigned long text_poke_addr) in map_patch_area() argument
91 if (is_vmalloc_or_module_addr(addr)) in map_patch_area()
92 pfn = vmalloc_to_pfn(addr); in map_patch_area()
94 pfn = __pa_symbol(addr) >> PAGE_SHIFT; in map_patch_area()
105 static inline int unmap_patch_area(unsigned long addr) in unmap_patch_area() argument
113 pgdp = pgd_offset_k(addr); in unmap_patch_area()
117 p4dp = p4d_offset(pgdp, addr); in unmap_patch_area()
121 pudp = pud_offset(p4dp, addr); in unmap_patch_area()
125 pmdp = pmd_offset(pudp, addr); in unmap_patch_area()
129 ptep = pte_offset_kernel(pmdp, addr); in unmap_patch_area()
133 pr_devel("clearing mm %p, pte %p, addr %lx\n", &init_mm, ptep, addr); in unmap_patch_area()
138 pte_clear(&init_mm, addr, ptep); in unmap_patch_area()
139 flush_tlb_kernel_range(addr, addr + PAGE_SIZE); in unmap_patch_area()
144 static int do_patch_instruction(u32 *addr, struct ppc_inst instr) in do_patch_instruction() argument
150 unsigned long kaddr = (unsigned long)addr; in do_patch_instruction()
158 return raw_patch_instruction(addr, instr); in do_patch_instruction()
162 text_poke_addr = (unsigned long)__this_cpu_read(text_poke_area)->addr; in do_patch_instruction()
163 if (map_patch_area(addr, text_poke_addr)) { in do_patch_instruction()
170 __patch_instruction(addr, instr, patch_addr); in do_patch_instruction()
183 static int do_patch_instruction(u32 *addr, struct ppc_inst instr) in do_patch_instruction() argument
185 return raw_patch_instruction(addr, instr); in do_patch_instruction()
190 int patch_instruction(u32 *addr, struct ppc_inst instr) in patch_instruction() argument
193 if (init_mem_is_free && init_section_contains(addr, 4)) { in patch_instruction()
194 pr_debug("Skipping init section patching addr: 0x%px\n", addr); in patch_instruction()
197 return do_patch_instruction(addr, instr); in patch_instruction()
201 int patch_branch(u32 *addr, unsigned long target, int flags) in patch_branch() argument
205 create_branch(&instr, addr, target, flags); in patch_branch()
206 return patch_instruction(addr, instr); in patch_branch()
258 int create_branch(struct ppc_inst *instr, const u32 *addr, in create_branch() argument
266 offset = offset - (unsigned long)addr; in create_branch()
278 int create_cond_branch(struct ppc_inst *instr, const u32 *addr, in create_cond_branch() argument
285 offset = offset - (unsigned long)addr; in create_cond_branch()
383 void __patch_exception(int exc, unsigned long addr) in __patch_exception() argument
394 patch_branch(ibase + (exc / 4) + 1, addr, 0); in __patch_exception()
400 static int instr_is_branch_to_addr(const u32 *instr, unsigned long addr) in instr_is_branch_to_addr() argument
404 return branch_target(instr) == addr; in instr_is_branch_to_addr()
423 unsigned long addr = (unsigned long)tmp; in test_branch_iform() local
451 check(instr_is_branch_to_addr(iptr, addr + 0x1FFFFFC)); in test_branch_iform()
454 check(instr_is_branch_to_addr(iptr, addr - 4)); in test_branch_iform()
457 check(instr_is_branch_to_addr(iptr, addr - 0x2000000)); in test_branch_iform()
460 err = create_branch(&instr, iptr, addr, BRANCH_SET_LINK); in test_branch_iform()
462 check(instr_is_branch_to_addr(iptr, addr)); in test_branch_iform()
465 err = create_branch(&instr, iptr, addr - 0x100, BRANCH_SET_LINK); in test_branch_iform()
467 check(instr_is_branch_to_addr(iptr, addr - 0x100)); in test_branch_iform()
470 err = create_branch(&instr, iptr, addr + 0x100, 0); in test_branch_iform()
472 check(instr_is_branch_to_addr(iptr, addr + 0x100)); in test_branch_iform()
475 err = create_branch(&instr, iptr, addr - 0x2000000, BRANCH_SET_LINK); in test_branch_iform()
477 check(instr_is_branch_to_addr(iptr, addr - 0x2000000)); in test_branch_iform()
480 err = create_branch(&instr, iptr, addr - 0x2000004, BRANCH_SET_LINK); in test_branch_iform()
484 err = create_branch(&instr, iptr, addr + 0x2000000, BRANCH_SET_LINK); in test_branch_iform()
488 err = create_branch(&instr, iptr, addr + 3, BRANCH_SET_LINK); in test_branch_iform()
492 err = create_branch(&instr, iptr, addr, 0xFFFFFFFC); in test_branch_iform()
494 check(instr_is_branch_to_addr(iptr, addr)); in test_branch_iform()
515 unsigned long addr; in test_branch_bform() local
521 addr = (unsigned long)iptr; in test_branch_bform()
540 check(instr_is_branch_to_addr(iptr, addr + 0x7FFC)); in test_branch_bform()
543 check(instr_is_branch_to_addr(iptr, addr - 4)); in test_branch_bform()
546 check(instr_is_branch_to_addr(iptr, addr - 0x8000)); in test_branch_bform()
552 err = create_cond_branch(&instr, iptr, addr, flags); in test_branch_bform()
554 check(instr_is_branch_to_addr(iptr, addr)); in test_branch_bform()
557 err = create_cond_branch(&instr, iptr, addr - 0x100, flags); in test_branch_bform()
559 check(instr_is_branch_to_addr(iptr, addr - 0x100)); in test_branch_bform()
562 err = create_cond_branch(&instr, iptr, addr + 0x100, flags); in test_branch_bform()
564 check(instr_is_branch_to_addr(iptr, addr + 0x100)); in test_branch_bform()
567 err = create_cond_branch(&instr, iptr, addr - 0x8000, flags); in test_branch_bform()
569 check(instr_is_branch_to_addr(iptr, addr - 0x8000)); in test_branch_bform()
572 err = create_cond_branch(&instr, iptr, addr - 0x8004, flags); in test_branch_bform()
576 err = create_cond_branch(&instr, iptr, addr + 0x8000, flags); in test_branch_bform()
580 err = create_cond_branch(&instr, iptr, addr + 3, flags); in test_branch_bform()
584 err = create_cond_branch(&instr, iptr, addr, 0xFFFFFFFC); in test_branch_bform()
586 check(instr_is_branch_to_addr(iptr, addr)); in test_branch_bform()
592 unsigned long addr; in test_translate_branch() local
604 addr = (unsigned long)p; in test_translate_branch()
605 patch_branch(p, addr, 0); in test_translate_branch()
606 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
610 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
614 addr = (unsigned long)p; in test_translate_branch()
615 patch_branch(p, addr, 0); in test_translate_branch()
619 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
620 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
625 addr = (unsigned long)p; in test_translate_branch()
626 patch_branch(p, addr, 0); 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()
636 addr = 0x1000000 + (unsigned long)buf; in test_translate_branch()
637 patch_branch(p, addr, BRANCH_SET_LINK); in test_translate_branch()
641 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
642 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
646 addr = 0x2000000 + (unsigned long)buf; in test_translate_branch()
647 patch_branch(p, addr, 0); in test_translate_branch()
651 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()
659 addr = (unsigned long)p; in test_translate_branch()
660 create_cond_branch(&instr, p, addr, 0); in test_translate_branch()
662 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
666 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
670 addr = (unsigned long)p; in test_translate_branch()
671 create_cond_branch(&instr, p, addr, 0xFFFFFFFC); in test_translate_branch()
676 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
677 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
682 addr = (unsigned long)p; in test_translate_branch()
683 create_cond_branch(&instr, p, addr, 0xFFFFFFFC); in test_translate_branch()
688 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
689 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
694 addr = 0x3000 + (unsigned long)buf; in test_translate_branch()
695 create_cond_branch(&instr, p, addr, BRANCH_SET_LINK); in test_translate_branch()
700 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
701 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
705 addr = 0x4000 + (unsigned long)buf; in test_translate_branch()
706 create_cond_branch(&instr, p, addr, 0); in test_translate_branch()
711 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
712 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()