]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Make uboot_devdesc properly alias disk_devdesc, so that parsing the u-boot
authorian <ian@FreeBSD.org>
Mon, 18 Feb 2019 04:44:52 +0000 (04:44 +0000)
committerian <ian@FreeBSD.org>
Mon, 18 Feb 2019 04:44:52 +0000 (04:44 +0000)
commitbd09fc364413fcfe6444a701522d854c8da719ae
tree02dd88752b8b6d62f3d0366605cb52d30cc43aa4
parente63c279cf7392b5494d32b13ed20c7a5e34cf8b6
Make uboot_devdesc properly alias disk_devdesc, so that parsing the u-boot
loaderdev variable works correctly.

The uboot_devdesc struct is variously cast back and forth between
uboot_devdesc and disk_devdesc as pointers are handed off through various
opaque interfaces.  uboot_devdesc attempted to mimic the layout of
disk_devdesc by having a devdesc struct, followed by a union of some
device-specific stuff that included a struct that contains the same fields
as a disk_devdesc.  However, one of those fields inside the struct is 64-bit
which causes the entire union to be 64-bit aligned -- 32 bits of padding
is added between the struct devdesc and the union, so the whole mess ends
up NOT properly mimicking a disk_devdesc after all.  (In disk_devdesc there
is also 32 bits of padding, but it shows up immediately before the d_offset
field, rather than before the whole collection of d_* fields.)

This fixes the problem by using an anonymous union to overlay the devdesc
field uboot network devices need with the disk_devdesc that uboot storage
devices need.  This is a different solution than the one contributed with
the PR (so if anything goes wrong, the blame goes to me), but 95% of the
credit for this fix goes to Pawel Worach and Manuel Stuhn who analyzed the
problem and proposed a fix.

PR: 233097
stand/uboot/common/main.c
stand/uboot/lib/libuboot.h