From patchwork Mon Oct 19 23:38:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 7440551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 750179F30B for ; Mon, 19 Oct 2015 23:41:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B6B420570 for ; Mon, 19 Oct 2015 23:41:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A05412054A for ; Mon, 19 Oct 2015 23:41:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoK18-0002nN-62; Mon, 19 Oct 2015 23:39:02 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoK12-0002eN-CI; Mon, 19 Oct 2015 23:38:56 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.85 #2 (Red Hat Linux)) id 1ZoK0z-0000wS-Qa; Mon, 19 Oct 2015 23:38:53 +0000 Message-Id: <0e27e2e50ae3c2aa867fd5e778bd2daeb3bc6eba.1445297709.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Fri, 9 Oct 2015 11:20:55 -0700 Subject: [PATCH 06/16] arm64: Add EL2 switch to cpu_reset To: Catalin Marinas , Will Deacon Date: Mon, 19 Oct 2015 23:38:53 +0000 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , AKASHI@infradead.org, marc.zyngier@arm.com, kexec@lists.infradead.org, Takahiro , linux-arm-kernel@lists.infradead.org, christoffer.dall@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a CPU is reset it needs to be put into the exception level it had when it entered the kernel. Update cpu_reset() to accept an argument which signals if the reset address needs to be entered at EL1 or EL2. Also, update the comments of cpu_reset() and cpu_soft_restart() to reflect this change. Signed-off-by: Geoff Levand --- arch/arm64/kernel/cpu-reset.S | 22 +++++++++++++++++++--- arch/arm64/kernel/cpu-reset.h | 4 +++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S index 64d9d7c..ffc9e385e 100644 --- a/arch/arm64/kernel/cpu-reset.S +++ b/arch/arm64/kernel/cpu-reset.S @@ -16,6 +16,7 @@ #include #include #include +#include .text .pushsection .idmap.text, "ax" @@ -23,9 +24,14 @@ .align 5 /* - * cpu_reset(addr) - Helper for cpu_soft_restart. + * cpu_reset(addr, el2_switch) - Helper for cpu_soft_restart. * * @addr: Location to jump to for soft reset. + * @el2_switch: Flag to indicate a swich to EL2 is needed. + * + * Put the CPU into the same state as it would be if it had been reset, and + * branch to what would be the reset vector. It must be executed with the + * flat identity mapping. */ ENTRY(cpu_reset) @@ -33,19 +39,28 @@ ENTRY(cpu_reset) bic x2, x2, #1 msr sctlr_el1, x2 // disable the MMU isb - ret x0 + + cbz x1, 1f // el2_switch? + mov x1, xzr + mov x2, xzr + mov x3, xzr + hvc #HVC_CALL_FUNC // no return + +1: ret x0 ENDPROC(cpu_reset) /* - * cpu_soft_restart(cpu_reset, addr) - Perform a cpu soft reset. + * cpu_soft_restart(cpu_reset, addr, el2_switch) - Perform a cpu soft reset. * * @cpu_reset: Physical address of the cpu_reset routine. * @addr: Location to jump to for soft reset, passed to cpu_reset. + * @el2_switch: Flag to indicate a swich to EL2 is needed, passed to cpu_reset. */ ENTRY(cpu_soft_restart) mov x19, x0 // cpu_reset mov x20, x1 // addr + mov x21, x2 // el2_switch /* Turn D-cache off */ mrs x0, sctlr_el1 @@ -54,6 +69,7 @@ ENTRY(cpu_soft_restart) isb mov x0, x20 + mov x1, x21 ret x19 ENDPROC(cpu_soft_restart) diff --git a/arch/arm64/kernel/cpu-reset.h b/arch/arm64/kernel/cpu-reset.h index 4e16dfe..ef3bba2 100644 --- a/arch/arm64/kernel/cpu-reset.h +++ b/arch/arm64/kernel/cpu-reset.h @@ -11,8 +11,10 @@ #if !defined(_ARM64_CPU_RESET_H) #define _ARM64_CPU_RESET_H +#include + void __attribute__((noreturn)) cpu_reset(unsigned long addr); void __attribute__((noreturn)) cpu_soft_restart(phys_addr_t cpu_reset, - unsigned long addr); + unsigned long addr, unsigned long el2_switch); #endif