[4/7] Xen VMM patch set : /dev/mem io_remap_page_range for CONFIG_XEN

From: Ian Pratt
Date: Fri Nov 19 2004 - 18:45:50 EST



This patch modifies /dev/mem to call io_remap_page_range rather than
remap_pfn_range under CONFIG_XEN. This is required because in arch
xen we need to use a different function for mapping MMIO space vs
mapping psueudo-physical memory. This allows the X server and other
programs that use /dev/mem for MMIO to work under Xen.

Signed-off-by: ian.pratt@xxxxxxxxxxxx

---


diff -Nurp pristine-linux-2.6.10-rc2/drivers/char/mem.c tmp-linux-2.6.10-rc2-xen.patch/drivers/char/mem.c
--- pristine-linux-2.6.10-rc2/drivers/char/mem.c 2004-11-15 01:27:41.000000000 +0000
+++ tmp-linux-2.6.10-rc2-xen.patch/drivers/char/mem.c 2004-11-19 16:33:04.000000000 +0000
@@ -42,7 +42,12 @@ extern void tapechar_init(void);
*/
static inline int uncached_access(struct file *file, unsigned long addr)
{
-#if defined(__i386__)
+#ifdef CONFIG_XEN
+ if (file->f_flags & O_SYNC)
+ return 1;
+ /* Xen sets correct MTRR type on non-RAM for us. */
+ return 0;
+#elif defined(__i386__)
/*
* On the PPro and successors, the MTRRs are used to set
* memory types for physical addresses outside main memory,
@@ -201,6 +206,14 @@ static int mmap_mem(struct file * file,
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
#endif

+#if defined(CONFIG_XEN)
+ if (io_remap_page_range(vma,
+ vma->vm_start,
+ vma->vm_pgoff << PAGE_SHIFT,
+ vma->vm_end-vma->vm_start,
+ vma->vm_page_prot))
+ return -EAGAIN;
+#else
/* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
if (remap_pfn_range(vma,
vma->vm_start,
@@ -208,6 +221,7 @@ static int mmap_mem(struct file * file,
vma->vm_end-vma->vm_start,
vma->vm_page_prot))
return -EAGAIN;
+#endif
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/