From patchwork Tue Apr 3 11:09:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 132735 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3666763ljb; Tue, 3 Apr 2018 04:10:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/MJxrdETSEp1JJIcAiO9FunJBOKwORwwqRYREZY5uR/5pTcFIjkzMZDBidivSacs6gHyk9 X-Received: by 2002:a17:902:ab86:: with SMTP id f6-v6mr14120480plr.258.1522753853525; Tue, 03 Apr 2018 04:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522753853; cv=none; d=google.com; s=arc-20160816; b=Wknq64ovI8gqpxpgm8Bfhmqj+ckJDtmPY2+sUT4Nfn0g+3quiqqBlOKm43XIQeUJGz /ISgZpwX6jVnvK+YPzKJsd+6oJeR4gyJo07TZzicw0rqLsXpPwMiV4lyXp9o5plQwCaG /q2b7eQXJ8M5nfs1MvRl7UkuaV19wzdQzvnKM58YNrKAy4UGcFNw4idha/lTbEZgRZNx SX4ewKrqP0JYJX6lDKF293EdeCZgPZmSEHdlSRkhXjKaYv2JfHKcDvC8a7KOKlQ6Biic 2yuCY8HWq7t9F2wuiopXyTmxQawg6ugR0vBDdiHDmvqHyIUBzCz2Qj3tSq5GeyXS2uWu fZxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1vFrnyjWcbCEEwIOXW5FqwNy+gD7OTbsQlP+2W2znRg=; b=OO9GJER5vXv4O+1jVzQai3jswmZrrA5OHNU7b5w4BNbsJvLeO4OUl8H96nyC/zw5oB RYa0AMToUsDfKNOqi3w+uwCjE1jer4SFpWYfGRn3LthTRIPZoYeotKpdiZqO8t6ofGE2 IGkOkol5IOjQBblTKn7c8I00QW8Hckn53d3u4i6227fWzAYxLK/aZE1znQmGHvfw8K/P VFcOz3C+JUyjlrEQ3aNMx3+f48bi4yFhksJ5KoiqA4VkFn/V/UzOYIBOeumFkfkyxn7l jfCsrOCZCPLz7lkgnCBELrdEMR1GAdAGhnrTk5KlTdrqniBjmBgpnNhCdQe1lv9raODj cdEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 q9-v6si295691plr.273.2018.04.03.04.10.53; Tue, 03 Apr 2018 04:10:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755379AbeDCLKJ (ORCPT + 11 others); Tue, 3 Apr 2018 07:10:09 -0400 Received: from foss.arm.com ([217.140.101.70]:59340 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755484AbeDCLKH (ORCPT ); Tue, 3 Apr 2018 07:10:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7D65715AD; Tue, 3 Apr 2018 04:10:07 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4CAF93F587; Tue, 3 Apr 2018 04:10:06 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com Subject: [PATCH v4.9.y 11/27] arm64: entry: Hook up entry trampoline to exception vectors Date: Tue, 3 Apr 2018 12:09:07 +0100 Message-Id: <20180403110923.43575-12-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180403110923.43575-1-mark.rutland@arm.com> References: <20180403110923.43575-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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] --- arch/arm64/kernel/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 0a9f6e7a76d6..623c160bf68e 100644 --- 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