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

[Xen-changelog] Make balloon driver arch-neutral.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID a08aef9f1c8e6f0350e89ee34ad6d3ba54027958
# Parent  89a2233056119e8008569fd38b078d6f4f4fcfec
Make balloon driver arch-neutral.

Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxx>

diff -r 89a223305611 -r a08aef9f1c8e 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Dec  8 
14:25:44 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Thu Dec  8 
14:33:10 2005
@@ -192,8 +192,8 @@
                page = balloon_retrieve();
                BUG_ON(page == NULL);
 
-               pfn = page - mem_map;
-               BUG_ON(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
+               pfn = page_to_pfn(page);
+               BUG_ON(phys_to_machine_mapping_valid(pfn));
 
                /* Update P->M and M->P tables. */
                set_phys_to_machine(pfn, mfn_list[i]);
@@ -253,8 +253,8 @@
                        break;
                }
 
-               pfn = page - mem_map;
-               mfn_list[i] = phys_to_machine_mapping[pfn];
+               pfn = page_to_pfn(page);
+               mfn_list[i] = pfn_to_mfn(pfn);
 
                if (!PageHighMem(page)) {
                        v = phys_to_virt(pfn << PAGE_SHIFT);
@@ -444,6 +444,9 @@
 
        IPRINTK("Initialising balloon driver.\n");
 
+       if (xen_init() < 0)
+               return -1;
+
        current_pages = min(xen_start_info->nr_pages, max_pfn);
        target_pages  = current_pages;
        balloon_low   = 0;
@@ -465,7 +468,7 @@
     
        /* Initialise the balloon with excess memory space. */
        for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
-               page = &mem_map[pfn];
+               page = pfn_to_page(pfn);
                if (!PageReserved(page))
                        balloon_append(page);
        }
diff -r 89a223305611 -r a08aef9f1c8e 
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 Dec  8 
14:25:44 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h      Thu Dec  8 
14:33:10 2005
@@ -65,6 +65,8 @@
 extern unsigned long *phys_to_machine_mapping;
 #define pfn_to_mfn(pfn)        \
 (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL<<31))
+#define        phys_to_machine_mapping_valid(pfn) \
+       (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
 static inline unsigned long mfn_to_pfn(unsigned long mfn)
 {
        unsigned long pfn;
diff -r 89a223305611 -r a08aef9f1c8e 
linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h Thu Dec  8 
14:25:44 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h Thu Dec  8 
14:33:10 2005
@@ -355,34 +355,27 @@
 #endif
     return 1;
 }
+#endif
 
 static inline int
 HYPERVISOR_update_va_mapping(
     unsigned long va, pte_t new_val, unsigned long flags)
 {
-#if 0
-    int ret;
-    unsigned long ign1, ign2, ign3;
-
-    __asm__ __volatile__ (
-        TRAP_INSTR
-        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
-       : "0" (__HYPERVISOR_update_va_mapping), 
-          "1" (va), "2" ((new_val).pte_low), "3" (flags)
-       : "memory" );
-
-    if ( unlikely(ret < 0) )
-    {
-        printk(KERN_ALERT "Failed update VA mapping: %08lx, %08lx, %08lx\n",
-               va, (new_val).pte_low, flags);
-        BUG();
-    }
-
-    return ret;
-#endif
-    return 1;
-}
-#endif
+    /* no-op */
+    return 1;
+}
+
+static inline int
+HYPERVISOR_memory_op(
+    unsigned int cmd, void *arg)
+{
+    int ret;
+    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r2=%1 ; break 
0x1000 ;; mov %0=r8 ;;"
+        : "=r" (ret)
+        : "i" (__HYPERVISOR_console_io), "r"(cmd), "r"(arg)
+        : "r14","r15","r2","r8","memory" );
+    return ret;
+}
 
 static inline int
 HYPERVISOR_event_channel_op(
diff -r 89a223305611 -r a08aef9f1c8e 
linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h        Thu Dec 
 8 14:25:44 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h        Thu Dec 
 8 14:33:10 2005
@@ -52,4 +52,19 @@
 #define        mfn_to_pfn(x)   (x)
 #define machine_to_phys_mapping 0
 
+// for drivers/xen/balloon/balloon.c
+#ifdef CONFIG_XEN_SCRUB_PAGES
+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
+#else
+#define scrub_pages(_p,_n) ((void)0)
+#endif
+#define        pte_mfn(_x)     pte_pfn(_x)
+#define INVALID_P2M_ENTRY      (~0UL)
+#define __pte_ma(_x)   ((pte_t) {(_x)})
+#define phys_to_machine_mapping_valid(_x)      (1)
+#define        kmap_flush_unused()     do {} while (0)
+#define set_phys_to_machine(_x,_y)     do {} while (0)
+#define xen_machphys_update(_x,_y)     do {} while (0)
+#define pfn_pte_ma(_x,_y)      __pte_ma(0)
+
 #endif /* __HYPERVISOR_H__ */
diff -r 89a223305611 -r a08aef9f1c8e 
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 Dec  8 
14:25:44 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h    Thu Dec  8 
14:33:10 2005
@@ -67,6 +67,8 @@
 extern unsigned long *phys_to_machine_mapping;
 #define pfn_to_mfn(pfn)        \
 (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL << 63))
+#define        phys_to_machine_mapping_valid(pfn) \
+       (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
 static inline unsigned long mfn_to_pfn(unsigned long mfn)
 {
        unsigned long pfn;

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


 


Rackspace

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