aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-17 16:21:08 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-17 16:21:08 +0100
commit738c1ffa96b8d8057f0698138d5a539e963116f2 (patch)
tree1178a6e7a42fc28f35b987c586cd09fb2824ca09
parent98abf9b1f795271a8bafb74b97e856aafb185eb9 (diff)
downloadxen-738c1ffa96b8d8057f0698138d5a539e963116f2.tar.gz
xen-738c1ffa96b8d8057f0698138d5a539e963116f2.tar.bz2
xen-738c1ffa96b8d8057f0698138d5a539e963116f2.zip
[HVM] Make grant tables functions work in PV-on-HVM drivers.
Signed-off-by: Steven Smith <ssmith@xensource.com>
-rw-r--r--linux-2.6-xen-sparse/drivers/xen/core/gnttab.c48
-rw-r--r--unmodified_drivers/linux-2.6/mkbuildtree1
-rw-r--r--unmodified_drivers/linux-2.6/platform-pci/Kbuild2
-rw-r--r--unmodified_drivers/linux-2.6/platform-pci/platform-pci.c9
-rw-r--r--unmodified_drivers/linux-2.6/platform-pci/platform-pci.h2
5 files changed, 54 insertions, 8 deletions
diff --git a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
index a8dc712109..36e627f60c 100644
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
@@ -41,6 +41,8 @@
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/synch_bitops.h>
+#include <asm/io.h>
+#include <xen/interface/memory.h>
/* External tools reserve first few grant table entries. */
#define NR_RESERVED_ENTRIES 8
@@ -350,6 +352,8 @@ void gnttab_cancel_free_callback(struct gnttab_free_callback *callback)
}
EXPORT_SYMBOL_GPL(gnttab_cancel_free_callback);
+#ifdef CONFIG_XEN
+
#ifndef __ia64__
static int map_pte_fn(pte_t *pte, struct page *pmd_page,
unsigned long addr, void *data)
@@ -404,23 +408,57 @@ int gnttab_resume(void)
shared = __va(frames[0] << PAGE_SHIFT);
printk("grant table at %p\n", shared);
#endif
-
- return 0;
}
int gnttab_suspend(void)
{
-
#ifndef __ia64__
apply_to_page_range(&init_mm, (unsigned long)shared,
PAGE_SIZE * NR_GRANT_FRAMES,
unmap_pte_fn, NULL);
#endif
+ return 0;
+}
+
+#else /* !CONFIG_XEN */
+
+#include <platform-pci.h>
+
+int gnttab_resume(void)
+{
+ unsigned long frames;
+ struct xen_add_to_physmap xatp;
+ unsigned int i;
+
+ frames = alloc_xen_mmio(PAGE_SIZE * NR_GRANT_FRAMES);
+
+ for (i = 0; i < NR_GRANT_FRAMES; i++) {
+ xatp.domid = DOMID_SELF;
+ xatp.idx = i;
+ xatp.space = XENMAPSPACE_grant_table;
+ xatp.gpfn = (frames >> PAGE_SHIFT) + i;
+ if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
+ BUG();
+ }
+
+ shared = ioremap(frames, PAGE_SIZE * NR_GRANT_FRAMES);
+ if (shared == NULL) {
+ printk("error to ioremap gnttab share frames\n");
+ return -1;
+ }
return 0;
}
-static int __init gnttab_init(void)
+int gnttab_suspend(void)
+{
+ iounmap(shared);
+ return 0;
+}
+
+#endif /* !CONFIG_XEN */
+
+int __init gnttab_init(void)
{
int i;
@@ -439,4 +477,6 @@ static int __init gnttab_init(void)
return 0;
}
+#ifdef CONFIG_XEN
core_initcall(gnttab_init);
+#endif
diff --git a/unmodified_drivers/linux-2.6/mkbuildtree b/unmodified_drivers/linux-2.6/mkbuildtree
index 618b5c594f..6002b2722d 100644
--- a/unmodified_drivers/linux-2.6/mkbuildtree
+++ b/unmodified_drivers/linux-2.6/mkbuildtree
@@ -5,6 +5,7 @@ C=$PWD
XEN=$C/../../xen
XL=$C/../../linux-2.6-xen-sparse
+ln -sf ${XL}/drivers/xen/core/gnttab.c platform-pci
ln -sf ${XL}/drivers/xen/core/features.c platform-pci
mkdir -p include
diff --git a/unmodified_drivers/linux-2.6/platform-pci/Kbuild b/unmodified_drivers/linux-2.6/platform-pci/Kbuild
index 0e85e50ff0..a4c1961a8a 100644
--- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild
+++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild
@@ -4,4 +4,4 @@ obj-m := xen-platform-pci.o
EXTRA_CFLAGS += -I$(M)/platform-pci
-xen-platform-pci-objs := evtchn.o platform-pci.o xen_support.o features.o
+xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o
diff --git a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
index 941608d12f..f32399c3ce 100644
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
@@ -64,15 +64,18 @@ static int __init init_xen_info(void)
xatp.idx = 0;
xatp.space = XENMAPSPACE_shared_info;
xatp.gpfn = shared_info_frame;
- BUG_ON(HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp));
+ if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
+ BUG();
+
shared_info_area =
ioremap(shared_info_frame << PAGE_SHIFT, PAGE_SIZE);
-
- if (!shared_info_area)
+ if (shared_info_area == NULL)
panic("can't map shared info\n");
phys_to_machine_mapping = NULL;
+ gnttab_init();
+
return 0;
}
diff --git a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h
index 8af732c69f..5e10413b13 100644
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h
@@ -36,6 +36,8 @@ static inline int set_callback_irq(int irq)
unsigned long alloc_xen_mmio(unsigned long len);
+int gnttab_init(void);
+
void setup_xen_features(void);
irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs);