From patchwork Fri Nov 6 19:14:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 7572161 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 DF59B9F1C4 for ; Fri, 6 Nov 2015 20:04:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0239E206F8 for ; Fri, 6 Nov 2015 20:04:47 +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 F05E4206F9 for ; Fri, 6 Nov 2015 20:04:45 +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 1ZunDy-0006se-0B; Fri, 06 Nov 2015 20:03: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 1Zun68-0004wL-11; Fri, 06 Nov 2015 19:54:56 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.85 #2 (Red Hat Linux)) id 1ZumT6-0000Bi-KU; Fri, 06 Nov 2015 19:14:36 +0000 Message-Id: <82b846e4b9855a02c404b5d1f70c79142f87c005.1446836443.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 22 Sep 2015 15:36:29 -0700 Subject: [PATCH 05/15] arm64: Add back cpu_reset routines To: Catalin Marinas , Will Deacon Date: Fri, 06 Nov 2015 19:14:36 +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 , marc.zyngier@arm.com, kexec@lists.infradead.org, AKASHI Takahiro , christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.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, T_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 Commit 68234df4ea7939f98431aa81113fbdce10c4a84b (arm64: kill flush_cache_all()) removed the global arm64 routines cpu_reset() and cpu_soft_restart() needed by the arm64 kexec and kdump support. Add simplified versions of those two routines back with some changes needed for kexec in the new files cpu_reset.S, and cpu_reset.h. 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. Signed-off-by: Geoff Levand --- arch/arm64/kernel/cpu-reset.S | 84 +++++++++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/cpu-reset.h | 22 ++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 arch/arm64/kernel/cpu-reset.S create mode 100644 arch/arm64/kernel/cpu-reset.h diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S new file mode 100644 index 0000000..0423f27 --- /dev/null +++ b/arch/arm64/kernel/cpu-reset.S @@ -0,0 +1,84 @@ +/* + * cpu reset routines + * + * Copyright (C) 2001 Deep Blue Solutions Ltd. + * Copyright (C) 2012 ARM Ltd. + * Copyright (C) 2015 Huawei Futurewei Technologies. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include + +#define SCTLR_ELx_I (1 << 12) +#define SCTLR_ELx_SA (1 << 3) +#define SCTLR_ELx_C (1 << 2) +#define SCTLR_ELx_A (1 << 1) +#define SCTLR_ELx_M 1 +#define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ + SCTLR_ELx_SA | SCTLR_ELx_I) + +.text +.pushsection .idmap.text, "ax" + +.align 5 + +/* + * cpu_soft_restart(cpu_reset, el2_switch, entry, arg0, arg1) - Perform a cpu + * soft reset. + * + * @cpu_reset: Physical address of the cpu_reset routine. + * @el2_switch: Flag to indicate a swich to EL2 is needed, passed to cpu_reset. + * @entry: Location to jump to for soft reset, passed to cpu_reset. + * arg0: First argument passed to @entry. + * arg1: Second argument passed to @entry. + */ + +ENTRY(cpu_soft_restart) + mov x18, x0 // cpu_reset + mov x0, x1 // el2_switch + mov x1, x2 // entry + mov x2, x3 // arg0 + mov x3, x4 // arg1 + ret x18 +ENDPROC(cpu_soft_restart) + +/* + * cpu_reset(el2_switch, entry, arg0, arg1) - Helper for cpu_soft_restart. + * + * @el2_switch: Flag to indicate a swich to EL2 is needed. + * @entry: Location to jump to for soft reset. + * arg0: First argument passed to @entry. + * arg1: Second argument passed to @entry. + * + * 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) + /* Clear sctlr_el1 flags. */ + mrs x12, sctlr_el1 + ldr x13, =SCTLR_ELx_FLAGS + bic x12, x12, x13 + msr sctlr_el1, x12 + isb + + cbz x0, 1f // el2_switch? + + mov x0, x1 // entry + mov x1, x2 // arg0 + mov x2, x3 // arg1 + hvc #HVC_CALL_FUNC // no return + +1: mov x18, x1 // entry + mov x0, x2 // arg0 + mov x1, x3 // arg1 + ret x18 +ENDPROC(cpu_reset) + +.popsection diff --git a/arch/arm64/kernel/cpu-reset.h b/arch/arm64/kernel/cpu-reset.h new file mode 100644 index 0000000..79816b6 --- /dev/null +++ b/arch/arm64/kernel/cpu-reset.h @@ -0,0 +1,22 @@ +/* + * cpu reset routines + * + * Copyright (C) 2015 Huawei Futurewei Technologies. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#if !defined(_ARM64_CPU_RESET_H) +#define _ARM64_CPU_RESET_H + +#include + +void __attribute__((noreturn)) cpu_reset(unsigned long el2_switch, + unsigned long entry, unsigned long arg0, unsigned long arg1); +void __attribute__((noreturn)) cpu_soft_restart(phys_addr_t cpu_reset, + unsigned long el2_switch, unsigned long entry, unsigned long arg0, + unsigned long arg1); + +#endif