aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2021-03-23 14:24:14 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2021-03-23 14:24:53 +0000
commit63f344024a0d336b116f3563a1604fbd9b4253c7 (patch)
treeedea3e054754637707ffdf2d94f1f50c554beb2d
parentb93a796b06ec013a75a08ac43d8acf6aa94aa970 (diff)
downloadsrc-63f344024a0d336b116f3563a1604fbd9b4253c7.tar.gz
src-63f344024a0d336b116f3563a1604fbd9b4253c7.zip
arm64: Check dtb version against the one we're expecting to find
Do for arm64 what was done for armv7 in e63faa9ba832b6
-rw-r--r--sys/arm64/arm64/machdep.c16
-rw-r--r--sys/conf/Makefile.arm643
2 files changed, 19 insertions, 0 deletions
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 8a1e7520aacb..308a870fe188 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -1241,6 +1241,8 @@ initarm(struct arm64_bootparams *abp)
#ifdef FDT
struct mem_region mem_regions[FDT_MEM_REGIONS];
int mem_regions_sz;
+ phandle_t root;
+ char dts_version[255];
#endif
vm_offset_t lastaddr;
caddr_t kmdp;
@@ -1353,6 +1355,20 @@ initarm(struct arm64_bootparams *abp)
if (env != NULL)
strlcpy(kernelname, env, sizeof(kernelname));
+#ifdef FDT
+ root = OF_finddevice("/");
+ if (OF_getprop(root, "freebsd,dts-version", dts_version, sizeof(dts_version)) > 0) {
+ if (strcmp(LINUX_DTS_VERSION, dts_version) != 0)
+ printf("WARNING: DTB version is %s while kernel expects %s, "
+ "please update the DTB in the ESP\n",
+ dts_version,
+ LINUX_DTS_VERSION);
+ } else {
+ printf("WARNING: Cannot find freebsd,dts-version property, "
+ "cannot check DTB compliance\n");
+ }
+#endif
+
if (boothowto & RB_VERBOSE) {
if (efihdr != NULL)
print_efi_map_entries(efihdr);
diff --git a/sys/conf/Makefile.arm64 b/sys/conf/Makefile.arm64
index c7951872ca2d..2e404664708c 100644
--- a/sys/conf/Makefile.arm64
+++ b/sys/conf/Makefile.arm64
@@ -27,6 +27,9 @@ S= ../../..
INCLUDES+= -I$S/contrib/libfdt -I$S/contrib/device-tree/include
+LINUX_DTS_VERSION!= awk '/freebsd,dts-version/ { sub(/;$$/,"", $$NF); print $$NF }' $S/dts/freebsd-compatible.dts
+CFLAGS += -DLINUX_DTS_VERSION=\"${LINUX_DTS_VERSION}\"
+
# Use a custom SYSTEM_LD command to generate the elf kernel, so we can
# set the text segment start address, and also strip the "arm mapping
# symbols" which have names like $a.0 and $d.2; see the document