I've refined the behaviour I observe, which isn't consistent depending
on the size one mallocates.
(see interleaved comments)

> In my driver, I need to map some malloc-ed memory, obtained from
> another module, into userspace.
>
> The problem: on the smaller mallocs, as well as on some bigeer ones
> (8k seems fine, 64k fails): vm_map_lookup() fails finding the
> underlying vm object.

In the current implementation I'm calling vm_map_lookup() against the kmem_map.
As a result it either return the kmem_object, or fails at all (for
smaller or larger mallocs.)

> Do somebody know how (or better, have a piece of code!) to retrieve
> the vm_object associated with malloc-ed memory? (small and big ones)
>
> As far as I can see in the vm code, there isn't any object associated
> with the slabs (the smaller mallocs), it seems that a huge chunk of
> virtual space is used "as is", so I presume the virtual addresses
> where the SLABs are have some remarkable property, with respect to
> physical addresses, that could allow creating an object from scratch?

By using kernel_map instead of kmem_map, vm_map_lookup() now always
return a vm_object. That's a big progress.
As expected, when this object is kmem_object, the user mapping works
fine (for smaller or larger mallocs.)

Otherwise that object doesn't match kernel_object. It's an anonymous
object to me.
Using that "anonymous" vm_object for mapping into user map (using
vm_map_find()) doesn't directly fail,
it does provide a virtual address in the user map. However I read
zeros at that address, from within the user process.

Any help would be highly appreciated.
Thanks!
Eric
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to