加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

LInux Kernel API查找vma对应的虚拟地址

发布时间:2020-12-13 23:03:39 所属栏目:Linux 来源:网络整理
导读:是否有任何内核API可以找到VMA对应的??虚拟地址? 示例:如果a的地址为0x13000,我需要一些如下所示的功能 struct vm_area_struct *vma = vma_corresponds_to (0x13000,task); 解决方法 你正在linux / mm.h中寻找find_vma. /* Look up the first VMA which sa
是否有任何内核API可以找到VMA对应的??虚拟地址?

示例:如果a的地址为0x13000,我需要一些如下所示的功能

struct vm_area_struct *vma =  vma_corresponds_to (0x13000,task);

解决方法

你正在linux / mm.h中寻找find_vma.

/* 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);

这应该做的伎俩:

struct vm_area_struct *vma = find_vma(task->mm,0x13000);
if (vma == NULL)
    return -EFAULT;
if (0x13000 >= vma->vm_end)
    return -EFAULT;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读