Subject: multiple references to p -> v mappings
To: None <tech-kern@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 09/11/2005 18:42:07
Hi,
this is a question for UVM gurus :)
I'm trying to implement 0-copy in xen's network backend, and have to solve
a VM issue.

Background: when a guest transmits a packet via the hypervisor to
the domain0's network backend, it gives domain0 a descriptor containing
a physical address and a size. domain0 has to map this in its own VM space
to be able to read it. Note that the page passed to domain0 is not part
of domain0's physical address space, and so not managed by the pmap
(it's mapped directly by calls to the hypervisor, using a virtual address
range reserved via uvm_km_alloc(), see xen/i386/xen_shm_machdep.c). This is
used by both the network and disk back-ends.
Maybe this could change and let UVM manage it, but I don't know how, or even
if it would be a good thing.

Now the problem I have to solve: the network backend can receive 2
requests which share a page. Right now it's not a problem because for
each request, the page is mapped, the packet copied and the page unmapped
in an atomic manner. My goal is to avoid copy if possible, by attaching
the data to a mbuf using MEXTADD(). This cause problem, because we may have
to handle a request which is in a page which is already mapped. So I have to:
- find if a given physical address is already mapped at some VA.
- use a reference count for these VAs, in order to know when it can be
  unmapped.

Is there some mechanism in UVM that could fix both of these problems,
and would be useable without too much work ? 

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