[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] netback: handle non-netback foreign pages



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1229596950 0
# Node ID 376283b531465c4adb2cd88e452e6ced52628dbb
# Parent  ff9683032b76f533509191bb9532df10cbb9830b
netback: handle non-netback foreign pages

An SKB can contain pages which are foreign but not tracked by netback,
such as those created by gnttab_copy_grant_page when in
NETBK_DELAYED_COPY_SKB mode. These pages do not have a mapping field
which points to a valid offset in the pending_tx_info array.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r ff9683032b76 -r 376283b53146 drivers/xen/netback/netback.c
--- a/drivers/xen/netback/netback.c     Sat Dec 13 16:00:43 2008 +0000
+++ b/drivers/xen/netback/netback.c     Thu Dec 18 10:42:30 2008 +0000
@@ -40,9 +40,6 @@
 
 /*define NETBE_DEBUG_INTERRUPT*/
 
-/* extra field used in struct page */
-#define netif_page_index(pg) (*(long *)&(pg)->mapping)
-
 struct netbk_rx_meta {
        skb_frag_t frag;
        int id;
@@ -87,6 +84,26 @@ static inline unsigned long idx_to_kaddr
 static inline unsigned long idx_to_kaddr(unsigned int idx)
 {
        return (unsigned long)pfn_to_kaddr(idx_to_pfn(idx));
+}
+
+/* extra field used in struct page */
+static inline void netif_set_page_index(struct page *pg, long index)
+{
+       BUG_ON(index < 0);
+       *((long *)&(pg->mapping)) = index;
+}
+
+static inline long netif_page_index(struct page *pg)
+{
+       long idx = (*(long *)&(pg)->mapping);
+
+       if (!PageForeign(pg))
+               return -1;
+
+       if (mmap_pages[idx] != pg)
+               return -1;
+
+       return idx;
 }
 
 #define PKT_PROT_LEN 64
@@ -370,6 +387,7 @@ static u16 netbk_gop_frag(netif_t *netif
        multicall_entry_t *mcl;
        netif_rx_request_t *req;
        unsigned long old_mfn, new_mfn;
+       long idx = netif_page_index(page);
 
        old_mfn = virt_to_mfn(page_address(page));
 
@@ -380,9 +398,8 @@ static u16 netbk_gop_frag(netif_t *netif
                meta->copy = 1;
                copy_gop = npo->copy + npo->copy_prod++;
                copy_gop->flags = GNTCOPY_dest_gref;
-               if (PageForeign(page)) {
-                       struct pending_tx_info *src_pend =
-                               &pending_tx_info[netif_page_index(page)];
+               if (idx > -1) {
+                       struct pending_tx_info *src_pend = 
&pending_tx_info[idx];
                        copy_gop->source.domid = src_pend->netif->domid;
                        copy_gop->source.u.ref = src_pend->req.gref;
                        copy_gop->flags |= GNTCOPY_source_gref;
@@ -1437,8 +1454,10 @@ static void netif_idx_release(u16 pendin
 
 static void netif_page_release(struct page *page, unsigned int order)
 {
+       long idx = netif_page_index(page);
        BUG_ON(order);
-       netif_idx_release(netif_page_index(page));
+       BUG_ON(idx < 0);
+       netif_idx_release(idx);
 }
 
 irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs)
@@ -1572,7 +1591,7 @@ static int __init netback_init(void)
        for (i = 0; i < MAX_PENDING_REQS; i++) {
                page = mmap_pages[i];
                SetPageForeign(page, netif_page_release);
-               netif_page_index(page) = i;
+               netif_set_page_index(page, i);
                INIT_LIST_HEAD(&pending_inuse[i].list);
        }
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.