From patchwork Fri May 30 19:34:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Bassel X-Patchwork-Id: 31216 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4386020068 for ; Fri, 30 May 2014 19:34:52 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id i57sf11195242yha.0 for ; Fri, 30 May 2014 12:34:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=IJ03EYa0CywZ57A6d8+wBdPmQpepLtya44kf6vd4g6o=; b=bLYgNFwTW3UQ72+3PjFTOdLTZEvIRz+zRIjU/y97T6L2Zfd94z35szvvBq6KZa3emH L8UP+Z58Zc/f0Wn3QyxbSctMqIt2UvSZhYoo3ivEmwAVMoGIyNl1lHjbwy8XE5xJWYeG oQ46SHCffonpDiOtJReTLTY1/2FO4E8EXkwUmfOPfAQZe41ygsKYoLTu71Yt9sk1dqPa EFubxoRnDb9wVx2+2bZ70LfW5cjVYL0n7XROV/gM6jXNDyDy/+ryzpny5JBcdi9ZnS48 SwCEIsor44G2bmmQzbIHZ2zyXwhceQNq2lCNzWpV15D+fW6kzuT8LpFKzNd64jzxWLOw 5yyg== X-Gm-Message-State: ALoCoQmoykVizhQLLxUO+lxS/MUi5KbQ+UmpAMMHLnh7IHlIAEjeTQcBmSkjevdntqM0IAK1mXZa X-Received: by 10.58.25.99 with SMTP id b3mr7175716veg.28.1401478491998; Fri, 30 May 2014 12:34:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.36 with SMTP id f33ls1244375qga.19.gmail; Fri, 30 May 2014 12:34:51 -0700 (PDT) X-Received: by 10.58.188.37 with SMTP id fx5mr16002588vec.17.1401478491801; Fri, 30 May 2014 12:34:51 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id nu8si3924173vcb.16.2014.05.30.12.34.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 12:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.174 as permitted sender) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jw12so2686616veb.33 for ; Fri, 30 May 2014 12:34:51 -0700 (PDT) X-Received: by 10.53.13.133 with SMTP id ey5mr13516996vdd.8.1401478491729; Fri, 30 May 2014 12:34:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp136558vcb; Fri, 30 May 2014 12:34:51 -0700 (PDT) X-Received: by 10.68.170.131 with SMTP id am3mr21173208pbc.97.1401478490626; Fri, 30 May 2014 12:34:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bw4si6800484pbd.160.2014.05.30.12.34.49; Fri, 30 May 2014 12:34:49 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756214AbaE3Teb (ORCPT + 28 others); Fri, 30 May 2014 15:34:31 -0400 Received: from mail-ob0-f170.google.com ([209.85.214.170]:51336 "EHLO mail-ob0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753955AbaE3Te3 (ORCPT ); Fri, 30 May 2014 15:34:29 -0400 Received: by mail-ob0-f170.google.com with SMTP id uy5so2287803obc.1 for ; Fri, 30 May 2014 12:34:28 -0700 (PDT) X-Received: by 10.182.38.199 with SMTP id i7mr20133721obk.68.1401478468444; Fri, 30 May 2014 12:34:28 -0700 (PDT) Received: from localhost.localdomain (adsl-71-136-229-5.dsl.sndg02.pacbell.net. [71.136.229.5]) by mx.google.com with ESMTPSA id m8sm8702259obz.2.2014.05.30.12.34.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 12:34:27 -0700 (PDT) From: Larry Bassel To: catalin.marinas@arm.com, will.deacon@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, khilman@linaro.org, Larry Bassel Subject: [PATCH v7 1/2] arm64: adjust el0_sync so that a function can be called Date: Fri, 30 May 2014 12:34:14 -0700 Message-Id: <1401478455-26391-2-git-send-email-larry.bassel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401478455-26391-1-git-send-email-larry.bassel@linaro.org> References: <1401478455-26391-1-git-send-email-larry.bassel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: larry.bassel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , To implement the context tracker properly on arm64, a function call needs to be made after debugging and interrupts are turned on, but before the lr is changed to point to ret_to_user(). If the function call is made after the lr is changed the function will not return to the correct place. For similar reasons, defer the setting of x0 so that it doesn't need to be saved around the function call (save far_el1 in x26 temporarily instead). Signed-off-by: Larry Bassel Acked-by: Will Deacon --- arch/arm64/kernel/entry.S | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index e8b23a3..b0101b9 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -354,7 +354,6 @@ el0_sync: lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class cmp x24, #ESR_EL1_EC_SVC64 // SVC in 64-bit state b.eq el0_svc - adr lr, ret_to_user cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0 b.eq el0_da cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0 @@ -383,7 +382,6 @@ el0_sync_compat: lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class cmp x24, #ESR_EL1_EC_SVC32 // SVC in 32-bit state b.eq el0_svc_compat - adr lr, ret_to_user cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0 b.eq el0_da cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0 @@ -426,22 +424,25 @@ el0_da: /* * Data abort handling */ - mrs x0, far_el1 - bic x0, x0, #(0xff << 56) + mrs x26, far_el1 // enable interrupts before calling the main handler enable_dbg_and_irq + bic x0, x26, #(0xff << 56) mov x1, x25 mov x2, sp + adr lr, ret_to_user b do_mem_abort el0_ia: /* * Instruction abort handling */ - mrs x0, far_el1 + mrs x26, far_el1 // enable interrupts before calling the main handler enable_dbg_and_irq + mov x0, x26 orr x1, x25, #1 << 24 // use reserved ISS bit for instruction aborts mov x2, sp + adr lr, ret_to_user b do_mem_abort el0_fpsimd_acc: /* @@ -450,6 +451,7 @@ el0_fpsimd_acc: enable_dbg mov x0, x25 mov x1, sp + adr lr, ret_to_user b do_fpsimd_acc el0_fpsimd_exc: /* @@ -458,16 +460,19 @@ el0_fpsimd_exc: enable_dbg mov x0, x25 mov x1, sp + adr lr, ret_to_user b do_fpsimd_exc el0_sp_pc: /* * Stack or PC alignment exception handling */ - mrs x0, far_el1 + mrs x26, far_el1 // enable interrupts before calling the main handler enable_dbg_and_irq + mov x0, x26 mov x1, x25 mov x2, sp + adr lr, ret_to_user b do_sp_pc_abort el0_undef: /* @@ -476,6 +481,7 @@ el0_undef: // enable interrupts before calling the main handler enable_dbg_and_irq mov x0, sp + adr lr, ret_to_user b do_undefinstr el0_dbg: /* @@ -493,6 +499,7 @@ el0_inv: mov x0, sp mov x1, #BAD_SYNC mrs x2, esr_el1 + adr lr, ret_to_user b bad_mode ENDPROC(el0_sync)