Index: head/sys/riscv/include/machdep.h =================================================================== --- head/sys/riscv/include/machdep.h +++ head/sys/riscv/include/machdep.h @@ -42,6 +42,7 @@ vm_offset_t kern_phys; /* Kernel base (physical) addr */ vm_offset_t kern_stack; vm_offset_t dtbp_virt; /* Device tree blob virtual addr */ + vm_offset_t dtbp_phys; /* Device tree blob physical addr */ }; extern vm_paddr_t physmap[PHYS_AVAIL_ENTRIES]; Index: head/sys/riscv/riscv/genassym.c =================================================================== --- head/sys/riscv/riscv/genassym.c +++ head/sys/riscv/riscv/genassym.c @@ -106,3 +106,4 @@ ASSYM(RISCV_BOOTPARAMS_KERN_STACK, offsetof(struct riscv_bootparams, kern_stack)); ASSYM(RISCV_BOOTPARAMS_DTBP_VIRT, offsetof(struct riscv_bootparams, dtbp_virt)); +ASSYM(RISCV_BOOTPARAMS_DTBP_PHYS, offsetof(struct riscv_bootparams, dtbp_phys)); Index: head/sys/riscv/riscv/locore.S =================================================================== --- head/sys/riscv/riscv/locore.S +++ head/sys/riscv/riscv/locore.S @@ -221,6 +221,7 @@ and t1, a1, t1 add t0, t0, t1 sd t0, RISCV_BOOTPARAMS_DTBP_VIRT(sp) + sd a1, RISCV_BOOTPARAMS_DTBP_PHYS(sp) mv a0, sp call _C_LABEL(initriscv) /* Off we go */ Index: head/sys/riscv/riscv/machdep.c =================================================================== --- head/sys/riscv/riscv/machdep.c +++ head/sys/riscv/riscv/machdep.c @@ -776,8 +776,19 @@ PRELOAD_PUSH_VALUE(uint32_t, 0); preload_metadata = (caddr_t)fake_preload; + /* Check if bootloader clobbered part of the kernel with the DTB. */ + KASSERT(rvbp->dtbp_phys + dtb_size <= rvbp->kern_phys || + rvbp->dtbp_phys >= rvbp->kern_phys + (lastaddr - KERNBASE), + ("FDT (%lx-%lx) and kernel (%lx-%lx) overlap", rvbp->dtbp_phys, + rvbp->dtbp_phys + dtb_size, rvbp->kern_phys, + rvbp->kern_phys + (lastaddr - KERNBASE))); KASSERT(fake_size < sizeof(fake_preload), ("Too many fake_preload items")); + + if (boothowto & RB_VERBOSE) + printf("FDT phys (%lx-%lx), kernel phys (%lx-%lx)\n", + rvbp->dtbp_phys, rvbp->dtbp_phys + dtb_size, + rvbp->kern_phys, rvbp->kern_phys + (lastaddr - KERNBASE)); return (lastaddr); }