# Access to memory that may be kernel or user land



## chodong (Jun 29, 2010)

I am writing a kernel module that gets I/O requests from kernel modules (buffers are in [font="Courier New"]UIO_SYSSPACE[/font]) as well as userland (buffers are in [font="Courier New"]UIO_USERSPACE[/font]).

I cannot tell where I was called from so it is not possible for me to correctly configure [font="Courier New"]uiomove[/font] when I want to read/write the buffers.

I obviously need to be able to take a page fault.

In Linux I would use [font="Courier New"]set_fs[/font] to accomplish this.

Is there a generic means to tell the kernel to allow a given address range?

Thank you,


----------



## doena (Jun 29, 2010)

What about mmap for sharing memory from kernelspace and userspace?
You just have to implement a device and its mmap-handler.


----------



## chodong (Jun 29, 2010)

That may work but I am concerned that I don't know when a buffer address is in userland or kernel space. The kernel should know so I'll give it a shot.

Thank you.


----------



## doena (Jul 1, 2010)

I think there is somewhere in the kernel where it defines the lowest kernel-space
border for virtual addresses.

```
- i386/include/vmparam.h:#define VM_MIN_KERNEL_ADDRESS
- i386/include/vmparam.h:#define VM_MAXUSER_ADDRESS       VADDR(PTDPTDI, 0)
```

Maybe they can help you determining the source of the access.

Regards,
Doena


----------

