Lines Matching full:addr

38 int raw_patch_instruction(struct ppc_inst *addr, struct ppc_inst instr)  in raw_patch_instruction()  argument
40 return __patch_instruction(addr, instr, addr); in raw_patch_instruction()
88 static int map_patch_area(void *addr, unsigned long text_poke_addr) in map_patch_area() argument
93 if (is_vmalloc_or_module_addr(addr)) in map_patch_area()
94 pfn = vmalloc_to_pfn(addr); in map_patch_area()
96 pfn = __pa_symbol(addr) >> PAGE_SHIFT; in map_patch_area()
100 pr_devel("Mapped addr %lx with pfn %lx:%d\n", text_poke_addr, pfn, err); in map_patch_area()
107 static inline int unmap_patch_area(unsigned long addr) in unmap_patch_area() argument
115 pgdp = pgd_offset_k(addr); in unmap_patch_area()
119 p4dp = p4d_offset(pgdp, addr); in unmap_patch_area()
123 pudp = pud_offset(p4dp, 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(struct ppc_inst *addr, struct ppc_inst 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()
172 __patch_instruction(addr, instr, patch_addr); in do_patch_instruction()
185 static int do_patch_instruction(struct ppc_inst *addr, struct ppc_inst instr) in do_patch_instruction() argument
187 return raw_patch_instruction(addr, instr); in do_patch_instruction()
192 int patch_instruction(struct ppc_inst *addr, struct ppc_inst instr) in patch_instruction() argument
195 if (init_mem_is_free && init_section_contains(addr, 4)) { in patch_instruction()
196 pr_debug("Skipping init section patching addr: 0x%px\n", addr); in patch_instruction()
199 return do_patch_instruction(addr, instr); in patch_instruction()
203 int patch_branch(struct ppc_inst *addr, unsigned long target, int flags) in patch_branch() argument
207 create_branch(&instr, addr, target, flags); in patch_branch()
208 return patch_instruction(addr, instr); in patch_branch()
256 const struct ppc_inst *addr, in create_branch() argument
264 offset = offset - (unsigned long)addr; in create_branch()
276 int create_cond_branch(struct ppc_inst *instr, const struct ppc_inst *addr, in create_cond_branch() argument
283 offset = offset - (unsigned long)addr; in create_cond_branch()
365 int instr_is_branch_to_addr(const struct ppc_inst *instr, unsigned long addr) in instr_is_branch_to_addr() argument
369 return branch_target(instr) == addr; in instr_is_branch_to_addr()
391 void __patch_exception(int exc, unsigned long addr) in __patch_exception() argument
402 patch_branch((struct ppc_inst *)(ibase + (exc / 4) + 1), addr, 0); in __patch_exception()
420 unsigned long addr; in test_branch_iform() local
422 addr = (unsigned long)&instr; in test_branch_iform()
450 check(instr_is_branch_to_addr(&instr, addr + 0x1FFFFFC)); in test_branch_iform()
453 check(instr_is_branch_to_addr(&instr, addr - 4)); in test_branch_iform()
456 check(instr_is_branch_to_addr(&instr, addr - 0x2000000)); in test_branch_iform()
459 err = create_branch(&instr, &instr, addr, BRANCH_SET_LINK); in test_branch_iform()
460 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_iform()
463 err = create_branch(&instr, &instr, addr - 0x100, BRANCH_SET_LINK); in test_branch_iform()
464 check(instr_is_branch_to_addr(&instr, addr - 0x100)); in test_branch_iform()
467 err = create_branch(&instr, &instr, addr + 0x100, 0); in test_branch_iform()
468 check(instr_is_branch_to_addr(&instr, addr + 0x100)); in test_branch_iform()
471 err = create_branch(&instr, &instr, addr - 0x2000000, BRANCH_SET_LINK); in test_branch_iform()
472 check(instr_is_branch_to_addr(&instr, addr - 0x2000000)); in test_branch_iform()
475 err = create_branch(&instr, &instr, addr - 0x2000004, BRANCH_SET_LINK); in test_branch_iform()
479 err = create_branch(&instr, &instr, addr + 0x2000000, BRANCH_SET_LINK); in test_branch_iform()
483 err = create_branch(&instr, &instr, addr + 3, BRANCH_SET_LINK); in test_branch_iform()
487 err = create_branch(&instr, &instr, addr, 0xFFFFFFFC); in test_branch_iform()
488 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_iform()
509 unsigned long addr; in test_branch_bform() local
514 addr = (unsigned long)iptr; in test_branch_bform()
533 check(instr_is_branch_to_addr(&instr, addr + 0x7FFC)); in test_branch_bform()
536 check(instr_is_branch_to_addr(&instr, addr - 4)); in test_branch_bform()
539 check(instr_is_branch_to_addr(&instr, addr - 0x8000)); in test_branch_bform()
545 err = create_cond_branch(&instr, iptr, addr, flags); in test_branch_bform()
546 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_bform()
549 err = create_cond_branch(&instr, iptr, addr - 0x100, flags); in test_branch_bform()
550 check(instr_is_branch_to_addr(&instr, addr - 0x100)); in test_branch_bform()
553 err = create_cond_branch(&instr, iptr, addr + 0x100, flags); in test_branch_bform()
554 check(instr_is_branch_to_addr(&instr, addr + 0x100)); in test_branch_bform()
557 err = create_cond_branch(&instr, iptr, addr - 0x8000, flags); in test_branch_bform()
558 check(instr_is_branch_to_addr(&instr, addr - 0x8000)); in test_branch_bform()
561 err = create_cond_branch(&instr, iptr, addr - 0x8004, flags); in test_branch_bform()
565 err = create_cond_branch(&instr, iptr, addr + 0x8000, flags); in test_branch_bform()
569 err = create_cond_branch(&instr, iptr, addr + 3, flags); in test_branch_bform()
573 err = create_cond_branch(&instr, iptr, addr, 0xFFFFFFFC); in test_branch_bform()
574 check(instr_is_branch_to_addr(&instr, addr)); in test_branch_bform()
580 unsigned long addr; in test_translate_branch() local
592 addr = (unsigned long)p; in test_translate_branch()
593 patch_branch(p, addr, 0); in test_translate_branch()
594 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
598 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
600 /* Maximum negative case, move b . to addr + 32 MB */ in test_translate_branch()
602 addr = (unsigned long)p; in test_translate_branch()
603 patch_branch(p, addr, 0); in test_translate_branch()
607 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
608 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
613 addr = (unsigned long)p; in test_translate_branch()
614 patch_branch(p, addr, 0); in test_translate_branch()
618 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
619 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
624 addr = 0x1000000 + (unsigned long)buf; in test_translate_branch()
625 patch_branch(p, addr, BRANCH_SET_LINK); in test_translate_branch()
629 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
630 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
634 addr = 0x2000000 + (unsigned long)buf; in test_translate_branch()
635 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 create_cond_branch(&instr, p, addr, 0); in test_translate_branch()
650 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
654 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()
656 /* Maximum negative case, move b . to addr + 32 KB */ in test_translate_branch()
658 addr = (unsigned long)p; in test_translate_branch()
659 create_cond_branch(&instr, p, addr, 0xFFFFFFFC); in test_translate_branch()
664 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
665 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 = 0x3000 + (unsigned long)buf; in test_translate_branch()
683 create_cond_branch(&instr, p, addr, BRANCH_SET_LINK); 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()
693 addr = 0x4000 + (unsigned long)buf; in test_translate_branch()
694 create_cond_branch(&instr, p, addr, 0); in test_translate_branch()
699 check(instr_is_branch_to_addr(p, addr)); in test_translate_branch()
700 check(instr_is_branch_to_addr(q, addr)); in test_translate_branch()