From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AED42C47404 for ; Fri, 11 Oct 2019 18:19:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7CF1220673 for ; Fri, 11 Oct 2019 18:19:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CF1220673 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 254278E0009; Fri, 11 Oct 2019 14:19:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 203E98E0007; Fri, 11 Oct 2019 14:19:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11A1A8E0009; Fri, 11 Oct 2019 14:19:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id E45578E0007 for ; Fri, 11 Oct 2019 14:19:17 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 8A0A04837 for ; Fri, 11 Oct 2019 18:19:17 +0000 (UTC) X-FDA: 76032315954.16.brake68_8b494dc1f4902 X-HE-Tag: brake68_8b494dc1f4902 X-Filterd-Recvd-Size: 4547 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Oct 2019 18:19:16 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43859142F; Fri, 11 Oct 2019 11:19:16 -0700 (PDT) Received: from [10.1.196.105] (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2BAC13F703; Fri, 11 Oct 2019 11:19:14 -0700 (PDT) Subject: Re: [PATCH v6 14/17] arm64: kexec: move relocation function setup and clean up To: Pavel Tatashin References: <20191004185234.31471-1-pasha.tatashin@soleen.com> <20191004185234.31471-15-pasha.tatashin@soleen.com> From: James Morse Cc: jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, bhsharma@redhat.com, linux-mm@kvack.org, mark.rutland@arm.com Message-ID: Date: Fri, 11 Oct 2019 19:19:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191004185234.31471-15-pasha.tatashin@soleen.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Pavel, On 04/10/2019 19:52, Pavel Tatashin wrote: > Currently, kernel relocation function is configured in machine_kexec() > at the time of kexec reboot by using control_code_page. > > This operation, however, is more logical to be done during kexec_load, > and thus remove from reboot time. Move, setup of this function to > newly added machine_kexec_post_load(). > > In addition, do some cleanup: add infor about reloction function to infor ? reloction? > kexec_image_info(), and remove extra messages from machine_kexec(). > Make dtb_mem, always available, if CONFIG_KEXEC_FILE is not configured > dtb_mem is set to zero anyway. This is unrelated cleanup, please do it as an earlier patch to make it clearer what you are changing here. (I'm not convinced you need to cache va<->pa) > diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h > index 12a561a54128..d15ca1ca1e83 100644 > --- a/arch/arm64/include/asm/kexec.h > +++ b/arch/arm64/include/asm/kexec.h > @@ -90,14 +90,15 @@ static inline void crash_prepare_suspend(void) {} > static inline void crash_post_resume(void) {} > #endif > > -#ifdef CONFIG_KEXEC_FILE > #define ARCH_HAS_KIMAGE_ARCH > > struct kimage_arch { > void *dtb; > unsigned long dtb_mem; > + unsigned long kern_reloc; This is cache-ing the physical address of an all-architectures value from struct kimage, in the arch specific part of struct kiamge. Why? (You must have the struct kimage on hand to access this thing at all!) If its supposed to be a physical address, please use phys_addr_t. > }; > diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c > index 0df8493624e0..9b41da50e6f7 100644 > --- a/arch/arm64/kernel/machine_kexec.c > +++ b/arch/arm64/kernel/machine_kexec.c > @@ -42,6 +42,7 @@ static void _kexec_image_info(const char *func, int line, > pr_debug(" start: %lx\n", kimage->start); > pr_debug(" head: %lx\n", kimage->head); > pr_debug(" nr_segments: %lu\n", kimage->nr_segments); > + pr_debug(" kern_reloc: %pa\n", &kimage->arch.kern_reloc); > > for (i = 0; i < kimage->nr_segments; i++) { > pr_debug(" segment[%lu]: %016lx - %016lx, 0x%lx bytes, %lu pages\n", > @@ -58,6 +59,19 @@ void machine_kexec_cleanup(struct kimage *kimage) > /* Empty routine needed to avoid build errors. */ > } > > +int machine_kexec_post_load(struct kimage *kimage) > +{ > + unsigned long kern_reloc; > + > + kern_reloc = page_to_phys(kimage->control_code_page); kern_reloc should be phys_addr_t. > + memcpy(__va(kern_reloc), arm64_relocate_new_kernel, > + arm64_relocate_new_kernel_size); > + kimage->arch.kern_reloc = kern_reloc; Please move the cache maintenance in here too. This will save us doing it late during kdump. This will also group the mmu-on changes together. > +} Thanks, James