ia64/xen-unstable

changeset 6907:e1cc553059e1

direct_remap_pfn_range() takes a vm_area_struct rather than
an mm_struct. Also it sets VM_RESERVED and VM_IO, just like
generic remap_pfn_range() in mm/memory.c.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 16 10:57:31 2005 +0000 (2005-09-16)
parents 0f851f965df9
children 3a7c0b00da8a
files linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c linux-2.6-xen-sparse/arch/xen/i386/pci/i386.c linux-2.6-xen-sparse/arch/xen/kernel/devmem.c linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Fri Sep 16 09:16:24 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Fri Sep 16 10:57:31 2005 +0000
     1.3 @@ -45,12 +45,12 @@ static int direct_remap_area_pte_fn(pte_
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 -int direct_remap_pfn_range(struct mm_struct *mm,
     1.8 -			    unsigned long address, 
     1.9 -			    unsigned long mfn,
    1.10 -			    unsigned long size, 
    1.11 -			    pgprot_t prot,
    1.12 -			    domid_t  domid)
    1.13 +static int __direct_remap_pfn_range(struct mm_struct *mm,
    1.14 +				    unsigned long address, 
    1.15 +				    unsigned long mfn,
    1.16 +				    unsigned long size, 
    1.17 +				    pgprot_t prot,
    1.18 +				    domid_t  domid)
    1.19  {
    1.20  	int i;
    1.21  	unsigned long start_address;
    1.22 @@ -98,6 +98,20 @@ int direct_remap_pfn_range(struct mm_str
    1.23  	return 0;
    1.24  }
    1.25  
    1.26 +int direct_remap_pfn_range(struct vm_area_struct *vma,
    1.27 +			   unsigned long address, 
    1.28 +			   unsigned long mfn,
    1.29 +			   unsigned long size, 
    1.30 +			   pgprot_t prot,
    1.31 +			   domid_t  domid)
    1.32 +{
    1.33 +	/* Same as remap_pfn_range(). */
    1.34 +	vma->vm_flags |= VM_IO | VM_RESERVED;
    1.35 +
    1.36 +	return __direct_remap_pfn_range(
    1.37 +		vma->vm_mm, address, mfn, size, prot, domid);
    1.38 +}
    1.39 +
    1.40  EXPORT_SYMBOL(direct_remap_pfn_range);
    1.41  
    1.42  
    1.43 @@ -221,8 +235,9 @@ void __iomem * __ioremap(unsigned long p
    1.44  #ifdef __x86_64__
    1.45  	flags |= _PAGE_USER;
    1.46  #endif
    1.47 -	if (direct_remap_pfn_range(&init_mm, (unsigned long) addr, phys_addr>>PAGE_SHIFT,
    1.48 -				    size, __pgprot(flags), domid)) {
    1.49 +	if (__direct_remap_pfn_range(&init_mm, (unsigned long)addr,
    1.50 +				     phys_addr>>PAGE_SHIFT,
    1.51 +				     size, __pgprot(flags), domid)) {
    1.52  		vunmap((void __force *) addr);
    1.53  		return NULL;
    1.54  	}
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/pci/i386.c	Fri Sep 16 09:16:24 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/pci/i386.c	Fri Sep 16 10:57:31 2005 +0000
     2.3 @@ -295,7 +295,7 @@ int pci_mmap_page_range(struct pci_dev *
     2.4  	/* Write-combine setting is ignored, it is changed via the mtrr
     2.5  	 * interfaces on this platform.
     2.6  	 */
     2.7 -	if (direct_remap_pfn_range(vma->vm_mm, vma->vm_start, vma->vm_pgoff,
     2.8 +	if (direct_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
     2.9  				   vma->vm_end - vma->vm_start,
    2.10  				   vma->vm_page_prot, DOMID_IO))
    2.11  		return -EAGAIN;
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/devmem.c	Fri Sep 16 09:16:24 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/devmem.c	Fri Sep 16 10:57:31 2005 +0000
     3.3 @@ -90,22 +90,10 @@ out:
     3.4  
     3.5  static int mmap_mem(struct file * file, struct vm_area_struct * vma)
     3.6  {
     3.7 -	int uncached;
     3.8 -
     3.9 -	uncached = uncached_access(file);
    3.10 -	if (uncached)
    3.11 +	if (uncached_access(file))
    3.12  		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
    3.13  
    3.14 -	/* Don't try to swap out physical pages.. */
    3.15 -	vma->vm_flags |= VM_RESERVED;
    3.16 -
    3.17 -	/*
    3.18 -	 * Don't dump addresses that are not real memory to a core file.
    3.19 -	 */
    3.20 -	if (uncached)
    3.21 -		vma->vm_flags |= VM_IO;
    3.22 -
    3.23 -	if (direct_remap_pfn_range(vma->vm_mm, vma->vm_start, vma->vm_pgoff,
    3.24 +	if (direct_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
    3.25  				   vma->vm_end - vma->vm_start,
    3.26  				   vma->vm_page_prot, DOMID_IO))
    3.27  		return -EAGAIN;
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Fri Sep 16 09:16:24 2005 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Fri Sep 16 10:57:31 2005 +0000
     4.3 @@ -130,12 +130,12 @@ static int privcmd_ioctl(struct inode *i
     4.4                  if ( (msg[j].va + (msg[j].npages<<PAGE_SHIFT)) > vma->vm_end )
     4.5                      return -EINVAL;
     4.6  
     4.7 -                if ( (rc = direct_remap_pfn_range(vma->vm_mm, 
     4.8 -                                                   msg[j].va&PAGE_MASK, 
     4.9 -                                                   msg[j].mfn, 
    4.10 -                                                   msg[j].npages<<PAGE_SHIFT, 
    4.11 -                                                   vma->vm_page_prot,
    4.12 -                                                   mmapcmd.dom)) < 0 )
    4.13 +                if ( (rc = direct_remap_pfn_range(vma,
    4.14 +                                                  msg[j].va&PAGE_MASK, 
    4.15 +                                                  msg[j].mfn, 
    4.16 +                                                  msg[j].npages<<PAGE_SHIFT, 
    4.17 +                                                  vma->vm_page_prot,
    4.18 +                                                  mmapcmd.dom)) < 0 )
    4.19                      return rc;
    4.20              }
    4.21          }
     5.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Sep 16 09:16:24 2005 +0000
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Sep 16 10:57:31 2005 +0000
     5.3 @@ -460,7 +460,7 @@ void make_pages_writable(void *va, unsig
     5.4  #define kern_addr_valid(addr)	(1)
     5.5  #endif /* !CONFIG_DISCONTIGMEM */
     5.6  
     5.7 -int direct_remap_pfn_range(struct mm_struct *mm,
     5.8 +int direct_remap_pfn_range(struct vm_area_struct *vma,
     5.9                              unsigned long address, 
    5.10                              unsigned long mfn,
    5.11                              unsigned long size, 
    5.12 @@ -474,10 +474,10 @@ int touch_pte_range(struct mm_struct *mm
    5.13                      unsigned long size);
    5.14  
    5.15  #define io_remap_page_range(vma,from,phys,size,prot) \
    5.16 -direct_remap_pfn_range(vma->vm_mm,from,phys>>PAGE_SHIFT,size,prot,DOMID_IO)
    5.17 +direct_remap_pfn_range(vma,from,(phys)>>PAGE_SHIFT,size,prot,DOMID_IO)
    5.18  
    5.19  #define io_remap_pfn_range(vma,from,pfn,size,prot) \
    5.20 -direct_remap_pfn_range(vma->vm_mm,from,pfn,size,prot,DOMID_IO)
    5.21 +direct_remap_pfn_range(vma,from,pfn,size,prot,DOMID_IO)
    5.22  
    5.23  #define MK_IOSPACE_PFN(space, pfn)	(pfn)
    5.24  #define GET_IOSPACE(pfn)		0
     6.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h	Fri Sep 16 09:16:24 2005 +0000
     6.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h	Fri Sep 16 10:57:31 2005 +0000
     6.3 @@ -526,7 +526,7 @@ extern int kern_addr_valid(unsigned long
     6.4  
     6.5  #define DOMID_LOCAL (0xFFFFU)
     6.6  
     6.7 -int direct_remap_pfn_range(struct mm_struct *mm,
     6.8 +int direct_remap_pfn_range(struct vm_area_struct *vma,
     6.9                              unsigned long address,
    6.10                              unsigned long mfn,
    6.11                              unsigned long size,
    6.12 @@ -542,10 +542,10 @@ int touch_pte_range(struct mm_struct *mm
    6.13                      unsigned long size);
    6.14  
    6.15  #define io_remap_page_range(vma, vaddr, paddr, size, prot)		\
    6.16 -		direct_remap_pfn_range((vma)->vm_mm,vaddr,paddr>>PAGE_SHIFT,size,prot,DOMID_IO)
    6.17 +		direct_remap_pfn_range(vma,vaddr,(paddr)>>PAGE_SHIFT,size,prot,DOMID_IO)
    6.18  
    6.19  #define io_remap_pfn_range(vma, vaddr, pfn, size, prot)		\
    6.20 -		direct_remap_pfn_range((vma)->vm_mm,vaddr,pfn,size,prot,DOMID_IO)
    6.21 +		direct_remap_pfn_range(vma,vaddr,pfn,size,prot,DOMID_IO)
    6.22  
    6.23  #define MK_IOSPACE_PFN(space, pfn)	(pfn)
    6.24  #define GET_IOSPACE(pfn)		0