Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3110965pxb; Fri, 12 Feb 2021 09:23:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdZWi6JxwVcadZ+PuxssA5BolU7BVW6XGuLPrXpg6aEOwcfNPephovajfarA8cZdA7LSuW X-Received: by 2002:aa7:d7c7:: with SMTP id e7mr1976323eds.77.1613150622057; Fri, 12 Feb 2021 09:23:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613150622; cv=none; d=google.com; s=arc-20160816; b=FFl6BsEQwm4WHgxoxeqrBK5Ec5hNf79n/6R9ZEHtbfHQyZe2sWRc5ROISgT/Mqb+Cg vLxuRk6pSdUm8W8DE9dzw8BIxOGueHfivK2uUYzF9zpkbVL/C5A95I9DrgM3FTfIkM6y LoGW27fDNp6YROXYkKEgac1yua8IZFVar8MAc6HvGKoNLznxE8MVncAOkA0VNJpKevnM 7O+cDW98d4s+rLWk2Ka0HNSnWoL7XkQWNdSLBFIdgfFgBEjdsopZRG0sDf0YP1Ootpf1 CzpoG2GpGD31Xdz+9btv+rcLQNrRj1pJmrS/8np1Uar9zANzArGhcLbuZn0HGSX+Kg4c zRqw== 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=ymZC2uSu1WhDmmhzMMk+j693znWvxWsQ0oRGutDXsUU=; b=IdOVnjVMTa2BZZ99cL+BsHnZEPLPJ9/DNIsxOtBFn1a0odoVGCN+01gNJXDhZRSStK M51IFQAa5TL5qPwqBdO5SawNfGXadbgR5l/JM/VZiWtPHET41uaHLNWt6eO2/mOdw6qZ li5AvXt13XvIdRrjJIO5QqdpXsMNYHomwHIoq3+zFqkHXruhHLX9T8P/wH9WpdYUPB1u LXBH/cy2TwolaZEvdrgfdDP6JlK5jTzbc46ptQEvXZQTT2Ov7+rxjOISsa6lfbnkOHKe wnS/hJpRTFSpM0/ObWXY3XyTiwzpma+9UAnekMzUFOwcf3mMJiy+CXLxOImXRoudWpsI yoGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="UFctr/Cj"; 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 bi22si6789268ejb.299.2021.02.12.09.23.18; Fri, 12 Feb 2021 09:23:42 -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="UFctr/Cj"; 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 S229797AbhBLRTp (ORCPT + 99 others); Fri, 12 Feb 2021 12:19:45 -0500 Received: from linux.microsoft.com ([13.77.154.182]:38426 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbhBLRTm (ORCPT ); Fri, 12 Feb 2021 12:19:42 -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 C5C7020B6C40; Fri, 12 Feb 2021 09:19:00 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C5C7020B6C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613150341; bh=ymZC2uSu1WhDmmhzMMk+j693znWvxWsQ0oRGutDXsUU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=UFctr/CjGfWUVNUkmlcZdiSnRimSYXYpf7boiSafTdIohyW4op8aqXiOPIXG7tD9w 2+CCCjIQwjmCzRCgCyJOtrEfXaan1toeQ6tewZfvQeoz8k1bHJnQ/MjJqkkzxmgjf+ fBeDNBT4ANHJIZyDIIuAoR7Wx92T/5Rbhxu+1Yog= Subject: Re: [PATCH v17 02/10] of: Add a common kexec FDT setup function To: Rob Herring Cc: Thiago Jung Bauermann , Mimi Zohar , "AKASHI, Takahiro" , Greg Kroah-Hartman , Will Deacon , Joe Perches , Catalin Marinas , Michael Ellerman , James Morse , Sasha Levin , Benjamin Herrenschmidt , Paul Mackerras , Frank Rowand , vincenzo.frascino@arm.com, Mark Rutland , dmitry.kasatkin@gmail.com, James Morris , "Serge E. Hallyn" , Pavel Tatashin , Allison Randal , Masahiro Yamada , Matthias Brugger , Hsin-Yi Wang , tao.li@vivo.com, Christophe Leroy , Prakhar Srivastava , balajib@linux.microsoft.com, linux-integrity@vger.kernel.org, "linux-kernel@vger.kernel.org" , linux-arm-kernel , devicetree@vger.kernel.org, linuxppc-dev References: <20210209182200.30606-1-nramas@linux.microsoft.com> <20210209182200.30606-3-nramas@linux.microsoft.com> <87k0reozwh.fsf@manicouagan.localdomain> <8a3aa3d2-2eba-549a-9970-a2b0fe3586c9@linux.microsoft.com> From: Lakshmi Ramasubramanian Message-ID: <55685b61-dac0-2f24-f74a-939acf74a4f2@linux.microsoft.com> Date: Fri, 12 Feb 2021 09:19:00 -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: 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/12/21 6:38 AM, Rob Herring wrote: > On Thu, Feb 11, 2021 at 7:17 PM Lakshmi Ramasubramanian > wrote: >> >> 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? > > Yes, I guess so. But please define the param as extra size, not total > size. The kernel command line size addition can be in the common code. Will do. Just to clarify - The common code will do: fdt_totalsize(initial_boot_params) + strlen(cmdline) + extra_fdt_size The caller will pass "extra_fdt_size" ARM64 => 4KB PPC64 => fdt_totalsize(initial_boot_params) - which will be updated when the patch Thiago had referred to is merged. > > The above change is also going to conflict, so I think this may have > to wait. Or I'll take the common and arm bits and powerpc can be > converted next cycle (or after the merge window). > thanks. -lakshmi