【发布时间】:2016-06-27 08:41:35
【问题描述】:
我有一个 char 驱动程序,其中我添加的接口函数之一是alloc_contig(int order),其中 order 是所需数量的 4K 页的 log2。
此函数分配连续的物理内存并使用remap_pfn_range 函数将其映射为用户空间使用。
我正在尝试编写释放此内存的函数dealloc_contig(va)
现在在内核中,我有用户提供的免费虚拟地址,我需要获取底层物理地址,所以我尝试使用virt_to_phys,但它没有给我想要的地址。
日志:
//allocating
page address is ffff880868764000 //allocated using alloc_pages
//deallocating
virtual address from user 7f4c7e095000
when converted to PA using virt_to_phys got f74c7e095000 instead of ffff880868764000
你能帮帮我吗?
【问题讨论】:
标签: c linux memory linux-kernel linux-device-driver