Re: [RFC PATCH 16/16] xen/grant-table: host_addr fixup in mapping on xenhost_r0

From: Ankur Arora
Date: Tue Jun 18 2019 - 23:06:43 EST


On 6/17/19 3:55 AM, Juergen Gross wrote:
On 09.05.19 19:25, Ankur Arora wrote:
Xenhost type xenhost_r0 does not support standard GNTTABOP_map_grant_ref
semantics (map a gref onto a specified host_addr). That's because
since the hypervisor is local (same address space as the caller of
GNTTABOP_map_grant_ref), there is no external entity that could
map an arbitrary page underneath an arbitrary address.

To handle this, the GNTTABOP_map_grant_ref hypercall on xenhost_r0
treats the host_addr as an OUT parameter instead of IN and expects the
gnttab_map_refs() and similar to fixup any state that caches the
value of host_addr from before the hypercall.

Accordingly gnttab_map_refs() now adds two parameters, a fixup function
and a pointer to cached maps to fixup:
 int gnttab_map_refs(xenhost_t *xh, struct gnttab_map_grant_ref *map_ops,
ÂÂÂÂÂÂÂÂÂÂÂÂÂ struct gnttab_map_grant_ref *kmap_ops,
-ÂÂÂÂÂÂÂÂÂÂÂ struct page **pages, unsigned int count)
+ÂÂÂÂÂÂÂÂÂÂÂ struct page **pages, gnttab_map_fixup_t map_fixup_fn,
+ÂÂÂÂÂÂÂÂÂÂÂ void **map_fixup[], unsigned int count)

The reason we use a fixup function and not an additional mapping op
in the xenhost_t is because, depending on the caller, what we are fixing
might be different: blkback, netback for instance cache host_addr in
via a struct page *, while __xenbus_map_ring() caches a phys_addr.

This patch fixes up xen-blkback and xen-gntdev drivers.

TODO:
ÂÂ - also rewrite gnttab_batch_map() and __xenbus_map_ring().
ÂÂ - modify xen-netback, scsiback, pciback etc

Co-developed-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
Signed-off-by: Ankur Arora <ankur.a.arora@xxxxxxxxxx>

Without seeing the __xenbus_map_ring() modification it is impossible to
do a proper review of this patch.
Will do in v2.

Ankur



Juergen