Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp457479pxb; Sat, 20 Feb 2021 09:16:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6px+ermkkXp3/scXvdj+OqXc37wmfPvYwu9/5uMxYDQG63wDlzjAzT+zzF9B4PJY6xvxt X-Received: by 2002:a17:906:958:: with SMTP id j24mr13495067ejd.411.1613841416553; Sat, 20 Feb 2021 09:16:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613841416; cv=none; d=google.com; s=arc-20160816; b=i9LSX7k4OFzsbvhh1+yhTS0veGp6LSEJuJNm28qwl8es2gD9K1o+XB4Svs1EtcFncN xmsHkbGaws2isRS+VvLaLDitxQ7y5TYnnlvB8/gLGZyYjoDSsYIHOo89X+fGC03bbI3z rutreatyGvzq1ZYFBMOidTp366z5M/r8TL2pHLA0/tGQ2LWdeObf9/iLVSSNAyEDWsrk c5AWN45QZ2fBto7Y0vGRrRYt4V04AVPGTwszuNk9eje4GlavCwQGEf/+eNr2GH9gHQW/ APvOvFh9VsNfic1ovb6BgiWTK55t595fN3hlimEKziZHzHBGKMoxkSi1YnK+iXxe/a6t pfCQ== 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; bh=5h/r7cKUsp0cobrNKkVCw6WpdLp0rAxXksScajR9jyU=; b=xXPoXs41sRSp108EFJ7brvoFNFBbxRumWgw5f4y67hHTFyuO/0O/PNGqmxgAvBz36O v+v0qz9od1J1+vLWEZXaT768dQblPL+/DQokHkCedkQTwtpfeqlnBBzKnFmuwmjDmbtw xuKH6bnsQYo5oGQVn9d2wM8pmJ4O3aW85U5izgJH3cmIhCy9ectr72/cvys78WY80RBZ Y8FVD4H5eWS5ChZz+fumK8VXEDKHWAN0BgY0ry4f9oIRPBX4Iw2n5YPlXp7C2beG4zOM uOTdDg1IGy5Bch1riQGD/1K3NOhobp6Ig3OCBlPZov68K3tkCowqrQVWFTwfspSgh3+D eFig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DAQJ+2zQ; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si297253eji.715.2021.02.20.09.16.33; Sat, 20 Feb 2021 09:16:56 -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=@ibm.com header.s=pp1 header.b=DAQJ+2zQ; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbhBTROE (ORCPT + 99 others); Sat, 20 Feb 2021 12:14:04 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:27586 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbhBTROD (ORCPT ); Sat, 20 Feb 2021 12:14:03 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11KH4X30110456; Sat, 20 Feb 2021 12:13:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=5h/r7cKUsp0cobrNKkVCw6WpdLp0rAxXksScajR9jyU=; b=DAQJ+2zQD81YMcC7xIKvsYIPUAJDxRrOUn6cJn4+KQGkeioHFvx5kollsE3bvckz0/p5 hj9pa4Q0KltOPsMWH5KbxGk7pujB46Mo1FK9eRRK971vS2KvLRoNBNooxZGvyXgN8vhj J2/8dLxPUUgybgh3gSptPxKwFHkuOiDPdbK+mDLNsbPxFRmxcUw7/ZjTJJzxeqCuUDzL hb6DTDgaGtuVCE6wXU524J5jGKqrJATd+Sgl30LoJ15+N8pF1TLhJj5kU00PKhWGiYrC +cdfGdDDLDoObTM6lmIv65UT6jnT6LsmTmgCgIXebSE+YqS3EVgCoiD7kxOTJf7apvdA 9A== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 36u6gq88gq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Feb 2021 12:13:12 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11KHC2tL021592; Sat, 20 Feb 2021 17:13:10 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 36tt288c5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Feb 2021 17:13:10 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11KHD7hf33095946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 20 Feb 2021 17:13:07 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C29674203F; Sat, 20 Feb 2021 17:13:07 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0627B42041; Sat, 20 Feb 2021 17:13:04 +0000 (GMT) Received: from [9.211.126.148] (unknown [9.211.126.148]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sat, 20 Feb 2021 17:13:03 +0000 (GMT) Subject: Re: [PATCH v2] powerpc/kexec_file: Restore FDT size estimation for kdump kernel To: Thiago Jung Bauermann , linuxppc-dev@lists.ozlabs.org Cc: Rob Herring , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Mimi Zohar , Lakshmi Ramasubramanian References: <20210220005204.1417200-1-bauerman@linux.ibm.com> From: Hari Bathini Message-ID: <1739b7f8-2b2f-1ae2-1785-4fedc7a973ed@linux.ibm.com> Date: Sat, 20 Feb 2021 22:43:01 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210220005204.1417200-1-bauerman@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-20_02:2021-02-18,2021-02-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 adultscore=0 impostorscore=0 priorityscore=1501 phishscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102200159 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/02/21 6:22 am, Thiago Jung Bauermann wrote: > 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. Thanks for fixing this, Thiago. Reviewed-by: Hari Bathini > > Signed-off-by: Thiago Jung Bauermann > Reviewed-by: Lakshmi Ramasubramanian > --- > 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. > > Changes since v1: > > - Adjusted comment describing kexec_extra_fdt_size_ppc64() as suggested > by Lakshmi. > > 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..297f73795a1f 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_ppc64 - Return the estimated additional size needed to > + * setup FDT 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)); > } > > /** >