svn commit: r367896 - head/sys/riscv/riscv

Mitchell Horne mhorne at FreeBSD.org
Fri Nov 20 15:21:11 UTC 2020


Author: mhorne
Date: Fri Nov 20 15:21:10 2020
New Revision: 367896
URL: https://svnweb.freebsd.org/changeset/base/367896

Log:
  riscv: always initialize the static kernel environment
  
  Ensure we initialize the static environment when not booting via
  loader(8), and provide a static buffer if this is the case. This fixes
  two issues.
  
  First, performing the initialization ensures that kenv variables set in
  the kernel's config file are honored. Previously, any new or overridden
  values were ignored.
  
  Second, providing the static buffer allows variables to be set in the
  device tree's bootargs property of the chosen node. This can be set by
  u-boot or by QEMU's '-append' flag. Attempting to this prior to this
  change resulted in an early panic, since the static environment had no
  buffer backing it.
  
  Submitted by:	syrinx (earlier version)
  Reviewed by:	kp
  Differential Revision:	https://reviews.freebsd.org/D25034

Modified:
  head/sys/riscv/riscv/machdep.c

Modified: head/sys/riscv/riscv/machdep.c
==============================================================================
--- head/sys/riscv/riscv/machdep.c	Fri Nov 20 15:19:30 2020	(r367895)
+++ head/sys/riscv/riscv/machdep.c	Fri Nov 20 15:21:10 2020	(r367896)
@@ -130,6 +130,8 @@ cpuset_t all_harts;
 
 extern int *end;
 
+static char static_kenv[PAGE_SIZE];
+
 static void
 cpu_startup(void *dummy)
 {
@@ -836,6 +838,8 @@ parse_metadata(void)
 	kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
 	if (kern_envp != NULL)
 		init_static_kenv(kern_envp, 0);
+	else
+		init_static_kenv(static_kenv, sizeof(static_kenv));
 #ifdef DDB
 	ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
 	ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);


More information about the svn-src-all mailing list