Sharing the same VM address space between Kernel and UserSpace

John Giacomoni John.Giacomoni at colorado.edu
Mon Nov 14 22:28:52 GMT 2005


On Nov 14, 2005, at 1:57 PM, Scott Long wrote:

> John Giacomoni wrote:
>
>> I am in need of a way to share memory between kernel space and  
>> possibly
>> multiple different user-space processes for an extended period of  
>> time.
>> This memory would need to be a single unpageable region.
>> I am using the vm routines as cribbed from mmap, however I'd like the
>> address spaces to be viewed as the same regardless of which  
>> process I'm
>> in to avoid swizzling pointers as I'm storing data structures in the
>> shared memory region.
>> I imagine I'd need to find a way to expose part of the kernel address
>> space to user space to accomplish this.
>> Is there a way to do this?
>> thanks
>> John G
>
> If you get this working then it'll be very useful for the syspage  
> support that was talked about recently.
>
> The kernel can access addresses in the user space so long as they
> are wired and won't cause a fault.  Thus I imagine that you
> only need to allocate the memory, wire it, mark it with the  
> appropriate
> page permissions, and reserve a user address range for it in the
> process map.  I'd look at the process exec path in the kernel for
> places to hook in.  The only other trick then is how to let the user
> process know the address for this magic region.  An easy way would be
> to store it in a sysctl that can be read at runtime.  A harder way  
> would
> be to have the kernel dummy up an elf segment in the image activator
> code that the dynamic linker could read and put into a global variable
> for the program to access.
>
> Scott
>

Which thread/list was the syspage support discussed?
(I did a quick search in my freebsd-hackers mailbox and didn't find it)

As for my problem I'm not sure that the kernel being able to access  
userpages
is quite what is needed.  The first reason is that if there are two  
processes
trying to map the same region it would be problematic if one of them had
allocated something in the same area of the heap as the shared memory  
region
resides. This suggests that to avoid swizzling the region needs to be  
in an
address region where the user-space processes will never allocate in  
(kernel).
The other reason is that the kernel code needs to be able to function  
using
the shared memory without a user-space process being attached at all  
times.

So the question is, is it possible to mark wired kernel pages as  
being accessible
to a user-space process without triggering a context switch?

John G

--

John.Giacomoni at colorado.edu
University of Colorado at Boulder
Department of Computer Science
Engineering Center, ECCR 1B05
430 UCB
Boulder, CO 80303-0430
USA




More information about the freebsd-hackers mailing list