From patchwork Tue Oct 20 13:26:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jungseok Lee X-Patchwork-Id: 7447441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F0AFBEEA4 for ; Tue, 20 Oct 2015 13:28:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A3582073A for ; Tue, 20 Oct 2015 13:28:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7075E20865 for ; Tue, 20 Oct 2015 13:28:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoWwN-0007c9-H4; Tue, 20 Oct 2015 13:26:59 +0000 Received: from mail-pa0-x242.google.com ([2607:f8b0:400e:c03::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoWwK-00076O-9U for linux-arm-kernel@lists.infradead.org; Tue, 20 Oct 2015 13:26:57 +0000 Received: by padda3 with SMTP id da3so2095938pad.1 for ; Tue, 20 Oct 2015 06:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=GZy75FEiQFrNRfoVDL9E4X5E4DOKG24CwxfP9rPyXqw=; b=fMJ5F+mPZ5AXqDe5e/M2dXbCWGnlSe2nqtjC+hlGc8znx6njnjl6VqHVw039bmOuNH AqAtkGIHR7rCT0OspmpsTOlVgE5yb8SWjtlvpqZao5WJFzsVM9UI/QjMj3+iPFTAsBY8 ABb5jng5i3hsbcovE5dWPdSOGamZPOPu7V5HEGzDaL/7ZU8RN0JWqev9ALU/qYTDPyTV ssQR5ojcMFjTCCu+TLiXQJO9Is4Qls0p2J/IZ0/q0rL68HuZgMvVDrxc/g3DctMs8WdC ccRDOpCN0Q6H+yq+QWK7c73aMJ5Qy4HXC+5zlRLuZIqSCqabBV+rtIXNZh4PJ1Vr0DCs HA1Q== X-Received: by 10.66.155.231 with SMTP id vz7mr3995492pab.58.1445347595045; Tue, 20 Oct 2015 06:26:35 -0700 (PDT) Received: from [192.168.123.149] ([116.121.77.221]) by smtp.gmail.com with ESMTPSA id qy7sm3893502pab.37.2015.10.20.06.26.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Oct 2015 06:26:34 -0700 (PDT) Subject: Re: [PATCH v2 1/2] arm64: revamp unwind_frame for interrupt stack Mime-Version: 1.0 (Apple Message framework v1283) From: Jungseok Lee In-Reply-To: <1445328019-23330-2-git-send-email-takahiro.akashi@linaro.org> Date: Tue, 20 Oct 2015 22:26:29 +0900 Message-Id: References: <1445328019-23330-1-git-send-email-takahiro.akashi@linaro.org> <1445328019-23330-2-git-send-email-takahiro.akashi@linaro.org> To: AKASHI Takahiro X-Mailer: Apple Mail (2.1283) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151020_062656_452465_CB056D8D X-CRM114-Status: GOOD ( 17.60 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, broonie@kernel.org, james.morse@arm.com, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Oct 20, 2015, at 5:00 PM, AKASHI Takahiro wrote: > This patch allows unwind_frame() to traverse from interrupt stack > to process stack correctly by having a dummy stack frame for irq > exception entry created at its prologue. > > Signed-off-by: AKASHI Takahiro > --- > arch/arm64/kernel/entry.S | 22 ++++++++++++++++++++-- > arch/arm64/kernel/stacktrace.c | 14 +++++++++++++- > 2 files changed, 33 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S > index c8e0bcf..779f807 100644 > --- a/arch/arm64/kernel/entry.S > +++ b/arch/arm64/kernel/entry.S > @@ -186,8 +186,26 @@ alternative_endif > and x23, x23, #~(IRQ_STACK_SIZE - 1) > cmp x20, x23 // check irq re-enterance > mov x19, sp > - csel x23, x19, x24, eq // x24 = top of irq stack > - mov sp, x23 > + beq 1f > + mov sp, x24 // x24 = top of irq stack > + stp x29, x19, [sp, #-16]! // for sanity check > + stp x29, x22, [sp, #-16]! // dummy stack frame > + mov x29, sp > +1: > + /* > + * Layout of interrupt stack after this macro is invoked: > + * > + * | | > + *-0x20+----------------+ <= dummy stack frame > + * | fp | : fp on process stack > + *-0x18+----------------+ > + * | lr | : return address > + *-0x10+----------------+ > + * | fp (copy) | : for sanity check > + * -0x8+----------------+ > + * | sp | : sp on process stack > + * 0x0+----------------+ > + */ > .endm > > /* > diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c > index 407991b..03611a1 100644 > --- a/arch/arm64/kernel/stacktrace.c > +++ b/arch/arm64/kernel/stacktrace.c > @@ -43,12 +43,24 @@ int notrace unwind_frame(struct stackframe *frame) > low = frame->sp; > high = ALIGN(low, THREAD_SIZE); > > - if (fp < low || fp > high - 0x18 || fp & 0xf) > + if (fp < low || fp > high - 0x20 || fp & 0xf) > return -EINVAL; > > frame->sp = fp + 0x10; > frame->fp = *(unsigned long *)(fp); > /* > + * check whether we are going to walk trough from interrupt stack > + * to process stack > + * If the previous frame is the initial (dummy) stack frame on > + * interrupt stack, frame->sp now points to just below the frame > + * (dummy frame + 0x10). > + * See entry.S > + */ > +#define STACK_LOW(addr) round_down((addr), THREAD_SIZE) > + if ((STACK_LOW(frame->sp) != STACK_LOW(frame->fp)) && > + (frame->fp == *(unsigned long *)frame->sp)) > + frame->sp = *((unsigned long *)(frame->sp + 8)); > + /* > * -4 here because we care about the PC at time of bl, > * not where the return will go. > */ > -- > 1.7.9.5 How about folding the following hunk into this patch? The comment would be helpful for people to follow this code. ----8<---- ----8<---- Best Regards Jungseok Lee diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index f1303c5..0ff7db3 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -122,7 +122,8 @@ * x21 - aborted SP * x22 - aborted PC * x23 - aborted PSTATE - */ + * x29 - aborted FP + */ .endm .macro kernel_exit, el