From owner-svn-src-head@freebsd.org Thu Jun 7 13:58:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B32D3FE9E4C; Thu, 7 Jun 2018 13:58:00 +0000 (UTC) (envelope-from leitao@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B658A6A828; Thu, 7 Jun 2018 13:57:35 +0000 (UTC) (envelope-from leitao@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 7D59C21006; Thu, 7 Jun 2018 13:57:35 +0000 (UTC) (envelope-from leitao@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w57DvZIM046388; Thu, 7 Jun 2018 13:57:35 GMT (envelope-from leitao@FreeBSD.org) Received: (from leitao@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w57DvYJn046385; Thu, 7 Jun 2018 13:57:34 GMT (envelope-from leitao@FreeBSD.org) Message-Id: <201806071357.w57DvYJn046385@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: leitao set sender to leitao@FreeBSD.org using -f From: Breno Leitao Date: Thu, 7 Jun 2018 13:57:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334784 - in head/sys: conf dev/md X-SVN-Group: head X-SVN-Commit-Author: leitao X-SVN-Commit-Paths: in head/sys: conf dev/md X-SVN-Commit-Revision: 334784 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2018 13:58:01 -0000 Author: leitao Date: Thu Jun 7 13:57:34 2018 New Revision: 334784 URL: https://svnweb.freebsd.org/changeset/base/334784 Log: md: use prestaged mfs_root On PowerNV systems, the rootfs is passed through kexec, which loads the rootfs into memory and set two fdt entries to describe where the file is located in the memory; I need to pass this memory region to the md device as a mfs_root, but, current md driver does not support two things: * Just getting a pointer from an external (bootloader) memory. If I need to workaround it, I would need to declare a static array and memcopy from this external memory to this static variable. * The size of the image. The usage of mfs_root_end, which is not a pointer, seems to be not possible for this prestaged scenario. This patch simply adds a new way to load mfs_root from memory. Differential Revision: https://reviews.freebsd.org/D15625 Approved by: kib, jhibbits (mentor) Modified: head/sys/conf/NOTES head/sys/conf/options head/sys/dev/md/md.c Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Thu Jun 7 13:29:54 2018 (r334783) +++ head/sys/conf/NOTES Thu Jun 7 13:57:34 2018 (r334784) @@ -1111,6 +1111,9 @@ options MD_ROOT # Write-protect the md root device so that it may not be mounted writeable. options MD_ROOT_READONLY +# Allow to read MD image from external memory regions +options MD_ROOT_MEM + # Disk quotas are supported when this option is enabled. options QUOTA #enable disk quotas Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Thu Jun 7 13:29:54 2018 (r334783) +++ head/sys/conf/options Thu Jun 7 13:57:34 2018 (r334784) @@ -168,6 +168,7 @@ MD_ROOT opt_md.h MD_ROOT_FSTYPE opt_md.h MD_ROOT_READONLY opt_md.h MD_ROOT_SIZE opt_md.h +MD_ROOT_MEM opt_md.h MFI_DEBUG opt_mfi.h MFI_DECODE_LOG opt_mfi.h MPROF_BUFFERS opt_mprof.h Modified: head/sys/dev/md/md.c ============================================================================== --- head/sys/dev/md/md.c Thu Jun 7 13:29:54 2018 (r334783) +++ head/sys/dev/md/md.c Thu Jun 7 13:57:34 2018 (r334784) @@ -180,6 +180,10 @@ SYSCTL_INT(_vm, OID_AUTO, md_malloc_wait, CTLFLAG_RW, */ u_char mfs_root[MD_ROOT_SIZE*1024] __attribute__ ((section ("oldmfs"))); const int mfs_root_size = sizeof(mfs_root); +#elif defined(MD_ROOT_MEM) +/* MD region already mapped in the memory */ +u_char *mfs_root; +int mfs_root_size; #else extern volatile u_char __weak_symbol mfs_root; extern volatile u_char __weak_symbol mfs_root_end; @@ -2074,8 +2078,12 @@ g_md_init(struct g_class *mp __unused) #ifdef MD_ROOT if (mfs_root_size != 0) { sx_xlock(&md_sx); +#ifdef MD_ROOT_MEM + md_preloaded(mfs_root, mfs_root_size, NULL); +#else md_preloaded(__DEVOLATILE(u_char *, &mfs_root), mfs_root_size, NULL); +#endif sx_xunlock(&md_sx); } #endif