public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] lib/devicetree: Support 64 bit addresses for the initrd
@ 2022-02-14 12:05 Alexandru Elisei
  2022-02-14 13:52 ` Andrew Jones
  0 siblings, 1 reply; 16+ messages in thread
From: Alexandru Elisei @ 2022-02-14 12:05 UTC (permalink / raw)
  To: pbonzini, thuth, drjones, kvm

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 <alexandru.elisei@arm.com>
---
 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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-02-15 16:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-14 12:05 [kvm-unit-tests PATCH] lib/devicetree: Support 64 bit addresses for the initrd Alexandru Elisei
2022-02-14 13:52 ` Andrew Jones
2022-02-14 14:06   ` Alexandru Elisei
2022-02-14 14:24     ` Andrew Jones
2022-02-14 16:20       ` Alexandru Elisei
2022-02-14 16:36         ` Andrew Jones
2022-02-14 17:01         ` Marc Zyngier
2022-02-15  7:32           ` Andrew Jones
2022-02-15  9:26             ` Marc Zyngier
2022-02-15 10:07             ` Alexandru Elisei
2022-02-15 12:53               ` Andrew Jones
2022-02-15 14:16                 ` Alexandru Elisei
2022-02-15 15:22                   ` Alexandru Elisei
2022-02-15 15:53                     ` Andrew Jones
2022-02-15 15:50                   ` Andrew Jones
2022-02-15 16:15                     ` Alexandru Elisei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox