Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Alloc userspace process to access mapped grant memory regions

On Fri, Nov 23, 2012 at 08:35:27PM +0100, Roger Pau Monné wrote:
> Hello,
> I'm trying to port something similar to Linux gntdev to NetBSD, but I'm
> finding some problems. The basic functionality of gntdev is that using a
> set of ioctls you can map a grant ref, and then you can access it doing
> a mmap to the gntdev pseudo-device. I've tried to do the same in NetBSD,
> but I'm finding some problems in the mmap device handler. What I've done
> is basically the following (very simplified of course):
> paddr_t
> gntdev_mmap(...) {
>       xen_shm_map(nentries, domid, grefp, &va, handlep, flags);
>       pmap_extract(pmap_kernel(), va, &pa);
>       return x86_btop(pa);
> }
> This however doesn't work. The user-space caller ends up with a vaddr
> that points to the same physical address as the kernel vaddr (so pa is
> equal in kernel and userspace), but the userspace vaddr doesn't point to
> the same mfn as the kernel vaddr (va in the example).

I don't follow you here. pa is the physical address, I'm not sure how you
can compare that is virtual user or kernel spaces.

> Does someone know
> of a way of returning a mfn instead of a pfn from the device mmap
> handler? Or is there anyway to get the vaddr that will be returned to
> the userspace program, so I can map the mfn directly to that vaddr?

returning the physical address should work. Did you check that the pa you
get from pmap_extract() points to the right mfn ?

Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference

Home | Main Index | Thread Index | Old Index