mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] arm: ioremap: Fix static vm area boundary check.
@ 2014-05-16  9:35 Xiubo Li
  2014-05-16 18:11 ` Nicolas Pitre
  0 siblings, 1 reply; 4+ messages in thread
From: Xiubo Li @ 2014-05-16  9:35 UTC (permalink / raw)
  To: linux, lauraa, linux-arm-kernel, nico, santosh.shilimkar,
	iamjoonsoo.kim, superlibj8301
  Cc: linux-kernel, Xiubo Li

For each vmalloc area, there is one guard page at the end of it.
so the vm->size = PAGE_ALIGN(offset + request size) + guard page size.

Signed-off-by: Richard Lee <superlibj8301@gmail.com>
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Cc: Nicolas Pitre <nico@linaro.org>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 arch/arm/mm/ioremap.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index be69333..758e8f7 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -49,14 +49,18 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
 	struct vm_struct *vm;
 
 	list_for_each_entry(svm, &static_vmlist, list) {
+		phys_addr_t paddr_end, phys_addr_end;
+
 		vm = &svm->vm;
 		if (!(vm->flags & VM_ARM_STATIC_MAPPING))
 			continue;
 		if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
 			continue;
 
-		if (vm->phys_addr > paddr ||
-			paddr + size - 1 > vm->phys_addr + vm->size - 1)
+		/* The PAGE_SIZE here is vmalloc area's guard page */
+		phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - 1;
+		paddr_end = paddr + size - 1;
+		if (vm->phys_addr > paddr || paddr_end > phys_addr_end)
 			continue;
 
 		return svm;
-- 
1.8.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] arm: ioremap: Fix static vm area boundary check.
  2014-05-16  9:35 [PATCH v3] arm: ioremap: Fix static vm area boundary check Xiubo Li
@ 2014-05-16 18:11 ` Nicolas Pitre
  2014-05-19  2:49   ` Li.Xiubo
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Pitre @ 2014-05-16 18:11 UTC (permalink / raw)
  To: Xiubo Li
  Cc: linux, lauraa, linux-arm-kernel, santosh.shilimkar,
	iamjoonsoo.kim, superlibj8301, linux-kernel

On Fri, 16 May 2014, Xiubo Li wrote:

> For each vmalloc area, there is one guard page at the end of it.
> so the vm->size = PAGE_ALIGN(offset + request size) + guard page size.

Nope.  There is no guard page for statically created vmalloc areas.


> Signed-off-by: Richard Lee <superlibj8301@gmail.com>
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> Cc: Nicolas Pitre <nico@linaro.org>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> ---
>  arch/arm/mm/ioremap.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
> index be69333..758e8f7 100644
> --- a/arch/arm/mm/ioremap.c
> +++ b/arch/arm/mm/ioremap.c
> @@ -49,14 +49,18 @@ static struct static_vm *find_static_vm_paddr(phys_addr_t paddr,
>  	struct vm_struct *vm;
>  
>  	list_for_each_entry(svm, &static_vmlist, list) {
> +		phys_addr_t paddr_end, phys_addr_end;
> +
>  		vm = &svm->vm;
>  		if (!(vm->flags & VM_ARM_STATIC_MAPPING))
>  			continue;
>  		if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
>  			continue;
>  
> -		if (vm->phys_addr > paddr ||
> -			paddr + size - 1 > vm->phys_addr + vm->size - 1)
> +		/* The PAGE_SIZE here is vmalloc area's guard page */
> +		phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - 1;
> +		paddr_end = paddr + size - 1;
> +		if (vm->phys_addr > paddr || paddr_end > phys_addr_end)
>  			continue;
>  
>  		return svm;
> -- 
> 1.8.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v3] arm: ioremap: Fix static vm area boundary check.
  2014-05-16 18:11 ` Nicolas Pitre
@ 2014-05-19  2:49   ` Li.Xiubo
  2014-05-20  3:13     ` Nicolas Pitre
  0 siblings, 1 reply; 4+ messages in thread
From: Li.Xiubo @ 2014-05-19  2:49 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: linux, lauraa, linux-arm-kernel, santosh.shilimkar,
	iamjoonsoo.kim, superlibj8301, linux-kernel

> > For each vmalloc area, there is one guard page at the end of it.
> > so the vm->size = PAGE_ALIGN(offset + request size) + guard page size.
> 
> Nope.  There is no guard page for statically created vmalloc areas.
> 

Yes, you are right, I'm thinking why the static area has no guard page?

Thanks very much,

BRs
Xiubo


> 
> > Signed-off-by: Richard Lee <superlibj8301@gmail.com>
> > Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> > Cc: Nicolas Pitre <nico@linaro.org>
> > Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> > Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> > ---
> >  arch/arm/mm/ioremap.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
> > index be69333..758e8f7 100644
> > --- a/arch/arm/mm/ioremap.c
> > +++ b/arch/arm/mm/ioremap.c
> > @@ -49,14 +49,18 @@ static struct static_vm
> *find_static_vm_paddr(phys_addr_t paddr,
> >  	struct vm_struct *vm;
> >
> >  	list_for_each_entry(svm, &static_vmlist, list) {
> > +		phys_addr_t paddr_end, phys_addr_end;
> > +
> >  		vm = &svm->vm;
> >  		if (!(vm->flags & VM_ARM_STATIC_MAPPING))
> >  			continue;
> >  		if ((vm->flags & VM_ARM_MTYPE_MASK) != VM_ARM_MTYPE(mtype))
> >  			continue;
> >
> > -		if (vm->phys_addr > paddr ||
> > -			paddr + size - 1 > vm->phys_addr + vm->size - 1)
> > +		/* The PAGE_SIZE here is vmalloc area's guard page */
> > +		phys_addr_end = vm->phys_addr + vm->size - PAGE_SIZE - 1;
> > +		paddr_end = paddr + size - 1;
> > +		if (vm->phys_addr > paddr || paddr_end > phys_addr_end)
> >  			continue;
> >
> >  		return svm;
> > --
> > 1.8.4
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v3] arm: ioremap: Fix static vm area boundary check.
  2014-05-19  2:49   ` Li.Xiubo
@ 2014-05-20  3:13     ` Nicolas Pitre
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Pitre @ 2014-05-20  3:13 UTC (permalink / raw)
  To: Li.Xiubo
  Cc: linux, lauraa, linux-arm-kernel, santosh.shilimkar,
	iamjoonsoo.kim, superlibj8301, linux-kernel

On Mon, 19 May 2014, Li.Xiubo@freescale.com wrote:

> > > For each vmalloc area, there is one guard page at the end of it.
> > > so the vm->size = PAGE_ALIGN(offset + request size) + guard page size.
> > 
> > Nope.  There is no guard page for statically created vmalloc areas.
> > 
> 
> Yes, you are right, I'm thinking why the static area has no guard page?

The virtual addresses being used are provided by the static mapping 
descriptions themselves.  Sometimes those mappings are large and 
contiguous, covering multiple peripherals at once with a single TLB, 
etc.  There is simply no room for a guard page, or no guard page at all 
between different areas covered by a single section mapping (1MB worth 
of mapping from a single page table entry).

All this to say that trying to enforce a guard page in those cases is 
likely to throw away all the performance advantage and conplexify 
things.


Nicolas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-20  3:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-16  9:35 [PATCH v3] arm: ioremap: Fix static vm area boundary check Xiubo Li
2014-05-16 18:11 ` Nicolas Pitre
2014-05-19  2:49   ` Li.Xiubo
2014-05-20  3:13     ` Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®