From patchwork Wed Apr 25 06:26:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 134227 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp470927lji; Tue, 24 Apr 2018 23:27:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx49k9E5bKlCzaBsQIRKc3ZIvfKE2tpjtIOLu/V4qS3sp88X5u6e4pQJRd220vqXuQXigFWwA X-Received: by 10.98.178.4 with SMTP id x4mr25910399pfe.21.1524637637563; Tue, 24 Apr 2018 23:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524637637; cv=none; d=google.com; s=arc-20160816; b=rFzAPSfFRLSpuATdJupAMYBVrJQ7lLLcOaoekqy2dDjoIZalI+wUViIu6/iLiiqGRU ah+5pNqNm6fXql8oMIkhB2UdNJrOG35p3wsAV/RnVEJsM+tSIn2ftyHaXAc4nG6q2tOp XK+A1EsWVIfro3L78S/Mm4iDTgI8h72PRCCMEGM+q9bCZ6EzCf9WFw6Fe/NsGlcEf9/v XCLmtAGO3vSZ8Ot/z9kjgSaRALqU4L2DRKR96+3npfdsPm16fCYX7lehXk42Kwir6KjZ SNN62y520mrRLmDI2Cysf0RQEOUINFnv6n6FHilB79H2Yl5G98T+en/Cjay6qG1t3/CZ JnHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ForuHUf7fRKkbyO6U4zbwFSqEvXWjf/5Ol9d4UtEg9Y=; b=nBr3c0WToy1o1pcmmIZpmWMK/zviEwiFbtULQkAJqSjY+rCee+dN3a3KGwviS/2/bb MvNvV2/NDs0rQCwenPZheQlt9jrt9/0Kik7Rb1p7fDr86Au16I47hc9BWuhE2H6oxyBp D2xDoIVdIlNnwNw4YXFWvdzEf6Ms0Om0ZloSID+TdOJHCdwYWVPgr+NQ8W+guwBiL47E 6Bpy2DSuuIjFOLUh220P0zL7b2Tfc8A96p85KacfRf4CMxggBCgMQyZt6MCAbjKeXCC4 JkhPOcjWBznhZDv+xAvMISnUG2/BPuAEZg4no7kwAS9N42fzGRhraMq/bx3BLVEBH0VG d8MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ITQBf6iS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o24si8177612pgn.36.2018.04.24.23.27.17; Tue, 24 Apr 2018 23:27:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ITQBf6iS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751494AbeDYG1M (ORCPT + 29 others); Wed, 25 Apr 2018 02:27:12 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:42999 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbeDYG1B (ORCPT ); Wed, 25 Apr 2018 02:27:01 -0400 Received: by mail-pf0-f195.google.com with SMTP id o16so14304833pfk.9 for ; Tue, 24 Apr 2018 23:27:01 -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=ForuHUf7fRKkbyO6U4zbwFSqEvXWjf/5Ol9d4UtEg9Y=; b=ITQBf6iSIlao16ECv8VirqBUtgAhKKF0jq9Hm5Ivm3mF5Oltyz5jikcUvHNghOtRy6 FZyPlO7Op8VlIaN2h0L4Ux92JViCHh5NitnhOxU8YNobhWYxsZMtZinK4xJxZbnM7QBB rFXd+qkOWRx9zqsIoRpCFLIIJpmww8ykdLyQw= 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=ForuHUf7fRKkbyO6U4zbwFSqEvXWjf/5Ol9d4UtEg9Y=; b=sOpR5x3N4UX7O46soTDtU3F/Q++P+QM117cFId7n57OfCKPVYetsVoQ+/eU0DvowNM yNmxnBRrRHEOk/Y8LPxVEdOFAlUuBbileSmRit0s1YjRpteEA6p3c3Vh8B7YbmzjJYG8 l07tHdTyRv7ewT5cHiBd1QxzP62rzLqIScYUO6tFHqzbSHtuEPBF0hHgkS1VW51auUVO GDhcDzrNKvIzLCNOgUtD8qj6tvuxYupD7+oP72q095huUDlthk2GIvobkSuiAb8HS829 7zYpVpoafkl5EcA9MrVaNFpl/2rYw50DiYQUJJ2chz9qc3VTdBs42sRmQHgLeJNAgAR5 uuog== X-Gm-Message-State: ALQs6tAeP5CgdUS6wPRLHqWYBXNuLoVRY3Riao54YvywLcGgxm++4y1r heR2+xhQIkGGPNSe794xL4BB3Q== X-Received: by 2002:a17:902:b191:: with SMTP id s17-v6mr27711983plr.339.1524637621153; Tue, 24 Apr 2018 23:27:01 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id b3sm30407840pff.11.2018.04.24.23.27.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 23:27:00 -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 Cc: ard.biesheuvel@linaro.org, james.morse@arm.com, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v9 03/11] arm64: kexec_file: invoke the kernel without purgatory Date: Wed, 25 Apr 2018 15:26:21 +0900 Message-Id: <20180425062629.29404-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425062629.29404-1-takahiro.akashi@linaro.org> References: <20180425062629.29404-1-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On arm64, purugatory would do almosty nothing. So just invoke secondary kernel directy 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 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(-) -- 2.17.0 Reviewed-by: James Morse diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S index 8021b46c9743..391df91328ac 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. (relocation list) + * 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