2019-11-01 06:19:05

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 0/3] libfdt: prepare for (U)INT32_MAX addition


As you may know, libfdt in the upstream DTC project
added referenced to (U)INT32_MAX.

The kernel code has three files to adjust:

include/linux/libfdt_env.h
arch/powerpc/boot/libfdt_env.h
arch/arm/boot/compressed/libfdt_env.h

Instead of fixing arch/arm/boot/compressed/libfdt_env.h,
it is pretty easy to refactor the ARM decompressor
to reuse <linux/lbifdt_env.h>
So, 2/3 simplifies the Makefile and deletes its own
libfdt_env.h

On the other hand, the PPC boot-wrapper is a can of worms.
I give up refactoring it.
Let's keep it closed, and just update arch/powerpc/boot/libfdt_env.h



Masahiro Yamada (3):
libfdt: add SPDX-License-Identifier to libfdt wrappers
ARM: decompressor: simplify libfdt builds
libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h

arch/arm/boot/compressed/.gitignore | 9 -------
arch/arm/boot/compressed/Makefile | 33 +++++++------------------
arch/arm/boot/compressed/atags_to_fdt.c | 1 +
arch/arm/boot/compressed/fdt.c | 2 ++
arch/arm/boot/compressed/fdt_ro.c | 2 ++
arch/arm/boot/compressed/fdt_rw.c | 2 ++
arch/arm/boot/compressed/fdt_wip.c | 2 ++
arch/arm/boot/compressed/libfdt_env.h | 22 -----------------
arch/powerpc/boot/libfdt_env.h | 2 ++
include/linux/libfdt_env.h | 3 +++
lib/fdt.c | 1 +
lib/fdt_empty_tree.c | 1 +
lib/fdt_ro.c | 1 +
lib/fdt_rw.c | 1 +
lib/fdt_strerror.c | 1 +
lib/fdt_sw.c | 1 +
lib/fdt_wip.c | 1 +
17 files changed, 30 insertions(+), 55 deletions(-)
create mode 100644 arch/arm/boot/compressed/fdt.c
create mode 100644 arch/arm/boot/compressed/fdt_ro.c
create mode 100644 arch/arm/boot/compressed/fdt_rw.c
create mode 100644 arch/arm/boot/compressed/fdt_wip.c
delete mode 100644 arch/arm/boot/compressed/libfdt_env.h

--
2.17.1


2019-11-01 06:20:45

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 3/3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h

The libfdt in the upstream DTC project added references to (U)INT32_MAX
by the following commits:

Commit 812b1956a076 ("libfdt: Tweak data handling to satisfy Coverity")
Commit 7fcf8208b8a9 ("libfdt: add fdt_append_addrrange()")

The kernel needs to adjust libfdt_env.h before pulling in the changes.

As for the user-space programs, <stdint.h> defines (U)INT32_MAX along
with (u)int32_t.

In the kernel, on the other hand, we usually use s32 / u32 instead of
(u)int32_t for the fixed-width types.

Accordingly, we already have S32_MAX / U32_MAX for their max values.
So, we won't add (U)INT32_MAX to <linux/limits.h> any more.

Instead, add them to the in-kernel libfdt_env.h to compile fdt.c and
fdt_addresses.c

Signed-off-by: Masahiro Yamada <[email protected]>
---

arch/powerpc/boot/libfdt_env.h | 2 ++
include/linux/libfdt_env.h | 3 +++
2 files changed, 5 insertions(+)

diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h
index 2abc8e83b95e..a4a386114ef5 100644
--- a/arch/powerpc/boot/libfdt_env.h
+++ b/arch/powerpc/boot/libfdt_env.h
@@ -6,6 +6,8 @@
#include <string.h>

#define INT_MAX ((int)(~0U>>1))
+#define INT32_MAX ((u32)~0U)
+#define UINT32_MAX ((s32)(INT_MAX >> 1))

#include "of.h"

diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h
index edb0f0c30904..0bd83bdb2482 100644
--- a/include/linux/libfdt_env.h
+++ b/include/linux/libfdt_env.h
@@ -11,6 +11,9 @@ typedef __be16 fdt16_t;
typedef __be32 fdt32_t;
typedef __be64 fdt64_t;

+#define INT32_MAX S32_MAX
+#define UINT32_MAX U32_MAX
+
#define fdt32_to_cpu(x) be32_to_cpu(x)
#define cpu_to_fdt32(x) cpu_to_be32(x)
#define fdt64_to_cpu(x) be64_to_cpu(x)
--
2.17.1

2019-11-01 06:30:25

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 1/3] libfdt: add SPDX-License-Identifier to libfdt wrappers

These are kernel source code even though they are just two-line wrappers.

Files without explicit license information fall back to GPL-2.0-only,
which is the project default.

Signed-off-by: Masahiro Yamada <[email protected]>
---

lib/fdt.c | 1 +
lib/fdt_empty_tree.c | 1 +
lib/fdt_ro.c | 1 +
lib/fdt_rw.c | 1 +
lib/fdt_strerror.c | 1 +
lib/fdt_sw.c | 1 +
lib/fdt_wip.c | 1 +
7 files changed, 7 insertions(+)

diff --git a/lib/fdt.c b/lib/fdt.c
index 97f20069fc37..041f8922a23c 100644
--- a/lib/fdt.c
+++ b/lib/fdt.c
@@ -1,2 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt.c"
diff --git a/lib/fdt_empty_tree.c b/lib/fdt_empty_tree.c
index 5d30c58150ad..452221227bf3 100644
--- a/lib/fdt_empty_tree.c
+++ b/lib/fdt_empty_tree.c
@@ -1,2 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_empty_tree.c"
diff --git a/lib/fdt_ro.c b/lib/fdt_ro.c
index f73c04ea7be4..9f696d19f060 100644
--- a/lib/fdt_ro.c
+++ b/lib/fdt_ro.c
@@ -1,2 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_ro.c"
diff --git a/lib/fdt_rw.c b/lib/fdt_rw.c
index 0c1f0f4a4b13..2a61e9c6dd44 100644
--- a/lib/fdt_rw.c
+++ b/lib/fdt_rw.c
@@ -1,2 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_rw.c"
diff --git a/lib/fdt_strerror.c b/lib/fdt_strerror.c
index 8713e3ff4707..4554e5fdac12 100644
--- a/lib/fdt_strerror.c
+++ b/lib/fdt_strerror.c
@@ -1,2 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_strerror.c"
diff --git a/lib/fdt_sw.c b/lib/fdt_sw.c
index 9ac7e50c76ce..d3345ca399cf 100644
--- a/lib/fdt_sw.c
+++ b/lib/fdt_sw.c
@@ -1,2 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_sw.c"
diff --git a/lib/fdt_wip.c b/lib/fdt_wip.c
index 45b3fc3d3ba1..9674d4c3b115 100644
--- a/lib/fdt_wip.c
+++ b/lib/fdt_wip.c
@@ -1,2 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_wip.c"
--
2.17.1

2019-11-04 14:02:47

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 1/3] libfdt: add SPDX-License-Identifier to libfdt wrappers

On Fri, Nov 1, 2019 at 1:19 AM Masahiro Yamada
<[email protected]> wrote:
>
> These are kernel source code even though they are just two-line wrappers.
>
> Files without explicit license information fall back to GPL-2.0-only,
> which is the project default.

That is true and these are kernel only files, but given they are just
a wrapper around the .c files, maybe they should have the same
license?

Rob

2019-11-05 01:46:51

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 1/3] libfdt: add SPDX-License-Identifier to libfdt wrappers

Hi Rob,
(+CC: David Daney)

On Mon, Nov 4, 2019 at 11:00 PM Rob Herring <[email protected]> wrote:
>
> On Fri, Nov 1, 2019 at 1:19 AM Masahiro Yamada
> <[email protected]> wrote:
> >
> > These are kernel source code even though they are just two-line wrappers.
> >
> > Files without explicit license information fall back to GPL-2.0-only,
> > which is the project default.
>
> That is true and these are kernel only files, but given they are just
> a wrapper around the .c files, maybe they should have the same
> license?


I just thought it at first
but this wraps two files, with different license.

include/linux/libfdt_env.h: GPLv2 only
scripts/dtc/libfdt/fdt*.c : GPLv2+ or BSD-2-Clause


Looking at the include/linux/libfdt_env.h,
I thought GPLv2 only would be preferred for
the kernel-specific code.

If you prefer to align with scripts/dtc/libfdt/fdt*.c
I can change it, but I would also respect
the opinion from David Daney, the author of the
following commit:


commit ab25383983fb8d7786696f5371e75e79c3e9a405
Author: David Daney <[email protected]>
Date: Thu Jul 5 18:12:38 2012 +0200

of/lib: Allow scripts/dtc/libfdt to be used from kernel code



--
Best Regards
Masahiro Yamada