From patchwork Thu May 29 21:45:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Bassel X-Patchwork-Id: 31149 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5246720068 for ; Thu, 29 May 2014 21:45:33 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id pa12sf4494804veb.3 for ; Thu, 29 May 2014 14:45:33 -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=mjmiMOfirID16EsoW706yJBjcWj0C2ATJSHtQ3HzDNA=; b=TUeyXDIGaVauP+QnpgrzBwCAPTpSHBitfcIrcRYSdhD5zxFt6KbmQxpiUpFikcdp3B kspU9fR+PMSbd9yBmax1D59KywFBK1AHHlzP44DWee1x+g3DjuNWcK8VfjkyeLsnfn93 sC7Npg6Mz02q7T11E1OwxaUcGYKF8R1Tusly5goMGK51D0kScZBLOpAjLFRTofSQovv0 pbCNgv/5Ygoa71UR+hLcH2unMC5OWhvn3jn0e7deQ7z+syfIJMv6LWgAMgWhsRcc6Vzq REPuHtHZjmmb2KriMRsVP3Q8uON5PfEwktxaDl2qtWV9GvmKWirhBLK4cFVbxz/4i8eL iF/A== X-Gm-Message-State: ALoCoQkjRr1l4fwmP/IOVhGvW+T+cRIZi+1afJgXi7AKOesiug6XIl/YqXIsjMyrcChARUwofHX9 X-Received: by 10.236.121.18 with SMTP id q18mr2681815yhh.47.1401399933181; Thu, 29 May 2014 14:45:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.83 with SMTP id 77ls920669qgg.28.gmail; Thu, 29 May 2014 14:45:33 -0700 (PDT) X-Received: by 10.220.167.2 with SMTP id o2mr9941130vcy.8.1401399932984; Thu, 29 May 2014 14:45:32 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id j10si1627652vdf.97.2014.05.29.14.45.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 14:45:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id il7so1116292vcb.4 for ; Thu, 29 May 2014 14:45:32 -0700 (PDT) X-Received: by 10.58.185.165 with SMTP id fd5mr4994055vec.41.1401399932863; Thu, 29 May 2014 14:45:32 -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 ib8csp62240vcb; Thu, 29 May 2014 14:45:32 -0700 (PDT) X-Received: by 10.68.245.100 with SMTP id xn4mr12528620pbc.152.1401399931606; Thu, 29 May 2014 14:45:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tk2si2712517pac.24.2014.05.29.14.45.31; Thu, 29 May 2014 14:45:31 -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 S932738AbaE2VpX (ORCPT + 28 others); Thu, 29 May 2014 17:45:23 -0400 Received: from mail-ob0-f170.google.com ([209.85.214.170]:49274 "EHLO mail-ob0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbaE2VpV (ORCPT ); Thu, 29 May 2014 17:45:21 -0400 Received: by mail-ob0-f170.google.com with SMTP id uy5so963436obc.15 for ; Thu, 29 May 2014 14:45:21 -0700 (PDT) X-Received: by 10.182.20.105 with SMTP id m9mr7674612obe.36.1401399920961; Thu, 29 May 2014 14:45:20 -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 b7sm6187924oed.7.2014.05.29.14.45.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 14:45:20 -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 v6 1/2] arm64: adjust el0_sync so that a function can be called Date: Thu, 29 May 2014 14:45:03 -0700 Message-Id: <1401399904-24471-2-git-send-email-larry.bassel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401399904-24471-1-git-send-email-larry.bassel@linaro.org> References: <1401399904-24471-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.220.173 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 --- 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)