Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1512383ybl; Mon, 2 Dec 2019 04:37:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyxnPZcwbvS1gYXbt03ph/9OrJA1DYZmnC7ik1hOxIfozQ06KBxf71hmMbQXr0fA0h6Ew3x X-Received: by 2002:a05:6402:b39:: with SMTP id bo25mr13337018edb.59.1575290267708; Mon, 02 Dec 2019 04:37:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575290267; cv=none; d=google.com; s=arc-20160816; b=btrOJY8yaABwh4YPJDQiB+1UJbK5PIaiO9AkGO1PuKjmPjqP9YNN8PF59NK/EAH0I/ tthQ64rajgaI+x/y6RJF01+XvgbZKm8ZOZQ5/ipkPUDkr2dENqaQI78XGe/Pz+w+veT4 xOtJpz7OM0xg+1Q/ML7KmmDrAz5Oq7uYGIbgzluyrW5YO+diZdujRt5vxP7S1t3APybA +V16nWfN8mY6AHt1rAaWKHLcSx9PzTrFztFjPOYgx02iw0xd59m5dpGQszk16675AZgv JR7ANT+T0gkmIk5Uz6GHUjPIR9MWVzgHGaf9pYRC8fszZBu57I7L21XJe4eaJjbUiPfb XZ0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rwDP6uD8laPcp8sx0+U6iQVswODIHB9BRvlsMiT/tzU=; b=msrpLzSkaqElfSZZTjnPOTmFzJKRDI3wia/0ngl4r7ij811TlR0cqGVRlZCIur9mdB Bg/sLMZcTE92mw9qbq/NEiu5tcWxUqzGOkRkuBH4PADr5iwyLG1/+itImuMM+VCG2Fqr Cs3HKpcqzK+uvNAuBakYiPGhA+wqUi5TlVttHoiOtpjXqdQyqq/3vj8M+pGo9dWHZ/WU sFDJaJx6AzLQU7nZbJbNbrHQ9syA45pB8h586tbZ2FhxP7UeNyZ15lmZEHAnutvr5OUe f1AMO9jyUBSC6l9BaAJdlpOcUA8NDyMc2Gd2v4vAdJVPPQXG310YI33A/RbDzT78ECA7 2Ynw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si20891306ejr.295.2019.12.02.04.37.22; Mon, 02 Dec 2019 04:37:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbfLBMd3 (ORCPT + 99 others); Mon, 2 Dec 2019 07:33:29 -0500 Received: from foss.arm.com ([217.140.110.172]:53912 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727381AbfLBMd3 (ORCPT ); Mon, 2 Dec 2019 07:33:29 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 876B1DA7; Mon, 2 Dec 2019 04:33:26 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A31F53F7D8; Mon, 2 Dec 2019 04:33:25 -0800 (PST) Date: Mon, 2 Dec 2019 12:33:19 +0000 From: Mark Rutland To: Heyi Guo Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com, Catalin Marinas , Will Deacon Subject: Re: [PATCH] arm64/kernel/entry: refine comment of stack overflow check Message-ID: <20191202123319.GA25809@lakrids.cambridge.arm.com> References: <20191202113702.34158-1-guoheyi@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191202113702.34158-1-guoheyi@huawei.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Cc: Catalin Marinas > Cc: Will Deacon > --- > 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. > add sp, sp, x0 // sp' = sp + x0 > sub x0, sp, x0 // x0' = sp' - x0 = (sp + x0) - x0 = sp > -- > 2.19.1 >