From 4e99f18f647a4e6821a3dbb4d1289dbcb961ba8d Mon Sep 17 00:00:00 2001 From: Artem Kuzmitskiy Date: Mon, 9 Nov 2015 10:49:00 +0300 Subject: [PATCH] Expand task_size variable for AArch32 Task size depends from VM_SPLIT_* kernel option and cannot be hard coded. This patch based on c0c0546c31e6df4932669f4740197bb830a24c8d from Christopher Covington. Signed-off-by: Artem Kuzmitskiy Reviewed-by: Christopher Covington Signed-off-by: Pavel Emelyanov --- arch/arm/include/asm/types.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h index 915db611b..d1d6cc3a2 100644 --- a/arch/arm/include/asm/types.h +++ b/arch/arm/include/asm/types.h @@ -96,9 +96,27 @@ struct user_vfp_exc { #define REG_IP(regs) ((regs).ARM_pc) #define REG_SYSCALL_NR(regs) ((regs).ARM_r7) -#define TASK_SIZE 0xbf000000 +/* + * Range for task size calculated from the following Linux kernel files: + * arch/arm/include/asm/memory.h + * arch/arm/Kconfig (PAGE_OFFSET values in Memory split section) + */ +#define TASK_SIZE_MIN 0x3f000000 +#define TASK_SIZE_MAX 0xbf000000 +#define SZ_1G 0x40000000 -static inline unsigned long task_size() { return TASK_SIZE; } +int munmap(void *addr, size_t length); + +static inline unsigned long task_size(void) +{ + unsigned long task_size; + + for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size += SZ_1G) + if (munmap((void *)task_size, page_size())) + break; + + return task_size; +} #define AT_VECTOR_SIZE 40