Re: [PATCH v7 0/8] libfdt: Allow more control of code size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Feb 20, 2020 at 02:45:49PM -0700, Simon Glass wrote:
> 
> Since v1.4.6 libfdt has gained a number of checks for incorrect
> device-tree input and incorrect parameters. These are valuable and should
> be enabled by default. Some are basic sanity checks and some are designed
> to avoid security risks with carefully crafted device-tree input.
> 
> However the checks have added to code size to such an extent that many
> U-Boot boards can no-longer build/boot in SPL. This has prevented recent
> versions of libfdt from being used by U-Boot.
> 
> U-Boot SPL generally reads a device tree which has been set up by the
> build system and is known to be correct (e.g. it may be cryptographically
> signed by the build system). Therefore sanity checks in SPL should never
> fail, and just contribute to longer run-time and larger code size.
> 
> During review of those patches[1] the code-size impact was discussed and
> a possible solution was suggested.
> 
> This series adds a new ASSUME_MASK option, which allows for some control
> over the checks used in libfdt. With all assumptions enabled, libfdt
> assumes that the input data and parameters are all correct and that
> internal errors cannot happen. This allows U-Boot SPL to continue to use
> later versions of libfdt.
> 
> Within the code, preprocessor macros and an inline function are used which
> resolve to true or false to control the use of checks in the code. This
> seems better than using '#ifdefs' throughout the code. It also ensures
> that all code is compiled regardless of which checks are enabled (useful
> for build coverage).
> 
> This series reduces the size of libfdt by about 3KB on 64-bit x86
> (about 6%) when all assumptions are enabled. Future work is planned to
> reduce this further, but this is a good start. It enables U-Boot to move
> to the latest libfdt.
> 
> Note: libfdt includes a number of assignments in conditional statements.
> I have only changed these where necessary. It might be desirable to remove
> them all, to reduce the output from checkpatch.pl.
> 
> Series available at https://github.com/sglass68/dtc/tree/small6

I've applied this series to my tree.

There are some things I'd still like polished - comments on the
individual patches - but those can be done as followups, they're not
fundamental enough for me to request another spin.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux