mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Heyi Guo <guoheyi@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH] arm64/kernel/entry: refine comment of stack overflow check
Date: Mon, 2 Dec 2019 12:33:19 +0000	[thread overview]
Message-ID: <20191202123319.GA25809@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20191202113702.34158-1-guoheyi@huawei.com>

On Mon, Dec 02, 2019 at 07:37:02PM +0800, Heyi Guo wrote:
> 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.

Good point, I was sloppy with this comment.

> 
> Fix the code comment to avoid confusion.
> 
> Signed-off-by: Heyi Guo <guoheyi@huawei.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> ---
>  arch/arm64/kernel/entry.S | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index cf3bd2976e57..9e8ba507090f 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -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:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Mark.

>  	add	sp, sp, x0			// sp' = sp + x0
>  	sub	x0, sp, x0			// x0' = sp' - x0 = (sp + x0) - x0 = sp
> -- 
> 2.19.1
> 

  reply	other threads:[~2019-12-02 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02 11:37 Heyi Guo
2019-12-02 12:33 ` Mark Rutland [this message]
2019-12-03  0:55   ` Guoheyi
2019-12-06 13:58 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191202123319.GA25809@lakrids.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=guoheyi@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wanghaibin.wang@huawei.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®