From patchwork Tue Jul 24 06:57:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10541493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCDDE90E3 for ; Tue, 24 Jul 2018 07:53:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D03AD28773 for ; Tue, 24 Jul 2018 07:53:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3FC22877B; Tue, 24 Jul 2018 07:53:19 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham 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 57FC528773 for ; Tue, 24 Jul 2018 07:53:19 +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=Jm9RRSb/yuOxP16pxewToUDfwXoiu2qeVG1CjQTK0XM=; b=mo8ANuebZogA3b7zB6+rCjBkkb m+YTxR5VEeYKAGuxRHq7BsJ1UeMEkqi3oZbO+EhB/3e1raWlOouibfG2RM3eUhXAOTTyjGVmOYXwB 6zFvWdtSz/YBu1/g6zsN2h8cgU7uAG4jMR67yQxYiCmXVVVzfEQKOPqKB/BKhvuuMmk8wSDorBkyU AmkdMrOUuMckWy8v6Sl+s5BV5K+GbGaxlohL7vOXIgvFvojTJ71mX5fWDwhwfb6OA70afmmdRQYIM 3kE3ftakfsQReTxHdg/rA5LZgY547LVCFc2sa2iVSoJtzVYy1EPdzYjq9MtDQZ8vwa9P6KM9i4YXT 0X2TAhBQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhs8A-0000RN-Hy; Tue, 24 Jul 2018 07:53:14 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhs87-0000PI-SI for linux-arm-kernel@bombadil.infradead.org; Tue, 24 Jul 2018 07:53:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LYcgh+nDPKM588JQ9ma6JrqSapqsGrXqoeVmNFniv60=; b=GbAJEb9lOL4/CxgHWnHQfOasm X/FAT9fXArAq67YWq+EUwGKoC2AJ2Kkfvza7q35oZm2sEA3vgYhNvfL9caRDWGRUwnep6Jy1U4Ei7 BGtv0x0hlV1tp15NuZrKfgvYdbecsPkoaiKfr40g3ugoL5PUyrQIm6JTRLXU3eVUEwrr0myvLqozT GOtHXcS7vaUIsG83TZ4TuEbPdNEYlaHHSRP27hpeZD0yNp7t7Ix8k87sn6aYSl8S2yhZjdfZkjkko SzUDh65rSkk0u+e2K4gK03ipq1PYwQ6e7n4U0DxPUFXzPYuXW/gRC/k6Vs+WVAzLqJLhGJYxxAeMa UpRfBR/Eg==; Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhrHp-0005gv-8a for linux-arm-kernel@lists.infradead.org; Tue, 24 Jul 2018 06:59:09 +0000 Received: by mail-pg1-x543.google.com with SMTP id p23-v6so2177056pgv.13 for ; Mon, 23 Jul 2018 23:58:59 -0700 (PDT) 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=LYcgh+nDPKM588JQ9ma6JrqSapqsGrXqoeVmNFniv60=; b=Tj1Kn5X7glWk0eA5Au7pf8DoGG35+0gnsScbyK63dcH0svlRAOtYPEmMQuiuHFyfvn qfhUyZPYaVraqD4EiL/GszUO461fcspkMlOuT125/tkekt551LIlH3/DhV9mJlo+nWtf IkBO56LtgEpsDzquzEqZqia1bu3RYc9Ef7Jl8= 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=LYcgh+nDPKM588JQ9ma6JrqSapqsGrXqoeVmNFniv60=; b=iC7HlNthLNoLd7cA2zWm8J4QDZxRqHy91pdDPp7I/vFjM7SRM8k1o3/6sT3/6rCMAv yj0FikHtRv8RbQNWaBBjuKaSEUVoQ0XJVNQcy+AAmA/9mP0zfSLIsNqshkaWKcJv3ato 925sOO68Hj/zOQ/c/XBJjSSHats/st+dQUsF32Swwi1nR8iLjGmFV+H1v8/q62D2oJzZ WdiOEZjmWxJlcQJLrVZrLX0khTkaAUG7xUF2pJgVjj2/0L5TaSTQl/YpiNi58FfAZXc9 2OqChqpt1JX/ZVIyxsmG9qKTnGFhlwva7aDrWpY8htq8kYLM+EC0vnCcAuj0PAc0eyiK qsuQ== X-Gm-Message-State: AOUpUlG/seuFTfe57sObToK1PjFlkxuSu8BlvBer+d5yi3BZ3EgIqP/K 8y6ijQDNC6jvEp7RzgLlZ+5unQ== X-Google-Smtp-Source: AAOMgpeL+YL92DjiK/BLD5vIT6GASjU4kc2OQmjU+/U49ayZjvZCokZNxmDfJzYiI2pyAcaAWfaJ8Q== X-Received: by 2002:a65:6143:: with SMTP id o3-v6mr15494531pgv.52.1532415536850; Mon, 23 Jul 2018 23:58:56 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id x22-v6sm503821pfh.67.2018.07.23.23.58.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 23:58:56 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Subject: [PATCH v12 13/16] arm64: kexec_file: invoke the kernel without purgatory Date: Tue, 24 Jul 2018 15:57:56 +0900 Message-Id: <20180724065759.19186-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724065759.19186-1-takahiro.akashi@linaro.org> References: <20180724065759.19186-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180724_025909_317158_A5785731 X-CRM114-Status: GOOD ( 17.31 ) 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: ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro , james.morse@arm.com, 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-Virus-Scanned: ClamAV using ClamSMTP On arm64, purgatory would do almost nothing. So just invoke secondary kernel directly by jumping into its entry code. While, in this case, cpu_soft_restart() must be called with dtb address in the fifth argument, the behavior still stays compatible with kexec_load case as long as the argument is null. Signed-off-by: AKASHI Takahiro Reviewed-by: James Morse Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/cpu-reset.S | 8 ++++---- arch/arm64/kernel/machine_kexec.c | 12 ++++++++++-- arch/arm64/kernel/relocate_kernel.S | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S index 8021b46c9743..a2be30275a73 100644 --- a/arch/arm64/kernel/cpu-reset.S +++ b/arch/arm64/kernel/cpu-reset.S @@ -22,11 +22,11 @@ * __cpu_soft_restart(el2_switch, entry, arg0, arg1, arg2) - Helper for * cpu_soft_restart. * - * @el2_switch: Flag to indicate a swich to EL2 is needed. + * @el2_switch: Flag to indicate a switch to EL2 is needed. * @entry: Location to jump to for soft reset. - * arg0: First argument passed to @entry. - * arg1: Second argument passed to @entry. - * arg2: Third argument passed to @entry. + * arg0: First argument passed to @entry. (relocation list) + * arg1: Second argument passed to @entry.(physical kernel entry) + * arg2: Third argument passed to @entry. (physical dtb address) * * 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 diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index f76ea92dff91..830a5063e09d 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -205,10 +205,18 @@ void machine_kexec(struct kimage *kimage) * uses physical addressing to relocate the new image to its final * position and transfers control to the image entry point when the * relocation is complete. + * In kexec case, kimage->start points to purgatory assuming that + * kernel entry and dtb address are embedded in purgatory by + * userspace (kexec-tools). + * In kexec_file case, the kernel starts directly without purgatory. */ - cpu_soft_restart(kimage != kexec_crash_image, - reboot_code_buffer_phys, kimage->head, kimage->start, 0); + reboot_code_buffer_phys, kimage->head, kimage->start, +#ifdef CONFIG_KEXEC_FILE + kimage->arch.dtb_mem); +#else + 0); +#endif BUG(); /* Should never get here. */ } diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index f407e422a720..95fd94209aae 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -32,6 +32,7 @@ ENTRY(arm64_relocate_new_kernel) /* Setup the list loop variables. */ + mov x18, x2 /* x18 = dtb address */ mov x17, x1 /* x17 = kimage_start */ mov x16, x0 /* x16 = kimage_head */ raw_dcache_line_size x15, x0 /* x15 = dcache line size */ @@ -107,7 +108,7 @@ ENTRY(arm64_relocate_new_kernel) isb /* Start new image. */ - mov x0, xzr + mov x0, x18 mov x1, xzr mov x2, xzr mov x3, xzr