]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
stand/fdt: don't send clobbered FDT to the kernel
authorkevans <kevans@FreeBSD.org>
Mon, 15 Jan 2018 05:00:26 +0000 (05:00 +0000)
committerkevans <kevans@FreeBSD.org>
Mon, 15 Jan 2018 05:00:26 +0000 (05:00 +0000)
commit6e1afb75f76a2c622f834996ee20b63277233d10
treed1115ca6054727f233bcea2cd1827e6d08bf90d5
parentc99f9e4f325b474ff95d40719f0b3ee543b8a872
stand/fdt: don't send clobbered FDT to the kernel

If fdt_overlay_apply fails at some stage to apply the overlay to the base,
both the base and overlay may be in an inconsistent state (some fixups
applied, some phandles adjusted, some symbols merged). These can be bad for
a number of reasons, to include user frustration if some fixups applied and
not others. Fail a little safer by making a clean copy of the base FDT for
every overlay that we can simply discard if things go awry.

This also allows us the luxury of simply discarding overlays if we hit some
kind of memory limit or if they're malformed and extremely large for some
reason. We'll now leave a nice error message indicating that some overlays
could not be applied due to size restrictions and we apply what we can.

I note that our overlay implementation has some flaws that might still leave
your system in an unbootable state even if an overlay applies correctly;
please exercise caution in using overlays until we can swap it out for
libfdt's implementation.

Tested on: BananaPi-M3 (armv7)
Tested on: Pine64 (aarch64)
Differential Revision: https://reviews.freebsd.org/D13709
stand/fdt/fdt_loader_cmd.c