# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID c3bb51c443a7a1a78a4917fd09e602fa35d9c318
# Parent a9ae49b52c28dd961984ab8f3250572f37b4d4f2
Make grant table map/unmap argument, host_addr, feature-specific.
Introduce gnttab_set_map_op() and gnttab_set_unmap_op() to initialize.
Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Thu Apr 13
09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c Thu Apr 13
09:29:27 2006
@@ -186,9 +186,8 @@
handle = pending_handle(req, i);
if (handle == BLKBACK_INVALID_HANDLE)
continue;
- unmap[invcount].host_addr = vaddr(req, i);
- unmap[invcount].dev_bus_addr = 0;
- unmap[invcount].handle = handle;
+ gnttab_set_unmap_op(&unmap[i], vaddr(req, i), GNTMAP_host_map,
+ handle);
pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
invcount++;
}
@@ -384,6 +383,8 @@
pending_req->nr_pages = nseg;
for (i = 0; i < nseg; i++) {
+ uint32_t flags;
+
seg[i].nsec = req->seg[i].last_sect -
req->seg[i].first_sect + 1;
@@ -392,12 +393,11 @@
goto fail_response;
preq.nr_sects += seg[i].nsec;
- map[i].host_addr = vaddr(pending_req, i);
- map[i].dom = blkif->domid;
- map[i].ref = req->seg[i].gref;
- map[i].flags = GNTMAP_host_map;
+ flags = GNTMAP_host_map;
if ( operation == WRITE )
- map[i].flags |= GNTMAP_readonly;
+ flags |= GNTMAP_readonly;
+ gnttab_set_map_op(&map[i], vaddr(pending_req, i), flags,
+ req->seg[i].gref, blkif->domid);
}
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nseg);
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c Thu Apr 13
09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c Thu Apr 13
09:29:27 2006
@@ -58,10 +58,8 @@
struct gnttab_map_grant_ref op;
int ret;
- op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
- op.flags = GNTMAP_host_map;
- op.ref = shared_page;
- op.dom = blkif->domid;
+ gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, shared_page, blkif->domid);
lock_vm_area(blkif->blk_ring_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -90,9 +88,8 @@
struct gnttab_unmap_grant_ref op;
int ret;
- op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
- op.handle = blkif->shmem_handle;
- op.dev_bus_addr = 0;
+ gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, blkif->shmem_handle);
lock_vm_area(blkif->blk_ring_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Thu Apr 13 09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Thu Apr 13 09:29:27 2006
@@ -418,9 +418,9 @@
if (BLKTAP_INVALID_HANDLE(handle))
continue;
- unmap[op].host_addr = MMAP_VADDR(mmap_vstart, idx, i);
- unmap[op].dev_bus_addr = 0;
- unmap[op].handle = handle->kernel;
+ gnttab_set_unmap_op(&unmap[op],
+ MMAP_VADDR(mmap_vstart, idx, i),
+ GNTMAP_host_map, handle->kernel);
op++;
if (create_lookup_pte_addr(
@@ -430,9 +430,10 @@
DPRINTK("Couldn't get a pte addr!\n");
return;
}
- unmap[op].host_addr = ptep;
- unmap[op].dev_bus_addr = 0;
- unmap[op].handle = handle->user;
+ gnttab_set_unmap_grnat_ref(&unmap[op], ptep,
+ GNTMAP_host_map |
+ GNTMAP_application_map |
+ GNTMAP_contains_pte, handle->user);
op++;
BLKTAP_INVALIDATE_HANDLE(handle);
@@ -703,21 +704,21 @@
unsigned long uvaddr;
unsigned long kvaddr;
uint64_t ptep;
+ uint32_t flags;
uvaddr = MMAP_VADDR(user_vstart, pending_idx, i);
kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i);
- /* Map the remote page to kernel. */
- map[op].host_addr = kvaddr;
- map[op].dom = blkif->domid;
- map[op].ref = req->seg[i].gref;
- map[op].flags = GNTMAP_host_map;
+ flags = GNTMAP_host_map;
/* This needs a bit more thought in terms of interposition:
* If we want to be able to modify pages during write using
* grant table mappings, the guest will either need to allow
* it, or we'll need to incur a copy. Bit of an fbufs moment.
;) */
if (req->operation == BLKIF_OP_WRITE)
- map[op].flags |= GNTMAP_readonly;
+ flags |= GNTMAP_readonly;
+ /* Map the remote page to kernel. */
+ gnttab_set_map_op(&map[op], kvaddr, flags, req->seg[i].gref,
+ blkif->domid);
op++;
/* Now map it to user. */
@@ -728,14 +729,13 @@
goto bad_descriptor;
}
- map[op].host_addr = ptep;
- map[op].dom = blkif->domid;
- map[op].ref = req->seg[i].gref;
- map[op].flags = GNTMAP_host_map | GNTMAP_application_map
+ flags = GNTMAP_host_map | GNTMAP_application_map
| GNTMAP_contains_pte;
/* Above interposition comment applies here as well. */
if (req->operation == BLKIF_OP_WRITE)
- map[op].flags |= GNTMAP_readonly;
+ flags |= GNTMAP_readonly;
+ gnttab_set_map_op(&map[op], ptep, flags, req->seg[i].gref,
+ blkif->domid);
op++;
}
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c Thu Apr 13
09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c Thu Apr 13
09:29:27 2006
@@ -33,10 +33,8 @@
struct gnttab_map_grant_ref op;
int ret;
- op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
- op.flags = GNTMAP_host_map;
- op.ref = shared_page;
- op.dom = blkif->domid;
+ gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, shared_page, blkif->domid);
lock_vm_area(blkif->blk_ring_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -59,9 +57,8 @@
struct gnttab_unmap_grant_ref op;
int ret;
- op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
- op.handle = blkif->shmem_handle;
- op.dev_bus_addr = 0;
+ gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, blkif->shmem_handle);
lock_vm_area(blkif->blk_ring_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Thu Apr 13
09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Thu Apr 13
09:29:27 2006
@@ -150,10 +150,8 @@
struct gnttab_map_grant_ref op;
int ret;
- op.host_addr = (unsigned long)netif->tx_comms_area->addr;
- op.flags = GNTMAP_host_map;
- op.ref = tx_ring_ref;
- op.dom = netif->domid;
+ gnttab_set_map_op(&op, (unsigned long)netif->tx_comms_area->addr,
+ GNTMAP_host_map, tx_ring_ref, netif->domid);
lock_vm_area(netif->tx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -168,10 +166,8 @@
netif->tx_shmem_ref = tx_ring_ref;
netif->tx_shmem_handle = op.handle;
- op.host_addr = (unsigned long)netif->rx_comms_area->addr;
- op.flags = GNTMAP_host_map;
- op.ref = rx_ring_ref;
- op.dom = netif->domid;
+ gnttab_set_map_op(&op, (unsigned long)netif->rx_comms_area->addr,
+ GNTMAP_host_map, rx_ring_ref, netif->domid);
lock_vm_area(netif->rx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -194,18 +190,16 @@
struct gnttab_unmap_grant_ref op;
int ret;
- op.host_addr = (unsigned long)netif->tx_comms_area->addr;
- op.handle = netif->tx_shmem_handle;
- op.dev_bus_addr = 0;
+ gnttab_set_unmap_op(&op, (unsigned long)netif->tx_comms_area->addr,
+ GNTMAP_host_map, netif->tx_shmem_handle);
lock_vm_area(netif->tx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
unlock_vm_area(netif->tx_comms_area);
BUG_ON(ret);
- op.host_addr = (unsigned long)netif->rx_comms_area->addr;
- op.handle = netif->rx_shmem_handle;
- op.dev_bus_addr = 0;
+ gnttab_set_unmap_op(&op, (unsigned long)netif->rx_comms_area->addr,
+ GNTMAP_host_map, netif->rx_shmem_handle);
lock_vm_area(netif->rx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Thu Apr 13
09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Thu Apr 13
09:29:27 2006
@@ -453,9 +453,9 @@
gop = tx_unmap_ops;
while (dc != dp) {
pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
- gop->host_addr = MMAP_VADDR(pending_idx);
- gop->dev_bus_addr = 0;
- gop->handle = grant_tx_handle[pending_idx];
+ gnttab_set_unmap_op(gop, MMAP_VADDR(pending_idx),
+ GNTMAP_host_map,
+ grant_tx_handle[pending_idx]);
gop++;
}
ret = HYPERVISOR_grant_table_op(
@@ -579,10 +579,9 @@
/* Packets passed to netif_rx() must have some headroom. */
skb_reserve(skb, 16);
- mop->host_addr = MMAP_VADDR(pending_idx);
- mop->dom = netif->domid;
- mop->ref = txreq.gref;
- mop->flags = GNTMAP_host_map | GNTMAP_readonly;
+ gnttab_set_map_op(mop, MMAP_VADDR(pending_idx),
+ GNTMAP_host_map | GNTMAP_readonly,
+ txreq.gref, netif->domid);
mop++;
memcpy(&pending_tx_info[pending_idx].req,
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Thu Apr 13
09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c Thu Apr 13
09:29:27 2006
@@ -13,6 +13,7 @@
#include "common.h"
#include <xen/balloon.h>
+#include <xen/gnttab.h>
static kmem_cache_t *tpmif_cachep;
int num_frontends = 0;
@@ -72,12 +73,10 @@
static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
{
int ret;
- struct gnttab_map_grant_ref op = {
- .host_addr = (unsigned long)tpmif->tx_area->addr,
- .flags = GNTMAP_host_map,
- .ref = shared_page,
- .dom = tpmif->domid,
- };
+ struct gnttab_map_grant_ref op;
+
+ gnttab_set_map_op(&op, (unsigned long)tpmif->tx_area->addr,
+ GNTMAP_host_map, shared_page, tpmif->domid);
lock_vm_area(tpmif->tx_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
@@ -100,9 +99,8 @@
struct gnttab_unmap_grant_ref op;
int ret;
- op.host_addr = (unsigned long)tpmif->tx_area->addr;
- op.handle = tpmif->shmem_handle;
- op.dev_bus_addr = 0;
+ gnttab_set_unmap_op(&op, (unsigned long)tpmif->tx_area->addr,
+ GNTMAP_host_map, tpmif->shmem_handle);
lock_vm_area(tpmif->tx_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Thu Apr 13
09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c Thu Apr 13
09:29:27 2006
@@ -21,6 +21,7 @@
#include <asm/uaccess.h>
#include <xen/xenbus.h>
#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
/* local data structures */
struct data_exchange {
@@ -278,10 +279,8 @@
return 0;
}
- map_op.host_addr = MMAP_VADDR(tpmif, i);
- map_op.flags = GNTMAP_host_map;
- map_op.ref = tx->ref;
- map_op.dom = tpmif->domid;
+ gnttab_set_map_op(&map_op, MMAP_VADDR(tpmif, i),
+ GNTMAP_host_map, tx->ref, tpmif->domid);
if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
&map_op, 1))) {
@@ -308,9 +307,8 @@
}
tx->size = tocopy;
- unmap_op.host_addr = MMAP_VADDR(tpmif, i);
- unmap_op.handle = handle;
- unmap_op.dev_bus_addr = 0;
+ gnttab_set_unmap_op(&unmap_op, MMAP_VADDR(tpmif, i),
+ GNTMAP_host_map, handle);
if (unlikely
(HYPERVISOR_grant_table_op
@@ -422,10 +420,8 @@
tx = &tpmif->tx->ring[i].req;
- map_op.host_addr = MMAP_VADDR(tpmif, i);
- map_op.flags = GNTMAP_host_map;
- map_op.ref = tx->ref;
- map_op.dom = tpmif->domid;
+ gnttab_set_map_op(&map_op, MMAP_VADDR(tpmif, i),
+ GNTMAP_host_map, tx->ref, tpmif->domid);
if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
&map_op, 1))) {
@@ -461,9 +457,8 @@
tpmif->domid, buffer[offset], buffer[offset + 1],
buffer[offset + 2], buffer[offset + 3]);
- unmap_op.host_addr = MMAP_VADDR(tpmif, i);
- unmap_op.handle = handle;
- unmap_op.dev_bus_addr = 0;
+ gnttab_set_unmap_op(&unmap_op, MMAP_VADDR(tpmif, i),
+ GNTMAP_host_map, handle);
if (unlikely
(HYPERVISOR_grant_table_op
diff -r a9ae49b52c28 -r c3bb51c443a7
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c Thu Apr
13 09:12:16 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c Thu Apr
13 09:29:27 2006
@@ -37,11 +37,7 @@
/* Based on Rusty Russell's skeleton driver's map_page */
int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void
**vaddr)
{
- struct gnttab_map_grant_ref op = {
- .flags = GNTMAP_host_map,
- .ref = gnt_ref,
- .dom = dev->otherend_id,
- };
+ struct gnttab_map_grant_ref op;
struct vm_struct *area;
*vaddr = NULL;
@@ -50,8 +46,9 @@
if (!area)
return -ENOMEM;
- op.host_addr = (unsigned long)area->addr;
-
+ gnttab_set_map_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
+ gnt_ref, dev->otherend_id);
+
lock_vm_area(area);
BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
unlock_vm_area(area);
@@ -76,13 +73,10 @@
int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
grant_handle_t *handle, void *vaddr)
{
- struct gnttab_map_grant_ref op = {
- .host_addr = (unsigned long)vaddr,
- .flags = GNTMAP_host_map,
- .ref = gnt_ref,
- .dom = dev->otherend_id,
- };
-
+ struct gnttab_map_grant_ref op;
+
+ gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+ gnt_ref, dev->otherend_id);
BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
if (op.status != GNTST_okay) {
@@ -101,9 +95,7 @@
int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
{
struct vm_struct *area;
- struct gnttab_unmap_grant_ref op = {
- .host_addr = (unsigned long)vaddr,
- };
+ struct gnttab_unmap_grant_ref op;
/* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
* method so that we don't have to muck with vmalloc internals here.
@@ -124,7 +116,8 @@
return GNTST_bad_virt_addr;
}
- op.handle = (grant_handle_t)area->phys_addr;
+ gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+ (grant_handle_t)area->phys_addr);
lock_vm_area(area);
BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
@@ -145,11 +138,10 @@
int xenbus_unmap_ring(struct xenbus_device *dev,
grant_handle_t handle, void *vaddr)
{
- struct gnttab_unmap_grant_ref op = {
- .host_addr = (unsigned long)vaddr,
- .handle = handle,
- };
+ struct gnttab_unmap_grant_ref op;
+ gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+ handle);
BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
if (op.status != GNTST_okay)
diff -r a9ae49b52c28 -r c3bb51c443a7 linux-2.6-xen-sparse/include/xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/xen/gnttab.h Thu Apr 13 09:12:16 2006
+++ b/linux-2.6-xen-sparse/include/xen/gnttab.h Thu Apr 13 09:29:27 2006
@@ -40,6 +40,7 @@
#include <linux/config.h>
#include <asm/hypervisor.h>
#include <xen/interface/grant_table.h>
+#include <xen/features.h>
/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
#ifdef __ia64__
@@ -113,6 +114,37 @@
int gnttab_suspend(void);
int gnttab_resume(void);
+static inline void
+gnttab_set_map_op(struct gnttab_map_grant_ref *map, unsigned long addr,
+ uint32_t flags, grant_ref_t ref, domid_t domid)
+{
+ if (flags & GNTMAP_contains_pte)
+ map->host_addr = addr;
+ else if (xen_feature(XENFEAT_auto_translated_physmap))
+ map->host_addr = __pa(addr);
+ else
+ map->host_addr = addr;
+
+ map->flags = flags;
+ map->ref = ref;
+ map->dom = domid;
+}
+
+static inline void
+gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, unsigned long addr,
+ uint32_t flags, grant_handle_t handle)
+{
+ if (flags & GNTMAP_contains_pte)
+ unmap->host_addr = addr;
+ else if (xen_feature(XENFEAT_auto_translated_physmap))
+ unmap->host_addr = __pa(addr);
+ else
+ unmap->host_addr = addr;
+
+ unmap->handle = handle;
+ unmap->dev_bus_addr = 0;
+}
+
#endif /* __ASM_GNTTAB_H__ */
/*
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|