ARM: memory: use SZ_ constants for defining the virtual memory layout
PATCH 1/2 ARM: memory: use SZ_ constants for defining the virtual memory layout
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.
--- arch/arm/include/asm/memory.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/include/asm/memory.h +4 -4
@@ -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
Signature · 1 line
1.8.0
PATCH 2/2 ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE
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.
--- arch/arm/include/asm/memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/memory.h +1 -1
@@ -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.
Signature · 1 line
1.8.0
PATCH 1/2 ARM: memory: use SZ_ constants for defining the virtual memory layout
In reply to Will DeaconQuoted 7 lines · Will Deacon
Parts of the virtual memory layout (mainly the modules area) are described using open-coded immediate values.
Use the
SZ_definitions fromlinux/sizes.hinstead to make the code clearer.Signed-off-by Will Deacon <[email protected]>
Quoted 45 lines
--- arch/arm/include/asm/memory.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/arm/include/asm/memory.h +4
-4@@ -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 Signature · 7 lines
1.8.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/2 ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE
In reply to Will DeaconQuoted 21 lines · Will Deacon
TASK_UNMAPPED_BASEis defined directly in terms ofPAGE_OFFSET, which is confusing given that the modules area sits between here andTASK_SIZEand is not available for user allocations.This patch defines
TASK_UNMAPPED_BASEin terms ofTASK_SIZEinstead and fixes a bug introduced by394ef6403abc("mm: usevm_unmapped_area()on arm architecture") wherebyTASK_UNMAPPED_BASEis no longer page-aligned for bottom-up mmap, causingget_unmapped_areato choke on misaligned addresses.Reported-by Christoffer Dall <[email protected]>Signed-off-by Will Deacon <[email protected]>--- arch/arm/include/asm/memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/include/asm/memory.h +0
-0
arch/arm/include/asm/memory.h line 40
Quoted 5 lines
arch/arm/include/asm/memory.h +1
-1@@ -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
PATCH 2/2 ARM: memory: define TASK_UNMAPPED_BASE in terms of TASK_SIZE
Quoted 18 lines · Nicolas Pitre
Quoted 16 lines · Will Deacon
TASK_UNMAPPED_BASEis defined directly in terms ofPAGE_OFFSET, which is confusing given that the modules area sits between here andTASK_SIZEand is not available for user allocations.This patch defines
TASK_UNMAPPED_BASEin terms ofTASK_SIZEinstead and fixes a bug introduced by394ef6403abc("mm: usevm_unmapped_area()on arm architecture") wherebyTASK_UNMAPPED_BASEis no longer page-aligned for bottom-up mmap, causingget_unmapped_areato choke on misaligned addresses.Reported-by Christoffer Dall <[email protected]>Signed-off-by Will Deacon <[email protected]>--- arch/arm/include/asm/memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
arch/arm/include/asm/memory.h line 40
Quoted 10 lines
arch/arm/include/asm/memory.h +1
-1@@ -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_SIZEis0xbf000000which is not nicely divisible by 3, unlikePAGE_OFFSETwas. By rounding up you get a nice0x40000000as before.
Sure, I think ALIGN does that for us, so I can use that instead.
Cheers,
Will
PATCH 1/2 ARM: memory: use SZ_ constants for defining the virtual memory layout
In reply to Will DeaconQuoted 18 lines · Will Deacon
Parts of the virtual memory layout (mainly the modules area) are described using open-coded immediate values.
Use the
SZ_definitions fromlinux/sizes.hinstead to make the code clearer.Signed-off-by Will Deacon <[email protected]>--- arch/arm/include/asm/memory.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/arm/include/asm/memory.h +0
-0@@ -36,23 +36,23 @@* TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area */
arch/arm/include/asm/memory.h line 45
Quoted 10 lines
arch/arm/include/asm/memory.h +2
-2#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) ?
Signature · 2 lines
Matt Sealey <[email protected]> Product Development Analyst, Genesi USA, Inc.