WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Indirect writes to phys_to_machine_mapping array through

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Indirect writes to phys_to_machine_mapping array through an inline
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Nov 2005 17:06:17 +0000
Delivery-date: Thu, 10 Nov 2005 17:08:08 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 4982559d8fde3d0a4401766deb54c5cc1e1a0ec5
# Parent  d916497135acf19d48c39e08eedefff621210996
Indirect writes to phys_to_machine_mapping array through an inline
function defined in page.h.

For self-migration, I need the ability to trap writes to the p2m map
during migration, because I keep a dictionary mapping mfns to pfns,
which I use for remapping the page tables once I am on the other side.

Signed-off-by: Jacob Gorm Hansen <jacobg@xxxxxxx>

diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Thu Nov 10 
14:16:01 2005
@@ -342,8 +342,8 @@
                mfn = pte_mfn(*pte);
                BUG_ON(HYPERVISOR_update_va_mapping(
                        vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
-               phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
-                       INVALID_P2M_ENTRY;
+               set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
+                       INVALID_P2M_ENTRY);
                BUG_ON(HYPERVISOR_memory_op(
                        XENMEM_decrease_reservation, &reservation) != 1);
        }
@@ -361,7 +361,7 @@
                        vstart + (i*PAGE_SIZE),
                        pfn_pte_ma(mfn+i, PAGE_KERNEL), 0));
                xen_machphys_update(mfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
-               phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn+i;
+               set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn+i);
        }
 
        flush_tlb_all();
@@ -383,7 +383,7 @@
                        vstart + (i*PAGE_SIZE),
                        pfn_pte_ma(mfn, PAGE_KERNEL), 0));
                xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
-               phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
+               set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
        }
 
        flush_tlb_all();
@@ -422,8 +422,8 @@
                mfn = pte_mfn(*pte);
                BUG_ON(HYPERVISOR_update_va_mapping(
                        vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
-               phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
-                       INVALID_P2M_ENTRY;
+               set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
+                       INVALID_P2M_ENTRY);
                BUG_ON(HYPERVISOR_memory_op(
                        XENMEM_decrease_reservation, &reservation) != 1);
        }
@@ -436,7 +436,7 @@
                        vstart + (i*PAGE_SIZE),
                        pfn_pte_ma(mfn, PAGE_KERNEL), 0));
                xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
-               phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
+               set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
        }
 
        flush_tlb_all();
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Nov 10 
14:16:01 2005
@@ -210,7 +210,7 @@
                BUG_ON(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
 
                /* Update P->M and M->P tables. */
-               phys_to_machine_mapping[pfn] = mfn_list[i];
+               set_phys_to_machine(pfn, mfn_list[i]);
                xen_machphys_update(mfn_list[i], pfn);
             
                /* Link back into the page tables if not highmem. */
@@ -295,7 +295,7 @@
        /* No more mappings: invalidate P2M and add to balloon. */
        for (i = 0; i < nr_pages; i++) {
                pfn = mfn_to_pfn(mfn_list[i]);
-               phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
+               set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
                balloon_append(pfn_to_page(pfn));
        }
 
@@ -515,8 +515,7 @@
                .domid        = DOMID_SELF
        };
        set_pte_at(&init_mm, addr, pte, __pte_ma(0));
-       phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
-               INVALID_P2M_ENTRY;
+       set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
        ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
        BUG_ON(ret != 1);
        return 0;
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Thu Nov 10 
14:16:01 2005
@@ -386,9 +386,9 @@
 #ifdef __ia64__
                        MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
 #else
-                       phys_to_machine_mapping[__pa(MMAP_VADDR(
-                               pending_idx, i)) >> PAGE_SHIFT] =
-                               FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
+                       set_phys_to_machine(__pa(MMAP_VADDR(
+                               pending_idx, i)) >> PAGE_SHIFT,
+                               FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
 #endif
                        fas        = req->frame_and_sects[i];
                        seg[i].buf = map[i].dev_bus_addr | 
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Thu Nov 10 14:03:33 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Thu Nov 10 14:16:01 2005
@@ -777,8 +777,8 @@
                /* Set the necessary mappings in p2m and in the VM_FOREIGN 
                 * vm_area_struct to allow user vaddr -> struct page lookups
                 * to work.  This is needed for direct IO to foreign pages. */
-               phys_to_machine_mapping[__pa(kvaddr) >> PAGE_SHIFT] =
-                       FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
+               set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
+                               FOREIGN_FRAME(map[i].dev_bus_addr >> 
PAGE_SHIFT));
 
                offset = (uvaddr - blktap_vma->vm_start) >> PAGE_SHIFT;
                ((struct page **)blktap_vma->vm_private_data)[offset] =
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Thu Nov 10 
14:16:01 2005
@@ -248,8 +248,7 @@
                 * Set the new P2M table entry before reassigning the old data
                 * page. Heed the comment in pgtable-2level.h:pte_page(). :-)
                 */
-               phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] =
-                       new_mfn;
+               set_phys_to_machine(__pa(skb->data) >> PAGE_SHIFT, new_mfn);
 
                MULTI_update_va_mapping(mcl, vdata,
                                        pfn_pte_ma(new_mfn, PAGE_KERNEL), 0);
@@ -631,9 +630,9 @@
                                pending_idx;
                        continue;
                }
-               phys_to_machine_mapping[
-                       __pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
-                       FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT);
+               set_phys_to_machine(
+                       __pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
+                       FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
                grant_tx_ref[pending_idx] = mop->handle;
 
                data_len = (txreq.size > PKT_PROT_LEN) ?
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Thu Nov 10 
14:16:01 2005
@@ -342,8 +342,7 @@
                rx_pfn_array[i] = virt_to_mfn(skb->head);
 
                /* Remove this page from map before passing back to Xen. */
-               phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
-                       = INVALID_P2M_ENTRY;
+               set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, 
INVALID_P2M_ENTRY);
 
                MULTI_update_va_mapping(rx_mcl+i, (unsigned long)skb->head,
                                        __pte(0), 0);
@@ -570,7 +569,7 @@
                                        pfn_pte_ma(mfn, PAGE_KERNEL), 0);
                mcl++;
 
-               phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = mfn;
+               set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, mfn);
 
                __skb_queue_tail(&rxq, skb);
        }
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Thu Nov 10 
14:16:01 2005
@@ -296,9 +296,8 @@
                        DPRINTK(" Grant table operation failure !\n");
                        return 0;
                }
-               phys_to_machine_mapping[__pa(MMAP_VADDR(tpmif,i)) >>
-                                       PAGE_SHIFT] =
-                       FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT);
+               set_phys_to_machine(__pa(MMAP_VADDR(tpmif,i)) >> PAGE_SHIFT,
+                       FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT));
 
                tocopy = MIN(size - offset, PAGE_SIZE);
 
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h      Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h      Thu Nov 10 
14:16:01 2005
@@ -84,6 +84,11 @@
                : "=r" (pfn) : "m" (machine_to_phys_mapping[mfn]) );
 
        return pfn;
+}
+
+static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
+{
+       phys_to_machine_mapping[pfn] = mfn;
 }
 
 /* Definitions for machine and pseudophysical addresses. */
diff -r d916497135ac -r 4982559d8fde 
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h    Thu Nov 10 
14:03:33 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h    Thu Nov 10 
14:16:01 2005
@@ -88,6 +88,11 @@
        return pfn;
 }
 
+static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
+{
+       phys_to_machine_mapping[pfn] = mfn;
+}
+
 /* Definitions for machine and pseudophysical addresses. */
 typedef unsigned long paddr_t;
 typedef unsigned long maddr_t;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Indirect writes to phys_to_machine_mapping array through an inline, Xen patchbot -unstable <=