Commit graph

976 commits

Author SHA1 Message Date
Viresh Kumar
163f0469bf dtc: Allow overlays to have .dtbo extension
Allow the overlays to have .dtbo extension instead of just .dtb. This
allows them to be identified easily by tools as well as humans.

Allow the dtbo outform in dtc.c for the same.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Message-Id: <30fd0e5f2156665c713cf191c5fea9a5548360c0.1609926856.git.viresh.kumar@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-01-11 21:55:55 +11:00
Justin Covell
3b01518e68 Set last_comp_version correctly in new dtb and fix potential version issues in fdt_open_into
Changes in v3:
- Remove noop version sets
- Set version correctly on loaded fdt in fdt_open_into

Fixes: f1879e1a50 ("Add limited read-only support for older (V2 and V3) device tree to libfdt.")

Signed-off-by: Justin Covell <jujugoboom@gmail.com>

Message-Id: <20201229041749.2187-1-jujugoboom@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-01-04 12:26:37 +11:00
Paul Barker
f7e5737f26 tests: Fix overlay_overlay_nosugar test case
This test was accidentally skipped as the wrong test dts file was built.
The fragment numbering in this sugar-free test case needed adjusting to
match the numbering generated by dtc for overlay_overlay.dts.

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Message-Id: <20201219143521.2118-1-pbarker@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-12-22 20:45:42 +11:00
David Gibson
7cd5d5fe43 libfdt: Tweak description of assume-aligned load helpers
There's a small inaccuracy in the comment describing these new helpers.
This corrects it, and reformats while we're there.

Fixes: f98f28ab ("libfdt: Internally perform potentially unaligned loads")
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-12-16 16:52:17 +11:00
Tom Rini
a7c4040993 libfdt: Internally perform potentially unaligned loads
Commits 6dcb8ba4 "libfdt: Add helpers for accessing unaligned words"
introduced changes to support unaligned reads for ARM platforms and
11738cf01f "libfdt: Don't use memcpy to handle unaligned reads on ARM"
improved the performance of these helpers.

On further discussion, while there are potential cases where we could be
used on platforms that do not fixup unaligned reads for us, making this
choice the default is very expensive in terms of binary size and access
time.  To address this, introduce and use new fdt{32,64}_ld_ functions
that call fdt{32,64}_to_cpu() as was done prior to the above mentioned
commits.  Leave the existing load functions as unaligned-safe and
include comments in both cases.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Message-Id: <20201211022736.31657-1-trini@konsulko.com>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-12-16 16:52:05 +11:00
Marc-André Lureau
bab85e48a6 meson: increase default timeout for tests
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20201207130055.462734-4-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-12-08 15:30:28 +11:00
Marc-André Lureau
f8b4609882 meson: do not assume python is installed, skip tests
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20201207130055.462734-3-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-12-08 15:30:28 +11:00
Marc-André Lureau
30a56bce4f meson: fix -Wall warning
Meson already handles Wall via the built-in warning_level option.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20201207130055.462734-2-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-12-08 15:30:28 +11:00
Tom Rini
5e735860c4 libfdt: Check for 8-byte address alignment in fdt_ro_probe_()
The device tree must be loaded in to memory at an 8-byte aligned
address.  Add a check for this condition in fdt_ro_probe_() and a new
error code to return if we are not.

Signed-off-by: Tom Rini <trini@konsulko.com>
Message-Id: <20201104130605.28874-1-trini@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-11-24 16:41:45 +11:00
Marc-André Lureau
67849a3279 build-sys: add meson build
The meson build system allows projects to "vendor" dtc easily, thanks to
subproject(). QEMU has recently switched to meson, and adding meson
support to dtc will help to handle the QEMU submodule.

meson rules are arguably simpler to write and maintain than
the hand-crafted/custom Makefile. meson support various backends, and
default build options (including coverage, sanitizer, debug/release
etc, see: https://mesonbuild.com/Builtin-options.html)

Compare to the Makefiles, the same build targets should be built and
installed and the same tests should be run ("meson test" can be provided
extra test arguments for running the equivalent of checkm/checkv).

There is no support EXTRAVERSION/LOCAL_VERSION/CONFIG_LOCALVERSION,
instead the version is simply set with project(), and vcs_tag() is
used for git/dirty version reporting (This is most common and is
hopefully enough. If necessary, configure-time options could be added
for extra versioning.).

libfdt shared library is build following regular naming conventions:
instead of libfdt.so.1 -> libfdt-1.6.0.so (with current build-sys),
libfdt.so.1 -> libfdt.so.1.6.0. I am not sure why the current build
system use an uncommon naming pattern. I also included a libfdt.pc
pkg-config file, as convenience.

Both Linux native build and mingw cross-build pass. CI pass. Tests are
only run on native build.

The current Makefiles are left in-tree, and make/check still work.
Eventually, the Makefiles could be marked as deprecated, to start a
transition period and avoid having to maintain 2 build systems in the
near future.

(run_tests.sh could eventually be replaced by the meson test runner,
which would have several advantages in term of flexibility/features,
but this is left for another day)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20201012073405.1682782-3-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-21 14:36:07 +11:00
Marc-André Lureau
05874d0821 pylibfdt: allow build out of tree
With meson, we have to support out-of-tree build.

Introduce a --top-builddir option, which will default to the current
directory to lookup generated filed such as version_gen.h and output
directories.

Other source paths are derived from the location of the setup.py script
in the source tree.

--build-lib is changed to be relative to the current directory, instead
of relative to setup.py. This has less surprising results!

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20201012073405.1682782-2-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-21 14:35:17 +11:00
Andre Przywara
3bc3a6b9fe dtc: Fix signedness comparisons warnings: Wrap (-1)
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in dtc's data_copy_file().

Even though maxlen is of an unsigned type, we compare against "-1",
which is passed in from the parser to indicate an unknown size.

Cast the "-1" to an unsigned size to make the comparison match.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201012161948.23994-9-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 15:58:53 +11:00
Andre Przywara
e1147b159e dtc: Fix signedness comparisons warnings: change types
With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in various parts of dtc.

Many variables are using signed types unnecessarily, as we never use
negative value in them.
Change their types to be unsigned, to prevent issues with comparisons.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201012161948.23994-7-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 15:56:53 +11:00
Andre Przywara
04cf1fdc0f convert-dtsv0: Fix signedness comparisons warning
With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in the generated lexer code.

In this case we walk over an array, and never use negative indicies, so
we can change the loop counter variable to be unsigned.

This fixes "make convert-dtsv0", when compiled with -Wsign-compare.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201012161948.23994-3-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 15:48:40 +11:00
Andre Przywara
b30013edb8 libfdt: Fix kernel-doc comments
The API documentation in libfdt.h seems to follow the Linux kernel's
kernel-doc format[1].

Running "scripts/kernel-doc -v -none" on the file reports some problems,
mostly missing return values and missing parameter descriptions.

Fix those up by providing the missing bits, and fixing the other small
issues reported by the script.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/doc-guide/kernel-doc.rst
Message-Id: <20201012165331.25016-1-andre.przywara@arm.com>

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-13 15:46:44 +11:00
Rob Herring
cbca977ea1 checks: Allow PCI bridge child nodes without an address
Some PCI bridge nodes have child nodes such as an interrupt controller
which are not PCI devices. Allow these nodes which don't have a
unit-address.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20200928201942.3242124-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 13:30:24 +10:00
Andre Przywara
73e0f143b7 libfdt: fdt_strerror(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_strerror().

Force FDT_ERRTABSIZE to be signed (it's surely small enough to fit), so
that the types match. Also move the minus sign to errval, as this is
actually what we use in the next line.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201001164630.4980-7-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 10:34:18 +10:00
Andre Przywara
6c2be7d853 libfdt: fdt_get_string(): Fix sequential write comparison warnings
With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in fdt_get_string().

Introduce a new usigned variable, which holds the actual (negated)
stroffset value, so we avoid negating all the other variables and have
proper types everywhere.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201001164630.4980-6-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 10:33:01 +10:00
Andre Przywara
82525f41d5 libfdt: libfdt_wip: Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_setprop_inplace_namelen_partial().

fdt_getprop_namelen() will only return negative error values in "proplen"
if the return value is NULL. So we can rely on "proplen" being positive
in our case and can safely cast it to an unsigned type.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201001164630.4980-5-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 10:30:07 +10:00
Andre Przywara
fb1f65f158 libfdt: fdt_create_with_flags(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_create_with_flags().

By making hdrsize a signed integer (we are sure it's a very small
number), we avoid all the casts and have matching types.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201001164630.4980-4-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 10:29:27 +10:00
Andre Przywara
f28aa27100 libfdt: fdt_move(): Fix comparison warnings
With -Wsign-compare, compilers warn about a mismatching signedness
in comparisons in fdt_move().

This stems from "bufsize" being passed in as a signed integer, even
though we would expect a buffer size to be positive.

Short of changing the prototype, check that bufsize is not negative, and
cast it to an unsigned type in the comparison.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201001164630.4980-3-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 10:28:36 +10:00
Andre Przywara
3d7c6f4419 libfdt: fdt_add_string_(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_add_string_().

Make all variables unsigned, and express the negative offset trick via
subtractions in the code.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201001164630.4980-2-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-10-02 10:22:37 +10:00
Andre Przywara
10f682788c libfdt: fdt_node_offset_by_phandle(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_node_offset_by_phandle().

Uses a better suited bitwise NOT operator to denote the special value of
-1, which automatically results in an unsigned type.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-14-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-25 14:09:41 +10:00
Andre Przywara
07158f4cf2 libfdt: overlay: Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness in
a comparison in overlay_update_local_node_references().

This happens because the division of a signed int by an unsigned int
promotes the dividend to unsigned first (ANSI C standard 6.1.3.8).

As in this case we basically just divide by 4, we can do the division
separately earlier, which preserves the original type.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-12-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-25 14:05:51 +10:00
Andre Przywara
ce9e1f25a7 libfdt: fdt_resize(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_resize().

A negative buffer size will surely do us no good, so let's rule this
case out first.
In the actual comparison we then know that a cast to an unsigned type is
safe.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-10-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-24 14:43:02 +10:00
Andre Przywara
faa76fc10b libfdt: fdt_splice_(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_splice_().

Since we just established that oldlen is not negative, we can safely
cast it to an unsigned type.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-8-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-24 11:07:27 +10:00
Simon Glass
54dca09853 libfdt: fdt_get_string(): Fix comparison warnings
With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in fdt_get_string().

In the first two cases, we have just established that the signed values
are not negative, so it's safe to cast the values to an unsigned type.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-7-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-24 11:06:30 +10:00
Andre Przywara
f8e11e6162 libfdt: fdt_grab_space_(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness
in a comparison in fdt_grab_space_().

All the involved values cannot be negative, so let's switch the types of
the local variables to unsigned to make the compiler happy.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-4-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-23 21:50:50 +10:00
Andre Przywara
0c43d4d7bf libfdt: fdt_mem_rsv(): Fix comparison warnings
With -Wsign-compare, compilers warn about a mismatching signedness
in comparisons in fdt_mem_rsv().

Since all involved values must be positive, change the used types to be
unsigned.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-3-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-23 21:50:17 +10:00
Andre Przywara
442ea3dd15 libfdt: fdt_offset_ptr(): Fix comparison warnings
With -Wsign-compare, compilers warn about mismatching signedness in
comparisons in fdt_offset_ptr().

This mostly stems from "offset" being passed in as a signed integer,
even though the function would not really tolerate negative values.

Short of changing the prototype, check that offset is not negative, and
use an unsigned type internally.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200921165303.9115-2-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-09-23 21:47:35 +10:00
Emmanuel Vadot
ca19c3db2b Makefile: Specify cflags for libyaml
Some systems don't install third party software includes in a default
path (like FreeBSD), add yaml cflags to fix compilation.

Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
2020-08-25 12:34:18 +02:00
Frank Mehnert
7bb86f1c09 libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT
fdt_check_node_offset_() checks for a valid offset but also changes the
offset by calling fdt_next_tag(). Hence, do not skip this function if
ASSUME_VALID_INPUT is set but only omit the initial offset check in that
case.

As this function works very similar to fdt_check_prop_offset_(), do the
offset check there as well depending on ASSUME_VALID_INPUT.
Message-Id: <1913141.TlUzK5foHS@noys4>

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-08-14 13:16:22 +10:00
Andrei Ziureaev
3d522abc75 dtc: Include stdlib.h in util.h
If used on its own, util.h needs stdlib.h for exit(), malloc() and
realloc().

Signed-off-by: Andrei Ziureaev <andrei.ziureaev@arm.com>
Message-Id: <20200721155900.9147-2-andrei.ziureaev@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-07-22 16:41:28 +10:00
Andrei Ziureaev
808cdaaf52 dtc: Avoid UB when shifting
Prevent undefined behavior when shifting by a number that's bigger than
or equal to the width of the first operand.

Signed-off-by: Andrei Ziureaev <andrei.ziureaev@arm.com>
Message-Id: <20200714154542.18064-2-andrei.ziureaev@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-07-15 20:40:54 +10:00
Patrick Oppenlander
3e3138b4a9 libfdt: fix fdt_check_full buffer overrun
fdt_check_header assumes that its argument points to a complete header
and can read data beyond the FDT_V1_SIZE bytes which fdt_check_full
can provide.

fdt_header_size can safely return a header size with FDT_V1_SIZE bytes
available and will return a usable value even for a corrupted header.

Signed-off-by: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Message-Id: <20200709041451.338548-1-patrick.oppenlander@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-07-10 19:55:36 +10:00
Geert Uytterhoeven
9d7888cbf1 dtc: Consider one-character strings as strings
When using overlays, a target-path property pointing to the root node is
quite common.  However, "dtc -O dts" prints it as a byte array:

    target-path = [2f 00];

instead of a string:

    target-path = "/";

For guess_value_type() to consider a value to be a string, it must
contain less nul bytes than non-nul bytes, thus ruling out strings
containing only a single character.  Allow printing such strings by
relaxing the condition slightly.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Message-Id: <20200623094343.26010-1-geert+renesas@glider.be>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-24 16:11:55 +10:00
Joel Stanley
8259d59f59 checks: Improve i2c reg property checking
The i2c bindings in the kernel tree describe support for 10 bit
addressing, which must be indicated with the I2C_TEN_BIT_ADDRESS flag.
When this is set the address can be up to 10 bits. When it is not set
the address is a maximum of 7 bits.

See Documentation/devicetree/bindings/i2c/i2c.txt.

Take into account this flag when checking the address is valid.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Message-Id: <20200622031005.1890039-3-joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-22 17:52:50 +10:00
Joel Stanley
fdabcf2980 checks: Remove warning for I2C_OWN_SLAVE_ADDRESS
dtc does a sanity check on reg properties that they are within the 10
bit address range for i2c slave addresses. In the case of multi-master
buses or devices that act as a slave, the binding may describe an
address that the bus will listen on as a device. Do not warn when this
flag is set.

See Documentation/devicetree/bindings/i2c/i2c.txt.

This fixes the following build warnings reported by Stephen and by Arnd:

arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:126.11-130.4:
  Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:
    I2C bus unit address format error, expected "40000010"
arch/arm/boot/dts/aspeed-bmc-facebook-yosemitev2.dts:128.3-30:
  Warning (i2c_bus_reg): /ahb/apb/bus@1e78a000/i2c-bus@80/ipmb1@10:reg:
    I2C address must be less than 10-bits, got "0x40000010"

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Message-Id: <20200622031005.1890039-2-joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-22 17:52:50 +10:00
Patrick Oppenlander
2478b1652c libfdt: add extern "C" for C++
Signed-off-by: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Message-Id: <20200616011217.15253-1-patrick.oppenlander@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-19 09:52:41 +10:00
Patrick Oppenlander
f68bfc2668 libfdt: trivial typo fix
Signed-off-by: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Message-Id: <20200618042117.131731-1-patrick.oppenlander@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-18 16:26:37 +10:00
Simon Glass
7be250b4d0 libfdt: Correct condition for reordering blocks
This condition uses bitwise OR but should be logical OR. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: kernel test robot <lkp@intel.com>
Message-Id: <20200615160033.87328-1-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-06-16 13:12:43 +10:00
Andre Przywara
81e0919a3e checks: Add interrupt provider test
An interrupt provider (an actual interrupt-controller node or an
interrupt nexus) should have both #address-cells and #interrupt-cells
properties explicitly defined.

Add an extra test for this. We check for the #interrupt-cells property
already, but this does not cover every controller so far, only those that
get referenced by an interrupts property in some node. Also we miss
interrupt nexus nodes.

A missing #address-cells property is less critical, but creates
ambiguities when used in interrupt-map properties, so warn about this as
well now.
This removes the now redundant warning in the existing interrupts test.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20200515141827.27957-2-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-05-18 14:26:12 +10:00
Claudio Fontana
85e5d83984 Makefile: when building libfdt only, do not add unneeded deps
implemented originally for the QEMU consumer of libfdt.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Message-Id: <20200512103315.1926-1-cfontana@suse.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-05-14 17:11:53 +10:00
David Gibson
b28464a550 Fix some potential unaligned accesses in dtc
Because of the convention of packed representations in property layouts,
it's not uncommon to have integer values in properties which aren't
naturally aligned.  Thus, there are several places in the dtc code where we
cast a potentially unaligned byte pointer into an integer pointer and load
it directly.  On a number of architectures (including sparc64 and arm) this
won't work and will cause a fault.  In some cases it may be trapped and
emulated by the kernel, but not always.

Therefore, replace such direct unaligned reads with a helper which will
handle unaligned data reads (a variant on the fdtXX_ld() functions already
used in libfdt).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 15:02:51 +10:00
Arkadiusz Drabczyk
87a656ae5f check: Inform about missing ranges
In check_unit_address_vs_reg() warning message already says 'reg _or_
ranges' when reg or ranges are present but unit name is missing.  Add
this message for compatibility to say "reg _or_ ranges" when unit name
is present but neither reg nor ranges are present.

Signed-off-by: Arkadiusz Drabczyk <arkadiusz@drabczyk.org>
Message-Id: <20200308165643.19281-1-arkadiusz@drabczyk.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-10 11:44:23 +11:00
Jan Beulich
73d6e9ecb4 libfdt: fix undefined behaviour in fdt_splice_()
libfdt: fix undefined behaviour in fdt_splice_()

Along the lines of commit d0b3ab0a0f ("libfdt: Fix undefined behaviour
in fdt_offset_ptr()"), fdt_splice_() similarly may not use pointer
arithmetic to do overflow checks. (The left side of the checks added by
d4c7c25c9e ["libfdt: check for potential overrun in _fdt_splice()"]
doesn't really lend itself to similar replacement though.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Message-Id: <f2d09e81-7cb8-c5cc-9699-1ac05b0626ff@suse.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-06 12:58:54 +11:00
David Gibson
2525da3dba Bump version to v1.6.0
We've accumulated some new features and a bunch of fixes.  Also the
versioning on v1.5.1 was messed up :(.  Prepare for another release.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04 17:14:58 +11:00
David Gibson
62cb4ad286 Execute tests on FreeBSD with Cirrus CI
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04 16:40:00 +11:00
David Gibson
1f9a417508 tests: Allow running the testsuite on already installed binary / libraries
Currently the test runner script always expects to be run from within the
tests/ subdirectory of a dtc source tree: it looks for dtc and other
binaries in the parent of the current directory and for the libfdt shared
library in ../libfdt.

That works great with make check and for testing a build you've just made.
However, sometimes it's useful to test a dtc & libfdt which have already
been installed on the system, or which for whatever reason are located
somewhere else.

This patch allows the test runner script to do this when TEST_BINDIR and/or
TEST_LIBDIR environment variables are set.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04 16:38:04 +11:00
David Gibson
c5995ddf4c tests: Honour NO_YAML make variable
Support for YAML output in dtc is optional (to cover systems that don't
have libyaml).  Currently the tests for yaml output test if the libyaml
package is locally installed.

That duplicates similar logic in the Makefile, and worse it will cause
failed tests if the user explicitly disables YAML support, rather than
simply not having libyaml installed.

Fix this by having the test script use the NO_YAML variable exported by
make.  Fall back to the current test if the variable isn't set, such as
when running the script manually.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04 16:10:06 +11:00