函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\events\uprobes.c Create Date:2022-07-27 15:06:19
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:NOTE:* Expect the breakpoint instruction to be the smallest size instruction for* the architecture

函数原型:int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr, uprobe_opcode_t opcode)

返回类型:int

参数:

类型参数名称
struct arch_uprobe *auprobe
struct mm_struct *mm
unsigned longvaddr
uprobe_opcode_topcode
475  ref_ctr_updated等于0
476  bool orig_page_huge = false
477  gup_flags等于get_user_pages read/write w/o permission
479  is_register等于s_swbp_insn - check if instruction is breakpoint instruction.*@insn: instruction to be checked.* Default implementation of is_swbp_insn* Returns true if @insn is a breakpoint instruction.
480  uprobe等于container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(auprobe, structuprobe, arch)
482  retry :
483  如果is_registergup_flags或等于split huge pmd before returning
486  ret等于get_user_pages_remote(NULL, mm, vaddr, 1, gup_flags, & old_page, & vma, NULL)
488  如果ret小于等于0则返回:ret
491  ret等于verify_opcode(old_page, vaddr, & opcode)
492  如果ret小于等于0则转到:put_old
495  如果WARN(!is_register && PageCompound(old_page), "uprobe unregister should never work on compound page\n")则
497  ret等于负EINVAL
498  转到:put_old
502  如果非ref_ctr_updatedref_ctr_offset
503  ret等于update_ref_ctr(uprobe, mm, is_register ? 1 : - 1)
504  如果ret则转到:put_old
507  ref_ctr_updated等于1
510  ret等于0
511  如果非is_register且非PageAnon(old_page)则转到:put_old
514  ret等于anon_vma_prepare(vma)
515  如果ret则转到:put_old
518  ret等于负ENOMEM
519  new_page等于alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vaddr)
520  如果非new_page则转到:put_old
523  __SetPageUptodate(new_page)
524  copy_highpage(new_page, old_page)
525  copy_to_page(new_page, vaddr, & opcode, UPROBE_SWBP_INSN_SIZE)
527  如果非is_register
531  VM_BUG_ON_PAGE(!PageAnon(old_page), old_page)
533  index等于vaddr_to_offset(vma, vaddr & PAGE_MASK)右移PAGE_SHIFT determines the page size
534  orig_page等于d_get_page - find and get a page reference*@mapping: the address_space to search*@offset: the page index* Looks up the page cache slot at @mapping & @offset. If there is a* page cache page, it is returned with an increased refcount.
537  如果orig_page
542  new_page = NULL
544  如果PageCompound(orig_page)则orig_page_huge = true
551  ret等于__replace_page - replace page in vma by new page
552  如果new_pageput_page(new_page)
554  put_old :
555  put_page(old_page)
557  如果此条件成立可能性小(为编译器优化)(ret == - EAGAIN)则转到:retry
561  如果retis_registerref_ctr_updatedupdate_ref_ctr(uprobe, mm, - 1)
565  如果非retorig_page_hugecollapse_pte_mapped_thp(mm, vaddr)
568  返回:ret
调用者
名称描述
set_swbpset_swbp - store breakpoint at a given address.*@auprobe: arch specific probepoint information.*@mm: the probed process address space.*@vaddr: the virtual address to insert the opcode.* For mm @mm, store the breakpoint instruction at @vaddr.
set_orig_insnset_orig_insn - Restore the original instruction.*@mm: the probed process address space.*@auprobe: arch specific probepoint information.*@vaddr: the virtual address to insert the opcode.* For mm @mm, restore the original opcode (opcode) at @vaddr.