arm64: Check dtb version against the one we're expecting to find

Do for arm64 what was done for armv7 in e63faa9ba8
This commit is contained in:
Emmanuel Vadot 2021-03-23 15:24:14 +01:00
parent b93a796b06
commit 63f344024a
2 changed files with 19 additions and 0 deletions

View File

@ -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);

View File

@ -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