Commit graph

1013 commits

Author SHA1 Message Date
Simon Glass
fc03c4a2e0 libfdt: Add support for disabling rollback handling
Allow enabling FDT_ASSUME_NO_ROLLBACK to disable rolling back after a
failed operation.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20200220214557.176528-6-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24 13:38:44 +11:00
Simon Glass
77563ae72b libfdt: Add support for disabling sanity checks
Allow enabling ASSUME_VALID_INPUT to disable sanity checks on the device
tree and the parameters to libfdt. This assumption covers that cases where
the problem could be with either.

Signed-off-by: Simon Glass <sjg@chromium.org>
Message-Id: <20200220214557.176528-5-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24 13:38:44 +11:00
Simon Glass
57bc6327b8 libfdt: Add support for disabling dtb checks
Support ASSUME_VALID_DTB to disable some sanity checks

If we assume that the DTB itself is valid then we can skip some checks and
save code space. Add various conditions to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Message-Id: <20200220214557.176528-4-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24 13:38:44 +11:00
Simon Glass
464962489d Add a way to control the level of checks in the code
Add 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.

By default no assumptions are made and all checks are enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Message-Id: <20200220214557.176528-3-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24 13:38:44 +11:00
Simon Glass
0c5326cb28 libfdt: De-inline fdt_header_size()
There does not seem to be a strong reason to inline this function. Also
we are about to add some extra code to it which will increase its size.

Move it into fdt.c and use a simple declaration in libfdt.h

Signed-off-by: Simon Glass <sjg@chromium.org>
Message-Id: <20200220214557.176528-2-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24 13:38:44 +11:00
Rob Herring
cc6a5a0715 Revert "yamltree: Ensure consistent bracketing of properties with phandles"
This reverts commit 18d7b2f4ee.

This doesn't work for properties such as 'interrupt-map' that has
phandle in the middle of an entry. It would also not work for a 0 or -1
phandle value that acts as a NULL.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20200124144657.29749-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-01-29 14:41:33 +11:00
Dirk Mueller
0e9225eb0d Remove redundant YYLOC global declaration
gcc 10 will default to -fno-common, which causes this error at link
time:

  (.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here

This is because both dtc-lexer as well as dtc-parser define the same
global symbol yyloc. Before with -fcommon those were merged into one
defintion. The proper solution would be to to mark this as "extern",
however that leads to:

  dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls]
   26 | extern YYLTYPE yylloc;
      |                ^~~~~~
In file included from dtc-lexer.l:24:
dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here
  127 | extern YYLTYPE yylloc;
      |                ^~~~~~
cc1: all warnings being treated as errors

which means the declaration is completely redundant and can just be
dropped.

Signed-off-by: Dirk Mueller <dmueller@suse.com>
Message-Id: <20200114175341.2994-1-dmueller@suse.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-01-16 11:00:19 +10:00
David Gibson
cab09eedd6 Move -DNO_VALGRIND into CPPFLAGS
Since -D sets preprocessor directives, it applies for the preprocessor not
just the C compiler proper and so belongs in CPPFLAGS rather than CFLAGS.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-12-19 13:14:45 +11:00
Ed Maste
0eb1cb0b53 Makefile: pass $(CFLAGS) also during dependency generation
When Valgrind is not available NO_VALGRIND is set in CFLAGS, and this
is needed during dependency generation as well as compilation.
Message-Id: <20191210163033.9888-1-emaste@freefall.freebsd.org>

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-12-17 12:34:46 +11:00
Thomas Huth
c40aeb60b4 travis.yml: Run tests on the non-x86 builders, too
Travis recently added the possibility to compile on aarch64, ppc64le
and s390x hosts, so let's add this possibility to the dtc CI, too.
Unfortunately, there are some weird valgrind errors when running
on ppc64le (which rather look like a problem on the valgrind side to
me, and not in dtc), so we can not use "checkm" on ppc64le yet.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20191203122020.14442-1-thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-12-04 16:54:04 +11:00
Ed Maste
9f86aff444 Add .cirrus.yml for FreeBSD build
Right now this is just a build test for FreeBSD, along with a Linux build
and "make check."  A later change will add "gmake check" for FreeBSD.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Message-Id: <20191120211133.69281-1-emaste@freefall.freebsd.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-21 12:33:24 +11:00
Ed Maste
34c82275ba Avoid gnu_printf attribute when using Clang
Clang does not support gnu_printf, so just use printf when using it to
compile.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Message-Id: <20191120210422.61327-1-emaste@freefall.freebsd.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-21 12:31:36 +11:00
Ed Maste
743000931b tests: default to 'cc' if CC not set
By default FreeBSD does not have 'gcc' in the PATH (on common platforms).
As on Linux 'cc' is available as a link to the default compiler (Clang or
GCC), so just use 'cc'.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Message-Id: <20191115155108.39488-1-emaste@freefall.freebsd.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-16 09:16:28 +11:00
Stefan Mavrodiev
adcd676491 Add test-case for trailing zero
If there is trailing zero, fdtget adds extra chacarter to the
property value. Thus comparing the expected with the actual
value, an error is emitted.

Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
Message-Id: <20191111080444.9819-3-stefan@olimex.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15 20:42:47 +11:00
Stefan Mavrodiev
d9c55f855b Remove trailing zero from the overlay path
The overlay path ends with trailing zero. When adding this path
as property value, this character should be removed. This is the case
when the overlay adds a node with an alias.

Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
Message-Id: <20191111080444.9819-2-stefan@olimex.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15 20:42:47 +11:00
Simon Glass
7a22132c79 pylibfdt: Adjust for deprecated test methods
Python recently deprecated some test methods in favour of others. Adjust
the code to avoid warnings.

Signed-off-by: Simon Glass <sjg@chromium.org>
Message-Id: <20191113012410.62550-1-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15 20:21:21 +11:00
Ed Maste
dbe80d577e tests: add extension to sed -i for GNU/BSD sed compatibility
BSD sed requires that an extension is provided to the -i (in-place edit)
flag, which may immediately follow the -i or may be separated by a space -
sed -i .bak and sed -i.bak are equivalent.  The extension is optional with
GNU sed, but if provided must immediately follow the -i.  Thus, sed -i.bak
behaves identically with both GNU and BSD sed.

Signed-off-by: Ed Maste <emaste@freebsd.org>
Message-Id: <20191114203615.2866-1-emaste@freefall.freebsd.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15 20:08:25 +11:00
David Gibson
af57d440d8 libfdt: Correct prototype for fdt_ro_probe_()
This function returns an int32_t, however the prototype in
libfdt_internal.h shows it returning an int.  We haven't caught this before
because they're the same type on nearly all platforms this gets built on.
Apparently it's not the case on FreeRTOS, so someone hit this mismatch
building for that platform.

Reported-by: dharani kumar <dharanikumarsrvn@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-08 14:42:53 +00:00
David Gibson
6ce585ac15 Use correct inttypes.h format specifier
The type here is uint32_t which should use PRIx32, not plain %x which is
for an int, we've just gotten away with it so far.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-07 17:46:43 +01:00
Ethan Sommer
7150286225 support byacc in addition to bison
Use -b to explicitly set file prefix, so that byacc generates files with
the same names as bison.

Add %locations to dtc-parser.y to explicitly enable location tracking
for byacc, and define YYERROR_CALL to prevent byacc from defining it to
call yyerror with 2 parameters because of the locations directive,
because dtc-parser.y defines yyerror to accept one parameter.

Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com>
Message-Id: <20191029162619.32561-1-e5ten.arch@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-03 20:20:22 +01:00
Simon Glass
fdf3f6d897 pylibfdt: Correct the type for fdt_property_stub()
This function should use a void * type, not char *. This causes an error:

TypeError: in method 'fdt_property_stub', argument 3 of type 'char const *'

Fix it and update the tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
Message-Id: <20191025010226.34378-1-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-27 17:50:53 +01:00
Marc-André Lureau
430419c281 tests: fix some python warnings
Fixes:
ResourceWarning: unclosed file <_io.BufferedReader name='test_tree1.dtb'>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-9-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14 17:09:13 +11:00
Marc-André Lureau
588a29ff2e util: use gnu_printf format attribute
dtc uses non-portable formats. Using gnu_printf attributes (for
warnings) in combination with __USE_MINGW_ANSI_STDIO allows to build
for win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-8-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14 17:07:46 +11:00
Marc-André Lureau
bc876708ab fstree: replace lstat with stat
Fixes mingw cross-compilation. lstat() doesn't exist on win32.

It seems to me that stat() is the right function there, to return
informations about the file it refers to.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-7-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14 17:07:10 +11:00
Marc-André Lureau
4c3c4ccb99 dumptrees: pass outputdir as first argument
Instead of outputing files to current directory, allow to specificy an
output directory. This helps with meson build system out-of-tree support.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-4-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14 16:20:32 +11:00
Marc-André Lureau
aa522da9ff tests: allow out-of-tree test run
meson runs out-of-tree, add absolute path location where necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-3-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14 16:19:29 +11:00
Valter Minute
0d0d0fa51b fdtoverlay: Return non-zero exit code if overlays can't be applied
At present the tool terminates its execution if one of the overlays passed
as command-line arguments can't be successfully read or applied, but the exit
code of the process is zero, making failures hard to detect inside scripts.

Signed-off-by: Valter Minute <valter.minute@toradex.com>
Message-Id: <20191009123256.14248-1-valter.minute@toradex.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-11 15:58:18 +11:00
Marc-André Lureau
4605eb047b Add .editorconfig
Set code style for various editors.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-2-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-09 22:41:44 +11:00
Rob Herring
18d7b2f4ee yamltree: Ensure consistent bracketing of properties with phandles
The dts syntax allows for '<>' around phandles and arg cells or not
which it didn't matter until adding type information. However, the YAML
encoding expects each phandle + args to be bracketed.

If TYPE_UINT32 markers are not present before each REF_PHANDLE, fix up
the markers and add the TYPE_UINT32 markers. This allows the subsequent
YAML emitting code to work as-is.

Adding the markers at an earlier stage doesn't work because of
possible labels in dts output. We'd have to define the ordering of
labels and brackets. Also, it is probably best to have dts output match
the input.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190918183534.24205-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-25 11:48:50 +10:00
Luc Michel
67f790c1ad libfdt.h: add explicit cast from void* to uint8_t* in fdt(32|64)_st
Including libfdt.h in a C++ project fails during compilation with recent
version of GCC or Clang.

This simple example:

extern "C" {
 #include <libfdt.h>
}

int main(void) { return 0; }

leads to the following errors with GCC 9.1.0:

/usr/include/libfdt.h: In function ‘void fdt32_st(void*, uint32_t)’:
/usr/include/libfdt.h:139:16: error: invalid conversion from ‘void*’ to ‘uint8_t*’ {aka ‘unsigned char*’} [-fpermissive]
  139 |  uint8_t *bp = property;
      |                ^~~~~~~~
      |                |
      |                void*
/usr/include/libfdt.h: In function ‘void fdt64_st(void*, uint64_t)’:
/usr/include/libfdt.h:163:16: error: invalid conversion from ‘void*’ to ‘uint8_t*’ {aka ‘unsigned char*’} [-fpermissive]
  163 |  uint8_t *bp = property;
      |                ^~~~~~~~
      |                |
      |                void*

This commit adds an explicit cast to uint8_t* to fix this issue.

Signed-off-by: Luc Michel <luc.michel@greensocs.com>
Message-Id: <20190910104824.1321594-1-luc.michel@greensocs.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-10 23:11:40 +10:00
Luca Weiss
b111122ea5 pylibfdt: use python3 shebang
The default Python version for pylibfdt is already Python 3 but if
called without specifiying an interpreter, the setup.py script gets
called with Python 2.

It's of course still possible to call setup.py with python2 directly.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Message-Id: <20190907152530.25102-1-luca@z3ntu.xyz>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-09 15:20:55 +10:00
David Gibson
60e0db3d65 Ignore phandle properties in /aliases
The 'alias_paths' check verifies that each property in /aliases is a valid
path to another node.  However this can cans false positives trees where
the /aliases node has a phandle property, which isn't in this format but
is allowed.  In particular this situation can be common with trees dumped
from some real OF systems (which typically generate a phandle for every
node).

Special case this to avoid the spurious error.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-04 14:58:28 +10:00
Luca Weiss
95ce19c140 README: update for Python 3
Convert the usage to be compatible with Python 3 and the current API.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Message-Id: <20190817212532.15661-2-luca@z3ntu.xyz>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-08-29 11:06:11 +10:00
Denis Efremov
5345db19f6 livetree: simplify condition in get_node_by_path
The "strlen && strprefixeq" check in get_node_by_path is
excessive, since strlen is checked in strprefixeq macro
internally. Thus, "strlen(child->name) == p-path"
conjunct duplicates after macro expansion and could
be removed.

Signed-off-by: Denis Efremov <efremov@linux.com>
Message-Id: <20190827204148.20604-1-efremov@linux.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-08-28 13:57:27 +10:00
David Gibson
b8d6eca782 libfdt: Allow #size-cells of 0
c12b2b0c20 "libfdt: fdt_address_cells() and fdt_size_cells()" introduced
a bug as it consolidated code between the helpers for getting
#address-cells and #size-cells.  Specifically #size-cells is allowed to
be 0, and is frequently found so in practice for /cpus.  IEEE1275 only
requires implementations to handle 1..4 for #address-cells, although one
could make a case for #address-cells == #size-cells == 0 being used to
represent a bridge with a single port.

While we're there, it's not totally obvious that the existing implicit
cast of a u32 to int will give the correct results according to strict C,
although it does work in practice.  Straighten that up to cast only after
we've made our range checks.

Reported-by: yonghuhaige via https://github.com/dgibson/dtc/issues/28
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-28 16:31:44 +10:00
Joel Stanley
184f510994 Makefile: Add EXTRA_CFLAGS variable
Distributions packaging dtc may need to set extra flags. Currently when
they do that it overrides the ones set by the makefile. This is
particularly problematic when compiling without yaml, as the yaml
detection is ignored.

 ld: dtc.o: in function `main':
 dtc.c:(.text.startup+0x718): undefined reference to `dt_to_yaml'

This patch provides a EXTRA_CFLAGS variable that is added to the list of
CFLAGS, and can be set on the command line when packaging.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Message-Id: <20190722030244.9580-1-joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-22 13:13:24 +10:00
David Gibson
812b1956a0 libfdt: Tweak data handling to satisfy Coverity
In libfdt we often sanity test fdt_totalsize(fdt) fairly early, then
trust it (but *only* that header field) for the remainder of our work.
However, Coverity gets confused by this - it sees the byteswap in
fdt32_ld() and assumes that means it is coming from an untrusted source
everytime, resulting in many tainted data warnings.

Most of these end up with logic in fdt_get_string() as the unsafe
destination for this tainted data, so let's tweak the logic there to make
it clearer to Coverity that this is ok.

We add a sanity test on fdt_totalsize() to fdt_probe_ro_().  Because the
interface allows bare ints to be used for offsets, we already have the
assumption that totalsize must be 31-bits or less (2GiB would be a
ludicrously large fdt).  This makes this more explicit.

We also make fdt_probe_ro() return the size for convenience, and change the
logic in fdt_get_string() to keep it in a local so that Coverity can see
that it has already been bounds-checked.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-05 15:31:12 +10:00
David Gibson
5c715a4477 fdtoverlay: Ignore symbols in overlays which don't apply to the target tree
Symbols from overlays are merged into the target tree, and are required to
have the form:
	/fragment@XXX/__overlay__/...
If any symbols don't have this form, the overlay is rejected.

But there's not really anything wrong with an overlay having "local"
labels referring to a fragment node or some other metadata, that's not
expected to end up in a target tree.

So change our overlay application to simply ignore such symbols rather than
fail.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-04 15:10:01 +10:00
David Gibson
b993534748 fdtoverlay: Allow adding labels to __overlay__ nodes in overlays
When applying overlays, we merge symbols from the overlay into the target
tree.  At the moment the logic for this assumes all symbols in the overlay
are attached to a node of the form:
	/fragment@XXX/__overlay__/relative/path

And will end up applied to the relative/path node under the fragment's
target.

However, this disallows the case of a symbol in the form just:
	/fragment@XXX/__overlay__

This does have a pretty obvious sensible meaning: attach the new symbol
directly to the fragment's target, but we don't currently do that.

It's pretty easy to workaround this limitation in one's overlays, but it's
also easy to handle in the overlay applying code, so we might as well
extend it to cover this case.

Reported-by: Christophe Braillon
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-04 14:39:02 +10:00
Appana Durga Kedareswara rao
d6de81b81b pylibfdt: Add support for fdt_get_alias()
Add this into the class to simplify use of this function.

Signed-off-by: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
Message-Id: <1562130487-27028-1-git-send-email-appana.durga.rao@xilinx.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-04 12:56:47 +10:00
Simon Glass
1c17714dbb pylibfdt: Correct the FdtSw example
At present this example is incorrect since it is missing the call to
finish_reservemap() and does not add a root node. Fix these problems.

Signed-off-by: Simon Glass <sjg@chromium.org>
Message-Id: <20190703000815.102459-1-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-03 10:23:21 +10:00
Fabrice Gasnier
ad57e4574a tests: Add a failed test case for 'fdtoverlay' with long target path
This adds a test case to demonstrate some issue seen when applying
overlays using 'fdtoverlay'. It fails with FDT_ERR_NOSPACE:
- with long target path
- symbols in order to use these nodes in possible subsequent overlay.

This is seen with this patch, by running:
$ make check # Reports a failed test
$ ./fdtoverlay -i tests/overlay_base.test.dtb -o out.dtb \
  tests/overlay_overlay_long_path.fdoverlay.test.dtb
  Failed to apply tests/overlay_overlay_long_path.fdoverlay.test.dtb (-3)

This overlay fails to apply, because dtb size is close to modulo 1024
bytes chunk: utilfdt_read() -> utilfdt_read_err() -> bufsize = 1024.

As there is not much extra space in the blob to resolve symbols (long
target path), it fails with FDT_ERR_NOSPACE. In fdtoverlay, size is :
 /* grow the blob to worst case */
 blob_len = fdt_totalsize(blob) + total_len;

I can see assumption is made that result should be lower than:
- base fdt size + overlay size. Is there a simple way to find to know
what the final size is?
I'm not sure what the correct fix might be, for such (worst) case?
Similar issue is also seen in u-boot/common/image-fit.c that implements
similar approach (e.g. base fdt size + overlay size).

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Message-Id: <1538553302-1353-1-git-send-email-fabrice.gasnier@st.com>
[dwg: To avoid breaking bisection, I committed this after a fix, so
 the "failed" description is no longer accurate]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-30 15:48:40 +10:00
David Gibson
bbe3b36f54 fdtoverlay: Rework output allocation
At present the fdtoverlay tool allocates space for its output based on a
calculation of the worse case size based on the size of the input blobs.

Except.. that certain edge cases with very long target paths can actually
exceed that "worst case" calculation.

This reworks the code to instead dynamically reallocate the output buffer
if we run out of space at any point.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-30 15:47:50 +10:00
David Gibson
6c2e61f083 fdtoverlay: Improve error messages
Make several improvements to the error messages from the fdtoverlay helper
program: improve brevity, consistently quote filenames and print symbolic
errors from libfdt rather than a raw error number.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-30 15:47:50 +10:00
David Gibson
297f5abb36 fdtoverlay: Check for truncated overlay blobs
The fdtoverlay helper program checks if it has read a base blob which is
incomplete: that is, where the amount of data read in is less that the
declared size of the blob.

This applies the same check for safety to each overlay blob as well.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-30 15:47:50 +10:00
Rob Herring
702c1b6c0e README.license: Update to reflect SPDX tag usage
Update README.license since files now have SPDX tags rather than license
text. Adding a copy of BSD-2-Clause license since that no longer exists
within the project.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190620211944.9378-8-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-21 21:06:10 +10:00
Rob Herring
4097bbffcf dtc: Add GPLv2 SPDX tags to files missing license text
A couple of dtc files are missing licenses. Add GPL-2.0-or-later SPDX
tag to them.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190620211944.9378-7-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-21 21:06:10 +10:00
Rob Herring
94f87cd5b7 libfdt: Add dual GPL/BSD SPDX tags to files missing license text
A couple of libfdt files are missing licenses. Add (GPL-2.0-or-later OR
BSD-2-Clause) SPDX tag to them.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190620211944.9378-6-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-21 21:06:10 +10:00
Rob Herring
c4ffc05574 tests: Replace license boilerplate with SPDX tags
Replace instances in tests of mostly LGPL-2.1 license boilerplate
with SPDX tags.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190620211944.9378-5-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-21 21:06:10 +10:00
Rob Herring
a5ac29baac pylibfdt: Replace dual GPLv2/BSD license boilerplate with SPDX tags
Replace pylibfdt GPLv2/BSD license boilerplate and add missing license
with SPDX tags.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190620211944.9378-4-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-06-21 21:06:10 +10:00