0

I'm writing a Linux kernel module. A userspace process (P1) sends a virtual address and size to my kernel module. I save the virtual address (V1). It corresponds to some physical address (Ph).

Now, another userspace process (P2) calls my kernel module. In this case, I want to create a virtual address (V2) for P2, that would be mapped to the same physical address (Ph) in my kernel module.

How can I do this in the kernel module?

Also, is there any way to get the value of Ph in the kernel module?

soham
  • 1,508
  • 6
  • 30
  • 47
  • 1
    It seems very close to the behavior of shared memory IPC. Maybe you could have a look at the source of kernel modules that implement it. – Alain Merigot Feb 21 '19 at 19:24
  • First, you'd need to pin down the virtual address range from process P1 using `get_user_pages` or `get_user_pages_fast`. Then you'd need to support `mmap` file operation for process P2 and map the pages into process P2's virtual address space. Tricky, and probably a lot of edge cases and race conditions to worry about. – Ian Abbott Feb 26 '19 at 13:13

0 Answers0