Received: by 10.213.65.68 with SMTP id h4csp711037imn; Fri, 6 Apr 2018 07:40:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/qiLkOTHtlBmhfeOvehZJG69+a1XOP/WUyd3XPqS+2sBXTPgM+bU2HAyvb5//gzt4rCqao X-Received: by 10.101.97.208 with SMTP id j16mr18109859pgv.431.1523025606003; Fri, 06 Apr 2018 07:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025605; cv=none; d=google.com; s=arc-20160816; b=P+8RjctCveJmgb6Xz+Z3VocMnl/pEFtj6C39NttK8df54WabaMkYixzrVdNJ+Y/rzC /ebOnq2e9lrOW2MTDe6Nns7zri3yaExvDh0rRUscyFvbuBvhIrEXJUqrn/a81IBbVA8/ kP1tfvyiwgXoTDgzNK7vtTGD95kfAWn2LaJwTovbE5qQJRx4iWxdSVyvEXXCRgGdf0vO xn163dvlWYMDXIm9r07bJn4YRmkJ0V1Ul8KxWdiZM+hbWejNpKZcYF2+soRo8lthM8tq rdxlPZPj2DZXnFFN0pAKppCu6vYwjVgMWbXrV9g9TqMdM82YIVdOBzRV6tnCfLLFIYR6 6IrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XukNshtXclaBv8jW/sn9Q/GDvNS/WMqQ1pfD1gvb8T0=; b=YQV1GtJL6G4RGfMXz8/QKjSLFYBrDh9qNBsoO7rGq0SjQbtxJAQHZmaktN/1CAptif 6JXkiw7SJsUkRR4KNMOZfIQ9mIQyHdYO8aXlqkh+P8ap6HUQETOfna4mdCOgWWPARgGx RMvNg8hzhcrdKT8GcSZ8zATLLdOZPm9e3uEbS/mHJJ/mWBb8rx/1YXGaBZU6Jva4UqVk JmFpK0lk6+H09Kw8CqwcWVsuyzj2Hx38kZZiZ8Zs3/SDsBP1c1OklQa88Ope6XCa3yy1 I/LknZeGn50sAbOkAKBicM6SWQQq/+VFZlqtxk3Eg9sM1e+3zFaQ/uuR1A+4YC6d6ehM ls8Q== 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 q29si8060055pfd.240.2018.04.06.07.39.51; Fri, 06 Apr 2018 07:40:05 -0700 (PDT) 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 S1755990AbeDFNfK (ORCPT + 99 others); Fri, 6 Apr 2018 09:35:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58626 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755976AbeDFNfH (ORCPT ); Fri, 6 Apr 2018 09:35:07 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BC93CDBB; Fri, 6 Apr 2018 13:35:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Mark Rutland , Laura Abbott , Shanker Donthineni , Will Deacon , Greg Hackmann , Alex Shi Subject: [PATCH 4.9 060/102] arm64: entry: Hook up entry trampoline to exception vectors Date: Fri, 6 Apr 2018 15:23:41 +0200 Message-Id: <20180406084340.016494702@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon commit 4bf3286d29f3 upstream. Hook up the entry trampoline to our exception vectors so that all exceptions from and returns to EL0 go via the trampoline, which swizzles the vector base register accordingly. Transitioning to and from the kernel clobbers x30, so we use tpidrro_el0 and far_el1 as scratch registers for native tasks. Reviewed-by: Mark Rutland Tested-by: Laura Abbott Tested-by: Shanker Donthineni Signed-off-by: Will Deacon Signed-off-by: Alex Shi [v4.9 backport] Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Will Deacon Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -72,10 +72,26 @@ .macro kernel_ventry, el, label, regsize = 64 .align 7 +#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 + .if \el == 0 + .if \regsize == 64 + mrs x30, tpidrro_el0 + msr tpidrro_el0, xzr + .else + mov x30, xzr + .endif + .endif +#endif + sub sp, sp, #S_FRAME_SIZE b el\()\el\()_\label .endm + .macro tramp_alias, dst, sym + mov_q \dst, TRAMP_VALIAS + add \dst, \dst, #(\sym - .entry.tramp.text) + .endm + .macro kernel_entry, el, regsize = 64 .if \regsize == 32 mov w0, w0 // zero upper 32 bits of x0 @@ -157,18 +173,20 @@ ct_user_enter ldr x23, [sp, #S_SP] // load return stack pointer msr sp_el0, x23 + tst x22, #PSR_MODE32_BIT // native task? + b.eq 3f + #ifdef CONFIG_ARM64_ERRATUM_845719 alternative_if ARM64_WORKAROUND_845719 - tbz x22, #4, 1f #ifdef CONFIG_PID_IN_CONTEXTIDR mrs x29, contextidr_el1 msr contextidr_el1, x29 #else msr contextidr_el1, xzr #endif -1: alternative_else_nop_endif #endif +3: .endif msr elr_el1, x21 // set up the return data msr spsr_el1, x22 @@ -189,7 +207,22 @@ alternative_else_nop_endif ldp x28, x29, [sp, #16 * 14] ldr lr, [sp, #S_LR] add sp, sp, #S_FRAME_SIZE // restore sp - eret // return to kernel + +#ifndef CONFIG_UNMAP_KERNEL_AT_EL0 + eret +#else + .if \el == 0 + bne 4f + msr far_el1, x30 + tramp_alias x30, tramp_exit_native + br x30 +4: + tramp_alias x30, tramp_exit_compat + br x30 + .else + eret + .endif +#endif .endm .macro get_thread_info, rd