问题
Is there any Kernel API to find the VMA corresponds to virtual address?
Example : if a have an address 0x13000 i need some function like below
struct vm_area_struct *vma = vma_corresponds_to (0x13000,task);
回答1:
You're looking for find_vma
in linux/mm.h
.
/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
This should do the trick:
struct vm_area_struct *vma = find_vma(task->mm, 0x13000);
if (vma == NULL)
return -EFAULT;
if (0x13000 >= vma->vm_end)
return -EFAULT;
来源:https://stackoverflow.com/questions/12388403/linux-kernel-api-to-find-the-vma-corresponds-to-a-virtual-address