From owner-svn-src-all@freebsd.org Thu Jun 4 16:47:33 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 BF868329274 for ; Thu, 4 Jun 2020 16:47:33 +0000 (UTC) (envelope-from misho@elwix.org) Received: from mail.elwix.net (ns.aitbg.com [84.242.154.175]) by mx1.freebsd.org (Postfix) with ESMTP id 49dBXP05Mnz4Gc8; Thu, 4 Jun 2020 16:47:32 +0000 (UTC) (envelope-from misho@elwix.org) Received: from t450.sof.cloudsigma.com.aitnet.org (unknown [87.246.28.119]) by mail.elwix.net (Postfix) with ESMTPSA id 7BC954A222F3; Thu, 4 Jun 2020 19:47:31 +0300 (EEST) Date: Thu, 4 Jun 2020 19:47:31 +0300 From: Michael Pounov To: ae@freebsd.org, svn-src-all@freebsd.org Subject: userboot.so can't open rootfs partition if you use raw BSD partitions directly on disk without any slices Message-Id: <20200604194731.4dc91e50744f8169aed46b10@elwix.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-unknown-openbsd6.6) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Thu__4_Jun_2020_19_47_31_+0300_kgcIgDnXC3FUhxTI" X-Rspamd-Queue-Id: 49dBXP05Mnz4Gc8 X-Spamd-Bar: +++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of misho@elwix.org has no SPF policy when checking 84.242.154.175) smtp.mailfrom=misho@elwix.org X-Spamd-Result: default: False [3.06 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; MV_CASE(0.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; HAS_ATTACHMENT(0.00)[]; TO_DN_NONE(0.00)[]; AUTH_NA(1.00)[]; DMARC_NA(0.00)[elwix.org]; NEURAL_SPAM_MEDIUM(0.43)[0.426]; NEURAL_SPAM_SHORT(0.21)[0.214]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_LONG(0.92)[0.924]; R_SPF_NA(0.00)[no SPF record]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:29580, ipnet:84.242.152.0/21, country:BG]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[87.246.28.119:received] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 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: Thu, 04 Jun 2020 16:47:33 -0000 This is a multi-part message in MIME format. --Multipart=_Thu__4_Jun_2020_19_47_31_+0300_kgcIgDnXC3FUhxTI Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Excuse me for double sent, but I forgot the attachment :( After upgrade from FreeBSD 12.0 to 12-STABLE of embedded image under BHyve guest I faced with bootloader issue. >From FreeBSD 12.1 till current version of FreeBFrom FreeBSD 12.1 till current version of FreeBSD. userboot.so loader haves issue with raw BSD partitions directly on disk without any PC slice schema aka MBR or GPT. Bug came after commit, when predefine constant values was replaced with macro definitions in userboot/main.c and common/disk.c. These two members of devsw structure d_slice and d_partition now have defined constants. One of them have different value from previous version of code. D_PARTWILD now have value -2, before that change dev.d_partition has 0. I didn't take easy step directly to change macro D_PARTWILD to 0, because I saw that uboot loader already used this macro. I made patch in common/disk.c file into disk_open() functionSD. userboot.so loader haves issue with raw BSD partitions directly on disk without any PC slice schema aka MBR or GPT. Bug came after commit, when predefine constant values was replaced with macro definitions in userboot/main.c and common/disk.c. These two members of devsw structure d_slice and d_partition now have defined constants. One of them have different value from previous version of code. D_PARTWILD now have value -2, before that change dev.d_partition has 0. I didn't take easy step directly to change macro D_PARTWILD to 0, because I saw that uboot loader already used this macro. I made patch in common/disk.c file into disk_open() function P.S. Patch was produced against base/head sources Regards Michael Pounov CloudSigma AG --Multipart=_Thu__4_Jun_2020_19_47_31_+0300_kgcIgDnXC3FUhxTI Content-Type: application/octet-stream; name="disk_open.patch" Content-Disposition: attachment; filename="disk_open.patch" Content-Transfer-Encoding: base64 LS0tIHN0YW5kL2NvbW1vbi9kaXNrLmMJMjAyMC0wNi0wNCAxODo1MDozMS44MjIyMzUwMDAgKzAz MDAKKysrIHN0YW5kL2NvbW1vbi9kaXNrLmMJMjAyMC0wNi0wNCAxODo1NDozMC45MjI3NzEwMDAg KzAzMDAKQEAgLTI4Miw3ICsyODIsOSBAQAogCW9kLT5tZWRpYXNpemUgPSBtZWRpYXNpemU7CiAK IAlpZiAocHRhYmxlX2dldHR5cGUob2QtPnRhYmxlKSA9PSBQVEFCTEVfQlNEICYmCi0JICAgIHBh cnRpdGlvbiA+PSAwKSB7CisJICAgIChwYXJ0aXRpb24gPj0gMCB8fCBwYXJ0aXRpb24gPT0gRF9Q QVJUV0lMRCkpIHsKKwkJaWYgKHBhcnRpdGlvbiA9PSBEX1BBUlRXSUxEKQorCQkJcGFydGl0aW9u IF49IHBhcnRpdGlvbjsKIAkJLyogSXQgZG9lc24ndCBtYXR0ZXIgd2hhdCB2YWx1ZSBoYXMgZF9z bGljZSAqLwogCQlyYyA9IHB0YWJsZV9nZXRwYXJ0KG9kLT50YWJsZSwgJnBhcnQsIHBhcnRpdGlv bik7CiAJCWlmIChyYyA9PSAwKSB7Cg== --Multipart=_Thu__4_Jun_2020_19_47_31_+0300_kgcIgDnXC3FUhxTI--