Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8126119pxb; Fri, 19 Feb 2021 08:02:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIKJBoR82UgVN4keqVsAyfEEs5J2zzdSDERwLgIElyEIRyFOEdj/VBv68FaUw+q9jb+KFS X-Received: by 2002:a05:6402:1c0f:: with SMTP id ck15mr9526985edb.16.1613750560347; Fri, 19 Feb 2021 08:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613750560; cv=none; d=google.com; s=arc-20160816; b=I0MzONFNbnd4uGi4txOGEm31BQhc9KjyaPzwUOA/xLhhX/8zQ8rvV5Zncr6bl5dLvK tNkrYLeSvMJkXoTYrbMhWayxISi+KQRgPLnALigpnHZ/RO9Z5hiGOZCLHr6T/+DzfmTG irqFrEbOdJqSJ+tgmEKmkzPVP7obBHuxKWJ1wVbLkssgeKytVWnylpS5SCSGmRJ5OJvN 1i0vPe99NeT30L5T906u6A2suHA2QgXqMYiCoW6DIOw6TOHR7vVLlRf4jZuh+OuiTIuV M2D9NW18fOxmjF/d9hkc3Bw0P5ZoixYZpyhy6tJBebpwQwfq/vXhzZC+zwwsU9BKfVtR NWIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-filter; bh=gWO09POLpbRs3/EzLyGBCNzjamt7jL02WPeWTp/RZMM=; b=IZoy4czAzRQbwzfPNesvUfONfob5VfgSXhDOUcZOG7LFrrLHMNae92GIFUS9FM5mEh hDXwNGi0VwqClFj0Ifsu7m3wrNU5ZwAKzkVtap8qg92rn0aCLqwibROFd50TKJQoPpYU mG/ya9mjwI1lakVUtWHCGAVux2bHouv7Tq99V1N/xtCK3SkKXYY1DaFK59t4KOhZmCh7 mwcwkzNHGpm0EzWQCGvFwLq0QjpIuGkFjXUg8gr95YIGLTYG1b9BdT7DlnABe9FHDNrx /k2BrNH8SsoG9v++MkMmOOjv2l3j+nA/Bkww6k/WCRvXuNBWsZ5UCopchogttHGbnUAf LY3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=HaaRbJuh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h18si2655258edv.33.2021.02.19.08.02.07; Fri, 19 Feb 2021 08:02:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=HaaRbJuh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbhBSQAr (ORCPT + 99 others); Fri, 19 Feb 2021 11:00:47 -0500 Received: from linux.microsoft.com ([13.77.154.182]:55924 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbhBSQAr (ORCPT ); Fri, 19 Feb 2021 11:00:47 -0500 Received: from [192.168.0.104] (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id BEFE220B6C40; Fri, 19 Feb 2021 08:00:03 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BEFE220B6C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613750403; bh=gWO09POLpbRs3/EzLyGBCNzjamt7jL02WPeWTp/RZMM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=HaaRbJuhrAjvvBhGOuR/dbZ7vG7nycnwhtUQrt56KCA5pjF2GLTBGeHfs/mATyroP 1yr3MLwn6jxIxHnnz7k8hh1ZwCTMgF9I81bZ88j4NZtxr6GH0NBtAue8K0mdkJ4W7R cEjzn7s92rpJlEHrUZH3IWrQnSvJDkNsQJdwIPLk= Subject: Re: [PATCH] powerpc/kexec_file: Restore FDT size estimation for kdump kernel To: Thiago Jung Bauermann , linuxppc-dev@lists.ozlabs.org Cc: kexec@lists.infradead.org, Hari Bathini , Rob Herring , Mimi Zohar , Michael Ellerman , linux-kernel@vger.kernel.org References: <20210219142552.762608-1-bauerman@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: <5a28907e-9231-7a19-62ff-3ed1c0282642@linux.microsoft.com> Date: Fri, 19 Feb 2021 08:00:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210219142552.762608-1-bauerman@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/19/21 6:25 AM, Thiago Jung Bauermann wrote: One small nit in the function header (please see below), but otherwise the change looks good. Reviewed-by: Lakshmi Ramasubramanian > Commit 2377c92e37fe ("powerpc/kexec_file: fix FDT size estimation for kdump > kernel") fixed how elf64_load() estimates the FDT size needed by the > crashdump kernel. > > At the same time, commit 130b2d59cec0 ("powerpc: Use common > of_kexec_alloc_and_setup_fdt()") changed the same code to use the generic > function of_kexec_alloc_and_setup_fdt() to calculate the FDT size. That > change made the code overestimate it a bit by counting twice the space > required for the kernel command line and /chosen properties. > > Therefore change kexec_fdt_totalsize_ppc64() to calculate just the extra > space needed by the kdump kernel, and change the function name so that it > better reflects what the function is now doing. > > Signed-off-by: Thiago Jung Bauermann > --- > arch/powerpc/include/asm/kexec.h | 2 +- > arch/powerpc/kexec/elf_64.c | 2 +- > arch/powerpc/kexec/file_load_64.c | 26 ++++++++------------------ > 3 files changed, 10 insertions(+), 20 deletions(-) > > Applies on top of next-20210219. > > diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h > index baab158e215c..5a11cc8d2350 100644 > --- a/arch/powerpc/include/asm/kexec.h > +++ b/arch/powerpc/include/asm/kexec.h > @@ -128,7 +128,7 @@ int load_crashdump_segments_ppc64(struct kimage *image, > int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, > const void *fdt, unsigned long kernel_load_addr, > unsigned long fdt_load_addr); > -unsigned int kexec_fdt_totalsize_ppc64(struct kimage *image); > +unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image); > int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, > unsigned long initrd_load_addr, > unsigned long initrd_len, const char *cmdline); > diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c > index 0492ca6003f3..5a569bb51349 100644 > --- a/arch/powerpc/kexec/elf_64.c > +++ b/arch/powerpc/kexec/elf_64.c > @@ -104,7 +104,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, > > fdt = of_kexec_alloc_and_setup_fdt(image, initrd_load_addr, > initrd_len, cmdline, > - kexec_fdt_totalsize_ppc64(image)); > + kexec_extra_fdt_size_ppc64(image)); > if (!fdt) { > pr_err("Error setting up the new device tree.\n"); > ret = -EINVAL; > diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c > index 3609de30a170..8541ba731908 100644 > --- a/arch/powerpc/kexec/file_load_64.c > +++ b/arch/powerpc/kexec/file_load_64.c > @@ -927,37 +927,27 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, > } > > /** > - * kexec_fdt_totalsize_ppc64 - Return the estimated size needed to setup FDT > - * for kexec/kdump kernel. > - * @image: kexec image being loaded. > + * kexec_extra_fdt_size_ppc63 - Return the estimated size needed to setup FDT Perhaps change to "Return the estimated additional size needed to setup FDT for kexec/kdump kernel"? -lakshmi > + * for kexec/kdump kernel. > + * @image: kexec image being loaded. > * > - * Returns the estimated size needed for kexec/kdump kernel FDT. > + * Returns the estimated extra size needed for kexec/kdump kernel FDT. > */ > -unsigned int kexec_fdt_totalsize_ppc64(struct kimage *image) > +unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image) > { > - unsigned int fdt_size; > u64 usm_entries; > > - /* > - * The below estimate more than accounts for a typical kexec case where > - * the additional space is to accommodate things like kexec cmdline, > - * chosen node with properties for initrd start & end addresses and > - * a property to indicate kexec boot.. > - */ > - fdt_size = fdt_totalsize(initial_boot_params) + (2 * COMMAND_LINE_SIZE); > if (image->type != KEXEC_TYPE_CRASH) > - return fdt_size; > + return 0; > > /* > - * For kdump kernel, also account for linux,usable-memory and > + * For kdump kernel, account for linux,usable-memory and > * linux,drconf-usable-memory properties. Get an approximate on the > * number of usable memory entries and use for FDT size estimation. > */ > usm_entries = ((memblock_end_of_DRAM() / drmem_lmb_size()) + > (2 * (resource_size(&crashk_res) / drmem_lmb_size()))); > - fdt_size += (unsigned int)(usm_entries * sizeof(u64)); > - > - return fdt_size; > + return (unsigned int)(usm_entries * sizeof(u64)); > } > > /** >