summaryrefslogtreecommitdiff
path: root/sys/dev/ofw
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-07-06 15:18:05 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-07-06 15:18:05 +0000
commitd8aa63df5fc8a037352f116c52139532d3af096d (patch)
tree8a932ff46a07abcd5523ece3945823a4273074c6 /sys/dev/ofw
parent5f3d71c2afe1c553b1c388aac3b59523d83e41c7 (diff)
IEEE1275 (Open Firmware) defines that parameter name strings can have a
length of up to 31 characters. This limit is also present in the flattened device tree specification/ Unfortunately this limit isn't enforced by the tooling and there are systems in the wild that use longer strings. This includes the device trees used on POWER9 systems and has been seen on some ARM systems as well. So bump the buffer size from 32 bytes (31 + terminating NUL) to 64 bytes. Centrally define OFMAXPARAM to this value (in <dev/ofw/openfirm.h>) replacing the various OPROMMAXPARAM definition scattered around the tree to make sure the FDT implementation of OF_nextprop() uses the same buffer size as its consumers. Eliminate the static buffer in various openprom(4) implementations on FDT systems. Makes it possible to dump the full device tree on POWER9 systems using eeprom -p. ok deraadt@, visa@
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r--sys/dev/ofw/fdt.c9
-rw-r--r--sys/dev/ofw/openfirm.h4
2 files changed, 6 insertions, 7 deletions
diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c
index 186cbe6ff2b..ddc837fa858 100644
--- a/sys/dev/ofw/fdt.c
+++ b/sys/dev/ofw/fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdt.c,v 1.23 2019/08/10 13:16:01 kettenis Exp $ */
+/* $OpenBSD: fdt.c,v 1.24 2020/07/06 15:18:03 kettenis Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
@@ -24,9 +24,6 @@
#include <dev/ofw/fdt.h>
#include <dev/ofw/openfirm.h>
-/* XXX */
-#define OPROMMAXPARAM 32
-
unsigned int fdt_check_head(void *);
char *fdt_get_str(u_int32_t);
void *skip_property(u_int32_t *);
@@ -904,13 +901,13 @@ OF_nextprop(int handle, char *prop, void *nextprop)
if (fdt_node_property(node, "name", &data) == -1) {
if (strcmp(prop, "") == 0)
- return strlcpy(nextprop, "name", OPROMMAXPARAM);
+ return strlcpy(nextprop, "name", OFMAXPARAM);
if (strcmp(prop, "name") == 0)
prop = "";
}
if (fdt_next_property(node, prop, &data))
- return strlcpy(nextprop, data, OPROMMAXPARAM);
+ return strlcpy(nextprop, data, OFMAXPARAM);
return -1;
}
diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h
index 45f8086d047..57022b05c85 100644
--- a/sys/dev/ofw/openfirm.h
+++ b/sys/dev/ofw/openfirm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: openfirm.h,v 1.15 2017/12/27 11:40:14 kettenis Exp $ */
+/* $OpenBSD: openfirm.h,v 1.16 2020/07/06 15:18:03 kettenis Exp $ */
/* $NetBSD: openfirm.h,v 1.1 1996/09/30 16:35:10 ws Exp $ */
/*
@@ -38,6 +38,8 @@
#include <sys/param.h>
#include <sys/device.h>
+#define OFMAXPARAM 64
+
int openfirmware(void *);
extern char OF_buf[];