Re: [Qemu-devel] [PATCH v3 3/8] xen: remove other open-coded use of libxengnttab
> -Original Message- > From: Anthony PERARD [mailto:anthony.per...@citrix.com] > Sent: 16 May 2018 15:14 > To: Paul Durrant> Cc: xen-de...@lists.xenproject.org; qemu-bl...@nongnu.org; qemu- > de...@nongnu.org; Stefano Stabellini ; Greg Kurz > ; Paolo Bonzini ; Jason Wang > ; Gerd Hoffmann > Subject: Re: [PATCH v3 3/8] xen: remove other open-coded use of > libxengnttab > > On Fri, May 04, 2018 at 08:26:02PM +0100, Paul Durrant wrote: > > Now that helpers are available in xen_backend, use them throughout all > > Xen PV backends. > > > > Signed-off-by: Paul Durrant > > --- > > diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c > > index 20c43a6..73d6f1b 100644 > > --- a/hw/net/xen_nic.c > > +++ b/hw/net/xen_nic.c > > @@ -160,9 +160,8 @@ static void net_tx_packets(struct XenNetDev > *netdev) > >(txreq.flags & NETTXF_more_data) ? " > > more_data" : "", > >(txreq.flags & NETTXF_extra_info) ? " > > extra_info" : ""); > > > > -page = xengnttab_map_grant_ref(netdev->xendev.gnttabdev, > > - netdev->xendev.dom, > > - txreq.gref, PROT_READ); > > +page = xen_be_map_grant_refs(>xendev, > > + , 1, PROT_READ); > > xen_be_map_grant_ref instead? > Yep. > > if (page == NULL) { > > xen_pv_printf(>xendev, 0, > >"error: tx gref dereference failed (%d)\n", > > @@ -183,7 +182,7 @@ static void net_tx_packets(struct XenNetDev > *netdev) > > qemu_send_packet(qemu_get_queue(netdev->nic), > > page + txreq.offset, txreq.size); > > } > > -xengnttab_unmap(netdev->xendev.gnttabdev, page, 1); > > +xen_be_unmap_grant_ref(>xendev, page); > > net_tx_response(netdev, , NETIF_RSP_OKAY); > > } > > if (!netdev->tx_work) { > > @@ -254,9 +253,8 @@ static ssize_t net_rx_packet(NetClientState *nc, > const uint8_t *buf, size_t size > > memcpy(, RING_GET_REQUEST(>rx_ring, rc), > sizeof(rxreq)); > > netdev->rx_ring.req_cons = ++rc; > > > > -page = xengnttab_map_grant_ref(netdev->xendev.gnttabdev, > > - netdev->xendev.dom, > > - rxreq.gref, PROT_WRITE); > > +page = xen_be_map_grant_refs(>xendev, , 1, > > + PROT_WRITE); > > xen_be_map_grant_ref instead? > And yep again. > With that fix: > Acked-by: Anthony PERARD > Thanks :-) Paul > -- > Anthony PERARD
Re: [Qemu-devel] [PATCH v3 3/8] xen: remove other open-coded use of libxengnttab
On Fri, May 04, 2018 at 08:26:02PM +0100, Paul Durrant wrote: > Now that helpers are available in xen_backend, use them throughout all > Xen PV backends. > > Signed-off-by: Paul Durrant> --- > diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c > index 20c43a6..73d6f1b 100644 > --- a/hw/net/xen_nic.c > +++ b/hw/net/xen_nic.c > @@ -160,9 +160,8 @@ static void net_tx_packets(struct XenNetDev *netdev) >(txreq.flags & NETTXF_more_data) ? " > more_data" : "", >(txreq.flags & NETTXF_extra_info) ? " > extra_info" : ""); > > -page = xengnttab_map_grant_ref(netdev->xendev.gnttabdev, > - netdev->xendev.dom, > - txreq.gref, PROT_READ); > +page = xen_be_map_grant_refs(>xendev, > + , 1, PROT_READ); xen_be_map_grant_ref instead? > if (page == NULL) { > xen_pv_printf(>xendev, 0, >"error: tx gref dereference failed (%d)\n", > @@ -183,7 +182,7 @@ static void net_tx_packets(struct XenNetDev *netdev) > qemu_send_packet(qemu_get_queue(netdev->nic), > page + txreq.offset, txreq.size); > } > -xengnttab_unmap(netdev->xendev.gnttabdev, page, 1); > +xen_be_unmap_grant_ref(>xendev, page); > net_tx_response(netdev, , NETIF_RSP_OKAY); > } > if (!netdev->tx_work) { > @@ -254,9 +253,8 @@ static ssize_t net_rx_packet(NetClientState *nc, const > uint8_t *buf, size_t size > memcpy(, RING_GET_REQUEST(>rx_ring, rc), sizeof(rxreq)); > netdev->rx_ring.req_cons = ++rc; > > -page = xengnttab_map_grant_ref(netdev->xendev.gnttabdev, > - netdev->xendev.dom, > - rxreq.gref, PROT_WRITE); > +page = xen_be_map_grant_refs(>xendev, , 1, > + PROT_WRITE); xen_be_map_grant_ref instead? With that fix: Acked-by: Anthony PERARD -- Anthony PERARD
[Qemu-devel] [PATCH v3 3/8] xen: remove other open-coded use of libxengnttab
Now that helpers are available in xen_backend, use them throughout all Xen PV backends. Signed-off-by: Paul Durrant--- Cc: Stefano Stabellini Cc: Anthony Perard Cc: Greg Kurz Cc: Paolo Bonzini Cc: Jason Wang Cc: Gerd Hoffmann v2: - New in v2 --- hw/9pfs/xen-9p-backend.c | 32 +++- hw/char/xen_console.c| 9 - hw/net/xen_nic.c | 34 +++--- hw/usb/xen-usb.c | 37 + 4 files changed, 51 insertions(+), 61 deletions(-) diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 95e50c4..6026780 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -331,14 +331,14 @@ static int xen_9pfs_free(struct XenDevice *xendev) for (i = 0; i < xen_9pdev->num_rings; i++) { if (xen_9pdev->rings[i].data != NULL) { -xengnttab_unmap(xen_9pdev->xendev.gnttabdev, -xen_9pdev->rings[i].data, -(1 << xen_9pdev->rings[i].ring_order)); +xen_be_unmap_grant_refs(_9pdev->xendev, +xen_9pdev->rings[i].data, +(1 << xen_9pdev->rings[i].ring_order)); } if (xen_9pdev->rings[i].intf != NULL) { -xengnttab_unmap(xen_9pdev->xendev.gnttabdev, -xen_9pdev->rings[i].intf, -1); +xen_be_unmap_grant_refs(_9pdev->xendev, +xen_9pdev->rings[i].intf, +1); } if (xen_9pdev->rings[i].bh != NULL) { qemu_bh_delete(xen_9pdev->rings[i].bh); @@ -390,11 +390,10 @@ static int xen_9pfs_connect(struct XenDevice *xendev) } g_free(str); -xen_9pdev->rings[i].intf = xengnttab_map_grant_ref( -xen_9pdev->xendev.gnttabdev, -xen_9pdev->xendev.dom, -xen_9pdev->rings[i].ref, -PROT_READ | PROT_WRITE); +xen_9pdev->rings[i].intf = +xen_be_map_grant_ref(_9pdev->xendev, + xen_9pdev->rings[i].ref, + PROT_READ | PROT_WRITE); if (!xen_9pdev->rings[i].intf) { goto out; } @@ -403,12 +402,11 @@ static int xen_9pfs_connect(struct XenDevice *xendev) goto out; } xen_9pdev->rings[i].ring_order = ring_order; -xen_9pdev->rings[i].data = xengnttab_map_domain_grant_refs( -xen_9pdev->xendev.gnttabdev, -(1 << ring_order), -xen_9pdev->xendev.dom, -xen_9pdev->rings[i].intf->ref, -PROT_READ | PROT_WRITE); +xen_9pdev->rings[i].data = +xen_be_map_grant_refs(_9pdev->xendev, + xen_9pdev->rings[i].intf->ref, + (1 << ring_order), + PROT_READ | PROT_WRITE); if (!xen_9pdev->rings[i].data) { goto out; } diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index bdfaa40..8b4b4bf 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -233,12 +233,11 @@ static int con_initialise(struct XenDevice *xendev) if (!xendev->dev) { xen_pfn_t mfn = con->ring_ref; con->sring = xenforeignmemory_map(xen_fmem, con->xendev.dom, - PROT_READ|PROT_WRITE, + PROT_READ | PROT_WRITE, 1, , NULL); } else { -con->sring = xengnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom, - con->ring_ref, - PROT_READ|PROT_WRITE); +con->sring = xen_be_map_grant_ref(xendev, con->ring_ref, + PROT_READ | PROT_WRITE); } if (!con->sring) return -1; @@ -267,7 +266,7 @@ static void con_disconnect(struct XenDevice *xendev) if (!xendev->dev) { xenforeignmemory_unmap(xen_fmem, con->sring, 1); } else { -xengnttab_unmap(xendev->gnttabdev, con->sring, 1); +xen_be_unmap_grant_ref(xendev, con->sring); } con->sring = NULL; } diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 20c43a6..73d6f1b 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -160,9 +160,8 @@ static void net_tx_packets(struct XenNetDev *netdev) (txreq.flags & NETTXF_more_data) ? " more_data" : "", (txreq.flags & NETTXF_extra_info) ? " extra_info" : ""); -page =