Commit b111757c authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Linus Torvalds

arch: personality independent stack top

New arch macro STACK_TOP_MAX it gives the larges valid stack address for the
architecture in question.

It differs from STACK_TOP in that it will not distinguish between
personalities but will always return the largest possible address.

This is used to create the initial stack on execve, which we will move down to
the proper location once the binfmt code has figured out where that is.
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarOllie Wild <aaw@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f34e3b61
...@@ -101,6 +101,8 @@ struct exec ...@@ -101,6 +101,8 @@ struct exec
#define STACK_TOP \ #define STACK_TOP \
(current->personality & ADDR_LIMIT_32BIT ? 0x80000000 : 0x00120000000UL) (current->personality & ADDR_LIMIT_32BIT ? 0x80000000 : 0x00120000000UL)
#define STACK_TOP_MAX 0x00120000000UL
#endif #endif
#endif /* __A_OUT_GNU_H__ */ #endif /* __A_OUT_GNU_H__ */
...@@ -30,6 +30,7 @@ struct exec ...@@ -30,6 +30,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP ((current->personality == PER_LINUX_32BIT) ? \ #define STACK_TOP ((current->personality == PER_LINUX_32BIT) ? \
TASK_SIZE : TASK_SIZE_26) TASK_SIZE : TASK_SIZE_26)
#define STACK_TOP_MAX TASK_SIZE
#endif #endif
#ifndef LIBRARY_START_TEXT #ifndef LIBRARY_START_TEXT
......
...@@ -29,6 +29,7 @@ struct exec ...@@ -29,6 +29,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
#ifndef LIBRARY_START_TEXT #ifndef LIBRARY_START_TEXT
......
...@@ -20,6 +20,7 @@ struct exec ...@@ -20,6 +20,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
/* grabbed from the intel stuff */ /* grabbed from the intel stuff */
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
struct exec struct exec
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
*/ */
#define BRK_BASE __UL(2 * 1024 * 1024 + PAGE_SIZE) #define BRK_BASE __UL(2 * 1024 * 1024 + PAGE_SIZE)
#define STACK_TOP __UL(2 * 1024 * 1024) #define STACK_TOP __UL(2 * 1024 * 1024)
#define STACK_TOP_MAX STACK_TOP
/* userspace process size */ /* userspace process size */
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
......
...@@ -20,6 +20,7 @@ struct exec ...@@ -20,6 +20,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
......
...@@ -20,6 +20,7 @@ struct exec ...@@ -20,6 +20,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
/* The absolute hard limit for stack size is 1/2 of the mappable space in the region */ /* The absolute hard limit for stack size is 1/2 of the mappable space in the region */
#define MAX_USER_STACK_SIZE (RGN_MAP_LIMIT/2) #define MAX_USER_STACK_SIZE (RGN_MAP_LIMIT/2)
#define STACK_TOP (0x6000000000000000UL + RGN_MAP_LIMIT) #define STACK_TOP (0x6000000000000000UL + RGN_MAP_LIMIT)
#define STACK_TOP_MAX STACK_TOP
#endif #endif
/* Make a default stack size of 2GiB */ /* Make a default stack size of 2GiB */
......
...@@ -20,6 +20,7 @@ struct exec ...@@ -20,6 +20,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
......
...@@ -20,6 +20,7 @@ struct exec ...@@ -20,6 +20,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
......
...@@ -40,6 +40,7 @@ struct exec ...@@ -40,6 +40,7 @@ struct exec
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
#define STACK_TOP (current->thread.mflags & MF_32BIT_ADDR ? TASK_SIZE32 : TASK_SIZE) #define STACK_TOP (current->thread.mflags & MF_32BIT_ADDR ? TASK_SIZE32 : TASK_SIZE)
#endif #endif
#define STACK_TOP_MAX TASK_SIZE
#endif #endif
......
...@@ -23,6 +23,7 @@ struct exec ...@@ -23,6 +23,7 @@ struct exec
* prumpf */ * prumpf */
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX DEFAULT_TASK_SIZE
#endif #endif
......
...@@ -26,9 +26,12 @@ struct exec ...@@ -26,9 +26,12 @@ struct exec
#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ #define STACK_TOP (test_thread_flag(TIF_32BIT) ? \
STACK_TOP_USER32 : STACK_TOP_USER64) STACK_TOP_USER32 : STACK_TOP_USER64)
#define STACK_TOP_MAX STACK_TOP_USER64
#else /* __powerpc64__ */ #else /* __powerpc64__ */
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif /* __powerpc64__ */ #endif /* __powerpc64__ */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -32,6 +32,7 @@ struct exec ...@@ -32,6 +32,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX DEFAULT_TASK_SIZE
#endif #endif
......
...@@ -20,6 +20,7 @@ struct exec ...@@ -20,6 +20,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
......
...@@ -31,6 +31,7 @@ struct exec ...@@ -31,6 +31,7 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
#endif #endif
......
...@@ -92,6 +92,7 @@ struct relocation_info /* used when header.a_machtype == M_SPARC */ ...@@ -92,6 +92,7 @@ struct relocation_info /* used when header.a_machtype == M_SPARC */
#include <asm/page.h> #include <asm/page.h>
#define STACK_TOP (PAGE_OFFSET - PAGE_SIZE) #define STACK_TOP (PAGE_OFFSET - PAGE_SIZE)
#define STACK_TOP_MAX STACK_TOP
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -101,6 +101,8 @@ struct relocation_info /* used when header.a_machtype == M_SPARC */ ...@@ -101,6 +101,8 @@ struct relocation_info /* used when header.a_machtype == M_SPARC */
#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ #define STACK_TOP (test_thread_flag(TIF_32BIT) ? \
STACK_TOP32 : STACK_TOP64) STACK_TOP32 : STACK_TOP64)
#define STACK_TOP_MAX STACK_TOP64
#endif #endif
#endif /* !(__ASSEMBLY__) */ #endif /* !(__ASSEMBLY__) */
......
...@@ -17,4 +17,6 @@ extern int honeypot; ...@@ -17,4 +17,6 @@ extern int honeypot;
#define STACK_TOP \ #define STACK_TOP \
CHOOSE_MODE((honeypot ? host_task_size : task_size), task_size) CHOOSE_MODE((honeypot ? host_task_size : task_size), task_size)
#define STACK_TOP_MAX STACK_TOP
#endif #endif
...@@ -21,7 +21,8 @@ struct exec ...@@ -21,7 +21,8 @@ struct exec
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/thread_info.h> #include <linux/thread_info.h>
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX TASK_SIZE64
#endif #endif
#endif /* __A_OUT_GNU_H__ */ #endif /* __A_OUT_GNU_H__ */
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
/* Note: the kernel needs the a.out definitions, even if only ELF is used. */ /* Note: the kernel needs the a.out definitions, even if only ELF is used. */
#define STACK_TOP TASK_SIZE #define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX STACK_TOP
struct exec struct exec
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment