From patchwork Thu Feb 22 11:17:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10235237 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 C872860224 for ; Thu, 22 Feb 2018 11:25:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C3D28B3E for ; Thu, 22 Feb 2018 11:25:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC76628B9F; Thu, 22 Feb 2018 11:25:05 +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 3DD7F28B3E for ; Thu, 22 Feb 2018 11:25:05 +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=JPdlK4eUn8Pgf2HcT6t86LPN5gMbOjSC0wUmrYsaGY8=; b=DBpCSoE2ocJLiZrGnhL2L+T0Ju tQ7r68r3CCp21ik3Gy+Fzw68R78lmqRrDjM6CLJ2fuNUxrdSDA9ZEvTi5q8WQbMuW2LijvSyOsRwe 5RlYCMs3YIS6zcgFNx/hO0/x8NI7sf3Aqe+BrPdXrxTLeyNxjCCAI9IfyaqlvnzKGnCwOQe+Ko8DM HGwDE3xk9Eh7w0hqIe/eMrf5WJzSHVO5VUrFD0omCcrnY8qlIUYPrLtMu9cO/wkjSAGBy5jpH7wpB bmU648xhwkHFO1luvmqC6NqVdY/+TkHR5dAnb9Cj+b6buuKTM6Fa3eXrzkU5JhveXhEQ6qe4C4pNy mdri3nTA==; 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 1eoozd-0006Ww-07; Thu, 22 Feb 2018 11:24:53 +0000 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoouc-0002hu-Ce for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2018 11:20:31 +0000 Received: by mail-it0-x244.google.com with SMTP id v194so6090253itb.0 for ; Thu, 22 Feb 2018 03:19:31 -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=QF60Fq3LXgQ/Pd/Rp8F+Wxzz522rhmYJZ34ba4IgsUA=; b=Q6ktHvwzgTxkesbjdLksjP6ZQYlj6arusHeRFijc1eWX+kpvaUDiW9puGMWUFYq+RX MElfzjBUlibLERBBX/WNdzHIHYxw0H3PA78pWC9ECcskj3dqanWIjQtxWs0NA/YIwekT t2xJb/AukRPU99+8YMkV0TOiRjU3usRlDcowk= 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=QF60Fq3LXgQ/Pd/Rp8F+Wxzz522rhmYJZ34ba4IgsUA=; b=hkT5L9PL5hgEOecVcqUY9DA2+nb9/XDwGMPQTR/jz+CzGQzffG2HO14PCsI0HRd/pA 8kIzOprueTSJQEgYY9Klq9Fb5WZg0++b8nzBHcK1JZx6gx8zyimBoUk746lcwN8zd81I 3j30C04Vv593/5PLH2bBJDv5ZelutdpeIBKrIijhTo5aUwEQOZbXJB5EuPwMoUretujg SLAANW1PiHvYl921XcrwB7ZklH4PGBg3GO8O06ag+OjeqXdhrb5wORvBNLslG1osnMkK sJQyiHug6AMRmYIeNlutdK3QItMz49MTRJzU1J/DgUrL16T4pfnPGk0siVBx4Oi51TXF 7p3g== X-Gm-Message-State: APf1xPArZ0/N5hBA4xI+pkttgrr3V9pcHghGmU4QtfhIS8a/fzGmR+6s 4D3r5n7OfJIDrHWwopSEO4WuqQ== X-Google-Smtp-Source: AH8x2268ztreO+5lFXJTCFD2jwb7ugCesFGxnMpTf/gfcjfRIbjfTwdhm2i8nrXsSjdGqB7TlGvn5g== X-Received: by 10.36.94.197 with SMTP id h188mr7474236itb.141.1519298371260; Thu, 22 Feb 2018 03:19:31 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id b185sm211689itb.20.2018.02.22.03.19.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Feb 2018 03:19:30 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, bauerman@linux.vnet.ibm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, akpm@linux-foundation.org, mpe@ellerman.id.au, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, ard.biesheuvel@linaro.org, julien.thierry@arm.com Subject: [PATCH v8 07/13] arm64: kexec_file: invoke the kernel without purgatory Date: Thu, 22 Feb 2018 20:17:26 +0900 Message-Id: <20180222111732.23051-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180222111732.23051-1-takahiro.akashi@linaro.org> References: <20180222111732.23051-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180222_031942_540615_641B0A52 X-CRM114-Status: GOOD ( 15.27 ) 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: AKASHI Takahiro , kexec@lists.infradead.org, linux-kernel@vger.kernel.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-Virus-Scanned: ClamAV using ClamSMTP On arm64, purugatory would do almosty nothing. So just invoke the second kernel by jumping into the entry code directly. While, in this case, cpu_soft_restart() must be called in a specific way, it still stays compatible with kexec as far as the fifth argument is null. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/cpu-reset.S | 6 +++--- arch/arm64/kernel/machine_kexec.c | 11 +++++++++-- arch/arm64/kernel/relocate_kernel.S | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S index 8021b46c9743..46fd9ea66ae8 100644 --- a/arch/arm64/kernel/cpu-reset.S +++ b/arch/arm64/kernel/cpu-reset.S @@ -24,9 +24,9 @@ * * @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. - * arg2: Third argument passed to @entry. + * arg0: First argument passed to @entry. (rellocator's address) + * arg1: Second argument passed to @entry.(physcal 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..f7dbba00be10 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -205,10 +205,17 @@ 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 case of kexec_file_load syscall, we directly start the kernel, + * skipping 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->purgatory_info.purgatory_buf ? + 0 : 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