From patchwork Wed Feb 28 03:56:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10246757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A96860362 for ; Wed, 28 Feb 2018 04:11:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35D4728A82 for ; Wed, 28 Feb 2018 04:11:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A9A028A89; Wed, 28 Feb 2018 04:11:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D35628A82 for ; Wed, 28 Feb 2018 04:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=J1EI2kxs5sHoPZ8vgid1LYqLAZ+2cGmWlOZrA7egkDo=; b=UKEeNMDdOElInE5qzaTWCQyJVq AKk1RhRIxFlUNH/jMxn2TH4D0Pq4J6Rhu75tocB1qn1xsSTSB9lTS/NqyG/sfJpPxADy+/q0ZPADK c5pu6fl8kEDkcg9vFIoM1vsChc2LSDZEKtODqdQqrEw5gxxiepR4xer3XnoqF06MN4xipr/Yvpte5 HlmsMKcihTlAhoWZ66ekwRZWnh5MHm7ttrBcMp5+/Nd4S2Q6AC77hkI+ctW+zrngPJG0F1M3ktpeP Z2ket8B8NvP1Hv7c5Jf3Ys5aJRb4IJyLy2n/nUi9MVlmqRPGbcZwR5qOwSr/8G+TPw6LAinZeeGSW LTaDs5wA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqt52-0000Gu-HH; Wed, 28 Feb 2018 04:11:00 +0000 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqstd-0007Q3-9H for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2018 04:00:01 +0000 Received: by mail-pl0-x242.google.com with SMTP id 61-v6so778629plf.3 for ; Tue, 27 Feb 2018 19:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3EefTrlVGpCtN2KCozRnf/Q739j84WLPOQ3GnGLPWwc=; b=I5i7fWK90jD96UsGo0uqR6y4N2ezALYxV9gmWp5olA7bwSpBVt4RywMawse2zn4sJN Q6DCBw+XtUieaL7IqLPwhQXo/YqiS4FPUXdNDq72dyogy0UVCoxnTW7P1MOmcoePAtFR Qn0/CuSnOMlaiS9l0ut+ER656ENPug5QQf1A8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3EefTrlVGpCtN2KCozRnf/Q739j84WLPOQ3GnGLPWwc=; b=FffDhP5tFXmYVOyCUsIerjQUyBCm2Agqust+GzQW1bh1IMum+5pRpwJZTJDnElrB5E 6ikTy1Qe41bxkJjQnNTj8R6gRl37txMSeDY2kD3iKxkgxFY3QcDTBuqIS7Jjr9BwFbZH zIBnDb0cD/nX0uQlrcfBtT53KzK+P4fvE+H3O2JVrANuUDoQPnBDRU7xlfvNXA23SaUa Xba6ddokIISXxh9Mmok3LejwDuESVoAIujkq8ftLB8iQf4gTblYWEDzgcW4YlmMuYNe2 FkH/CuVV+ai6FG8EZ30Gy0cModoarrgPxPlcjZjV/UZyjWjId0yCTBiNUhnD+CrGwM8x qalA== X-Gm-Message-State: APf1xPDT86RUvk/N08LYRDIxhcoiiE1qEbLG05jFA+FpHBF4YNhGCZnP PIeT4uoCtDZZRTjZ33GxTAwU2g== X-Google-Smtp-Source: AG47ELvLCJAXe4ltlS2QX/wSfaM8zGnK8Ma3IjTADbId4S/uiOQHVMd0p1Hb7Jah7W1/7shfiJlEgw== X-Received: by 2002:a17:902:4025:: with SMTP id b34-v6mr8396044pld.359.1519790341925; Tue, 27 Feb 2018 19:59:01 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id q17sm739911pgt.7.2018.02.27.19.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 19:59:01 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/29] arm64: entry: Hook up entry trampoline to exception vectors Date: Wed, 28 Feb 2018 11:56:34 +0800 Message-Id: <1519790211-16582-13-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> References: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_195913_990959_9174C67C X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- arch/arm64/kernel/entry.S | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 7b1be51..eccb6d8 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