[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [IA64] Add support for enforcing singleshot mmap() semantics at the
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Node ID 5b3ec078993b11433ba6345e0651143d350b488d # Parent d2e6a7be622d306528074b62ea21d0b672ebd0ea [IA64] Add support for enforcing singleshot mmap() semantics at the privcmd interface. From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx> Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> --- linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c | 14 ++++++++++++++ linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c | 14 +++++++------- linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff -r d2e6a7be622d -r 5b3ec078993b linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c --- a/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c Thu Oct 12 11:44:53 2006 +0100 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c Thu Oct 12 13:55:03 2006 +0100 @@ -546,6 +546,7 @@ struct xen_ia64_privcmd_range { }; struct xen_ia64_privcmd_vma { + int is_privcmd_mmapped; struct xen_ia64_privcmd_range* range; unsigned long num_entries; @@ -684,12 +685,15 @@ static void static void xen_ia64_privcmd_vma_open(struct vm_area_struct* vma) { + struct xen_ia64_privcmd_vma* old_privcmd_vma = (struct xen_ia64_privcmd_vma*)vma->vm_private_data; struct xen_ia64_privcmd_vma* privcmd_vma = (struct xen_ia64_privcmd_vma*)vma->vm_private_data; struct xen_ia64_privcmd_range* privcmd_range = privcmd_vma->range; atomic_inc(&privcmd_range->ref_count); // vm_op->open() can't fail. privcmd_vma = kmalloc(sizeof(*privcmd_vma), GFP_KERNEL | __GFP_NOFAIL); + // copy original value if necessary + privcmd_vma->is_privcmd_mmapped = old_privcmd_vma->is_privcmd_mmapped; __xen_ia64_privcmd_vma_open(vma, privcmd_vma, privcmd_range); } @@ -722,6 +726,14 @@ xen_ia64_privcmd_vma_close(struct vm_are kfree(privcmd_range->res); vfree(privcmd_range); } +} + +int +privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma) +{ + struct xen_ia64_privcmd_vma* privcmd_vma = + (struct xen_ia64_privcmd_vma *)vma->vm_private_data; + return (xchg(&privcmd_vma->is_privcmd_mmapped, 1) == 0); } int @@ -749,6 +761,8 @@ privcmd_mmap(struct file * file, struct if (privcmd_vma == NULL) { goto out_enomem1; } + privcmd_vma->is_privcmd_mmapped = 0; + res = kzalloc(sizeof(*res), GFP_KERNEL); if (res == NULL) { goto out_enomem1; diff -r d2e6a7be622d -r 5b3ec078993b linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Thu Oct 12 11:44:53 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Thu Oct 12 13:55:03 2006 +0100 @@ -35,14 +35,9 @@ static struct proc_dir_entry *privcmd_in static struct proc_dir_entry *privcmd_intf; static struct proc_dir_entry *capabilities_intf; -static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma) -{ #ifndef HAVE_ARCH_PRIVCMD_MMAP - if (xchg(&vma->vm_private_data, (void *)1) != NULL) - return 0; -#endif - return 1; -} +static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma); +#endif static int privcmd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data) @@ -255,6 +250,11 @@ static int privcmd_mmap(struct file * fi return 0; } + +static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma) +{ + return (xchg(&vma->vm_private_data, (void *)1) == NULL); +} #endif static struct file_operations privcmd_file_ops = { diff -r d2e6a7be622d -r 5b3ec078993b linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Thu Oct 12 11:44:53 2006 +0100 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h Thu Oct 12 13:55:03 2006 +0100 @@ -138,6 +138,7 @@ int direct_remap_pfn_range(struct vm_are pgprot_t prot, domid_t domid); struct file; +int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma); int privcmd_mmap(struct file * file, struct vm_area_struct * vma); #define HAVE_ARCH_PRIVCMD_MMAP _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |