Message ID | 1403099422-850-1-git-send-email-a.ryabinin@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Jun 18, 2014 at 02:50:22PM +0100, Andrey Ryabinin wrote: > Changing kernel stack size on arm is not as simple as it should be: > 1) THRED_SIZE macro doen't respect PAGE_SIZE and THREAD_SIZE_ORDER THREAD_SIZE > 2) stack size is hardcoded in get_thread_info macro > > This patch fixes it by caculating THREAD_SIZE and thread_info address > taking into account PAGE_SIZE and THREAD_SIZE_ORDER. > > Now changing stack size becomes simply changing THREAD_SIZE_ORDER. Curious: is this just a cleanup, or are you actually running out of kernel stack on an ARM platform? Will
On Wed, 18 Jun 2014, Andrey Ryabinin wrote: > Changing kernel stack size on arm is not as simple as it should be: > 1) THRED_SIZE macro doen't respect PAGE_SIZE and THREAD_SIZE_ORDER > 2) stack size is hardcoded in get_thread_info macro > > This patch fixes it by caculating THREAD_SIZE and thread_info address > taking into account PAGE_SIZE and THREAD_SIZE_ORDER. > > Now changing stack size becomes simply changing THREAD_SIZE_ORDER. > > Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> Acked-by: Nicolas Pitre <nico@linaro.org> > --- > arch/arm/include/asm/assembler.h | 8 +++++--- > arch/arm/include/asm/thread_info.h | 3 ++- > 2 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h > index 57f0584..906703a 100644 > --- a/arch/arm/include/asm/assembler.h > +++ b/arch/arm/include/asm/assembler.h > @@ -24,6 +24,8 @@ > #include <asm/domain.h> > #include <asm/opcodes-virt.h> > #include <asm/asm-offsets.h> > +#include <asm/page.h> > +#include <asm/thread_info.h> > > #define IOMEM(x) (x) > > @@ -179,10 +181,10 @@ > * Get current thread_info. > */ > .macro get_thread_info, rd > - ARM( mov \rd, sp, lsr #13 ) > + ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT ) > THUMB( mov \rd, sp ) > - THUMB( lsr \rd, \rd, #13 ) > - mov \rd, \rd, lsl #13 > + THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT ) > + mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT > .endm > > /* > diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h > index f989d7c..f85d2b0 100644 > --- a/arch/arm/include/asm/thread_info.h > +++ b/arch/arm/include/asm/thread_info.h > @@ -14,9 +14,10 @@ > > #include <linux/compiler.h> > #include <asm/fpstate.h> > +#include <asm/page.h> > > #define THREAD_SIZE_ORDER 1 > -#define THREAD_SIZE 8192 > +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) > #define THREAD_START_SP (THREAD_SIZE - 8) > > #ifndef __ASSEMBLY__ > -- > 1.8.5.5 >
On 06/18/14 18:31, Will Deacon wrote: > On Wed, Jun 18, 2014 at 02:50:22PM +0100, Andrey Ryabinin wrote: >> Changing kernel stack size on arm is not as simple as it should be: >> 1) THRED_SIZE macro doen't respect PAGE_SIZE and THREAD_SIZE_ORDER > > THREAD_SIZE > Yup, I just found some more typos in my commit message. I'll fix them in update. >> 2) stack size is hardcoded in get_thread_info macro >> >> This patch fixes it by caculating THREAD_SIZE and thread_info address >> taking into account PAGE_SIZE and THREAD_SIZE_ORDER. >> >> Now changing stack size becomes simply changing THREAD_SIZE_ORDER. > > Curious: is this just a cleanup, or are you actually running out of kernel > stack on an ARM platform? > It's actually both. I'm working on address sanitizer for kernel [1]. Recently we started experiments with stack instrumentation. Compiler inserts redzones around every variable on stack, so we could detect accesses to such redzones and catch out-of-bound read/write bugs on stack variables. Obviously stack is bloated in such kernel. For mainline kernel it just a cleanup. [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerForKernel > Will >
On 06/18/14 18:40, Nicolas Pitre wrote: > On Wed, 18 Jun 2014, Andrey Ryabinin wrote: > >> Changing kernel stack size on arm is not as simple as it should be: >> 1) THRED_SIZE macro doen't respect PAGE_SIZE and THREAD_SIZE_ORDER >> 2) stack size is hardcoded in get_thread_info macro >> >> This patch fixes it by caculating THREAD_SIZE and thread_info address >> taking into account PAGE_SIZE and THREAD_SIZE_ORDER. >> >> Now changing stack size becomes simply changing THREAD_SIZE_ORDER. >> >> Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> > > Acked-by: Nicolas Pitre <nico@linaro.org> > > Thanks. Patch with fixes in commit message pushed to Russel's patch tracking system, #8078/1. http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=8078/1 >> --- >> arch/arm/include/asm/assembler.h | 8 +++++--- >> arch/arm/include/asm/thread_info.h | 3 ++- >> 2 files changed, 7 insertions(+), 4 deletions(-) >> >> diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h >> index 57f0584..906703a 100644 >> --- a/arch/arm/include/asm/assembler.h >> +++ b/arch/arm/include/asm/assembler.h >> @@ -24,6 +24,8 @@ >> #include <asm/domain.h> >> #include <asm/opcodes-virt.h> >> #include <asm/asm-offsets.h> >> +#include <asm/page.h> >> +#include <asm/thread_info.h> >> >> #define IOMEM(x) (x) >> >> @@ -179,10 +181,10 @@ >> * Get current thread_info. >> */ >> .macro get_thread_info, rd >> - ARM( mov \rd, sp, lsr #13 ) >> + ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT ) >> THUMB( mov \rd, sp ) >> - THUMB( lsr \rd, \rd, #13 ) >> - mov \rd, \rd, lsl #13 >> + THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT ) >> + mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT >> .endm >> >> /* >> diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h >> index f989d7c..f85d2b0 100644 >> --- a/arch/arm/include/asm/thread_info.h >> +++ b/arch/arm/include/asm/thread_info.h >> @@ -14,9 +14,10 @@ >> >> #include <linux/compiler.h> >> #include <asm/fpstate.h> >> +#include <asm/page.h> >> >> #define THREAD_SIZE_ORDER 1 >> -#define THREAD_SIZE 8192 >> +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) >> #define THREAD_START_SP (THREAD_SIZE - 8) >> >> #ifndef __ASSEMBLY__ >> -- >> 1.8.5.5 >> >
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index 57f0584..906703a 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -24,6 +24,8 @@ #include <asm/domain.h> #include <asm/opcodes-virt.h> #include <asm/asm-offsets.h> +#include <asm/page.h> +#include <asm/thread_info.h> #define IOMEM(x) (x) @@ -179,10 +181,10 @@ * Get current thread_info. */ .macro get_thread_info, rd - ARM( mov \rd, sp, lsr #13 ) + ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT ) THUMB( mov \rd, sp ) - THUMB( lsr \rd, \rd, #13 ) - mov \rd, \rd, lsl #13 + THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT ) + mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT .endm /* diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index f989d7c..f85d2b0 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -14,9 +14,10 @@ #include <linux/compiler.h> #include <asm/fpstate.h> +#include <asm/page.h> #define THREAD_SIZE_ORDER 1 -#define THREAD_SIZE 8192 +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) #define THREAD_START_SP (THREAD_SIZE - 8) #ifndef __ASSEMBLY__
Changing kernel stack size on arm is not as simple as it should be: 1) THRED_SIZE macro doen't respect PAGE_SIZE and THREAD_SIZE_ORDER 2) stack size is hardcoded in get_thread_info macro This patch fixes it by caculating THREAD_SIZE and thread_info address taking into account PAGE_SIZE and THREAD_SIZE_ORDER. Now changing stack size becomes simply changing THREAD_SIZE_ORDER. Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> --- arch/arm/include/asm/assembler.h | 8 +++++--- arch/arm/include/asm/thread_info.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-)