ia64/xen-unstable

changeset 11789:d2e6a7be622d

[PRIVCMD] Fix ia64 domain creation by abstracting the singleshot mapping check.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Oct 12 11:44:53 2006 +0100 (2006-10-12)
parents 5297ced4d610
children 5b3ec078993b
files linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu Oct 12 11:26:07 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu Oct 12 11:44:53 2006 +0100
     1.3 @@ -35,6 +35,15 @@
     1.4  static struct proc_dir_entry *privcmd_intf;
     1.5  static struct proc_dir_entry *capabilities_intf;
     1.6  
     1.7 +static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma)
     1.8 +{
     1.9 +#ifndef HAVE_ARCH_PRIVCMD_MMAP
    1.10 +	if (xchg(&vma->vm_private_data, (void *)1) != NULL)
    1.11 +		return 0;
    1.12 +#endif
    1.13 +	return 1;
    1.14 +}
    1.15 +
    1.16  static int privcmd_ioctl(struct inode *inode, struct file *file,
    1.17  			 unsigned int cmd, unsigned long data)
    1.18  {
    1.19 @@ -122,12 +131,10 @@ static int privcmd_ioctl(struct inode *i
    1.20  
    1.21  		vma = find_vma(mm, msg.va);
    1.22  		rc = -EINVAL;
    1.23 -		if (!vma || (msg.va != vma->vm_start) || vma->vm_private_data)
    1.24 +		if (!vma || (msg.va != vma->vm_start) ||
    1.25 +		    !privcmd_enforce_singleshot_mapping(vma))
    1.26  			goto mmap_out;
    1.27  
    1.28 -		/* Mapping is a one-shot operation per vma. */
    1.29 -		vma->vm_private_data = (void *)1;
    1.30 -
    1.31  		va = vma->vm_start;
    1.32  
    1.33  		for (i = 0; i < mmapcmd.num; i++) {
    1.34 @@ -190,14 +197,11 @@ static int privcmd_ioctl(struct inode *i
    1.35  		if (!vma ||
    1.36  		    (m.addr != vma->vm_start) ||
    1.37  		    ((m.addr + (m.num<<PAGE_SHIFT)) != vma->vm_end) ||
    1.38 -		    vma->vm_private_data) {
    1.39 +		    !privcmd_enforce_singleshot_mapping(vma)) {
    1.40  			up_read(&mm->mmap_sem);
    1.41  			return -EINVAL;
    1.42  		}
    1.43  
    1.44 -		/* Mapping is a one-shot operation per vma. */
    1.45 -		vma->vm_private_data = (void *)1;
    1.46 -
    1.47  		p = m.arr;
    1.48  		addr = m.addr;
    1.49  		for (i = 0; i < m.num; i++, addr += PAGE_SIZE, p++) {