Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Aug 2021 16:11:30 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 5c010b3aa7c7 - stable/13 - arm64: Check dtb version against the one we're expecting to find
Message-ID:  <202108161611.17GGBUbW045774@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=5c010b3aa7c775a1e8b1a41b59e923e1d0ccdba6

commit 5c010b3aa7c775a1e8b1a41b59e923e1d0ccdba6
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2021-03-23 14:24:14 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2021-08-16 16:07:53 +0000

    arm64: Check dtb version against the one we're expecting to find
    
    Do for arm64 what was done for armv7 in e63faa9ba832b6
    
    (cherry picked from commit 63f344024a0d336b116f3563a1604fbd9b4253c7)
---
 sys/arm64/arm64/machdep.c | 16 ++++++++++++++++
 sys/conf/Makefile.arm64   |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 071bf3e51ab2..3c77300f6f2b 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -1244,6 +1244,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;
@@ -1356,6 +1358,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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108161611.17GGBUbW045774>