diff -r 4c96da4993b8 drivers/char/tpm/tpm_xen.c --- a/drivers/char/tpm/tpm_xen.c Mon Nov 12 10:17:44 2007 +0000 +++ b/drivers/char/tpm/tpm_xen.c Wed Nov 14 11:47:09 2007 +0000 @@ -266,8 +266,7 @@ static void destroy_tpmring(struct tpm_p tpmif_set_connected_state(tp, 0); if (tp->ring_ref != GRANT_INVALID_REF) { - gnttab_end_foreign_access(tp->ring_ref, 0, - (unsigned long)tp->tx); + gnttab_end_foreign_access(tp->ring_ref, (unsigned long)tp->tx); tp->ring_ref = GRANT_INVALID_REF; tp->tx = NULL; } diff -r 4c96da4993b8 drivers/xen/blkfront/blkfront.c --- a/drivers/xen/blkfront/blkfront.c Mon Nov 12 10:17:44 2007 +0000 +++ b/drivers/xen/blkfront/blkfront.c Wed Nov 14 16:22:32 2007 +0000 @@ -622,7 +622,7 @@ static int blkif_queue_request(struct re ref, info->xbdev->otherend_id, buffer_mfn, - rq_data_dir(req) ); + rq_data_dir(req) ? GTF_readonly : 0 ); info->shadow[id].frame[ring_req->nr_segments] = mfn_to_pfn(buffer_mfn); @@ -790,7 +790,7 @@ static void blkif_free(struct blkfront_i /* Free resources associated with old device channel. */ if (info->ring_ref != GRANT_INVALID_REF) { - gnttab_end_foreign_access(info->ring_ref, 0, + gnttab_end_foreign_access(info->ring_ref, (unsigned long)info->ring.sring); info->ring_ref = GRANT_INVALID_REF; info->ring.sring = NULL; @@ -804,7 +804,7 @@ static void blkif_completion(struct blk_ { int i; for (i = 0; i < s->req.nr_segments; i++) - gnttab_end_foreign_access(s->req.seg[i].gref, 0, 0UL); + gnttab_end_foreign_access(s->req.seg[i].gref, 0UL); } static void blkif_recover(struct blkfront_info *info) @@ -846,9 +846,9 @@ static void blkif_recover(struct blkfron req->seg[j].gref, info->xbdev->otherend_id, pfn_to_mfn(info->shadow[req->id].frame[j]), - rq_data_dir( - (struct request *) - info->shadow[req->id].request)); + rq_data_dir((struct request *) + info->shadow[req->id].request) ? + GTF_readonly : 0); info->shadow[req->id].req = *req; info->ring.req_prod_pvt++; diff -r 4c96da4993b8 drivers/xen/core/gnttab.c --- a/drivers/xen/core/gnttab.c Mon Nov 12 10:17:44 2007 +0000 +++ b/drivers/xen/core/gnttab.c Wed Nov 14 16:25:45 2007 +0000 @@ -140,7 +140,7 @@ static void put_free_entry(grant_ref_t r */ int gnttab_grant_foreign_access(domid_t domid, unsigned long frame, - int readonly) + int flags) { int ref; @@ -150,19 +150,21 @@ int gnttab_grant_foreign_access(domid_t shared[ref].frame = frame; shared[ref].domid = domid; wmb(); - shared[ref].flags = GTF_permit_access | (readonly ? GTF_readonly : 0); + BUG_ON(flags & (GTF_accept_transfer | GTF_reading | GTF_writing)); + shared[ref].flags = GTF_permit_access | flags; return ref; } EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access); void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid, - unsigned long frame, int readonly) + unsigned long frame, int flags) { shared[ref].frame = frame; shared[ref].domid = domid; wmb(); - shared[ref].flags = GTF_permit_access | (readonly ? GTF_readonly : 0); + BUG_ON(flags & (GTF_accept_transfer | GTF_reading | GTF_writing)); + shared[ref].flags = GTF_permit_access | flags; } EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref); @@ -177,7 +179,7 @@ int gnttab_query_foreign_access(grant_re } EXPORT_SYMBOL_GPL(gnttab_query_foreign_access); -int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly) +int gnttab_end_foreign_access_ref(grant_ref_t ref) { u16 flags, nflags; @@ -194,10 +196,9 @@ int gnttab_end_foreign_access_ref(grant_ } EXPORT_SYMBOL_GPL(gnttab_end_foreign_access_ref); -void gnttab_end_foreign_access(grant_ref_t ref, int readonly, - unsigned long page) -{ - if (gnttab_end_foreign_access_ref(ref, readonly)) { +void gnttab_end_foreign_access(grant_ref_t ref, unsigned long page) +{ + if (gnttab_end_foreign_access_ref(ref)) { put_free_entry(ref); if (page != 0) free_page(page); diff -r 4c96da4993b8 drivers/xen/netfront/netfront.c --- a/drivers/xen/netfront/netfront.c Mon Nov 12 10:17:44 2007 +0000 +++ b/drivers/xen/netfront/netfront.c Wed Nov 14 16:22:57 2007 +0000 @@ -663,8 +663,7 @@ static void network_tx_buf_gc(struct net "domain.\n"); BUG(); } - gnttab_end_foreign_access_ref( - np->grant_tx_ref[id], GNTMAP_readonly); + gnttab_end_foreign_access_ref(np->grant_tx_ref[id]); gnttab_release_grant_reference( &np->gref_tx_head, np->grant_tx_ref[id]); np->grant_tx_ref[id] = GRANT_INVALID_REF; @@ -888,7 +887,7 @@ static void xennet_make_frags(struct sk_ mfn = virt_to_mfn(data); gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id, - mfn, GNTMAP_readonly); + mfn, GTF_readonly); tx->gref = np->grant_tx_ref[id] = ref; tx->offset = offset; @@ -910,7 +909,7 @@ static void xennet_make_frags(struct sk_ mfn = pfn_to_mfn(page_to_pfn(frag->page)); gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id, - mfn, GNTMAP_readonly); + mfn, GTF_readonly); tx->gref = np->grant_tx_ref[id] = ref; tx->offset = frag->page_offset; @@ -972,7 +971,7 @@ static int network_start_xmit(struct sk_ BUG_ON((signed short)ref < 0); mfn = virt_to_mfn(data); gnttab_grant_foreign_access_ref( - ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly); + ref, np->xbdev->otherend_id, mfn, GTF_readonly); tx->gref = np->grant_tx_ref[id] = ref; tx->offset = offset; tx->size = len; @@ -1198,7 +1197,7 @@ static int xennet_get_responses(struct n } pages_flipped++; } else { - ret = gnttab_end_foreign_access_ref(ref, 0); + ret = gnttab_end_foreign_access_ref(ref); BUG_ON(!ret); } @@ -1531,8 +1530,7 @@ static void netif_release_tx_bufs(struct continue; skb = np->tx_skbs[i]; - gnttab_end_foreign_access_ref( - np->grant_tx_ref[i], GNTMAP_readonly); + gnttab_end_foreign_access_ref(np->grant_tx_ref[i]); gnttab_release_grant_reference( &np->gref_tx_head, np->grant_tx_ref[i]); np->grant_tx_ref[i] = GRANT_INVALID_REF; @@ -1642,7 +1640,7 @@ static void netif_release_rx_bufs_copy(s skb = np->rx_skbs[i]; - if (!gnttab_end_foreign_access_ref(ref, 0)) + if (!gnttab_end_foreign_access_ref(ref)) { busy++; continue; @@ -2151,7 +2149,7 @@ static void end_access(int ref, void *pa static void end_access(int ref, void *page) { if (ref != GRANT_INVALID_REF) - gnttab_end_foreign_access(ref, 0, (unsigned long)page); + gnttab_end_foreign_access(ref, (unsigned long)page); } diff -r 4c96da4993b8 drivers/xen/pcifront/xenbus.c --- a/drivers/xen/pcifront/xenbus.c Mon Nov 12 10:17:44 2007 +0000 +++ b/drivers/xen/pcifront/xenbus.c Wed Nov 14 11:47:07 2007 +0000 @@ -57,7 +57,7 @@ static void free_pdev(struct pcifront_de xenbus_free_evtchn(pdev->xdev, pdev->evtchn); if (pdev->gnt_ref != INVALID_GRANT_REF) - gnttab_end_foreign_access(pdev->gnt_ref, 0, + gnttab_end_foreign_access(pdev->gnt_ref, (unsigned long)pdev->sh_info); pdev->xdev->dev.driver_data = NULL; diff -r 4c96da4993b8 include/xen/gnttab.h --- a/include/xen/gnttab.h Mon Nov 12 10:17:44 2007 +0000 +++ b/include/xen/gnttab.h Wed Nov 14 09:51:06 2007 +0000 @@ -51,14 +51,14 @@ struct gnttab_free_callback { }; int gnttab_grant_foreign_access(domid_t domid, unsigned long frame, - int readonly); + int flags); /* * End access through the given grant reference, iff the grant entry is no * longer in use. Return 1 if the grant entry was freed, 0 if it is still in * use. */ -int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly); +int gnttab_end_foreign_access_ref(grant_ref_t ref); /* * Eventually end access through the given grant reference, and once that @@ -66,8 +66,7 @@ int gnttab_end_foreign_access_ref(grant_ * immediately iff the grant entry is not in use, otherwise it will happen * some time later. page may be 0, in which case no freeing will occur. */ -void gnttab_end_foreign_access(grant_ref_t ref, int readonly, - unsigned long page); +void gnttab_end_foreign_access(grant_ref_t ref, unsigned long page); int gnttab_grant_foreign_transfer(domid_t domid, unsigned long pfn); @@ -97,7 +96,7 @@ void gnttab_cancel_free_callback(struct void gnttab_cancel_free_callback(struct gnttab_free_callback *callback); void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid, - unsigned long frame, int readonly); + unsigned long frame, int flags); void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid, unsigned long pfn); diff -r 4c96da4993b8 include/xen/interface/grant_table.h --- a/include/xen/interface/grant_table.h Mon Nov 12 10:17:44 2007 +0000 +++ b/include/xen/interface/grant_table.h Wed Nov 14 09:46:25 2007 +0000 @@ -119,6 +119,7 @@ typedef struct grant_entry grant_entry_t * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] + * GTF_PAT, GTF_PWT, GTF_PCD: Cache attribute flags for the grant [GST] */ #define _GTF_readonly (2) #define GTF_readonly (1U<<_GTF_readonly) @@ -126,6 +127,12 @@ typedef struct grant_entry grant_entry_t #define GTF_reading (1U<<_GTF_reading) #define _GTF_writing (4) #define GTF_writing (1U<<_GTF_writing) +#define _GTF_PAT (5) +#define GTF_PAT (1U<<_GTF_PAT) +#define _GTF_PWT (6) +#define GTF_PWT (1U<<_GTF_PWT) +#define _GTF_PCD (7) +#define GTF_PCD (1U<<_GTF_PCD) /* * Subflags for GTF_accept_transfer: