* [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout
@ 2013-01-30 14:08 Will Deacon
2013-01-30 14:08 ` [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE Will Deacon
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Will Deacon @ 2013-01-30 14:08 UTC (permalink / raw)
To: linux-arm-kernel
Parts of the virtual memory layout (mainly the modules area) are
described using open-coded immediate values.
Use the SZ_ definitions from linux/sizes.h instead to make the code
clearer.
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm/include/asm/memory.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 73cf03a..a0fd518 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -36,23 +36,23 @@
* TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
*/
#define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
-#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
+#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
#define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
/*
* The maximum size of a 26-bit user space task.
*/
-#define TASK_SIZE_26 UL(0x04000000)
+#define TASK_SIZE_26 UL(SZ_64M)
/*
* The module space lives between the addresses given by TASK_SIZE
* and PAGE_OFFSET - it must be within 32MB of the kernel text.
*/
#ifndef CONFIG_THUMB2_KERNEL
-#define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024)
+#define MODULES_VADDR (PAGE_OFFSET - SZ_16M)
#else
/* smaller range for Thumb-2 symbols relocation (2^24)*/
-#define MODULES_VADDR (PAGE_OFFSET - 8*1024*1024)
+#define MODULES_VADDR (PAGE_OFFSET - SZ_8M)
#endif
#if TASK_SIZE > MODULES_VADDR
--
1.8.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE
2013-01-30 14:08 [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout Will Deacon
@ 2013-01-30 14:08 ` Will Deacon
2013-01-30 18:57 ` Nicolas Pitre
2013-01-30 18:49 ` [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout Nicolas Pitre
2013-01-30 20:41 ` Matt Sealey
2 siblings, 1 reply; 7+ messages in thread
From: Will Deacon @ 2013-01-30 14:08 UTC (permalink / raw)
To: linux-arm-kernel
TASK_UNMAPPED_BASE is defined directly in terms of PAGE_OFFSET, which is
confusing given that the modules area sits between here and TASK_SIZE
and is not available for user allocations.
This patch defines TASK_UNMAPPED_BASE in terms of TASK_SIZE instead and
fixes a bug introduced by 394ef6403abc ("mm: use vm_unmapped_area() on
arm architecture") whereby TASK_UNMAPPED_BASE is no longer page-aligned
for bottom-up mmap, causing get_unmapped_area to choke on misaligned
addresses.
Reported-by: Christoffer Dall <cdall@cs.columbia.edu>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm/include/asm/memory.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index a0fd518..255a01b 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -37,7 +37,7 @@
*/
#define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
-#define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
+#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~UL(SZ_16M - 1))
/*
* The maximum size of a 26-bit user space task.
--
1.8.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout
2013-01-30 14:08 [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout Will Deacon
2013-01-30 14:08 ` [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE Will Deacon
@ 2013-01-30 18:49 ` Nicolas Pitre
2013-01-30 20:41 ` Matt Sealey
2 siblings, 0 replies; 7+ messages in thread
From: Nicolas Pitre @ 2013-01-30 18:49 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 30 Jan 2013, Will Deacon wrote:
> Parts of the virtual memory layout (mainly the modules area) are
> described using open-coded immediate values.
>
> Use the SZ_ definitions from linux/sizes.h instead to make the code
> clearer.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
> ---
> arch/arm/include/asm/memory.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index 73cf03a..a0fd518 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -36,23 +36,23 @@
> * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
> */
> #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
> -#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
> +#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
> #define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
>
> /*
> * The maximum size of a 26-bit user space task.
> */
> -#define TASK_SIZE_26 UL(0x04000000)
> +#define TASK_SIZE_26 UL(SZ_64M)
>
> /*
> * The module space lives between the addresses given by TASK_SIZE
> * and PAGE_OFFSET - it must be within 32MB of the kernel text.
> */
> #ifndef CONFIG_THUMB2_KERNEL
> -#define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024)
> +#define MODULES_VADDR (PAGE_OFFSET - SZ_16M)
> #else
> /* smaller range for Thumb-2 symbols relocation (2^24)*/
> -#define MODULES_VADDR (PAGE_OFFSET - 8*1024*1024)
> +#define MODULES_VADDR (PAGE_OFFSET - SZ_8M)
> #endif
>
> #if TASK_SIZE > MODULES_VADDR
> --
> 1.8.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE
2013-01-30 14:08 ` [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE Will Deacon
@ 2013-01-30 18:57 ` Nicolas Pitre
2013-01-30 19:13 ` Will Deacon
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Pitre @ 2013-01-30 18:57 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 30 Jan 2013, Will Deacon wrote:
> TASK_UNMAPPED_BASE is defined directly in terms of PAGE_OFFSET, which is
> confusing given that the modules area sits between here and TASK_SIZE
> and is not available for user allocations.
>
> This patch defines TASK_UNMAPPED_BASE in terms of TASK_SIZE instead and
> fixes a bug introduced by 394ef6403abc ("mm: use vm_unmapped_area() on
> arm architecture") whereby TASK_UNMAPPED_BASE is no longer page-aligned
> for bottom-up mmap, causing get_unmapped_area to choke on misaligned
> addresses.
>
> Reported-by: Christoffer Dall <cdall@cs.columbia.edu>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm/include/asm/memory.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index a0fd518..255a01b 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -37,7 +37,7 @@
> */
> #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
> #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
> -#define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
> +#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~UL(SZ_16M - 1))
Please round this up not down. In most cases, TASK_SIZE is 0xbf000000
which is not nicely divisible by 3, unlike PAGE_OFFSET was. By rounding
up you get a nice 0x40000000 as before.
Nicolas
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE
2013-01-30 18:57 ` Nicolas Pitre
@ 2013-01-30 19:13 ` Will Deacon
0 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2013-01-30 19:13 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 30, 2013 at 06:57:24PM +0000, Nicolas Pitre wrote:
> On Wed, 30 Jan 2013, Will Deacon wrote:
>
> > TASK_UNMAPPED_BASE is defined directly in terms of PAGE_OFFSET, which is
> > confusing given that the modules area sits between here and TASK_SIZE
> > and is not available for user allocations.
> >
> > This patch defines TASK_UNMAPPED_BASE in terms of TASK_SIZE instead and
> > fixes a bug introduced by 394ef6403abc ("mm: use vm_unmapped_area() on
> > arm architecture") whereby TASK_UNMAPPED_BASE is no longer page-aligned
> > for bottom-up mmap, causing get_unmapped_area to choke on misaligned
> > addresses.
> >
> > Reported-by: Christoffer Dall <cdall@cs.columbia.edu>
> > Signed-off-by: Will Deacon <will.deacon@arm.com>
> > ---
> > arch/arm/include/asm/memory.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> > index a0fd518..255a01b 100644
> > --- a/arch/arm/include/asm/memory.h
> > +++ b/arch/arm/include/asm/memory.h
> > @@ -37,7 +37,7 @@
> > */
> > #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
> > #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
> > -#define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
> > +#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~UL(SZ_16M - 1))
>
> Please round this up not down. In most cases, TASK_SIZE is 0xbf000000
> which is not nicely divisible by 3, unlike PAGE_OFFSET was. By rounding
> up you get a nice 0x40000000 as before.
Sure, I think ALIGN does that for us, so I can use that instead.
Cheers,
Will
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout
2013-01-30 14:08 [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout Will Deacon
2013-01-30 14:08 ` [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE Will Deacon
2013-01-30 18:49 ` [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout Nicolas Pitre
@ 2013-01-30 20:41 ` Matt Sealey
2 siblings, 0 replies; 7+ messages in thread
From: Matt Sealey @ 2013-01-30 20:41 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jan 30, 2013 at 8:08 AM, Will Deacon <will.deacon@arm.com> wrote:
> Parts of the virtual memory layout (mainly the modules area) are
> described using open-coded immediate values.
>
> Use the SZ_ definitions from linux/sizes.h instead to make the code
> clearer.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm/include/asm/memory.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index 73cf03a..a0fd518 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -36,23 +36,23 @@
> * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
> */
> #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
> -#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
> +#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
> #define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
>
> /*
> * The maximum size of a 26-bit user space task.
> */
> -#define TASK_SIZE_26 UL(0x04000000)
> +#define TASK_SIZE_26 UL(SZ_64M)
Wouldn't this make far more sense as UL(1<<26) ?
--
Matt Sealey <matt@genesi-usa.com>
Product Development Analyst, Genesi USA, Inc.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout
@ 2013-01-31 18:17 Will Deacon
0 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2013-01-31 18:17 UTC (permalink / raw)
To: linux-arm-kernel
Parts of the virtual memory layout (mainly the modules area) are
described using open-coded immediate values.
Use the SZ_ definitions from linux/sizes.h instead to make the code
clearer.
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
KernelVersion: 3.8-rc5
---
arch/arm/include/asm/memory.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 73cf03a..924320f 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -36,23 +36,23 @@
* TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
*/
#define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
-#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
+#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
#define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
/*
* The maximum size of a 26-bit user space task.
*/
-#define TASK_SIZE_26 UL(0x04000000)
+#define TASK_SIZE_26 (UL(1) << 26)
/*
* The module space lives between the addresses given by TASK_SIZE
* and PAGE_OFFSET - it must be within 32MB of the kernel text.
*/
#ifndef CONFIG_THUMB2_KERNEL
-#define MODULES_VADDR (PAGE_OFFSET - 16*1024*1024)
+#define MODULES_VADDR (PAGE_OFFSET - SZ_16M)
#else
/* smaller range for Thumb-2 symbols relocation (2^24)*/
-#define MODULES_VADDR (PAGE_OFFSET - 8*1024*1024)
+#define MODULES_VADDR (PAGE_OFFSET - SZ_8M)
#endif
#if TASK_SIZE > MODULES_VADDR
--
1.8.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-01-31 18:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-30 14:08 [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout Will Deacon
2013-01-30 14:08 ` [PATCH 2/2] ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE Will Deacon
2013-01-30 18:57 ` Nicolas Pitre
2013-01-30 19:13 ` Will Deacon
2013-01-30 18:49 ` [PATCH 1/2] ARM: memory: use SZ_ constants for defining the virtual memory layout Nicolas Pitre
2013-01-30 20:41 ` Matt Sealey
-- strict thread matches above, loose matches on Subject: below --
2013-01-31 18:17 Will Deacon
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).