Attached patch makes the balloon driver arch-neutral
(compiles on ia64... look ma, no #ifdef's!). Please apply
to xen-unstable.
One change should be eyeballed, line 257 in balloon.c, because
phys_to_machine_mapping[pfn] is not identical to pfn_to_mfn
(different by sign bit, should be OK?)
Signed-off by: Dan Magenheimer <dan.magenheimer@xxxxxx>
diff -r 0255f48b757f linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Tue Dec
6 16:25:53 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 0255f48b757f
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 Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h Tue Dec
6 16:25:53 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 0255f48b757f
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 Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h Tue Dec
6 16:25:53 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 0255f48b757f
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
Sun Dec 4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h
Tue Dec 6 16:25:53 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 0255f48b757f
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 Sun Dec
4 19:12:00 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h Tue Dec
6 16:25:53 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|