Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 2020 19:47:31 +0300
From:      Michael Pounov <misho@elwix.org>
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>

next in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200604194731.4dc91e50744f8169aed46b10>