更新时间:2023-11-08 09:59:52
PROBLEM
尤里卡
但是这个功能确实存在!埋在深处2.6内核源代码在于这个函数从一个虚拟地址获取一个结构页,标记为只用于测试"并用#if 0阻塞:
But the function does exist! Buried deep in the 2.6 kernel source code lies this function to get a struct page from a virtual address, marked as "just for testing" and blocked with #if 0:
#if 0 /* This is just for testing */
struct page *
follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
{
unsigned long start = address;
int length = 1;
int nr;
struct page *page;
struct vm_area_struct *vma;
vma = find_vma(mm, addr);
if (!vma || !is_vm_hugetlb_page(vma))
return ERR_PTR(-EINVAL);
pte = huge_pte_offset(mm, address);
/* hugetlb should be locked, and hence, prefaulted */
WARN_ON(!pte || pte_none(*pte));
page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
WARN_ON(!PageHead(page));
return page;
}
解决方案:由于上面的函数实际上并未编译到内核中,因此您需要将其添加到驱动程序源中.
SOLUTION: Since the function above isn't actually compiled into the kernel, you will need to add it to your driver source.
用户端工作流程
内核驱动程序工作流程
免责声明