arm64/kernel/entry: refine comment of stack overflow check
PATCH 1/1 arm64/kernel/entry: refine comment of stack overflow check
Stack overflow checking can be done by testing
sp & (1 << THREAD_SHIFT)
only for the stacks are aligned to (2 << THREAD_SHIFT) with size of (1 << THREAD_SIZE), and this is the case when CONFIG_VMAP_STACK is set.
Fix the code comment to avoid confusion.
--- arch/arm64/kernel/entry.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/kernel/entry.S +2 -1
@@ -76,7 +76,8 @@ alternative_else_nop_endif #ifdef CONFIG_VMAP_STACK /* * Test whether the SP has overflowed, without corrupting a GPR. - * Task and IRQ stacks are aligned to (1 << THREAD_SHIFT). + * Task and IRQ stacks are aligned to (2 << THREAD_SHIFT) with size of + * (1 << THREAD_SHIFT). */ add sp, sp, x0 // sp' = sp + x0 sub x0, sp, x0 // x0' = sp' - x0 = (sp + x0) - x0 = sp
Signature · 1 line
2.19.1
Quoted 5 lines · Heyi Guo
Stack overflow checking can be done by testing
sp & (1 <<THREAD_SHIFT)
only for the stacks are aligned to (2 <<THREAD_SHIFT) with size of (1 <<THREAD_SIZE), and this is the case whenCONFIG_VMAP_STACKis set.
Good point, I was sloppy with this comment.
Quoted 15 lines
Fix the code comment to avoid confusion.
Signed-off-by Heyi Guo <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kernel/entry.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm64/kernel/entry.S +0
-0
arch/arm64/kernel/entry.S alternative_else_nop_endif · line 81
Quoted 7 lines
arch/arm64/kernel/entry.S +2
-1@@ -76,7 +76,8 @@ alternative_else_nop_endif #ifdef CONFIG_VMAP_STACK /* * Test whether the SP has overflowed, without corrupting a GPR. - * Task and IRQ stacks are aligned to (1 << THREAD_SHIFT). + * Task and IRQ stacks are aligned to (2 << THREAD_SHIFT) with size of + * (1 << THREAD_SHIFT). */
Can we make that:
Task and IRQ stacks are aligned so that SP & (1 << THREAD_SHIFT) should always be zero.
... which I think is a bit clearer.
With that wording:
Mark.
Quoted 5 lines
arch/arm64/kernel/entry.S +0
-0add sp, sp, x0 // sp' = sp + x0 sub x0, sp, x0 // x0' = sp' - x0 = (sp + x0) - x0 = spSignature · 1 line
2.19.1
Quoted 31 lines · Mark Rutland
Quoted 5 lines · Heyi Guo
Stack overflow checking can be done by testing
sp & (1 <<THREAD_SHIFT)
only for the stacks are aligned to (2 <<THREAD_SHIFT) with size of (1 <<THREAD_SIZE), and this is the case whenCONFIG_VMAP_STACKis set.Good point, I was sloppy with this comment.
Quoted 14 lines
Fix the code comment to avoid confusion.
Signed-off-by Heyi Guo <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kernel/entry.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm64/kernel/entry.S +0
-0arch/arm64/kernel/entry.S alternative_else_nop_endif · line 81
Quoted 7 lines
arch/arm64/kernel/entry.S +2
-1@@ -76,7 +76,8 @@ alternative_else_nop_endif #ifdef CONFIG_VMAP_STACK /* * Test whether the SP has overflowed, without corrupting a GPR. - * Task and IRQ stacks are aligned to (1 << THREAD_SHIFT). + * Task and IRQ stacks are aligned to (2 << THREAD_SHIFT) with size of + * (1 << THREAD_SHIFT). */Can we make that:
Quoted 4 lines
Task and IRQ stacks are aligned so that SP & (1 <<
THREAD_SHIFT) should always be zero.... which I think is a bit clearer.
Sure :)
Thanks,
Heyi
Quoted 13 lines
With that wording:
Acked-by Mark Rutland <[email protected]>Mark.
Quoted 5 lines
arch/arm64/kernel/entry.S +0
-0add sp, sp, x0 // sp' = sp + x0 sub x0, sp, x0 // x0' = sp' - x0 = (sp + x0) - x0 = spSignature · 1 line
2.19.1.
Catalin Marinas
maintainerQuoted 11 lines · Heyi Guo
Stack overflow checking can be done by testing
sp & (1 <<THREAD_SHIFT)
only for the stacks are aligned to (2 <<THREAD_SHIFT) with size of (1 <<THREAD_SIZE), and this is the case whenCONFIG_VMAP_STACKis set.Fix the code comment to avoid confusion.
Signed-off-by Heyi Guo <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>
Queued with Mark's suggested update.
Signature · 1 line
Catalin