Skip to content

Commit 9a2b51b

Browse files
aryabininRussell King
authored andcommitted
ARM: 8078/1: get rid of hardcoded assumptions about kernel stack size
Changing kernel stack size on arm is not as simple as it should be: 1) THREAD_SIZE macro doesn't respect PAGE_SIZE and THREAD_SIZE_ORDER 2) stack size is hardcoded in get_thread_info macro This patch fixes it by calculating 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> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent c79bf92 commit 9a2b51b

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎arch/arm/include/asm/assembler.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <asm/domain.h>
2525
#include <asm/opcodes-virt.h>
2626
#include <asm/asm-offsets.h>
27+
#include <asm/page.h>
28+
#include <asm/thread_info.h>
2729

2830
#define IOMEM(x) (x)
2931

@@ -179,10 +181,10 @@
179181
* Get current thread_info.
180182
*/
181183
.macro get_thread_info, rd
182-
ARM( mov \rd, sp, lsr #13 )
184+
ARM( mov \rd, sp, lsr #THREAD_SIZE_ORDER + PAGE_SHIFT )
183185
THUMB( mov \rd, sp )
184-
THUMB( lsr \rd, \rd, #13 )
185-
mov \rd, \rd, lsl #13
186+
THUMB( lsr \rd, \rd, #THREAD_SIZE_ORDER + PAGE_SHIFT )
187+
mov \rd, \rd, lsl #THREAD_SIZE_ORDER + PAGE_SHIFT
186188
.endm
187189

188190
/*

‎arch/arm/include/asm/thread_info.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
#include <linux/compiler.h>
1616
#include <asm/fpstate.h>
17+
#include <asm/page.h>
1718

1819
#define THREAD_SIZE_ORDER 1
19-
#define THREAD_SIZE 8192
20+
#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
2021
#define THREAD_START_SP (THREAD_SIZE - 8)
2122

2223
#ifndef __ASSEMBLY__

0 commit comments

Comments
 (0)