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: 142699 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp6919095ljj; Mon, 23 Jul 2018 23:59:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf3N+xryOw8fjPoTJreg9W48/o5GSb0vmkb5AsXTLkABBF54A9HE7LfNzbZ5MQOsG4RDw4Y X-Received: by 2002:a63:4506:: with SMTP id s6-v6mr15553635pga.422.1532415540383; Mon, 23 Jul 2018 23:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532415540; cv=none; d=google.com; s=arc-20160816; b=RtAlt838FU3ujguYwYNwhLFSWHGoVRQyyEILXC0plCFHzGJhhHQ3emkFk1ccl1GMIx DDuqBewMw9a3LvfYapnLdf4WpGBqFfRQnvzCqnKXn3yrTFxRmU9G8OCEiDTBwAdQ+Dsq mq2nzGzkuJ17ho19TLcKMndfzHLcnIB9Qe9ehV/zy6+6AJcJcCFFecEUD5kIdvk2hFrc rPif9ffn8OBo5OGUnE24Y64jlkohgscSRhJwBPT9K+vvMuR8qGdo8jyRvQq5KByGnX0t 2f7eiaTDIl1EMRtsqZNlCvB846j59itU8n2sh+U6QWGAVw4rKANtw/qLCnoWbSf70pGy W8Zw== 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=LYcgh+nDPKM588JQ9ma6JrqSapqsGrXqoeVmNFniv60=; b=QikzqlKo+CK2sOSr2HQoOivExTXghioXJaJY6r42tvogDtNrUdhgnmlDm0NZo72tHR FLLAh1T1h09ismrczcrnIvDpiguQaJvaYXWdrgL1Cr4rU4ef3FGXN7e/s8uoOo1WSgsd 0JQFjNHPgxS+gJCU7a9wEJM/heKjY+MKlyI8srCvFLvGtYbjKkdQn6rb9cDnUWFIj46a wqJ6O5N2r34znPkcZleq1v6Vd7H1gVWoh5gGM29PSGxupsmb4sasI2ysQKk1wT9XhaUg iYm3X67p2kDi+hJBSH4Hq1RHzxEnMgSS16+mLPpsUw3C5xz1v8vTl3lAV6LG8OSFCvAR d07w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tj1Kn5X7; 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 r65-v6si11333141pfe.298.2018.07.23.23.59.00; Mon, 23 Jul 2018 23:59:00 -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=Tj1Kn5X7; 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 S2388564AbeGXIDz (ORCPT + 31 others); Tue, 24 Jul 2018 04:03:55 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34050 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388264AbeGXIDz (ORCPT ); Tue, 24 Jul 2018 04:03:55 -0400 Received: by mail-pg1-f196.google.com with SMTP id y5-v6so2199006pgv.1 for ; Mon, 23 Jul 2018 23:58:57 -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=lXe+O0NVaf8G8F0ccxnhI5s/3CVHCM97cE9SjyEUXeYTPQCE7Ys830sPvE2bLlG1Uh 5UoVSD//ZfqOqre93Bm0b90iLHGG6gMIc5eX9FD/ZSkH5GaQ5XLoBRsq/4h1cAa7KoKV lTqB04WXbgKxdn1D+nGQAw6WvASHDhjZkGGpxLdt+ROC4goBdSb3Emh0R79yi3sNP6Nd j2841ODMq/0eV+ChrOq9wrGxvkcSrtTHgtDo2AumwLuxadaN8HtzMN0cuXD9iY8u2Ng+ bw+YYEaim77WLsSOygnALwrXC+4XRaSWIAs2oOH3wWTk4TX7dHbTeZScOI7CSSeb4CoI r98A== X-Gm-Message-State: AOUpUlHIIQ7tSuzCDApht3zfZTmvXB06wOyjNCIIvbcNPLnNuTWJWD0w TTgyREUMFXJPw852Y+4rhqO6rA== 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 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 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.18.0 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