How remap_pfn_range remaps kernel memory to user space?

前端 未结 2 671
自闭症患者
自闭症患者 2020-12-14 19:39

remap_pfn_range function (used in mmap call in driver) can be used to map kernel memory to user space. How is it done? Can anyone explain precise s

2条回答
  •  渐次进展
    2020-12-14 20:21

    It's simple really, kernel memory (usually) simply has a page table entry with the architecture specific bit that says: "this page table entry is only valid while the CPU is in kernel mode".

    What remap_pfn_range does is create another page table entry, with a different virtual address to the same physical memory page that doesn't have that bit set.

    Usually, it's a bad idea btw :-)

提交回复
热议问题