I'm trying to understand what I need to do in order to map a user's page to kernel space.
Now, I know that the user memory can already be accessed from the kernel using get_user
and put_user
. This is not what I'm after. In my scenario, the user's page has r/o permissions and I want to write to it. I have not tried (and maybe I should) writing to it, since I guess it would result in a page fault.
As far as I can tell, what I need to do is this:
- Find the physical address of the user page
- Find (and reserve) a virtual address in the kernel space
- Add a PTE under the kernel's PGD (
current->mm->pgd
???) that points to said physical address with desired permissions
So my question is actually twofold - are my intuition and steps correct, and how do I implement those steps?