- Update Xen patches to 3.3-rc5 and c/s 1157.
[linux-flexiantxendom0-3.2.10.git] / drivers / char / mem.c
index d6e9d08..764cfb1 100644 (file)
@@ -87,6 +87,7 @@ void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr)
 {
 }
 
+#ifndef ARCH_HAS_DEV_MEM
 /*
  * This funcion reads the *physical* memory. The f_pos points directly to the
  * memory location.
@@ -209,6 +210,7 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
        *ppos += written;
        return written;
 }
+#endif
 
 int __weak phys_mem_access_prot_allowed(struct file *file,
        unsigned long pfn, unsigned long size, pgprot_t *vma_prot)
@@ -335,6 +337,9 @@ static int mmap_mem(struct file *file, struct vm_area_struct *vma)
 static int mmap_kmem(struct file *file, struct vm_area_struct *vma)
 {
        unsigned long pfn;
+#ifdef CONFIG_XEN
+       unsigned long i, count;
+#endif
 
        /* Turn a kernel-virtual address into a physical page frame */
        pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT;
@@ -349,6 +354,13 @@ static int mmap_kmem(struct file *file, struct vm_area_struct *vma)
        if (!pfn_valid(pfn))
                return -EIO;
 
+#ifdef CONFIG_XEN
+       count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+       for (i = 0; i < count; i++)
+               if ((pfn + i) != mfn_to_local_pfn(pfn_to_mfn(pfn + i)))
+                       return -EIO;
+#endif
+
        vma->vm_pgoff = pfn;
        return mmap_mem(file, vma);
 }
@@ -740,6 +752,7 @@ static int open_port(struct inode * inode, struct file * filp)
 #define open_kmem      open_mem
 #define open_oldmem    open_mem
 
+#ifndef ARCH_HAS_DEV_MEM
 static const struct file_operations mem_fops = {
        .llseek         = memory_lseek,
        .read           = read_mem,
@@ -748,6 +761,9 @@ static const struct file_operations mem_fops = {
        .open           = open_mem,
        .get_unmapped_area = get_unmapped_area_mem,
 };
+#else
+extern const struct file_operations mem_fops;
+#endif
 
 #ifdef CONFIG_DEVKMEM
 static const struct file_operations kmem_fops = {