Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp32079pxb; Fri, 19 Feb 2021 16:57:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmppadVTu1a28HImPQcVNQwwpwoWRLB+PK43ZXWFoBsbFC9Vqv3kQQYF2/HJl6pq6z2wz3 X-Received: by 2002:a17:907:20e8:: with SMTP id rh8mr11343593ejb.119.1613782667874; Fri, 19 Feb 2021 16:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613782667; cv=none; d=google.com; s=arc-20160816; b=Ru3fwodKQ/6Ae3As6srrF1vfcbg0OpSaDFrp2Cn5+o2I/N+rFVoyx9TZXav3HMYnW2 ePO3WBzXVnkGIakjHp7Ncb4lec3S+dWzO54UeBFRhP5StcZZIJ3/bNGr6FvCKj0QkUQV toLjsEGOGTlidz7glOMbYiAIC66q3pTqC+tNgm6sCAAD66S+9dLnHKDTFCkM8GxKZmzp DJr3GYMuH8s7L16JdqCp1skR+htL2scDe6qsaWTb/wy2fDpViaKZLhOTMVSw8NjDgcb2 Y2RDashBYZkVxUU8T5yMU0vkGfZr8gR5KAvf2tA4/pcGHO0Gn7knVTCRR2oy3BrPHs5R Pd4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OSByV+b1Nklm13aT9EiqD6ae/H4Zz6W+SPfdmBvZsCo=; b=N4YoMtjmT1koXRvVdfO1D0+kmXoDPsTbZmXabHBUgQCrUauAJGDvrcIWPAMojuY2W3 nLI0rNe918jJMWQOm0K7HQREqpVm7fJI1dO2rEdFypLHnIW3Lb0x1hP/ahKDya4VE0Pa BDOx6Ruf/xEjtogPYaEYbgv4FTsXBrLa6BiVuVEBC0s4ixhZDMdpNHJ/QAQyjlMUaLvf yng4pL6K/hs/QVBPZ/2ZSNpngiwsDL3MkXDkh+e+gEwdnrr7qa3WW0w/rYDKa/ZgaCNu XZ9Yfd8Vyys9FBoDv8WDFhC7DH586EhZRfB9EG5zc32Qk230ZaIhQxYAMS4CG2e6/l+i SXrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=sioyeRCh; 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 sb17si7679613ejb.228.2021.02.19.16.57.09; Fri, 19 Feb 2021 16:57:47 -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=sioyeRCh; 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 S229765AbhBTAxU (ORCPT + 99 others); Fri, 19 Feb 2021 19:53:20 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55056 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229700AbhBTAxU (ORCPT ); Fri, 19 Feb 2021 19:53:20 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11K0VtFv132651; Fri, 19 Feb 2021 19:52:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=OSByV+b1Nklm13aT9EiqD6ae/H4Zz6W+SPfdmBvZsCo=; b=sioyeRChu6DdQVvOTKELFPFyQqnfbJWwwM6frENi3CcszG7xR8/DjHYzU6WzJL9cFfs3 m1BVf7yP49lg4LhS8Rf0sHkygsSVnXPmRiJw7DoFldGIEI+AV8sh7J8Xuwr3WCIIskAH dYFdJgrlD9/fR12bXi5pZNcDWI6BkL+rwReSOAKFRII3BZR7heQqvv/UcrhMyRvHvN4g /QZjgqxmmtsktBnjU4qoTKzK4QkiUDliwkxXINnI58MtQFWVnrLREEVsYFdugcNDlIvU B1cmlf5uh1KzQoJOUWephOtwKQ22Y2NQDlQU7Aj756J/652/oMOGQ1b3bdDOyfmm9lXF MQ== Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 36tqp7rj09-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 19:52:22 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11K0qBD1014875; Sat, 20 Feb 2021 00:52:21 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma04dal.us.ibm.com with ESMTP id 36p6dadmu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Feb 2021 00:52:21 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11K0qKFb33751520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 20 Feb 2021 00:52:20 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E79FAC05F; Sat, 20 Feb 2021 00:52:20 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68FFCAC060; Sat, 20 Feb 2021 00:52:17 +0000 (GMT) Received: from manicouagan.localdomain.com (unknown [9.85.174.98]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Sat, 20 Feb 2021 00:52:17 +0000 (GMT) From: Thiago Jung Bauermann To: linuxppc-dev@lists.ozlabs.org Cc: kexec@lists.infradead.org, Hari Bathini , Lakshmi Ramasubramanian , Rob Herring , Mimi Zohar , Michael Ellerman , linux-kernel@vger.kernel.org, Thiago Jung Bauermann Subject: [PATCH v2] powerpc/kexec_file: Restore FDT size estimation for kdump kernel Date: Fri, 19 Feb 2021 21:52:04 -0300 Message-Id: <20210220005204.1417200-1-bauerman@linux.ibm.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-19_08:2021-02-18,2021-02-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102190196 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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)); } /**