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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AB41C433F5 for ; Mon, 14 Feb 2022 14:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354878AbiBNOGA (ORCPT ); Mon, 14 Feb 2022 09:06:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234550AbiBNOF7 (ORCPT ); Mon, 14 Feb 2022 09:05:59 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4ED0BBCBF for ; Mon, 14 Feb 2022 06:05:52 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE55C1042; Mon, 14 Feb 2022 06:05:51 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ECB9B3F66F; Mon, 14 Feb 2022 06:05:50 -0800 (PST) Date: Mon, 14 Feb 2022 14:06:04 +0000 From: Alexandru Elisei To: Andrew Jones Cc: pbonzini@redhat.com, thuth@redhat.com, kvm@vger.kernel.org Subject: Re: [kvm-unit-tests PATCH] lib/devicetree: Support 64 bit addresses for the initrd Message-ID: References: <20220214120506.30617-1-alexandru.elisei@arm.com> <20220214135226.joxzj2tgg244wl6n@gator> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220214135226.joxzj2tgg244wl6n@gator> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Drew, On Mon, Feb 14, 2022 at 02:52:26PM +0100, Andrew Jones wrote: > On Mon, Feb 14, 2022 at 12:05:06PM +0000, Alexandru Elisei wrote: > > The "linux,initrd-start" and "linux,initrd-end" properties encode the start > > and end address of the initrd. The size of the address is encoded in the > > root node #address-cells property and can be 1 cell (32 bits) or 2 cells > > (64 bits). Add support for parsing a 64 bit address. > > > > Signed-off-by: Alexandru Elisei > > --- > > lib/devicetree.c | 18 +++++++++++++----- > > 1 file changed, 13 insertions(+), 5 deletions(-) > > > > diff --git a/lib/devicetree.c b/lib/devicetree.c > > index 409d18bedbba..7cf64309a912 100644 > > --- a/lib/devicetree.c > > +++ b/lib/devicetree.c > > @@ -288,7 +288,7 @@ int dt_get_default_console_node(void) > > int dt_get_initrd(const char **initrd, u32 *size) > > { > > const struct fdt_property *prop; > > - const char *start, *end; > > + u64 start, end; > > int node, len; > > u32 *data; > > > > @@ -303,7 +303,11 @@ int dt_get_initrd(const char **initrd, u32 *size) > > if (!prop) > > return len; > > data = (u32 *)prop->data; > > - start = (const char *)(unsigned long)fdt32_to_cpu(*data); > > + start = fdt32_to_cpu(*data); > > + if (len == 8) { > > + data++; > > + start = (start << 32) | fdt32_to_cpu(*data); > > + } > > > > prop = fdt_get_property(fdt, node, "linux,initrd-end", &len); > > if (!prop) { > > @@ -311,10 +315,14 @@ int dt_get_initrd(const char **initrd, u32 *size) > > return len; > > } > > data = (u32 *)prop->data; > > - end = (const char *)(unsigned long)fdt32_to_cpu(*data); > > + end = fdt32_to_cpu(*data); > > + if (len == 8) { > > + data++; > > + end = (end << 32) | fdt32_to_cpu(*data); > > + } > > > > - *initrd = start; > > - *size = (unsigned long)end - (unsigned long)start; > > + *initrd = (char *)start; > > + *size = end - start; > > > > return 0; > > } > > -- > > 2.35.1 > > > > I added this patch on Thanks for the quick reply! > > diff --git a/lib/devicetree.c b/lib/devicetree.c > index 7cf64309a912..fa8399a7513d 100644 > --- a/lib/devicetree.c > +++ b/lib/devicetree.c > @@ -305,6 +305,7 @@ int dt_get_initrd(const char **initrd, u32 *size) > data = (u32 *)prop->data; > start = fdt32_to_cpu(*data); > if (len == 8) { > + assert(sizeof(long) == 8); I'm sketchy about arm with LPAE, but wouldn't it be legal to have here a 64 bit address, even if the architecture is 32 bits? Or was the assert added more because kvm-unit-tests doesn't support LPAE on arm? > data++; > start = (start << 32) | fdt32_to_cpu(*data); > } > @@ -321,7 +322,7 @@ int dt_get_initrd(const char **initrd, u32 *size) > end = (end << 32) | fdt32_to_cpu(*data); > } > > - *initrd = (char *)start; > + *initrd = (char *)(unsigned long)start; My bad here, I forgot to test on arm. Tested your fix and the compilation error goes away. Thanks, Alex > *size = end - start; > > return 0; > > > To fix compilation on 32-bit arm. > > > And now merged through misc/queue. > > Thanks, > drew >