From cf5cd89c3a93eb41213a0fe83be7ff79c3d9bb63 Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Sun, 19 Jul 2020 23:34:52 +0000 Subject: [PATCH] riscv: look for bootargs in FDT The FDT may contain a short /chosen/bootargs string which we should pass to boot_parse_cmdline. Notably, this allows the use of qemu's -append option to pass things like -s to boot to single user mode. Submitted by: Nathaniel Filardo Reviewed by: mhorne MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25544 --- sys/riscv/riscv/machdep.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 2c6bd016ce6..6b42e9b4b8b 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -800,6 +801,19 @@ fake_preload_metadata(struct riscv_bootparams *rvbp) rvbp->kern_phys, rvbp->kern_phys + (lastaddr - KERNBASE)); } +#ifdef FDT +static void +parse_fdt_bootargs(void) +{ + char bootargs[512]; + + bootargs[sizeof(bootargs) - 1] = '\0'; + if (fdt_get_chosen_bootargs(bootargs, sizeof(bootargs) - 1) == 0) { + boothowto |= boot_parse_cmdline(bootargs); + } +} +#endif + static vm_offset_t parse_metadata(void) { @@ -829,6 +843,8 @@ parse_metadata(void) #endif #ifdef FDT try_load_dtb(kmdp); + if (kern_envp == NULL) + parse_fdt_bootargs(); #endif return (lastaddr); }