From owner-svn-src-all@freebsd.org Fri Nov 20 15:21:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E4DDE2EDBAE; Fri, 20 Nov 2020 15:21:10 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cd0ck6CkQz3mDw; Fri, 20 Nov 2020 15:21:10 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C883B17C77; Fri, 20 Nov 2020 15:21:10 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AKFLAYF036551; Fri, 20 Nov 2020 15:21:10 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AKFLAQx036541; Fri, 20 Nov 2020 15:21:10 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202011201521.0AKFLAQx036541@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Fri, 20 Nov 2020 15:21:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367896 - head/sys/riscv/riscv X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/sys/riscv/riscv X-SVN-Commit-Revision: 367896 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 15:21:11 -0000 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);