From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1914EC48BDF for ; Tue, 15 Jun 2021 16:03:18 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD7F561458 for ; Tue, 15 Jun 2021 16:03:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD7F561458 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WkmWfA5VizS6+wFj40AmKwBWcdiyEzDffGIbYMt00HE=; b=zE7bOwc5hSVmgs UpelQpOYgV/wvjQ63O1thlI7p1PNc2ReUPu6ytmjc7VXCkzk0Gwb0B789yN3diz8X+lxTGzI6iJTL HQs56W0W3ji2Jz6OPmVmMeJteyBRBGayftynGQ1rtHQkacmJww/yapzPxxAHW23h/PY0Eimvj1Uis nN5wQ8LxuHPxhMMke6Nw/9DOVtzg8XwSQ7T27Xke6mWin+wI6xqxW+y7LizaxLCguU0p+ac4OefG5 TxlEfx06B6jQT2xD+Y9qI+E2/oBZmaGqjbiYrOkRCJz07hXNHXL0Trq4QH/Mt1IVwllUkjOQuLcav Wc1eL3yK0OFC73C05ZOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltBPw-0019PP-Rv; Tue, 15 Jun 2021 15:55:58 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9dt-000Q0M-IQ for linux-arm-kernel@bombadil.infradead.org; Tue, 15 Jun 2021 14:02:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uQvcw409bUYt5ntSksRRAtFhCkSszffh/wc89WWTrIQ=; b=S1P//KQEqWZQHrrfLbNRZR4TqA 4G4H8/gCLLx/od+UUXNf6xviWaWowouceDRaGHZJsL+K5luDtnI9ZkCfQz3HhlJaleL7BidLbg78t Y+9EfYJVNSxQGTtob0kn5LLyDMJInuAtv44PJBiKHd/oulsY9YevX2ougDw50K6kj26mA4iWVxNNR ThxfhMkmXRHjJV0NLpZmd3Bp55qukavUL1IUtWJRK9cEFO7RBlwd25mHXS3skHCPNI+Rt6x6aHxur s0YXxeF03teVbiIOQ+BvLzfDIEG1RQbmHDKdotl07jLJC+bTNg1YEZP2VA533dAm/jTq63mxzHqOJ havnK5oQ==; Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9di-007zag-6m for linux-arm-kernel@lists.infradead.org; Tue, 15 Jun 2021 14:02:11 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 37BDE613D9 for ; Tue, 15 Jun 2021 14:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623765721; bh=QlhAPeeyHHRjIGhNphYkDKi45QaQ5wrJVvOCJ5iwTZk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HLZk5o1OlBgpmgNxo3t078PtogHJjxbNiaBMRlwd2BTkB/WBR8vXsVYBqyF+p9ELR 25tMDLO5H37Av/dobs/EnUv0epiWfN1DRzdmonV2WmbiiePuuyRnmmMGquVFkN8NlL 0ulmWZjqmJU8v27pswwRbHqymC8TPZh024JoCTjJFPFtCpzeHQmwtL9U1PjWFNRE7i u5QvonJ5dI3P8UPxmKaow53KojSZjBQrv0U2nGZVQciJ58MStXS73Gtk/yUq/6SA88 Y4zC+BAIY8lS1IIOCyLzMVJPYA0ZsjKwuFD5pgL9ZjJTWLv+VTpzKOYQ48v2+DYqZP hHIBiq3hJJWEg== Received: by mail-lj1-f178.google.com with SMTP id n17so25260379ljg.2 for ; Tue, 15 Jun 2021 07:02:01 -0700 (PDT) X-Gm-Message-State: AOAM533MlLVXAyg/qM0/pHc+pjTcviqKyWMS9NB2hoY8CRcoYMze+kHG Mrr/r0TKRZ364J3tYVThpzycpeQO7sfoh4j3ng== X-Google-Smtp-Source: ABdhPJxVqI8MHrcAWKd/OVKi4zXYd9o5Ej5sqMSK1SDKoChQIuRHCXHX7nfhLloiCMRd7u65oO394YM97kSgD621jRA= X-Received: by 2002:a17:906:85d5:: with SMTP id i21mr20560813ejy.360.1623765708507; Tue, 15 Jun 2021 07:01:48 -0700 (PDT) MIME-Version: 1.0 References: <20210221174930.27324-1-nramas@linux.microsoft.com> <20210221174930.27324-6-nramas@linux.microsoft.com> In-Reply-To: From: Rob Herring Date: Tue, 15 Jun 2021 08:01:35 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v19 05/13] of: Add a common kexec FDT setup function To: Geert Uytterhoeven Cc: Lakshmi Ramasubramanian , Mimi Zohar , Thiago Jung Bauermann , AKASHI Takahiro , Greg KH , Will Deacon , Joe Perches , Catalin Marinas , Michael Ellerman , Stephen Rothwell , James Morse , Sasha Levin , Benjamin Herrenschmidt , Paul Mackerras , Frank Rowand , Vincenzo Frascino , 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 , Linux Kernel Mailing List , Linux ARM , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linuxppc-dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_150209_369759_DD4EC4C9 X-CRM114-Status: GOOD ( 31.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 15, 2021 at 6:18 AM Geert Uytterhoeven wrote: > > Hi Lakshmi and Rob, > > On Sun, Feb 21, 2021 at 6:52 PM Lakshmi Ramasubramanian > wrote: > > From: Rob Herring > > > > Both arm64 and powerpc do essentially the same FDT /chosen setup for > > kexec. The differences are either omissions that arm64 should have > > or additional properties that will be ignored. The setup code can be > > combined and shared by both powerpc and arm64. > > > > The differences relative to the arm64 version: > > - If /chosen doesn't exist, it will be created (should never happen). > > - Any old dtb and initrd reserved memory will be released. > > - The new initrd and elfcorehdr are marked reserved. > > - "linux,booted-from-kexec" is set. > > > > The differences relative to the powerpc version: > > - "kaslr-seed" and "rng-seed" may be set. > > - "linux,elfcorehdr" is set. > > - Any existing "linux,usable-memory-range" is removed. > > > > Combine the code for setting up the /chosen node in the FDT and updating > > the memory reservation for kexec, for powerpc and arm64, in > > of_kexec_alloc_and_setup_fdt() and move it to "drivers/of/kexec.c". > > > > Signed-off-by: Rob Herring > > Signed-off-by: Lakshmi Ramasubramanian > > > --- /dev/null > > +++ b/drivers/of/kexec.c > > > +/* > > + * 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. > > + * @extra_fdt_size: Additional size for the new FDT buffer. > > + * > > + * 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, size_t extra_fdt_size) > > +{ > > > + /* Did we boot using an initrd? */ > > + prop = fdt_getprop(fdt, chosen_node, "linux,initrd-start", NULL); > > + if (prop) { > > + u64 tmp_start, tmp_end, tmp_size; > > + > > + tmp_start = fdt64_to_cpu(*((const fdt64_t *) prop)); > > + > > + prop = fdt_getprop(fdt, chosen_node, "linux,initrd-end", NULL); > > + if (!prop) { > > + ret = -EINVAL; > > + goto out; > > + } > > + > > + tmp_end = fdt64_to_cpu(*((const fdt64_t *) prop)); > > Some kernel code assumes "linux,initrd-{start,end}" are 64-bit, > other code assumes 32-bit. It can be either. The above code was a merge of arm64 and powerpc both of which use 64-bit and still only runs on those arches. It looks like some powerpc platforms may use 32-bit, but this would have been broken before. The code in drivers/of/fdt.c handles either case. We should probably refactor early_init_dt_check_for_initrd() and this function to use a common routine. > linux/Documentation/arm/uefi.rst says 64-bit, > dt-schema/schemas/chosen.yaml says 32-bit. We should fix that. Rob _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel