* nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces.
@ 2007-11-28 8:49 Paul Mundt
2007-11-28 10:18 ` David McCullough
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paul Mundt @ 2007-11-28 8:49 UTC (permalink / raw)
To: Andrew Morton; +Cc: David Howells, Greg Ungerer, David McCullough, linux-kernel
This builds on top of the earlier vmalloc_32_user() work introduced by
b50731732f926d6c49fd0724616a7344c31cd5cf, as we now have places in the
nommu allmodconfig that hit up against these missing APIs.
As vmalloc_32_user() is already implemented, this is moved over to
vmalloc_user() and simply made a wrapper. As all current nommu platforms
are 32-bit addressable, there's no special casing we have to do for
ZONE_DMA and things of that nature as per GFP_VMALLOC32.
remap_vmalloc_range() needs to check VM_USERMAP in order to figure out
whether we permit the remap or not, which means that we also have to
rework the vmalloc_user() code to grovel for the VMA and set the flag.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
---
mm/nommu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index 35622c5..c4768d0 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -10,6 +10,7 @@
* Copyright (c) 2000-2003 David McCullough <davidm@snapgear.com>
* Copyright (c) 2000-2001 D Jeff Dionne <jeff@uClinux.org>
* Copyright (c) 2002 Greg Ungerer <gerg@snapgear.com>
+ * Copyright (c) 2007 Paul Mundt <lethal@linux-sh.org>
*/
#include <linux/module.h>
@@ -183,6 +184,26 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
}
EXPORT_SYMBOL(__vmalloc);
+void *vmalloc_user(unsigned long size)
+{
+ void *ret;
+
+ ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
+ PAGE_KERNEL);
+ if (ret) {
+ struct vm_area_struct *vma;
+
+ down_write(¤t->mm->mmap_sem);
+ vma = find_vma(current->mm, (unsigned long)ret);
+ if (vma)
+ vma->vm_flags |= VM_USERMAP;
+ up_write(¤t->mm->mmap_sem);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(vmalloc_user);
+
struct page * vmalloc_to_page(void *addr)
{
return virt_to_page(addr);
@@ -253,10 +274,17 @@ EXPORT_SYMBOL(vmalloc_32);
*
* The resulting memory area is 32bit addressable and zeroed so it can be
* mapped to userspace without leaking data.
+ *
+ * VM_USERMAP is set on the corresponding VMA so that subsequent calls to
+ * remap_vmalloc_range() are permissible.
*/
void *vmalloc_32_user(unsigned long size)
{
- return __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
+ /*
+ * We'll have to sort out the ZONE_DMA bits for 64-bit,
+ * but for now this can simply use vmalloc_user() directly.
+ */
+ return vmalloc_user(size);
}
EXPORT_SYMBOL(vmalloc_32_user);
@@ -1213,6 +1241,21 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
}
EXPORT_SYMBOL(remap_pfn_range);
+int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
+ unsigned long pgoff)
+{
+ unsigned int size = vma->vm_end - vma->vm_start;
+
+ if (!(vma->vm_flags & VM_USERMAP))
+ return -EINVAL;
+
+ vma->vm_start = (unsigned long)(addr + (pgoff << PAGE_SHIFT));
+ vma->vm_end = vma->vm_start + size;
+
+ return 0;
+}
+EXPORT_SYMBOL(remap_vmalloc_range);
+
void swap_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
{
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces.
2007-11-28 8:49 nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces Paul Mundt
@ 2007-11-28 10:18 ` David McCullough
2007-11-28 14:39 ` David Howells
2007-11-29 6:17 ` Greg Ungerer
2 siblings, 0 replies; 4+ messages in thread
From: David McCullough @ 2007-11-28 10:18 UTC (permalink / raw)
To: Paul Mundt, Andrew Morton, David Howells, Greg Ungerer,
linux-kernel
Jivin Paul Mundt lays it down ...
> This builds on top of the earlier vmalloc_32_user() work introduced by
> b50731732f926d6c49fd0724616a7344c31cd5cf, as we now have places in the
> nommu allmodconfig that hit up against these missing APIs.
>
> As vmalloc_32_user() is already implemented, this is moved over to
> vmalloc_user() and simply made a wrapper. As all current nommu platforms
> are 32-bit addressable, there's no special casing we have to do for
> ZONE_DMA and things of that nature as per GFP_VMALLOC32.
>
> remap_vmalloc_range() needs to check VM_USERMAP in order to figure out
> whether we permit the remap or not, which means that we also have to
> rework the vmalloc_user() code to grovel for the VMA and set the flag.
Seems fine to me,
Cheers,
Davidm
Acked-by: David McCullough <david_mccullough@securecomputing.com>
> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
>
> ---
>
> mm/nommu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 35622c5..c4768d0 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -10,6 +10,7 @@
> * Copyright (c) 2000-2003 David McCullough <davidm@snapgear.com>
> * Copyright (c) 2000-2001 D Jeff Dionne <jeff@uClinux.org>
> * Copyright (c) 2002 Greg Ungerer <gerg@snapgear.com>
> + * Copyright (c) 2007 Paul Mundt <lethal@linux-sh.org>
> */
>
> #include <linux/module.h>
> @@ -183,6 +184,26 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
> }
> EXPORT_SYMBOL(__vmalloc);
>
> +void *vmalloc_user(unsigned long size)
> +{
> + void *ret;
> +
> + ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
> + PAGE_KERNEL);
> + if (ret) {
> + struct vm_area_struct *vma;
> +
> + down_write(¤t->mm->mmap_sem);
> + vma = find_vma(current->mm, (unsigned long)ret);
> + if (vma)
> + vma->vm_flags |= VM_USERMAP;
> + up_write(¤t->mm->mmap_sem);
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(vmalloc_user);
> +
> struct page * vmalloc_to_page(void *addr)
> {
> return virt_to_page(addr);
> @@ -253,10 +274,17 @@ EXPORT_SYMBOL(vmalloc_32);
> *
> * The resulting memory area is 32bit addressable and zeroed so it can be
> * mapped to userspace without leaking data.
> + *
> + * VM_USERMAP is set on the corresponding VMA so that subsequent calls to
> + * remap_vmalloc_range() are permissible.
> */
> void *vmalloc_32_user(unsigned long size)
> {
> - return __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
> + /*
> + * We'll have to sort out the ZONE_DMA bits for 64-bit,
> + * but for now this can simply use vmalloc_user() directly.
> + */
> + return vmalloc_user(size);
> }
> EXPORT_SYMBOL(vmalloc_32_user);
>
> @@ -1213,6 +1241,21 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
> }
> EXPORT_SYMBOL(remap_pfn_range);
>
> +int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
> + unsigned long pgoff)
> +{
> + unsigned int size = vma->vm_end - vma->vm_start;
> +
> + if (!(vma->vm_flags & VM_USERMAP))
> + return -EINVAL;
> +
> + vma->vm_start = (unsigned long)(addr + (pgoff << PAGE_SHIFT));
> + vma->vm_end = vma->vm_start + size;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(remap_vmalloc_range);
> +
> void swap_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
> {
> }
--
David McCullough, david_mccullough@securecomputing.com, Ph:+61 734352815
Secure Computing - SnapGear http://www.uCdot.org http://www.cyberguard.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces.
2007-11-28 8:49 nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces Paul Mundt
2007-11-28 10:18 ` David McCullough
@ 2007-11-28 14:39 ` David Howells
2007-11-29 6:17 ` Greg Ungerer
2 siblings, 0 replies; 4+ messages in thread
From: David Howells @ 2007-11-28 14:39 UTC (permalink / raw)
To: Paul Mundt
Cc: dhowells, Andrew Morton, Greg Ungerer, David McCullough,
linux-kernel
Paul Mundt <lethal@linux-sh.org> wrote:
> This builds on top of the earlier vmalloc_32_user() work introduced by
> b50731732f926d6c49fd0724616a7344c31cd5cf, as we now have places in the
> nommu allmodconfig that hit up against these missing APIs.
>
> As vmalloc_32_user() is already implemented, this is moved over to
> vmalloc_user() and simply made a wrapper. As all current nommu platforms
> are 32-bit addressable, there's no special casing we have to do for
> ZONE_DMA and things of that nature as per GFP_VMALLOC32.
>
> remap_vmalloc_range() needs to check VM_USERMAP in order to figure out
> whether we permit the remap or not, which means that we also have to
> rework the vmalloc_user() code to grovel for the VMA and set the flag.
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces.
2007-11-28 8:49 nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces Paul Mundt
2007-11-28 10:18 ` David McCullough
2007-11-28 14:39 ` David Howells
@ 2007-11-29 6:17 ` Greg Ungerer
2 siblings, 0 replies; 4+ messages in thread
From: Greg Ungerer @ 2007-11-29 6:17 UTC (permalink / raw)
To: Paul Mundt, Andrew Morton, David Howells, David McCullough,
linux-kernel
Paul Mundt wrote:
> This builds on top of the earlier vmalloc_32_user() work introduced by
> b50731732f926d6c49fd0724616a7344c31cd5cf, as we now have places in the
> nommu allmodconfig that hit up against these missing APIs.
>
> As vmalloc_32_user() is already implemented, this is moved over to
> vmalloc_user() and simply made a wrapper. As all current nommu platforms
> are 32-bit addressable, there's no special casing we have to do for
> ZONE_DMA and things of that nature as per GFP_VMALLOC32.
>
> remap_vmalloc_range() needs to check VM_USERMAP in order to figure out
> whether we permit the remap or not, which means that we also have to
> rework the vmalloc_user() code to grovel for the VMA and set the flag.
>
> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Greg Ungerer <gerg@snapgear.com>
> mm/nommu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 35622c5..c4768d0 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -10,6 +10,7 @@
> * Copyright (c) 2000-2003 David McCullough <davidm@snapgear.com>
> * Copyright (c) 2000-2001 D Jeff Dionne <jeff@uClinux.org>
> * Copyright (c) 2002 Greg Ungerer <gerg@snapgear.com>
> + * Copyright (c) 2007 Paul Mundt <lethal@linux-sh.org>
> */
>
> #include <linux/module.h>
> @@ -183,6 +184,26 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
> }
> EXPORT_SYMBOL(__vmalloc);
>
> +void *vmalloc_user(unsigned long size)
> +{
> + void *ret;
> +
> + ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
> + PAGE_KERNEL);
> + if (ret) {
> + struct vm_area_struct *vma;
> +
> + down_write(¤t->mm->mmap_sem);
> + vma = find_vma(current->mm, (unsigned long)ret);
> + if (vma)
> + vma->vm_flags |= VM_USERMAP;
> + up_write(¤t->mm->mmap_sem);
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(vmalloc_user);
> +
> struct page * vmalloc_to_page(void *addr)
> {
> return virt_to_page(addr);
> @@ -253,10 +274,17 @@ EXPORT_SYMBOL(vmalloc_32);
> *
> * The resulting memory area is 32bit addressable and zeroed so it can be
> * mapped to userspace without leaking data.
> + *
> + * VM_USERMAP is set on the corresponding VMA so that subsequent calls to
> + * remap_vmalloc_range() are permissible.
> */
> void *vmalloc_32_user(unsigned long size)
> {
> - return __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
> + /*
> + * We'll have to sort out the ZONE_DMA bits for 64-bit,
> + * but for now this can simply use vmalloc_user() directly.
> + */
> + return vmalloc_user(size);
> }
> EXPORT_SYMBOL(vmalloc_32_user);
>
> @@ -1213,6 +1241,21 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
> }
> EXPORT_SYMBOL(remap_pfn_range);
>
> +int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
> + unsigned long pgoff)
> +{
> + unsigned int size = vma->vm_end - vma->vm_start;
> +
> + if (!(vma->vm_flags & VM_USERMAP))
> + return -EINVAL;
> +
> + vma->vm_start = (unsigned long)(addr + (pgoff << PAGE_SHIFT));
> + vma->vm_end = vma->vm_start + size;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(remap_vmalloc_range);
> +
> void swap_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
> {
> }
>
--
------------------------------------------------------------------------
Greg Ungerer -- Chief Software Dude EMAIL: gerg@snapgear.com
Secure Computing Corporation PHONE: +61 7 3435 2888
825 Stanley St, FAX: +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia WEB: http://www.SnapGear.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-11-29 6:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-28 8:49 nommu: Add new vmalloc_user() and remap_vmalloc_range() interfaces Paul Mundt
2007-11-28 10:18 ` David McCullough
2007-11-28 14:39 ` David Howells
2007-11-29 6:17 ` Greg Ungerer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).