Received: by 2002:a05:6520:2586:b029:fa:41f3:c225 with SMTP id u6csp4306356lky; Tue, 15 Jun 2021 19:24:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW0twj/RsPqPMndOQ5fNgLyXfZV5YDsfArn8RTjUOxgAhHk8vP+2N270Cl9adRZ7snqjNy X-Received: by 2002:a5e:a515:: with SMTP id 21mr1795798iog.175.1623810289815; Tue, 15 Jun 2021 19:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623810289; cv=none; d=google.com; s=arc-20160816; b=oeBwrHnmVxCrbPDD/wiohiadhb61XGu3sAjFaHB0j9AujNfzII4eXGmnwsDqVep7X3 D9FsRZFqo8cADWS1jrU9M8K67JrL+7ljdE6/l40Hb5qHghxOivTAsJ5GIvwMfS2z/JHI qLnH/jPnlf9senbhpUJLyx0olOAJbxYh++RKZMF4Tb+ZzO+qxL2qTxvU7/1eXQEPfQel 0v9o4DfyP2+bNsviz857YyNprkKSOIZIIyirUGhGlxJ9J4FiyhyeCJfPiYngtQaTirkP /xMUvTGoHUh2seKbdyYx2LiouFkyp5z1cFnX3cih/jW2JVJQgRpZP3xvnXQCe1J00XZ0 QvXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=Nm+l8rJizQQL2FBS7iLJTN/nUtVFqRCrTrsf6rUna3c=; b=yLYQUBOGzaI0GBi3tHyJgx3MAJR94Hl/LD3KHMXQE2q/xc/v9Zn2QaBPVq4uK9Q8TI HGUPTcXvxQlC569L0IHJRUdUkt7uJruHy4qoG2kjsYDX/Y+P7vTdOZt9F3AgshcKJiD/ 0WGR/ifI2/XCxr+Oy0/ms5Vo4ocFHNA7Hh0Hs07lN7A+lWfrxR1gICHUuiVQ+hC+bAel QFoXGPvdpjWGjnPfGilndkQ686G6z97IA2mHTZvZjFD0lPgU1syIPbxB0tR0/yCUuZ27 aVdG9hb/1adusVXkVn5qWf0AtXMzkgvnbFsIDWWaMUsKZw4E1dKHPuodKcBmxiwrwDou dWXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=bFttHDSY; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si712985iod.34.2021.06.15.19.24.36; Tue, 15 Jun 2021 19:24:49 -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=@ellerman.id.au header.s=201909 header.b=bFttHDSY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbhFPC0B (ORCPT + 99 others); Tue, 15 Jun 2021 22:26:01 -0400 Received: from ozlabs.org ([203.11.71.1]:56549 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230454AbhFPC0B (ORCPT ); Tue, 15 Jun 2021 22:26:01 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4G4TWn4TqHz9sWX; Wed, 16 Jun 2021 12:23:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1623810234; bh=P3MCetIfzZtPqhiTVaYvru4yq+FzxZnPf34lNt0JVNs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=bFttHDSYDF8hs1GhcNrBuxC8r7YR1FbbNwSxkDAL7lQtIx4XxJMkGgJ7lrWjuZU9K hHlMI3fju9iswEdIjo7GjpwxP1Gj1Fm/KYx+39MCmWGuFbgefyJ9+AnXWm5Gf/e/WE A3rk+pmgQ4nYUF6AN4aESjVY9NcZzs/XD9grffQ9ZgTrSzGhxqLEc7HLOf2IyR5wUs BEgh91+kA9k66Ony2Qct/YJq45j32aDa0BAlicNYsFLF+qSWSLxNmpFtktw78LYU6u aLSqG0ucZiktlwstD97l1OxIipFzxib0Y/fOq3lYLMw7V3BV6g9i2RPMf7XTojDwDI 6cNIWLPIEvGYQ== From: Michael Ellerman To: Rob Herring , nramas Cc: 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 Subject: Re: [PATCH v19 05/13] of: Add a common kexec FDT setup function In-Reply-To: References: <20210221174930.27324-1-nramas@linux.microsoft.com> <20210221174930.27324-6-nramas@linux.microsoft.com> <54efb4fce5aac7efbd0b1b3885e9098b1d4ea745.camel@linux.microsoft.com> Date: Wed, 16 Jun 2021 12:23:44 +1000 Message-ID: <87y2basg27.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). 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. Although I'm not sure how much testing the 64-bit case gets, because the distros tend to just use the vmlinux. cheers