* [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage
@ 2022-04-04 6:19 Masahiro Yamada
2022-04-04 6:19 ` [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header Masahiro Yamada
` (8 more replies)
0 siblings, 9 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
Here are more efforts to put more headers to UAPI compile testing
(CONFIG_UAPI_HEADER_TEST).
I am sending this series to Arnd because he has deep knowledge for the
kernel APIs and manages asm-generic pull requests.
Masahiro Yamada (8):
agpgart.h: do not include <stdlib.h> from exported header
kbuild: prevent exported headers from including <stdlib.h>,
<stdbool.h>
riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage
mips: add asm/stat.h to UAPI compile-test coverage
powerpc: add asm/stat.h to UAPI compile-test coverage
sparc: add asm/stat.h to UAPI compile-test coverage
posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h
virtio_ring.h: do not include <stdint.h> from exported header
arch/h8300/include/uapi/asm/posix_types.h | 1 +
arch/mips/include/uapi/asm/stat.h | 20 ++++++++++----------
arch/powerpc/include/uapi/asm/stat.h | 10 +++++-----
arch/s390/include/uapi/asm/posix_types.h | 2 ++
arch/sparc/include/uapi/asm/posix_types.h | 1 +
arch/sparc/include/uapi/asm/stat.h | 12 ++++++------
arch/xtensa/include/uapi/asm/posix_types.h | 1 +
include/linux/types.h | 2 +-
include/uapi/asm-generic/posix_types.h | 2 ++
include/uapi/linux/agpgart.h | 9 ++++-----
include/uapi/linux/virtio_ring.h | 6 ++----
tools/arch/h8300/include/asm/bitsperlong.h | 1 +
usr/dummy-include/stdbool.h | 7 +++++++
usr/dummy-include/stdlib.h | 7 +++++++
usr/include/Makefile | 12 +-----------
15 files changed, 51 insertions(+), 42 deletions(-)
create mode 100644 usr/dummy-include/stdbool.h
create mode 100644 usr/dummy-include/stdlib.h
--
2.32.0
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 7:40 ` Christoph Hellwig
2022-04-04 17:27 ` Nick Desaulniers
2022-04-04 6:19 ` [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h> Masahiro Yamada
` (7 subsequent siblings)
8 siblings, 2 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
Commit 35d0f1d54ecd ("include/uapi/linux/agpgart.h: include stdlib.h in
userspace") included <stdlib.h> to fix the unknown size_t error, but
I do not think it is the right fix.
This header already uses __kernel_size_t a few lines below.
Replace the remaining size_t, and stop including <stdlib.h>.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
include/uapi/linux/agpgart.h | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/include/uapi/linux/agpgart.h b/include/uapi/linux/agpgart.h
index f5251045181a..9cc3448c0b5b 100644
--- a/include/uapi/linux/agpgart.h
+++ b/include/uapi/linux/agpgart.h
@@ -52,7 +52,6 @@
#ifndef __KERNEL__
#include <linux/types.h>
-#include <stdlib.h>
struct agp_version {
__u16 major;
@@ -64,10 +63,10 @@ typedef struct _agp_info {
__u32 bridge_id; /* bridge vendor/device */
__u32 agp_mode; /* mode info of bridge */
unsigned long aper_base;/* base of aperture */
- size_t aper_size; /* size of aperture */
- size_t pg_total; /* max pages (swap + system) */
- size_t pg_system; /* max pages (system) */
- size_t pg_used; /* current pages used */
+ __kernel_size_t aper_size; /* size of aperture */
+ __kernel_size_t pg_total; /* max pages (swap + system) */
+ __kernel_size_t pg_system; /* max pages (system) */
+ __kernel_size_t pg_used; /* current pages used */
} agp_info;
typedef struct _agp_setup {
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
2022-04-04 6:19 ` [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 7:41 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 3/8] riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage Masahiro Yamada
` (6 subsequent siblings)
8 siblings, 1 reply; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel
Cc: linux-kbuild, linux-arch, Masahiro Yamada, Greg Kroah-Hartman
Some UAPI headers included <stdlib.h>, like this:
#ifndef __KERNEL__
#include <stdlib.h>
#endif
As it turned out, they just included it for no good reason.
After some fixes, now I can compile-test UAPI headers
(CONFIG_UAPI_HEADER_TEST=y) without including <stdlib.h> from the
system header search paths.
To avoid somebody getting it back again, this commit adds the dummy
header, usr/dummy-include/stdlib.h
I added $(srctree)/usr/dummy-include to the header search paths.
Because it is searched before the system directories, if someone
tries to include <stdlib.h>, they will see the error message.
While I am here, I also replaced $(objtree)/usr/include with $(obj),
but it has no functional change.
If we can make kernel headers self-contained (that is, none of exported
kernel headers includes system headers), we will be able to add the
-nostdinc flag, but that is much far from where we stand now.
As a realistic solution, we can ban header inclusion individually by
putting a dummy header into usr/dummy-include/.
Currently, no header include <stdbool.h>. I put it as well before somebody
attempts to use it.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
usr/dummy-include/stdbool.h | 7 +++++++
usr/dummy-include/stdlib.h | 7 +++++++
usr/include/Makefile | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 usr/dummy-include/stdbool.h
create mode 100644 usr/dummy-include/stdlib.h
diff --git a/usr/dummy-include/stdbool.h b/usr/dummy-include/stdbool.h
new file mode 100644
index 000000000000..54ff9e9c90ac
--- /dev/null
+++ b/usr/dummy-include/stdbool.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+#error "Please do not include <stdbool.h> from exported headers"
+
+#endif /* _STDBOOL_H */
diff --git a/usr/dummy-include/stdlib.h b/usr/dummy-include/stdlib.h
new file mode 100644
index 000000000000..e8c21888e371
--- /dev/null
+++ b/usr/dummy-include/stdlib.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+#error "Please do not include <stdlib.h> from exported headers"
+
+#endif /* _STDLIB_H */
diff --git a/usr/include/Makefile b/usr/include/Makefile
index fa9819e022b7..7740777b49f8 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -15,7 +15,7 @@ UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
# USERCFLAGS might contain sysroot location for CC.
UAPI_CFLAGS += $(USERCFLAGS)
-override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include
+override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include
# The following are excluded for now because they fail to build.
#
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 3/8] riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
2022-04-04 6:19 ` [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header Masahiro Yamada
2022-04-04 6:19 ` [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h> Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 7:41 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 4/8] mips: add asm/stat.h " Masahiro Yamada
` (5 subsequent siblings)
8 siblings, 1 reply; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
I can compile this for ARCH=riscv with CONFIG_UAPI_HEADER_TEST=y.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
usr/include/Makefile | 4 ----
1 file changed, 4 deletions(-)
diff --git a/usr/include/Makefile b/usr/include/Makefile
index 7740777b49f8..a1a8403896cf 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -74,10 +74,6 @@ no-header-test += asm/stat.h
no-header-test += linux/bpf_perf_event.h
endif
-ifeq ($(SRCARCH),riscv)
-no-header-test += linux/bpf_perf_event.h
-endif
-
ifeq ($(SRCARCH),sparc)
no-header-test += asm/stat.h
no-header-test += asm/uctx.h
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 4/8] mips: add asm/stat.h to UAPI compile-test coverage
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
` (2 preceding siblings ...)
2022-04-04 6:19 ` [PATCH 3/8] riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 7:42 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 5/8] powerpc: " Masahiro Yamada
` (4 subsequent siblings)
8 siblings, 1 reply; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
asm/stat.h is currently excluded from the UAPI compile-test for
ARCH=mips because of the errors like follows:
HDRTEST usr/include/asm/stat.h
In file included from <command-line>:32:
./usr/include/asm/stat.h:22:2: error: unknown type name 'ino_t'
22 | ino_t st_ino;
| ^~~~~
./usr/include/asm/stat.h:23:2: error: unknown type name 'mode_t'
23 | mode_t st_mode;
| ^~~~~~
./usr/include/asm/stat.h:25:2: error: unknown type name 'uid_t'
25 | uid_t st_uid;
| ^~~~~
./usr/include/asm/stat.h:26:2: error: unknown type name 'gid_t'
26 | gid_t st_gid;
| ^~~~~
./usr/include/asm/stat.h:58:2: error: unknown type name 'mode_t'
58 | mode_t st_mode;
| ^~~~~~
./usr/include/asm/stat.h:61:2: error: unknown type name 'uid_t'
61 | uid_t st_uid;
| ^~~~~
./usr/include/asm/stat.h:62:2: error: unknown type name 'gid_t'
62 | gid_t st_gid;
| ^~~~~
The errors can be fixed by prefixing the types with __kernel_.
Then, remove the no-header-test entry from user/include/Makefile.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
arch/mips/include/uapi/asm/stat.h | 20 ++++++++++----------
usr/include/Makefile | 4 ----
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/arch/mips/include/uapi/asm/stat.h b/arch/mips/include/uapi/asm/stat.h
index 3d2a3b71845c..8a8bb78883a4 100644
--- a/arch/mips/include/uapi/asm/stat.h
+++ b/arch/mips/include/uapi/asm/stat.h
@@ -19,11 +19,11 @@
struct stat {
unsigned st_dev;
long st_pad1[3]; /* Reserved for network id */
- ino_t st_ino;
- mode_t st_mode;
+ __kernel_ino_t st_ino;
+ __kernel_mode_t st_mode;
__u32 st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid_t st_uid;
+ __kernel_gid_t st_gid;
unsigned st_rdev;
long st_pad2[2];
long st_size;
@@ -55,11 +55,11 @@ struct stat64 {
unsigned long long st_ino;
- mode_t st_mode;
+ __kernel_mode_t st_mode;
__u32 st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid_t st_uid;
+ __kernel_gid_t st_gid;
unsigned long st_rdev;
unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
@@ -96,11 +96,11 @@ struct stat {
unsigned long st_ino;
- mode_t st_mode;
+ __kernel_mode_t st_mode;
__u32 st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid_t st_uid;
+ __kernel_gid_t st_gid;
unsigned int st_rdev;
unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
diff --git a/usr/include/Makefile b/usr/include/Makefile
index a1a8403896cf..da280bdcb391 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -65,10 +65,6 @@ no-header-test += asm/sigcontext.h
no-header-test += linux/if_bonding.h
endif
-ifeq ($(SRCARCH),mips)
-no-header-test += asm/stat.h
-endif
-
ifeq ($(SRCARCH),powerpc)
no-header-test += asm/stat.h
no-header-test += linux/bpf_perf_event.h
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 5/8] powerpc: add asm/stat.h to UAPI compile-test coverage
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
` (3 preceding siblings ...)
2022-04-04 6:19 ` [PATCH 4/8] mips: add asm/stat.h " Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 7:42 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 6/8] sparc: " Masahiro Yamada
` (3 subsequent siblings)
8 siblings, 1 reply; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
asm/stat.h is currently excluded from the UAPI compile-test for
ARCH=powerpc because of the errors like follows:
HDRTEST usr/include/asm/stat.h
In file included from <command-line>:32:
./usr/include/asm/stat.h:32:2: error: unknown type name 'ino_t'
32 | ino_t st_ino;
| ^~~~~
./usr/include/asm/stat.h:35:2: error: unknown type name 'mode_t'
35 | mode_t st_mode;
| ^~~~~~
./usr/include/asm/stat.h:40:2: error: unknown type name 'uid_t'
40 | uid_t st_uid;
| ^~~~~
./usr/include/asm/stat.h:41:2: error: unknown type name 'gid_t'
41 | gid_t st_gid;
| ^~~~~
The errors can be fixed by prefixing the types with __kernel_.
Then, remove the no-header-test entry from user/include/Makefile.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
arch/powerpc/include/uapi/asm/stat.h | 10 +++++-----
usr/include/Makefile | 1 -
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/uapi/asm/stat.h b/arch/powerpc/include/uapi/asm/stat.h
index 7871055e5e32..a28c9a1201fa 100644
--- a/arch/powerpc/include/uapi/asm/stat.h
+++ b/arch/powerpc/include/uapi/asm/stat.h
@@ -29,16 +29,16 @@ struct __old_kernel_stat {
struct stat {
unsigned long st_dev;
- ino_t st_ino;
+ __kernel_ino_t st_ino;
#ifdef __powerpc64__
unsigned long st_nlink;
- mode_t st_mode;
+ __kernel_mode_t st_mode;
#else
- mode_t st_mode;
+ __kernel_mode_t st_mode;
unsigned short st_nlink;
#endif
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid_t st_uid;
+ __kernel_gid_t st_gid;
unsigned long st_rdev;
long st_size;
unsigned long st_blksize;
diff --git a/usr/include/Makefile b/usr/include/Makefile
index da280bdcb391..9d9dea32e3a0 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -66,7 +66,6 @@ no-header-test += linux/if_bonding.h
endif
ifeq ($(SRCARCH),powerpc)
-no-header-test += asm/stat.h
no-header-test += linux/bpf_perf_event.h
endif
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 6/8] sparc: add asm/stat.h to UAPI compile-test coverage
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
` (4 preceding siblings ...)
2022-04-04 6:19 ` [PATCH 5/8] powerpc: " Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 7:43 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h Masahiro Yamada
` (2 subsequent siblings)
8 siblings, 1 reply; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
asm/stat.h is currently excluded from the UAPI compile-test for
ARCH=sparc because of the errors like follows:
In file included from <command-line>:
./usr/include/asm/stat.h:11:2: error: unknown type name 'ino_t'
11 | ino_t st_ino;
| ^~~~~
HDRTEST usr/include/asm/param.h
./usr/include/asm/stat.h:12:2: error: unknown type name 'mode_t'
12 | mode_t st_mode;
| ^~~~~~
./usr/include/asm/stat.h:14:2: error: unknown type name 'uid_t'
14 | uid_t st_uid;
| ^~~~~
./usr/include/asm/stat.h:15:2: error: unknown type name 'gid_t'
15 | gid_t st_gid;
| ^~~~~
The errors can be fixed by prefixing the types with __kernel_.
Then, remove the no-header-test entry from user/include/Makefile.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
arch/sparc/include/uapi/asm/stat.h | 12 ++++++------
usr/include/Makefile | 1 -
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/arch/sparc/include/uapi/asm/stat.h b/arch/sparc/include/uapi/asm/stat.h
index 732c41720e24..e03d6f8ec301 100644
--- a/arch/sparc/include/uapi/asm/stat.h
+++ b/arch/sparc/include/uapi/asm/stat.h
@@ -8,11 +8,11 @@
/* 64 bit sparc */
struct stat {
unsigned int st_dev;
- ino_t st_ino;
- mode_t st_mode;
+ __kernel_ino_t st_ino;
+ __kernel_mode_t st_mode;
short st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid_t st_uid;
+ __kernel_gid_t st_gid;
unsigned int st_rdev;
long st_size;
long st_atime;
@@ -51,8 +51,8 @@ struct stat64 {
/* 32 bit sparc */
struct stat {
unsigned short st_dev;
- ino_t st_ino;
- mode_t st_mode;
+ __kernel_ino_t st_ino;
+ __kernel_mode_t st_mode;
short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
diff --git a/usr/include/Makefile b/usr/include/Makefile
index 9d9dea32e3a0..e2615b9b0402 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -70,7 +70,6 @@ no-header-test += linux/bpf_perf_event.h
endif
ifeq ($(SRCARCH),sparc)
-no-header-test += asm/stat.h
no-header-test += asm/uctx.h
no-header-test += asm/fbio.h
endif
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
` (5 preceding siblings ...)
2022-04-04 6:19 ` [PATCH 6/8] sparc: " Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 11:30 ` kernel test robot
` (2 more replies)
2022-04-04 6:19 ` [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header Masahiro Yamada
2022-04-04 7:34 ` [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Arnd Bergmann
8 siblings, 3 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
This will allow us to replace uintptr_t with __kernel_uintptr_t in
exported headers. I think this is acceptable because we already have
__kernel_ptrdiff_t.
Define __kernel_uintptr_t in the same ways as __kernel_ptrdiff_t
but with 'unsigned' qualifier.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
arch/h8300/include/uapi/asm/posix_types.h | 1 +
arch/s390/include/uapi/asm/posix_types.h | 2 ++
arch/sparc/include/uapi/asm/posix_types.h | 1 +
arch/xtensa/include/uapi/asm/posix_types.h | 1 +
include/linux/types.h | 2 +-
include/uapi/asm-generic/posix_types.h | 2 ++
tools/arch/h8300/include/asm/bitsperlong.h | 1 +
7 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/h8300/include/uapi/asm/posix_types.h b/arch/h8300/include/uapi/asm/posix_types.h
index 3efc9dd59476..9728120c6742 100644
--- a/arch/h8300/include/uapi/asm/posix_types.h
+++ b/arch/h8300/include/uapi/asm/posix_types.h
@@ -7,6 +7,7 @@
typedef unsigned long __kernel_size_t;
typedef long __kernel_ssize_t;
typedef long __kernel_ptrdiff_t;
+typedef unsigned long __kernel_uintptr_t;
#include <asm-generic/posix_types.h>
diff --git a/arch/s390/include/uapi/asm/posix_types.h b/arch/s390/include/uapi/asm/posix_types.h
index 1913613e71b6..2c700a44bf83 100644
--- a/arch/s390/include/uapi/asm/posix_types.h
+++ b/arch/s390/include/uapi/asm/posix_types.h
@@ -34,6 +34,7 @@ typedef unsigned short __kernel_ipc_pid_t;
typedef unsigned short __kernel_uid_t;
typedef unsigned short __kernel_gid_t;
typedef int __kernel_ptrdiff_t;
+typedef unsigned int __kernel_uintptr_t;
#else /* __s390x__ */
@@ -43,6 +44,7 @@ typedef int __kernel_ipc_pid_t;
typedef unsigned int __kernel_uid_t;
typedef unsigned int __kernel_gid_t;
typedef long __kernel_ptrdiff_t;
+typedef unsigned long __kernel_uintptr_t;
typedef unsigned long __kernel_sigset_t; /* at least 32 bits */
#endif /* __s390x__ */
diff --git a/arch/sparc/include/uapi/asm/posix_types.h b/arch/sparc/include/uapi/asm/posix_types.h
index f139e0048628..402e1656e3b5 100644
--- a/arch/sparc/include/uapi/asm/posix_types.h
+++ b/arch/sparc/include/uapi/asm/posix_types.h
@@ -35,6 +35,7 @@ struct __kernel_old_timeval {
typedef unsigned int __kernel_size_t;
typedef int __kernel_ssize_t;
typedef long int __kernel_ptrdiff_t;
+typedef unsigned long __kernel_uintptr_t;
#define __kernel_size_t __kernel_size_t
typedef unsigned short __kernel_ipc_pid_t;
diff --git a/arch/xtensa/include/uapi/asm/posix_types.h b/arch/xtensa/include/uapi/asm/posix_types.h
index 1dc67592881f..5ba366f6c789 100644
--- a/arch/xtensa/include/uapi/asm/posix_types.h
+++ b/arch/xtensa/include/uapi/asm/posix_types.h
@@ -26,6 +26,7 @@ typedef unsigned short __kernel_ipc_pid_t;
typedef unsigned int __kernel_size_t;
typedef int __kernel_ssize_t;
typedef long __kernel_ptrdiff_t;
+typedef unsigned long __kernel_uintptr_t;
#define __kernel_size_t __kernel_size_t
typedef unsigned short __kernel_old_uid_t;
diff --git a/include/linux/types.h b/include/linux/types.h
index ea8cf60a8a79..a54335007fe2 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -34,7 +34,7 @@ typedef __kernel_gid32_t gid_t;
typedef __kernel_uid16_t uid16_t;
typedef __kernel_gid16_t gid16_t;
-typedef unsigned long uintptr_t;
+typedef __kernel_uintptr_t uintptr_t;
#ifdef CONFIG_HAVE_UID16
/* This is defined by include/asm-{arch}/posix_types.h */
diff --git a/include/uapi/asm-generic/posix_types.h b/include/uapi/asm-generic/posix_types.h
index b5f7594eee7a..4a7c5b852e38 100644
--- a/include/uapi/asm-generic/posix_types.h
+++ b/include/uapi/asm-generic/posix_types.h
@@ -68,10 +68,12 @@ typedef unsigned int __kernel_old_dev_t;
typedef unsigned int __kernel_size_t;
typedef int __kernel_ssize_t;
typedef int __kernel_ptrdiff_t;
+typedef unsigned int __kernel_uintptr_t;
#else
typedef __kernel_ulong_t __kernel_size_t;
typedef __kernel_long_t __kernel_ssize_t;
typedef __kernel_long_t __kernel_ptrdiff_t;
+typedef __kernel_ulong_t __kernel_uintptr_t;
#endif
#endif
diff --git a/tools/arch/h8300/include/asm/bitsperlong.h b/tools/arch/h8300/include/asm/bitsperlong.h
index fa1508337ffc..fea7dc923006 100644
--- a/tools/arch/h8300/include/asm/bitsperlong.h
+++ b/tools/arch/h8300/include/asm/bitsperlong.h
@@ -10,6 +10,7 @@
typedef unsigned long __kernel_size_t;
typedef long __kernel_ssize_t;
typedef long __kernel_ptrdiff_t;
+typedef unsigned long __kernel_uintptr_t;
#endif
#endif /* __ASM_H8300_BITS_PER_LONG */
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
` (6 preceding siblings ...)
2022-04-04 6:19 ` [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h Masahiro Yamada
@ 2022-04-04 6:19 ` Masahiro Yamada
2022-04-04 7:44 ` Christoph Hellwig
2022-04-05 11:57 ` Michael S. Tsirkin
2022-04-04 7:34 ` [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Arnd Bergmann
8 siblings, 2 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 6:19 UTC (permalink / raw)
To: Arnd Bergmann, linux-kernel; +Cc: linux-kbuild, linux-arch, Masahiro Yamada
Arnd mentioned a limitation when including <stdint.h> from UAPI
headers. [1]
Besides, I'd like exported headers to be as compliant with the
traditional C as possible.
In fact, the UAPI headers are compile-tested with -std=c90 (see
usr/include/Makefile) even though the kernel itself is now built
with -std=gnu11.
Currently, include/uapi/linux/virtio_ring.h includes <stdint.h>
presumably because it uses uintptr_t.
Replace it with __kernel_uintptr_t, and stop including <stdint.h>.
[1]: https://lore.kernel.org/all/CAK8P3a0bz8XYJOsmND2=CT_oTDmGMJGaRo9+QMroEhpekSMEaQ@mail.gmail.com/
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
include/uapi/linux/virtio_ring.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
index 476d3e5c0fe7..6329e4ff35f4 100644
--- a/include/uapi/linux/virtio_ring.h
+++ b/include/uapi/linux/virtio_ring.h
@@ -31,9 +31,7 @@
* SUCH DAMAGE.
*
* Copyright Rusty Russell IBM Corporation 2007. */
-#ifndef __KERNEL__
-#include <stdint.h>
-#endif
+
#include <linux/types.h>
#include <linux/virtio_types.h>
@@ -196,7 +194,7 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
vr->num = num;
vr->desc = p;
vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
- vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
+ vr->used = (void *)(((__kernel_uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
+ align-1) & ~(align - 1));
}
--
2.32.0
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
` (7 preceding siblings ...)
2022-04-04 6:19 ` [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header Masahiro Yamada
@ 2022-04-04 7:34 ` Arnd Bergmann
2022-05-13 8:43 ` Masahiro Yamada
8 siblings, 1 reply; 39+ messages in thread
From: Arnd Bergmann @ 2022-04-04 7:34 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Arnd Bergmann, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch
On Mon, Apr 4, 2022 at 8:19 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
>
> Here are more efforts to put more headers to UAPI compile testing
> (CONFIG_UAPI_HEADER_TEST).
>
> I am sending this series to Arnd because he has deep knowledge for the
> kernel APIs and manages asm-generic pull requests.
These all look good to me, I can apply them for 5.19 but would wait
a few days for others to comment.
Arnd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header
2022-04-04 6:19 ` [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header Masahiro Yamada
@ 2022-04-04 7:40 ` Christoph Hellwig
2022-04-04 17:27 ` Nick Desaulniers
1 sibling, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-04 7:40 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 3/8] riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage
2022-04-04 6:19 ` [PATCH 3/8] riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage Masahiro Yamada
@ 2022-04-04 7:41 ` Christoph Hellwig
0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-04 7:41 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>
2022-04-04 6:19 ` [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h> Masahiro Yamada
@ 2022-04-04 7:41 ` Christoph Hellwig
2022-04-04 8:01 ` Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-04 7:41 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch,
Greg Kroah-Hartman
On Mon, Apr 04, 2022 at 03:19:42PM +0900, Masahiro Yamada wrote:
> If we can make kernel headers self-contained (that is, none of exported
> kernel headers includes system headers), we will be able to add the
> -nostdinc flag, but that is much far from where we stand now.
What is still missing for that?
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 4/8] mips: add asm/stat.h to UAPI compile-test coverage
2022-04-04 6:19 ` [PATCH 4/8] mips: add asm/stat.h " Masahiro Yamada
@ 2022-04-04 7:42 ` Christoph Hellwig
0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-04 7:42 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 5/8] powerpc: add asm/stat.h to UAPI compile-test coverage
2022-04-04 6:19 ` [PATCH 5/8] powerpc: " Masahiro Yamada
@ 2022-04-04 7:42 ` Christoph Hellwig
0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-04 7:42 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 6/8] sparc: add asm/stat.h to UAPI compile-test coverage
2022-04-04 6:19 ` [PATCH 6/8] sparc: " Masahiro Yamada
@ 2022-04-04 7:43 ` Christoph Hellwig
0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-04 7:43 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-04 6:19 ` [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header Masahiro Yamada
@ 2022-04-04 7:44 ` Christoph Hellwig
2022-04-04 7:58 ` Masahiro Yamada
` (2 more replies)
2022-04-05 11:57 ` Michael S. Tsirkin
1 sibling, 3 replies; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-04 7:44 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
On Mon, Apr 04, 2022 at 03:19:48PM +0900, Masahiro Yamada wrote:
> vr->num = num;
> vr->desc = p;
> vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
> - vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> + vr->used = (void *)(((__kernel_uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> + align-1) & ~(align - 1));
This really does not look like it should be in a uapi header to start
with.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-04 7:44 ` Christoph Hellwig
@ 2022-04-04 7:58 ` Masahiro Yamada
2022-04-04 8:04 ` Arnd Bergmann
2022-04-05 11:59 ` Michael S. Tsirkin
2 siblings, 0 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 7:58 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Arnd Bergmann, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch
On Mon, Apr 4, 2022 at 4:44 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Mon, Apr 04, 2022 at 03:19:48PM +0900, Masahiro Yamada wrote:
> > vr->num = num;
> > vr->desc = p;
> > vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
> > - vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> > + vr->used = (void *)(((__kernel_uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> > + align-1) & ~(align - 1));
>
> This really does not look like it should be in a uapi header to start
> with.
Then, could you send a proper fix?
I have no idea how to do this...
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>
2022-04-04 7:41 ` Christoph Hellwig
@ 2022-04-04 8:01 ` Arnd Bergmann
2022-04-04 8:03 ` Masahiro Yamada
2022-04-04 17:34 ` Nick Desaulniers
2 siblings, 0 replies; 39+ messages in thread
From: Arnd Bergmann @ 2022-04-04 8:01 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Masahiro Yamada, Arnd Bergmann, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch, Greg Kroah-Hartman
On Mon, Apr 4, 2022 at 9:41 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Mon, Apr 04, 2022 at 03:19:42PM +0900, Masahiro Yamada wrote:
> > If we can make kernel headers self-contained (that is, none of exported
> > kernel headers includes system headers), we will be able to add the
> > -nostdinc flag, but that is much far from where we stand now.
>
> What is still missing for that?
One case that I don't know how to solve is
include/uapi/sound/asound.h:typedef struct { unsigned char
pad[sizeof(time_t) - sizeof(int)]; } __time_pad;
Here we define a structure layout based on a libc-provided type. There are two
possible variants (32-bit and 64-bit time_t), and the kernel interface
can handle
both versions because they get different ioctl command numbers, but user space
must see the one that matches its normal time_t.
There are a couple of similar cases like this, but I think the other ones don't
need to define architecture specific padding like this.
Arnd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>
2022-04-04 7:41 ` Christoph Hellwig
2022-04-04 8:01 ` Arnd Bergmann
@ 2022-04-04 8:03 ` Masahiro Yamada
2022-04-04 17:34 ` Nick Desaulniers
2 siblings, 0 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 8:03 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Arnd Bergmann, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch, Greg Kroah-Hartman
On Mon, Apr 4, 2022 at 4:41 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Mon, Apr 04, 2022 at 03:19:42PM +0900, Masahiro Yamada wrote:
> > If we can make kernel headers self-contained (that is, none of exported
> > kernel headers includes system headers), we will be able to add the
> > -nostdinc flag, but that is much far from where we stand now.
>
> What is still missing for that?
I changed as follows:
diff --git a/usr/include/Makefile b/usr/include/Makefile
index fa9819e022b7..169fca1a0f28 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -15,7 +15,7 @@ UAPI_CFLAGS += $(filter -m32 -m64 --target=%,
$(KBUILD_CFLAGS))
# USERCFLAGS might contain sysroot location for CC.
UAPI_CFLAGS += $(USERCFLAGS)
-override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include
+override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile)
-I$(objtree)/usr/include -nostdinc
# The following are excluded for now because they fail to build.
#
I got this:
masahiro@grover:~/ref/linux$ make -j8 allyesconfig usr/include/
#
# No change to .config
#
DESCEND objtool
CALL scripts/atomic/check-atomics.sh
CALL scripts/checksyscalls.sh
HDRTEST usr/include/linux/wireless.h
HDRTEST usr/include/linux/atmlec.h
HDRTEST usr/include/linux/if_fc.h
HDRTEST usr/include/linux/iso_fs.h
HDRTEST usr/include/linux/sysinfo.h
HDRTEST usr/include/linux/un.h
HDRTEST usr/include/linux/ax25.h
HDRTEST usr/include/linux/map_to_14segment.h
In file included from ./usr/include/linux/wireless.h:75,
from <command-line>:
./usr/include/linux/if.h:28:10: fatal error: sys/socket.h: No such
file or directory
28 | #include <sys/socket.h> /* for struct
sockaddr. */
| ^~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [usr/include/Makefile:101:
usr/include/linux/wireless.hdrtest] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts/Makefile.build:550: usr/include] Error 2
make[1]: *** [Makefile:1834: usr] Error 2
make: *** [Makefile:350: __build_one_by_one] Error 2
--
Best Regards
Masahiro Yamada
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-04 7:44 ` Christoph Hellwig
2022-04-04 7:58 ` Masahiro Yamada
@ 2022-04-04 8:04 ` Arnd Bergmann
2022-04-05 5:35 ` Christoph Hellwig
2022-04-05 11:59 ` Michael S. Tsirkin
2 siblings, 1 reply; 39+ messages in thread
From: Arnd Bergmann @ 2022-04-04 8:04 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Masahiro Yamada, Arnd Bergmann, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch
On Mon, Apr 4, 2022 at 9:44 AM Christoph Hellwig <hch@infradead.org> wrote:
> On Mon, Apr 04, 2022 at 03:19:48PM +0900, Masahiro Yamada wrote:
> > vr->num = num;
> > vr->desc = p;
> > vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
> > - vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> > + vr->used = (void *)(((__kernel_uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> > + align-1) & ~(align - 1));
>
> This really does not look like it should be in a uapi header to start
> with.
The header is shared between kernel and other projects using virtio, such as
qemu and any boot loaders booting from virtio devices. It's not technically a
/kernel/ ABI, but it is an ABI and for practical reasons the kernel version is
maintained as the master copy if I understand it correctly.
Arnd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h
2022-04-04 6:19 ` [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h Masahiro Yamada
@ 2022-04-04 11:30 ` kernel test robot
2022-04-04 11:51 ` Masahiro Yamada
2022-04-04 11:51 ` kernel test robot
2022-04-04 13:04 ` kernel test robot
2 siblings, 1 reply; 39+ messages in thread
From: kernel test robot @ 2022-04-04 11:30 UTC (permalink / raw)
To: Masahiro Yamada, Arnd Bergmann, linux-kernel
Cc: llvm, kbuild-all, linux-kbuild, linux-arch, Masahiro Yamada
Hi Masahiro,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on linux/master v5.18-rc1 next-20220404]
[cannot apply to soc/for-next drm/drm-next powerpc/next uclinux-h8/h8300-next s390/features arnd-asm-generic/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git be2d3ecedd9911fbfd7e55cc9ceac5f8b79ae4cf
config: i386-randconfig-a006 (https://download.01.org/0day-ci/archive/20220404/202204041919.bIUKxOch-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/e8154d995f34b79843e473d85645fb543d554e7f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
git checkout e8154d995f34b79843e473d85645fb543d554e7f
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash sound/soc/fsl/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> sound/soc/fsl/imx-audmux.c:148:40: warning: format specifies type 'unsigned long' but the argument has type 'uintptr_t' (aka 'unsigned int') [-Wformat]
snprintf(buf, sizeof(buf), "ssi%lu", i);
~~~ ^
%u
1 warning generated.
vim +148 sound/soc/fsl/imx-audmux.c
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 139
b8909783a22b4f sound/soc/fsl/imx-audmux.c Lars-Peter Clausen 2014-04-24 140 static void audmux_debugfs_init(void)
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 141 {
e5f89768e9bc1f sound/soc/fsl/imx-audmux.c Mark Brown 2014-08-01 142 uintptr_t i;
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 143 char buf[20];
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 144
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 145 audmux_debugfs_root = debugfs_create_dir("audmux", NULL);
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 146
409b78cc17a4a3 sound/soc/fsl/imx-audmux.c Torben Hohn 2012-07-18 147 for (i = 0; i < MX31_AUDMUX_PORT7_SSI_PINS_7 + 1; i++) {
e5f89768e9bc1f sound/soc/fsl/imx-audmux.c Mark Brown 2014-08-01 @148 snprintf(buf, sizeof(buf), "ssi%lu", i);
227ab8baa15bdd sound/soc/fsl/imx-audmux.c Greg Kroah-Hartman 2019-06-14 149 debugfs_create_file(buf, 0444, audmux_debugfs_root,
227ab8baa15bdd sound/soc/fsl/imx-audmux.c Greg Kroah-Hartman 2019-06-14 150 (void *)i, &audmux_debugfs_fops);
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 151 }
7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 152 }
3bc34a6143359d arch/arm/plat-mxc/audmux.c Richard Zhao 2012-03-05 153
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h
2022-04-04 6:19 ` [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h Masahiro Yamada
2022-04-04 11:30 ` kernel test robot
@ 2022-04-04 11:51 ` kernel test robot
2022-04-04 13:04 ` kernel test robot
2 siblings, 0 replies; 39+ messages in thread
From: kernel test robot @ 2022-04-04 11:51 UTC (permalink / raw)
To: Masahiro Yamada, Arnd Bergmann, linux-kernel
Cc: kbuild-all, linux-kbuild, linux-arch, Masahiro Yamada
Hi Masahiro,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on davem-sparc/master linux/master v5.18-rc1 next-20220404]
[cannot apply to soc/for-next drm/drm-next powerpc/next uclinux-h8/h8300-next s390/features arnd-asm-generic/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git be2d3ecedd9911fbfd7e55cc9ceac5f8b79ae4cf
config: nios2-allyesconfig (https://download.01.org/0day-ci/archive/20220404/202204041932.AgusAQLn-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/e8154d995f34b79843e473d85645fb543d554e7f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
git checkout e8154d995f34b79843e473d85645fb543d554e7f
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/misc/ sound/soc/fsl/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
In file included from include/linux/printk.h:555,
from include/asm-generic/bug.h:22,
from ./arch/nios2/include/generated/asm/bug.h:1,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from include/asm-generic/preempt.h:5,
from ./arch/nios2/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:55,
from include/linux/swait.h:7,
from include/linux/completion.h:12,
from drivers/misc/fastrpc.c:5:
drivers/misc/fastrpc.c: In function 'fastrpc_req_munmap_impl':
>> drivers/misc/fastrpc.c:1639:30: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uintptr_t' {aka 'unsigned int'} [-Wformat=]
1639 | dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:134:29: note: in definition of macro '__dynamic_func_call'
134 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:166:9: note: in expansion of macro '_dynamic_func_call'
166 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:9: note: in expansion of macro 'dynamic_dev_dbg'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:30: note: in expansion of macro 'dev_fmt'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/misc/fastrpc.c:1639:17: note: in expansion of macro 'dev_dbg'
1639 | dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr);
| ^~~~~~~
drivers/misc/fastrpc.c:1639:48: note: format string is defined here
1639 | dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr);
| ~~~~^
| |
| long unsigned int
| %09x
In file included from include/linux/device.h:15,
from drivers/misc/fastrpc.c:6:
drivers/misc/fastrpc.c:1645:30: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'uintptr_t' {aka 'unsigned int'} [-Wformat=]
1645 | dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/misc/fastrpc.c:1645:17: note: in expansion of macro 'dev_err'
1645 | dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr);
| ^~~~~~~
drivers/misc/fastrpc.c:1645:48: note: format string is defined here
1645 | dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr);
| ~~~~^
| |
| long unsigned int
| %09x
In file included from include/linux/printk.h:555,
from include/asm-generic/bug.h:22,
from ./arch/nios2/include/generated/asm/bug.h:1,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from include/asm-generic/preempt.h:5,
from ./arch/nios2/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:55,
from include/linux/swait.h:7,
from include/linux/completion.h:12,
from drivers/misc/fastrpc.c:5:
drivers/misc/fastrpc.c: In function 'fastrpc_req_mmap':
drivers/misc/fastrpc.c:1736:22: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uintptr_t' {aka 'unsigned int'} [-Wformat=]
1736 | dev_dbg(dev, "mmap\t\tpt 0x%09lx OK [len 0x%08llx]\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:134:29: note: in definition of macro '__dynamic_func_call'
134 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:166:9: note: in expansion of macro '_dynamic_func_call'
166 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:9: note: in expansion of macro 'dynamic_dev_dbg'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:155:30: note: in expansion of macro 'dev_fmt'
155 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/misc/fastrpc.c:1736:9: note: in expansion of macro 'dev_dbg'
1736 | dev_dbg(dev, "mmap\t\tpt 0x%09lx OK [len 0x%08llx]\n",
| ^~~~~~~
drivers/misc/fastrpc.c:1736:40: note: format string is defined here
1736 | dev_dbg(dev, "mmap\t\tpt 0x%09lx OK [len 0x%08llx]\n",
| ~~~~^
| |
| long unsigned int
| %09x
--
sound/soc/fsl/imx-audmux.c: In function 'audmux_debugfs_init':
>> sound/soc/fsl/imx-audmux.c:148:50: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uintptr_t' {aka 'unsigned int'} [-Wformat=]
148 | snprintf(buf, sizeof(buf), "ssi%lu", i);
| ~~^ ~
| | |
| | uintptr_t {aka unsigned int}
| long unsigned int
| %u
vim +1639 drivers/misc/fastrpc.c
6c16fd8bdd4058 Jeya R 2022-02-14 1604
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1605 static int fastrpc_req_munmap_impl(struct fastrpc_user *fl,
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1606 struct fastrpc_req_munmap *req)
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1607 {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1608 struct fastrpc_invoke_args args[1] = { [0] = { 0 } };
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1609 struct fastrpc_buf *buf, *b;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1610 struct fastrpc_munmap_req_msg req_msg;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1611 struct device *dev = fl->sctx->dev;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1612 int err;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1613 u32 sc;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1614
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1615 spin_lock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1616 list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1617 if ((buf->raddr == req->vaddrout) && (buf->size == req->size))
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1618 break;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1619 buf = NULL;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1620 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1621 spin_unlock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1622
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1623 if (!buf) {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1624 dev_err(dev, "mmap not in list\n");
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1625 return -EINVAL;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1626 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1627
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1628 req_msg.pgid = fl->tgid;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1629 req_msg.size = buf->size;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1630 req_msg.vaddr = buf->raddr;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1631
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1632 args[0].ptr = (u64) (uintptr_t) &req_msg;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1633 args[0].length = sizeof(req_msg);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1634
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1635 sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MUNMAP, 1, 0);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1636 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc,
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1637 &args[0]);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1638 if (!err) {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 @1639 dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1640 spin_lock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1641 list_del(&buf->node);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1642 spin_unlock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1643 fastrpc_buf_free(buf);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1644 } else {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1645 dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1646 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1647
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1648 return err;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1649 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1650
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h
2022-04-04 11:30 ` kernel test robot
@ 2022-04-04 11:51 ` Masahiro Yamada
2022-04-04 12:02 ` Masahiro Yamada
0 siblings, 1 reply; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 11:51 UTC (permalink / raw)
To: kernel test robot
Cc: Arnd Bergmann, Linux Kernel Mailing List, llvm, kbuild-all,
Linux Kbuild mailing list, linux-arch
On Mon, Apr 4, 2022 at 8:31 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Masahiro,
>
> I love your patch! Perhaps something to improve:
>
> [auto build test WARNING on linus/master]
> [also build test WARNING on linux/master v5.18-rc1 next-20220404]
> [cannot apply to soc/for-next drm/drm-next powerpc/next uclinux-h8/h8300-next s390/features arnd-asm-generic/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
> base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git be2d3ecedd9911fbfd7e55cc9ceac5f8b79ae4cf
> config: i386-randconfig-a006 (https://download.01.org/0day-ci/archive/20220404/202204041919.bIUKxOch-lkp@intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/intel-lab-lkp/linux/commit/e8154d995f34b79843e473d85645fb543d554e7f
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
> git checkout e8154d995f34b79843e473d85645fb543d554e7f
> # save the config file to linux build tree
> mkdir build_dir
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash sound/soc/fsl/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> sound/soc/fsl/imx-audmux.c:148:40: warning: format specifies type 'unsigned long' but the argument has type 'uintptr_t' (aka 'unsigned int') [-Wformat]
> snprintf(buf, sizeof(buf), "ssi%lu", i);
> ~~~ ^
> %u
> 1 warning generated.
>
Hmm, we highly relied on the fact that the pointer size and
the 'long' size are the same.
(for both 32-bit and 64-bit).
So, using %lu specifier for printing 'uintptr_t' seems correct.
typedef unsigned long __kernel_uintptr_t;
is OK from the kernel space perspective,
but I do not know the impact to the userspace.
Arnd, any thoughts?
> vim +148 sound/soc/fsl/imx-audmux.c
>
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 139
> b8909783a22b4f sound/soc/fsl/imx-audmux.c Lars-Peter Clausen 2014-04-24 140 static void audmux_debugfs_init(void)
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 141 {
> e5f89768e9bc1f sound/soc/fsl/imx-audmux.c Mark Brown 2014-08-01 142 uintptr_t i;
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 143 char buf[20];
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 144
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 145 audmux_debugfs_root = debugfs_create_dir("audmux", NULL);
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 146
> 409b78cc17a4a3 sound/soc/fsl/imx-audmux.c Torben Hohn 2012-07-18 147 for (i = 0; i < MX31_AUDMUX_PORT7_SSI_PINS_7 + 1; i++) {
> e5f89768e9bc1f sound/soc/fsl/imx-audmux.c Mark Brown 2014-08-01 @148 snprintf(buf, sizeof(buf), "ssi%lu", i);
> 227ab8baa15bdd sound/soc/fsl/imx-audmux.c Greg Kroah-Hartman 2019-06-14 149 debugfs_create_file(buf, 0444, audmux_debugfs_root,
> 227ab8baa15bdd sound/soc/fsl/imx-audmux.c Greg Kroah-Hartman 2019-06-14 150 (void *)i, &audmux_debugfs_fops);
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 151 }
> 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 152 }
> 3bc34a6143359d arch/arm/plat-mxc/audmux.c Richard Zhao 2012-03-05 153
>
> --
> 0-DAY CI Kernel Test Service
> https://01.org/lkp
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h
2022-04-04 11:51 ` Masahiro Yamada
@ 2022-04-04 12:02 ` Masahiro Yamada
0 siblings, 0 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-04 12:02 UTC (permalink / raw)
To: kernel test robot
Cc: Arnd Bergmann, Linux Kernel Mailing List, llvm, kbuild-all,
Linux Kbuild mailing list, linux-arch
On Mon, Apr 4, 2022 at 8:51 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Mon, Apr 4, 2022 at 8:31 PM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Masahiro,
> >
> > I love your patch! Perhaps something to improve:
> >
> > [auto build test WARNING on linus/master]
> > [also build test WARNING on linux/master v5.18-rc1 next-20220404]
> > [cannot apply to soc/for-next drm/drm-next powerpc/next uclinux-h8/h8300-next s390/features arnd-asm-generic/master]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git be2d3ecedd9911fbfd7e55cc9ceac5f8b79ae4cf
> > config: i386-randconfig-a006 (https://download.01.org/0day-ci/archive/20220404/202204041919.bIUKxOch-lkp@intel.com/config)
> > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
> > reproduce (this is a W=1 build):
> > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > # https://github.com/intel-lab-lkp/linux/commit/e8154d995f34b79843e473d85645fb543d554e7f
> > git remote add linux-review https://github.com/intel-lab-lkp/linux
> > git fetch --no-tags linux-review Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
> > git checkout e8154d995f34b79843e473d85645fb543d554e7f
> > # save the config file to linux build tree
> > mkdir build_dir
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash sound/soc/fsl/
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All warnings (new ones prefixed by >>):
> >
> > >> sound/soc/fsl/imx-audmux.c:148:40: warning: format specifies type 'unsigned long' but the argument has type 'uintptr_t' (aka 'unsigned int') [-Wformat]
> > snprintf(buf, sizeof(buf), "ssi%lu", i);
> > ~~~ ^
> > %u
> > 1 warning generated.
> >
>
> Hmm, we highly relied on the fact that the pointer size and
> the 'long' size are the same.
> (for both 32-bit and 64-bit).
>
> So, using %lu specifier for printing 'uintptr_t' seems correct.
>
> typedef unsigned long __kernel_uintptr_t;
>
> is OK from the kernel space perspective,
> but I do not know the impact to the userspace.
>
> Arnd, any thoughts?
I think we should do the same as
int-ll64.h vs int-l64.h
We completely switched to int-ll64.h for the kernel space,
but some architectures export int-l64.h
For example,
arch/mips/include/uapi/asm/types.h
>
>
>
>
>
>
> > vim +148 sound/soc/fsl/imx-audmux.c
> >
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 139
> > b8909783a22b4f sound/soc/fsl/imx-audmux.c Lars-Peter Clausen 2014-04-24 140 static void audmux_debugfs_init(void)
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 141 {
> > e5f89768e9bc1f sound/soc/fsl/imx-audmux.c Mark Brown 2014-08-01 142 uintptr_t i;
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 143 char buf[20];
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 144
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 145 audmux_debugfs_root = debugfs_create_dir("audmux", NULL);
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 146
> > 409b78cc17a4a3 sound/soc/fsl/imx-audmux.c Torben Hohn 2012-07-18 147 for (i = 0; i < MX31_AUDMUX_PORT7_SSI_PINS_7 + 1; i++) {
> > e5f89768e9bc1f sound/soc/fsl/imx-audmux.c Mark Brown 2014-08-01 @148 snprintf(buf, sizeof(buf), "ssi%lu", i);
> > 227ab8baa15bdd sound/soc/fsl/imx-audmux.c Greg Kroah-Hartman 2019-06-14 149 debugfs_create_file(buf, 0444, audmux_debugfs_root,
> > 227ab8baa15bdd sound/soc/fsl/imx-audmux.c Greg Kroah-Hartman 2019-06-14 150 (void *)i, &audmux_debugfs_fops);
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 151 }
> > 7b4e08a77f0cbf arch/arm/plat-mxc/audmux-v2.c Mark Brown 2010-01-11 152 }
> > 3bc34a6143359d arch/arm/plat-mxc/audmux.c Richard Zhao 2012-03-05 153
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://01.org/lkp
>
>
>
> --
> Best Regards
> Masahiro Yamada
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h
2022-04-04 6:19 ` [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h Masahiro Yamada
2022-04-04 11:30 ` kernel test robot
2022-04-04 11:51 ` kernel test robot
@ 2022-04-04 13:04 ` kernel test robot
2 siblings, 0 replies; 39+ messages in thread
From: kernel test robot @ 2022-04-04 13:04 UTC (permalink / raw)
To: Masahiro Yamada, Arnd Bergmann, linux-kernel
Cc: llvm, kbuild-all, linux-kbuild, linux-arch, Masahiro Yamada
Hi Masahiro,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on linux/master v5.18-rc1 next-20220404]
[cannot apply to soc/for-next drm/drm-next powerpc/next uclinux-h8/h8300-next s390/features arnd-asm-generic/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git be2d3ecedd9911fbfd7e55cc9ceac5f8b79ae4cf
config: arm-randconfig-r016-20220404 (https://download.01.org/0day-ci/archive/20220404/202204042058.5Kr6q6YX-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c4a1b07d0979e7ff20d7d541af666d822d66b566)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/e8154d995f34b79843e473d85645fb543d554e7f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Masahiro-Yamada/UAPI-make-more-exported-headers-self-contained-and-put-them-into-test-coverage/20220404-142226
git checkout e8154d995f34b79843e473d85645fb543d554e7f
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/misc/ sound/soc/fsl/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> drivers/misc/fastrpc.c:1639:43: warning: format specifies type 'unsigned long' but the argument has type 'uintptr_t' (aka 'unsigned int') [-Wformat]
dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr);
~~~~~ ^~~~~~~~~~
%09x
include/linux/dev_printk.h:163:47: note: expanded from macro 'dev_dbg'
dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:129:34: note: expanded from macro 'dev_printk'
_dev_printk(level, dev, fmt, ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
drivers/misc/fastrpc.c:1645:46: warning: format specifies type 'unsigned long' but the argument has type 'uintptr_t' (aka 'unsigned int') [-Wformat]
dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr);
~~~~~ ^~~~~~~~~~
%09x
include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
_p_func(dev, fmt, ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
drivers/misc/fastrpc.c:1737:3: warning: format specifies type 'unsigned long' but the argument has type 'uintptr_t' (aka 'unsigned int') [-Wformat]
buf->raddr, buf->size);
^~~~~~~~~~
include/linux/dev_printk.h:163:47: note: expanded from macro 'dev_dbg'
dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
include/linux/dev_printk.h:129:34: note: expanded from macro 'dev_printk'
_dev_printk(level, dev, fmt, ##__VA_ARGS__); \
~~~ ^~~~~~~~~~~
3 warnings generated.
--
>> sound/soc/fsl/imx-audmux.c:148:40: warning: format specifies type 'unsigned long' but the argument has type 'uintptr_t' (aka 'unsigned int') [-Wformat]
snprintf(buf, sizeof(buf), "ssi%lu", i);
~~~ ^
%u
1 warning generated.
vim +1639 drivers/misc/fastrpc.c
6c16fd8bdd4058 Jeya R 2022-02-14 1604
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1605 static int fastrpc_req_munmap_impl(struct fastrpc_user *fl,
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1606 struct fastrpc_req_munmap *req)
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1607 {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1608 struct fastrpc_invoke_args args[1] = { [0] = { 0 } };
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1609 struct fastrpc_buf *buf, *b;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1610 struct fastrpc_munmap_req_msg req_msg;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1611 struct device *dev = fl->sctx->dev;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1612 int err;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1613 u32 sc;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1614
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1615 spin_lock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1616 list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1617 if ((buf->raddr == req->vaddrout) && (buf->size == req->size))
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1618 break;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1619 buf = NULL;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1620 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1621 spin_unlock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1622
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1623 if (!buf) {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1624 dev_err(dev, "mmap not in list\n");
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1625 return -EINVAL;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1626 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1627
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1628 req_msg.pgid = fl->tgid;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1629 req_msg.size = buf->size;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1630 req_msg.vaddr = buf->raddr;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1631
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1632 args[0].ptr = (u64) (uintptr_t) &req_msg;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1633 args[0].length = sizeof(req_msg);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1634
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1635 sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MUNMAP, 1, 0);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1636 err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc,
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1637 &args[0]);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1638 if (!err) {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 @1639 dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1640 spin_lock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1641 list_del(&buf->node);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1642 spin_unlock(&fl->lock);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1643 fastrpc_buf_free(buf);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1644 } else {
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1645 dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr);
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1646 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1647
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1648 return err;
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1649 }
2419e55e532de1 Jorge Ramirez-Ortiz 2019-10-09 1650
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header
2022-04-04 6:19 ` [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header Masahiro Yamada
2022-04-04 7:40 ` Christoph Hellwig
@ 2022-04-04 17:27 ` Nick Desaulniers
1 sibling, 0 replies; 39+ messages in thread
From: Nick Desaulniers @ 2022-04-04 17:27 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
On Mon, Apr 04, 2022 at 03:19:41PM +0900, Masahiro Yamada wrote:
> Commit 35d0f1d54ecd ("include/uapi/linux/agpgart.h: include stdlib.h in
> userspace") included <stdlib.h> to fix the unknown size_t error, but
> I do not think it is the right fix.
>
> This header already uses __kernel_size_t a few lines below.
>
> Replace the remaining size_t, and stop including <stdlib.h>.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>
> include/uapi/linux/agpgart.h | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/include/uapi/linux/agpgart.h b/include/uapi/linux/agpgart.h
> index f5251045181a..9cc3448c0b5b 100644
> --- a/include/uapi/linux/agpgart.h
> +++ b/include/uapi/linux/agpgart.h
> @@ -52,7 +52,6 @@
>
> #ifndef __KERNEL__
> #include <linux/types.h>
> -#include <stdlib.h>
>
> struct agp_version {
> __u16 major;
> @@ -64,10 +63,10 @@ typedef struct _agp_info {
> __u32 bridge_id; /* bridge vendor/device */
> __u32 agp_mode; /* mode info of bridge */
> unsigned long aper_base;/* base of aperture */
> - size_t aper_size; /* size of aperture */
> - size_t pg_total; /* max pages (swap + system) */
> - size_t pg_system; /* max pages (system) */
> - size_t pg_used; /* current pages used */
> + __kernel_size_t aper_size; /* size of aperture */
> + __kernel_size_t pg_total; /* max pages (swap + system) */
> + __kernel_size_t pg_system; /* max pages (system) */
> + __kernel_size_t pg_used; /* current pages used */
> } agp_info;
>
> typedef struct _agp_setup {
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>
2022-04-04 7:41 ` Christoph Hellwig
2022-04-04 8:01 ` Arnd Bergmann
2022-04-04 8:03 ` Masahiro Yamada
@ 2022-04-04 17:34 ` Nick Desaulniers
2022-04-05 1:12 ` Masahiro Yamada
2 siblings, 1 reply; 39+ messages in thread
From: Nick Desaulniers @ 2022-04-04 17:34 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Masahiro Yamada, Arnd Bergmann, linux-kernel, linux-kbuild,
linux-arch, Greg Kroah-Hartman
On Mon, Apr 04, 2022 at 12:41:54AM -0700, Christoph Hellwig wrote:
> On Mon, Apr 04, 2022 at 03:19:42PM +0900, Masahiro Yamada wrote:
> > If we can make kernel headers self-contained (that is, none of exported
> > kernel headers includes system headers), we will be able to add the
> > -nostdinc flag, but that is much far from where we stand now.
This is something I'd like to see done. IMO, the kernel headers should
be the independent variable of which the libc is the dependendent
variable.
Android's libc, Bionic, is making use of the UAPI headers. They are
doing some rewriting of UAPI headers, but I'd like to see what needs to
be upstreamed from there. I just noticed
include/uapi/linux/libc-compat.h, which seems like a good place for such
compat related issues.
In particular, having UAPI_HEADER_TESTS depend on CC_CAN_LINK is
something I think we can works towards removing. The header tests
themselves don't link; they force a dependency on a prebuilt libc
sysroot, and they only need the headers from the sysroot because of this
existing circular dependency between kernel headers and libc headers.
I'd be happy to be explicitly cc'ed on changes like this series, going
forward. Masahiro, if there's parts you'd like me to help with besides
just code review, please let me know how I can help.
>
> What is still missing for that?
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h>
2022-04-04 17:34 ` Nick Desaulniers
@ 2022-04-05 1:12 ` Masahiro Yamada
0 siblings, 0 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-04-05 1:12 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Arnd Bergmann, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch, Greg Kroah-Hartman
On Tue, Apr 5, 2022 at 2:34 AM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Mon, Apr 04, 2022 at 12:41:54AM -0700, Christoph Hellwig wrote:
> > On Mon, Apr 04, 2022 at 03:19:42PM +0900, Masahiro Yamada wrote:
> > > If we can make kernel headers self-contained (that is, none of exported
> > > kernel headers includes system headers), we will be able to add the
> > > -nostdinc flag, but that is much far from where we stand now.
>
> This is something I'd like to see done. IMO, the kernel headers should
> be the independent variable of which the libc is the dependendent
> variable.
>
> Android's libc, Bionic, is making use of the UAPI headers. They are
> doing some rewriting of UAPI headers, but I'd like to see what needs to
> be upstreamed from there. I just noticed
> include/uapi/linux/libc-compat.h, which seems like a good place for such
> compat related issues.
>
> In particular, having UAPI_HEADER_TESTS depend on CC_CAN_LINK is
> something I think we can works towards removing. The header tests
> themselves don't link; they force a dependency on a prebuilt libc
> sysroot, and they only need the headers from the sysroot because of this
> existing circular dependency between kernel headers and libc headers.
>
> I'd be happy to be explicitly cc'ed on changes like this series, going
> forward. Masahiro, if there's parts you'd like me to help with besides
> just code review, please let me know how I can help.
I wanted to make uapi headers as self-contained as possible,
but I did not see much progress.
I just fixed up some low-hanging fruits, but there are still
many remaining issues.
Thank you very much for your contribution:
https://lore.kernel.org/all/20220404175448.46200-1-ndesaulniers@google.com/
If you eliminate other issues, that would be appreciated.
> >
> > What is still missing for that?
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-04 8:04 ` Arnd Bergmann
@ 2022-04-05 5:35 ` Christoph Hellwig
2022-04-05 6:29 ` Arnd Bergmann
0 siblings, 1 reply; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-05 5:35 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Christoph Hellwig, Masahiro Yamada, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch
On Mon, Apr 04, 2022 at 10:04:02AM +0200, Arnd Bergmann wrote:
> The header is shared between kernel and other projects using virtio, such as
> qemu and any boot loaders booting from virtio devices. It's not technically a
> /kernel/ ABI, but it is an ABI and for practical reasons the kernel version is
> maintained as the master copy if I understand it correctly.
Besides that fact that as you correctly states these are not a UAPI at
all, qemu and bootloades are not specific to Linux and can't require a
specific kernel version. So the same thing we do for file system
formats or network protocols applies here: just copy the damn header.
And as stated above any reasonably portable userspace needs to have a
copy anyway.
If it is just as a "master copy" it can live in drivers/virtio/, just
like we do for other formats.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-05 5:35 ` Christoph Hellwig
@ 2022-04-05 6:29 ` Arnd Bergmann
2022-04-05 7:01 ` Christoph Hellwig
2022-04-05 11:57 ` Michael S. Tsirkin
0 siblings, 2 replies; 39+ messages in thread
From: Arnd Bergmann @ 2022-04-05 6:29 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Arnd Bergmann, Masahiro Yamada, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch, Michael S. Tsirkin,
Jason Wang, virtualization list
On Tue, Apr 5, 2022 at 7:35 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Mon, Apr 04, 2022 at 10:04:02AM +0200, Arnd Bergmann wrote:
> > The header is shared between kernel and other projects using virtio, such as
> > qemu and any boot loaders booting from virtio devices. It's not technically a
> > /kernel/ ABI, but it is an ABI and for practical reasons the kernel version is
> > maintained as the master copy if I understand it correctly.
>
> Besides that fact that as you correctly states these are not a UAPI at
> all, qemu and bootloades are not specific to Linux and can't require a
> specific kernel version. So the same thing we do for file system
> formats or network protocols applies here: just copy the damn header.
> And as stated above any reasonably portable userspace needs to have a
> copy anyway.
I think the users all have their own copies, at least the ones I could
find on codesearch.debian.org. However, there are 27 virtio_*.h
files in include/uapi/linux that probably should stay together for
the purpose of defining the virtio protocol, and some others might
be uapi relevant.
I see that at least include/uapi/linux/vhost.h has ioctl() definitions
in it, and includes the virtio_ring.h header indirectly.
Adding the virtio maintainers to Cc to see if they can provide
more background on this.
> If it is just as a "master copy" it can live in drivers/virtio/, just
> like we do for other formats.
It has to be in include/linux/ at least because it's used by a number
of drivers outside of drivers/virtio/.
Arnd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-05 6:29 ` Arnd Bergmann
@ 2022-04-05 7:01 ` Christoph Hellwig
2022-04-05 11:55 ` Michael S. Tsirkin
2022-04-05 11:57 ` Michael S. Tsirkin
1 sibling, 1 reply; 39+ messages in thread
From: Christoph Hellwig @ 2022-04-05 7:01 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Christoph Hellwig, Masahiro Yamada, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch, Michael S. Tsirkin,
Jason Wang, virtualization list
On Tue, Apr 05, 2022 at 08:29:36AM +0200, Arnd Bergmann wrote:
> I think the users all have their own copies, at least the ones I could
> find on codesearch.debian.org. However, there are 27 virtio_*.h
> files in include/uapi/linux that probably should stay together for
> the purpose of defining the virtio protocol, and some others might
> be uapi relevant.
>
> I see that at least include/uapi/linux/vhost.h has ioctl() definitions
> in it, and includes the virtio_ring.h header indirectly.
Uhh. We had a somilar mess (but at a smaller scale) in nvme, where
the uapi nvme.h contained both the UAPI and the protocol definition.
We took a hard break to only have a nvme_ioctl.h in the uapi header
and linux/nvme.h for the protocol. This did break a bit of userspace
compilation (but not running obviously) at the time, but really made
the headers much easier to main. Some userspace keeps on copying
nvme.h with the protocol definitions.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-05 7:01 ` Christoph Hellwig
@ 2022-04-05 11:55 ` Michael S. Tsirkin
0 siblings, 0 replies; 39+ messages in thread
From: Michael S. Tsirkin @ 2022-04-05 11:55 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Arnd Bergmann, Masahiro Yamada, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch, Jason Wang,
virtualization list
On Tue, Apr 05, 2022 at 12:01:35AM -0700, Christoph Hellwig wrote:
> On Tue, Apr 05, 2022 at 08:29:36AM +0200, Arnd Bergmann wrote:
> > I think the users all have their own copies, at least the ones I could
> > find on codesearch.debian.org. However, there are 27 virtio_*.h
> > files in include/uapi/linux that probably should stay together for
> > the purpose of defining the virtio protocol, and some others might
> > be uapi relevant.
> >
> > I see that at least include/uapi/linux/vhost.h has ioctl() definitions
> > in it, and includes the virtio_ring.h header indirectly.
>
> Uhh. We had a somilar mess (but at a smaller scale) in nvme, where
> the uapi nvme.h contained both the UAPI and the protocol definition.
> We took a hard break to only have a nvme_ioctl.h in the uapi header
> and linux/nvme.h for the protocol. This did break a bit of userspace
> compilation (but not running obviously) at the time, but really made
> the headers much easier to main. Some userspace keeps on copying
> nvme.h with the protocol definitions.
So far we are quite happy with the status quo, I don't see any issues
maintaining the headers. And yes, through vhost and vringh they are part
of UAPI.
Yes users have their own copies but they synch with the kernel.
That's generally. Specifically the vring_init thing is a legacy thingy
used by kvmtool and maybe others, and it inits the ring in the way that
vring/virtio expect. Has been there since day 1 and we are careful not
to add more stuff like that, so I don't see a lot of gain from incurring
this pain for users.
--
MST
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-05 6:29 ` Arnd Bergmann
2022-04-05 7:01 ` Christoph Hellwig
@ 2022-04-05 11:57 ` Michael S. Tsirkin
1 sibling, 0 replies; 39+ messages in thread
From: Michael S. Tsirkin @ 2022-04-05 11:57 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Christoph Hellwig, linux-arch, Masahiro Yamada,
Linux Kbuild mailing list, Linux Kernel Mailing List,
virtualization list
On Tue, Apr 05, 2022 at 08:29:36AM +0200, Arnd Bergmann wrote:
> On Tue, Apr 5, 2022 at 7:35 AM Christoph Hellwig <hch@infradead.org> wrote:
> >
> > On Mon, Apr 04, 2022 at 10:04:02AM +0200, Arnd Bergmann wrote:
> > > The header is shared between kernel and other projects using virtio, such as
> > > qemu and any boot loaders booting from virtio devices. It's not technically a
> > > /kernel/ ABI, but it is an ABI and for practical reasons the kernel version is
> > > maintained as the master copy if I understand it correctly.
> >
> > Besides that fact that as you correctly states these are not a UAPI at
> > all, qemu and bootloades are not specific to Linux and can't require a
> > specific kernel version. So the same thing we do for file system
> > formats or network protocols applies here: just copy the damn header.
> > And as stated above any reasonably portable userspace needs to have a
> > copy anyway.
>
> I think the users all have their own copies, at least the ones I could
> find on codesearch.debian.org.
kvmtool does not seem to have its own copy, just grep vring_init.
> However, there are 27 virtio_*.h
> files in include/uapi/linux that probably should stay together for
> the purpose of defining the virtio protocol, and some others might
> be uapi relevant.
>
> I see that at least include/uapi/linux/vhost.h has ioctl() definitions
> in it, and includes the virtio_ring.h header indirectly.
>
> Adding the virtio maintainers to Cc to see if they can provide
> more background on this.
>
> > If it is just as a "master copy" it can live in drivers/virtio/, just
> > like we do for other formats.
>
> It has to be in include/linux/ at least because it's used by a number
> of drivers outside of drivers/virtio/.
>
> Arnd
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/virtualization
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-04 6:19 ` [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header Masahiro Yamada
2022-04-04 7:44 ` Christoph Hellwig
@ 2022-04-05 11:57 ` Michael S. Tsirkin
1 sibling, 0 replies; 39+ messages in thread
From: Michael S. Tsirkin @ 2022-04-05 11:57 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
On Mon, Apr 04, 2022 at 03:19:48PM +0900, Masahiro Yamada wrote:
> Arnd mentioned a limitation when including <stdint.h> from UAPI
> headers. [1]
>
> Besides, I'd like exported headers to be as compliant with the
> traditional C as possible.
>
> In fact, the UAPI headers are compile-tested with -std=c90 (see
> usr/include/Makefile) even though the kernel itself is now built
> with -std=gnu11.
>
> Currently, include/uapi/linux/virtio_ring.h includes <stdint.h>
> presumably because it uses uintptr_t.
>
> Replace it with __kernel_uintptr_t, and stop including <stdint.h>.
>
> [1]: https://lore.kernel.org/all/CAK8P3a0bz8XYJOsmND2=CT_oTDmGMJGaRo9+QMroEhpekSMEaQ@mail.gmail.com/
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> include/uapi/linux/virtio_ring.h | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
> index 476d3e5c0fe7..6329e4ff35f4 100644
> --- a/include/uapi/linux/virtio_ring.h
> +++ b/include/uapi/linux/virtio_ring.h
> @@ -31,9 +31,7 @@
> * SUCH DAMAGE.
> *
> * Copyright Rusty Russell IBM Corporation 2007. */
> -#ifndef __KERNEL__
> -#include <stdint.h>
> -#endif
> +
> #include <linux/types.h>
> #include <linux/virtio_types.h>
>
> @@ -196,7 +194,7 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
> vr->num = num;
> vr->desc = p;
> vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
> - vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> + vr->used = (void *)(((__kernel_uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> + align-1) & ~(align - 1));
> }
>
> --
> 2.32.0
>
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header
2022-04-04 7:44 ` Christoph Hellwig
2022-04-04 7:58 ` Masahiro Yamada
2022-04-04 8:04 ` Arnd Bergmann
@ 2022-04-05 11:59 ` Michael S. Tsirkin
2 siblings, 0 replies; 39+ messages in thread
From: Michael S. Tsirkin @ 2022-04-05 11:59 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Masahiro Yamada, Arnd Bergmann, linux-kernel, linux-kbuild, linux-arch
On Mon, Apr 04, 2022 at 12:44:30AM -0700, Christoph Hellwig wrote:
> On Mon, Apr 04, 2022 at 03:19:48PM +0900, Masahiro Yamada wrote:
> > vr->num = num;
> > vr->desc = p;
> > vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
> > - vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> > + vr->used = (void *)(((__kernel_uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
> > + align-1) & ~(align - 1));
>
> This really does not look like it should be in a uapi header to start
> with.
It's a way to document a complex structure layout of virtio 0.9. It's
ugly but it's been like this for years. For virtio 1.0 we moved away
from this but a bunch of tools keep using legacy.
--
MST
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage
2022-04-04 7:34 ` [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Arnd Bergmann
@ 2022-05-13 8:43 ` Masahiro Yamada
2022-05-13 9:01 ` Arnd Bergmann
0 siblings, 1 reply; 39+ messages in thread
From: Masahiro Yamada @ 2022-05-13 8:43 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linux Kernel Mailing List, Linux Kbuild mailing list, linux-arch
Hi Arnd,
On Mon, Apr 4, 2022 at 4:35 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Mon, Apr 4, 2022 at 8:19 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> >
> > Here are more efforts to put more headers to UAPI compile testing
> > (CONFIG_UAPI_HEADER_TEST).
> >
> > I am sending this series to Arnd because he has deep knowledge for the
> > kernel APIs and manages asm-generic pull requests.
>
> These all look good to me, I can apply them for 5.19 but would wait
> a few days for others to comment.
>
> Arnd
Can you apply 01-06 for the next MW?
I got a 0-day bot report for 07, but
I may not have time to come back to it
in this development cycle.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage
2022-05-13 8:43 ` Masahiro Yamada
@ 2022-05-13 9:01 ` Arnd Bergmann
2022-05-13 9:13 ` Masahiro Yamada
0 siblings, 1 reply; 39+ messages in thread
From: Arnd Bergmann @ 2022-05-13 9:01 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Arnd Bergmann, Linux Kernel Mailing List,
Linux Kbuild mailing list, linux-arch
On Fri, May 13, 2022 at 10:43 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Hi Arnd,
>
> On Mon, Apr 4, 2022 at 4:35 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > On Mon, Apr 4, 2022 at 8:19 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > >
> > > Here are more efforts to put more headers to UAPI compile testing
> > > (CONFIG_UAPI_HEADER_TEST).
> > >
> > > I am sending this series to Arnd because he has deep knowledge for the
> > > kernel APIs and manages asm-generic pull requests.
> >
> > These all look good to me, I can apply them for 5.19 but would wait
> > a few days for others to comment.
>
> Can you apply 01-06 for the next MW?
>
> I got a 0-day bot report for 07, but
> I may not have time to come back to it
> in this development cycle.
Ok, done now. What about patch 8? I left it out for now, but could
include it as well
if you want.
Arnd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage
2022-05-13 9:01 ` Arnd Bergmann
@ 2022-05-13 9:13 ` Masahiro Yamada
0 siblings, 0 replies; 39+ messages in thread
From: Masahiro Yamada @ 2022-05-13 9:13 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Linux Kernel Mailing List, Linux Kbuild mailing list, linux-arch
On Fri, May 13, 2022 at 6:01 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Fri, May 13, 2022 at 10:43 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Hi Arnd,
> >
> > On Mon, Apr 4, 2022 at 4:35 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > >
> > > On Mon, Apr 4, 2022 at 8:19 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > >
> > > >
> > > > Here are more efforts to put more headers to UAPI compile testing
> > > > (CONFIG_UAPI_HEADER_TEST).
> > > >
> > > > I am sending this series to Arnd because he has deep knowledge for the
> > > > kernel APIs and manages asm-generic pull requests.
> > >
> > > These all look good to me, I can apply them for 5.19 but would wait
> > > a few days for others to comment.
> >
> > Can you apply 01-06 for the next MW?
> >
> > I got a 0-day bot report for 07, but
> > I may not have time to come back to it
> > in this development cycle.
>
> Ok, done now. What about patch 8? I left it out for now, but could
> include it as well
> if you want.
>
> Arnd
No.
08 depends on 07.
We do not have __kernel_uintptr_t yet.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 39+ messages in thread
end of thread, other threads:[~2022-05-13 9:15 UTC | newest]
Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 6:19 [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Masahiro Yamada
2022-04-04 6:19 ` [PATCH 1/8] agpgart.h: do not include <stdlib.h> from exported header Masahiro Yamada
2022-04-04 7:40 ` Christoph Hellwig
2022-04-04 17:27 ` Nick Desaulniers
2022-04-04 6:19 ` [PATCH 2/8] kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h> Masahiro Yamada
2022-04-04 7:41 ` Christoph Hellwig
2022-04-04 8:01 ` Arnd Bergmann
2022-04-04 8:03 ` Masahiro Yamada
2022-04-04 17:34 ` Nick Desaulniers
2022-04-05 1:12 ` Masahiro Yamada
2022-04-04 6:19 ` [PATCH 3/8] riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage Masahiro Yamada
2022-04-04 7:41 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 4/8] mips: add asm/stat.h " Masahiro Yamada
2022-04-04 7:42 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 5/8] powerpc: " Masahiro Yamada
2022-04-04 7:42 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 6/8] sparc: " Masahiro Yamada
2022-04-04 7:43 ` Christoph Hellwig
2022-04-04 6:19 ` [PATCH 7/8] posix_types.h: add __kernel_uintptr_t to UAPI posix_types.h Masahiro Yamada
2022-04-04 11:30 ` kernel test robot
2022-04-04 11:51 ` Masahiro Yamada
2022-04-04 12:02 ` Masahiro Yamada
2022-04-04 11:51 ` kernel test robot
2022-04-04 13:04 ` kernel test robot
2022-04-04 6:19 ` [PATCH 8/8] virtio_ring.h: do not include <stdint.h> from exported header Masahiro Yamada
2022-04-04 7:44 ` Christoph Hellwig
2022-04-04 7:58 ` Masahiro Yamada
2022-04-04 8:04 ` Arnd Bergmann
2022-04-05 5:35 ` Christoph Hellwig
2022-04-05 6:29 ` Arnd Bergmann
2022-04-05 7:01 ` Christoph Hellwig
2022-04-05 11:55 ` Michael S. Tsirkin
2022-04-05 11:57 ` Michael S. Tsirkin
2022-04-05 11:59 ` Michael S. Tsirkin
2022-04-05 11:57 ` Michael S. Tsirkin
2022-04-04 7:34 ` [PATCH 0/8] UAPI: make more exported headers self-contained, and put them into test coverage Arnd Bergmann
2022-05-13 8:43 ` Masahiro Yamada
2022-05-13 9:01 ` Arnd Bergmann
2022-05-13 9:13 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).