diff options
author | Juergen Gross <jgross@suse.com> | 2022-05-24 14:46:30 +0300 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2022-05-27 12:05:29 +0300 |
commit | 49f8b459fc1de5e3712b57c8ccefae9ec45270f8 (patch) | |
tree | a94aa459860a3d82cae0933e922e1cbfaa980766 /drivers/xen | |
parent | 5b3353949e89d48b4faf54a9cc241ee5d70df615 (diff) | |
download | linux-49f8b459fc1de5e3712b57c8ccefae9ec45270f8.tar.xz |
xen: switch gnttab_end_foreign_access() to take a struct page pointer
Instead of a virtual kernel address use a pointer of the associated
struct page as second parameter of gnttab_end_foreign_access().
Most users have that pointer available already and are creating the
virtual address from it, risking problems in case the memory is
located in highmem.
gnttab_end_foreign_access() itself won't need to get the struct page
from the address again.
Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/gntalloc.c | 9 | ||||
-rw-r--r-- | drivers/xen/gntdev-dmabuf.c | 2 | ||||
-rw-r--r-- | drivers/xen/grant-table.c | 8 | ||||
-rw-r--r-- | drivers/xen/pvcalls-front.c | 6 | ||||
-rw-r--r-- | drivers/xen/xen-front-pgdir-shbuf.c | 2 | ||||
-rw-r--r-- | drivers/xen/xenbus/xenbus_client.c | 2 |
6 files changed, 13 insertions, 16 deletions
diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c index 55acb32842a3..a15729beb9d1 100644 --- a/drivers/xen/gntalloc.c +++ b/drivers/xen/gntalloc.c @@ -175,8 +175,6 @@ undo: static void __del_gref(struct gntalloc_gref *gref) { - unsigned long addr; - if (gref->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) { uint8_t *tmp = kmap_local_page(gref->page); tmp[gref->notify.pgoff] = 0; @@ -190,10 +188,9 @@ static void __del_gref(struct gntalloc_gref *gref) gref->notify.flags = 0; if (gref->gref_id) { - if (gref->page) { - addr = (unsigned long)page_to_virt(gref->page); - gnttab_end_foreign_access(gref->gref_id, addr); - } else + if (gref->page) + gnttab_end_foreign_access(gref->gref_id, gref->page); + else gnttab_free_grant_reference(gref->gref_id); } diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c index 91073b4e4a20..940e5e9e8a54 100644 --- a/drivers/xen/gntdev-dmabuf.c +++ b/drivers/xen/gntdev-dmabuf.c @@ -524,7 +524,7 @@ static void dmabuf_imp_end_foreign_access(u32 *refs, int count) for (i = 0; i < count; i++) if (refs[i] != INVALID_GRANT_REF) - gnttab_end_foreign_access(refs[i], 0UL); + gnttab_end_foreign_access(refs[i], NULL); } static void dmabuf_imp_free_storage(struct gntdev_dmabuf *gntdev_dmabuf) diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 1a1aec0a88a1..1b9b28bc3228 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -430,13 +430,13 @@ int gnttab_try_end_foreign_access(grant_ref_t ref) } EXPORT_SYMBOL_GPL(gnttab_try_end_foreign_access); -void gnttab_end_foreign_access(grant_ref_t ref, unsigned long page) +void gnttab_end_foreign_access(grant_ref_t ref, struct page *page) { if (gnttab_try_end_foreign_access(ref)) { - if (page != 0) - put_page(virt_to_page(page)); + if (page) + put_page(page); } else - gnttab_add_deferred(ref, page ? virt_to_page(page) : NULL); + gnttab_add_deferred(ref, page); } EXPORT_SYMBOL_GPL(gnttab_end_foreign_access); diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c index e254ed19488f..1826e8e67125 100644 --- a/drivers/xen/pvcalls-front.c +++ b/drivers/xen/pvcalls-front.c @@ -238,8 +238,8 @@ static void pvcalls_front_free_map(struct pvcalls_bedata *bedata, spin_unlock(&bedata->socket_lock); for (i = 0; i < (1 << PVCALLS_RING_ORDER); i++) - gnttab_end_foreign_access(map->active.ring->ref[i], 0); - gnttab_end_foreign_access(map->active.ref, 0); + gnttab_end_foreign_access(map->active.ring->ref[i], NULL); + gnttab_end_foreign_access(map->active.ref, NULL); free_page((unsigned long)map->active.ring); kfree(map); @@ -1117,7 +1117,7 @@ static int pvcalls_front_remove(struct xenbus_device *dev) } } if (bedata->ref != -1) - gnttab_end_foreign_access(bedata->ref, 0); + gnttab_end_foreign_access(bedata->ref, NULL); kfree(bedata->ring.sring); kfree(bedata); xenbus_switch_state(dev, XenbusStateClosed); diff --git a/drivers/xen/xen-front-pgdir-shbuf.c b/drivers/xen/xen-front-pgdir-shbuf.c index b6433761d42c..bef8d72a6ca6 100644 --- a/drivers/xen/xen-front-pgdir-shbuf.c +++ b/drivers/xen/xen-front-pgdir-shbuf.c @@ -135,7 +135,7 @@ void xen_front_pgdir_shbuf_free(struct xen_front_pgdir_shbuf *buf) for (i = 0; i < buf->num_grefs; i++) if (buf->grefs[i] != INVALID_GRANT_REF) - gnttab_end_foreign_access(buf->grefs[i], 0UL); + gnttab_end_foreign_access(buf->grefs[i], NULL); } kfree(buf->grefs); kfree(buf->directory); diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index d6fdd2d209d3..d5f3f763717e 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -439,7 +439,7 @@ void xenbus_teardown_ring(void **vaddr, unsigned int nr_pages, for (i = 0; i < nr_pages; i++) { if (grefs[i] != INVALID_GRANT_REF) { - gnttab_end_foreign_access(grefs[i], 0); + gnttab_end_foreign_access(grefs[i], NULL); grefs[i] = INVALID_GRANT_REF; } } |