Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2596158pxb; Thu, 11 Feb 2021 17:21:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkhRzyzKIaCtA3INMEB7R6gdrvPcM6OXfD+MsVSNQUkBoR9ANtzaNOaWsFOUvMlxM5PKXi X-Received: by 2002:a05:6402:2553:: with SMTP id l19mr913163edb.326.1613092911530; Thu, 11 Feb 2021 17:21:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613092911; cv=none; d=google.com; s=arc-20160816; b=hbccTPDxqJsl+jaPy14hHAqG0Ojr6fMKsYfd7fUOHKC3Z6Vrzy84iimJosqfp5M2cb 8FydAi18N0SgWDJ69U3h+3N+/OLD4RYjKzVI425R0XoO+7vRVWetwAgcKSC/tgz8qlD6 4zLULPcZP/JI3Rlj1o2W7hodnl3cxedztDtkx4milG3Wr2TATtC+28EzQ/1bFJS3HwOV +D4/6QRwQIjy8QQ4X5mSxXiGvgX2P9j3PXIAEAr4unDqj/W7VwnnmUUVXyjdyRk7mSlG R/7B3NQzC7u/hq5t+Xpkh6M3nQ+eaR5MO4RYsjf3zM1Cf9yZuUvVZ1z37f0nTJ/MIfxr a++g== 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=Y7BtTH5ulPnacnf3FX5f0RFcRSYsD0USlFVkCyasTd4=; b=Xt0yQSJrQDnUPwXhgm0NoJUeHDyEsm0pGPHlufiluDvJrLocR4S1IO/FJJUKEMbOta BOA4IqMpOuriDvRKo3RpsJQV/o+XG0T0l1/OjqkGX0e4Qh9+RheU0JWoGs+5nnhk5oqu OC3khcmdGgRHeG1HlDo7bEc9cysAwkiony7GPeWYrwKUvPkz6HvB5GuNo6liLCnVwM2O zt8f0G1D8KAsqyxSjbEijtKBI8IEx4mNEP5DGGUYCSGN/sHN0X75gAOkUolzicCjCcCy ApmqF3QYTKSegADT3UL1RnkxyfC7fpCUogjOR8I8PkwNmahKyG5UYJXZj8IFtgUugC5r st9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=gyo459kl; 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 m1si4883622eje.652.2021.02.11.17.21.27; Thu, 11 Feb 2021 17:21:51 -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=gyo459kl; 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 S229623AbhBLBSk (ORCPT + 99 others); Thu, 11 Feb 2021 20:18:40 -0500 Received: from linux.microsoft.com ([13.77.154.182]:36180 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhBLBSi (ORCPT ); Thu, 11 Feb 2021 20:18:38 -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 3434B20B6C40; Thu, 11 Feb 2021 17:17:57 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3434B20B6C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613092677; bh=Y7BtTH5ulPnacnf3FX5f0RFcRSYsD0USlFVkCyasTd4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=gyo459klbjM84xwkX6PXkazK+7OzLyws3VPz679/pgnVlag/yYxfVMm7nXbGMrkcm tMcaGkes9he/hxnfLrRRLCNmuf6kZxit5kxbALc4vmgd+a1J78MYVjD93gERNjxLcM U979bY8a948Kz/YGiY2ldd16eUNbb2nnfsD1Ybms= Subject: Re: [PATCH v17 02/10] of: Add a common kexec FDT setup function To: Thiago Jung Bauermann Cc: zohar@linux.ibm.com, robh@kernel.org, takahiro.akashi@linaro.org, gregkh@linuxfoundation.org, will@kernel.org, joe@perches.com, catalin.marinas@arm.com, mpe@ellerman.id.au, james.morse@arm.com, sashal@kernel.org, benh@kernel.crashing.org, paulus@samba.org, frowand.list@gmail.com, vincenzo.frascino@arm.com, mark.rutland@arm.com, dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, pasha.tatashin@soleen.com, allison@lohutok.net, masahiroy@kernel.org, mbrugger@suse.com, hsinyi@chromium.org, tao.li@vivo.com, christophe.leroy@c-s.fr, prsriva@linux.microsoft.com, balajib@linux.microsoft.com, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <20210209182200.30606-1-nramas@linux.microsoft.com> <20210209182200.30606-3-nramas@linux.microsoft.com> <87k0reozwh.fsf@manicouagan.localdomain> From: Lakshmi Ramasubramanian Message-ID: <8a3aa3d2-2eba-549a-9970-a2b0fe3586c9@linux.microsoft.com> Date: Thu, 11 Feb 2021 17:17:56 -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: <87k0reozwh.fsf@manicouagan.localdomain> 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/11/21 5:09 PM, Thiago Jung Bauermann wrote: > > There's actually a complication that I just noticed and needs to be > addressed. More below. > <...> >> + >> +/* >> + * of_kexec_alloc_and_setup_fdt - Alloc and setup a new Flattened Device Tree >> + * >> + * @image: kexec image being loaded. >> + * @initrd_load_addr: Address where the next initrd will be loaded. >> + * @initrd_len: Size of the next initrd, or 0 if there will be none. >> + * @cmdline: Command line for the next kernel, or NULL if there will >> + * be none. >> + * >> + * Return: fdt on success, or NULL errno on error. >> + */ >> +void *of_kexec_alloc_and_setup_fdt(const struct kimage *image, >> + unsigned long initrd_load_addr, >> + unsigned long initrd_len, >> + const char *cmdline) >> +{ >> + void *fdt; >> + int ret, chosen_node; >> + const void *prop; >> + unsigned long fdt_size; >> + >> + fdt_size = fdt_totalsize(initial_boot_params) + >> + (cmdline ? strlen(cmdline) : 0) + >> + FDT_EXTRA_SPACE; > > Just adding 4 KB to initial_boot_params won't be enough for crash > kernels on ppc64. The current powerpc code doubles the size of > initial_boot_params (which is normally larger than 4 KB) and even that > isn't enough. A patch was added to powerpc/next today which uses a more > precise (but arch-specific) formula: > > https://lore.kernel.org/linuxppc-dev/161243826811.119001.14083048209224609814.stgit@hbathini/ > > So I believe we need a hook here where architectures can provide their > own specific calculation for the size of the fdt. Perhaps a weakly > defined function providing a default implementation which an > arch-specific file can override (a la arch_kexec_kernel_image_load())? > > Then the powerpc specific hook would be the kexec_fdt_totalsize_ppc64() > function from the patch I linked above. > Do you think it'd better to add "fdt_size" parameter to of_kexec_alloc_and_setup_fdt() so that the caller can provide the desired FDT buffer size? thanks, -lakshmi