Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp737010pxj; Wed, 16 Jun 2021 12:22:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDBKY9W0VW/cg8viyFQqPjYEfP8woYT0W4QFv1WLHP+mb8nL9A+3AJP14OGNlqzkalcf+s X-Received: by 2002:a92:d451:: with SMTP id r17mr852032ilm.109.1623871347247; Wed, 16 Jun 2021 12:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623871347; cv=none; d=google.com; s=arc-20160816; b=KQZ0wmt6bxR7squG919vQQjIAkVA3Klf6wk5TBWARwGQJbGW4VNHsF1AFqyFNUNc91 15RjoedzUYazEI+P4W3eRnj5FfHx91krDGzorlQEsnlXVIILxERnKpilMM1FRQnyib6j fyAJXxp6jIfFJEABX1xIWnn0H+pu20PAN5M3JvZQHsyZlZ186irm+RxMWCUVwVaR8Prc l3MM/zoL7ttopNs4OOs2ZEqDT5KSeLAKNFCAYF5hFWQAKXmbvNkDHyjW3z7RKz7Exw8q ghMjLUa7IXAC/zCMsTlvb4XTjfYYrJvdE6tpE8UhgnbJBG2dRonybqOqv4MZRsgneVY+ CqVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4qgSd062Am+Kr3bFAQ3nL+suaeudLdVvvbcMlE6aGcs=; b=wGOynKI2ORaFotjig1vJLjx2RjobBrFhcXtiL4oyGZgmsMMZaYUkOOjwG2+c3+pJxJ HyviUiMwdKsO5O/SxcB5jGW0PWcHw33R0IJnH+BnMQ3Eh/sUIWCrEdwBkVUQA0Q0bl8a au4k/KCIJKi6mbpstkruD2GMdtsE8iv4KQT7U6hTcDq1zTuRpCFSlhcsh6CrG0dsE/6E zNKWAZy1Ij5bRF80KQg3ZmJdHCRvUEY7DcWb/otS4UjLdd1l53ZvZ7Qm4J9TMOZ6UYlU cWSFeF8LLp3n5nzJZXIeHPXgR4L6JzEMstFidXhmpdhzgHc2/c7qr6AqI/ZxC5vZzG9J b31g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BqW78zvf; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x19si3246564jat.6.2021.06.16.12.22.14; Wed, 16 Jun 2021 12:22:27 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=BqW78zvf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234390AbhFPPOt (ORCPT + 99 others); Wed, 16 Jun 2021 11:14:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:44886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234537AbhFPPOk (ORCPT ); Wed, 16 Jun 2021 11:14:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5478361166; Wed, 16 Jun 2021 15:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623856354; bh=79yfQdKxv3qf+Uv+p6L1hNCWKPz5Fwg5T6U9zNgNXKw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BqW78zvfiJFX1WM3aDIknqlHXv25abiaKRQGWflPbVe5mHb8O9l3o/637flx39WEV cxE5w+ImnzJWcupRqiIlSCdWw3mWk3Cx9zyVndQ6dkPj5t43AKjeBGVfcpsgenW4vb OtKupuD0Ntu2vsfS9jGRg8LEs4BP2xDparQODe4NbrpL5Ifi5OWG2B4/P9HW70cQ+p X/YEaHt+LUkVEt4USF3AMG74opsi25veGHPjoUFr0Y86T4K0ypaX1XE8w1CW0XHn0r M7bIYHn+eSLwn7g9EpX8Xjv0jQ72wzH8eddElWFaUDVLoyT0S+osdrecHy6yxIijoO vHMYPlo4SyQqg== Received: by mail-ed1-f53.google.com with SMTP id s15so3141786edt.13; Wed, 16 Jun 2021 08:12:34 -0700 (PDT) X-Gm-Message-State: AOAM532lCtCMzVKAZETEBvNqLjW+kwqaIONtY78GGoD/rm4MyUFmoZhU cQUSrR8lEzHQcUxRceMGzKqrL9sRZpb2GOWMHw== X-Received: by 2002:a05:6402:cb0:: with SMTP id cn16mr69518edb.165.1623856342407; Wed, 16 Jun 2021 08:12:22 -0700 (PDT) MIME-Version: 1.0 References: <20210221174930.27324-1-nramas@linux.microsoft.com> <20210221174930.27324-6-nramas@linux.microsoft.com> <54efb4fce5aac7efbd0b1b3885e9098b1d4ea745.camel@linux.microsoft.com> <87y2basg27.fsf@mpe.ellerman.id.au> In-Reply-To: <87y2basg27.fsf@mpe.ellerman.id.au> From: Rob Herring Date: Wed, 16 Jun 2021 09:12:10 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v19 05/13] of: Add a common kexec FDT setup function To: Michael Ellerman Cc: nramas , Geert Uytterhoeven , Mimi Zohar , Thiago Jung Bauermann , AKASHI Takahiro , Greg KH , Will Deacon , Joe Perches , Catalin Marinas , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 15, 2021 at 8:23 PM Michael Ellerman wrote: > > Rob Herring writes: > > On Tue, Jun 15, 2021 at 10:13 AM nramas wrote: > >> > >> On Tue, 2021-06-15 at 08:01 -0600, Rob Herring wrote: > >> > On Tue, Jun 15, 2021 at 6:18 AM Geert Uytterhoeven < > >> > geert@linux-m68k.org> wrote: > >> > > > >> > > > +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. > > >> of_kexec_alloc_and_setup_fdt() is called from elf_64.c (in > >> arch/powerpc/kexec) which is for 64-bit powerpc platform only. > > > > 64-bit PPC could be writing 32-bit property values. The architecture > > size doesn't necessarily matter. And if the values came from the > > bootloader, who knows what size it used. > > > > This code is 32-bit powerpc only?: > > > > arch/powerpc/boot/main.c- /* Tell the kernel initrd address via device tree */ > > arch/powerpc/boot/main.c: setprop_val(chosen, "linux,initrd-start", (u32)(initrd_addr)); > > arch/powerpc/boot/main.c- setprop_val(chosen, "linux,initrd-end", (u32)(initrd_addr+initrd_size)); > > Historically that code was always built 32-bit, even when used with a > 64-bit kernel. > > These days it is also built 64-bit (for ppc64le). How it is built is immaterial. It's always writing a 32-bit value due to the u32 cast. > It looks like the drivers/of/fdt.c code can handle either 64 or 32-bit, > so I guess that's why it seems to be working. Yes, that works, but that's not the issue. The question is does the main.c code run in combination with kexec. The kexec code above (copied straight from PPC code) would not work if linux,initrd-* are written by the main.c code. Rob