* [PATCH] kbuild: uapi: Avoid testing certain headers on ARCH=arm with CC=clang
@ 2026-01-11 0:52 Nathan Chancellor
2026-01-11 10:29 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2026-01-11 0:52 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Thomas Weißschuh,
Arnd Bergmann
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kbuild, llvm,
patches
After commit e3970d77ec50 ("kbuild: uapi: drop dependency on
CC_CAN_LINK"), which enables compile testing of UAPI headers in more
circumstances due to dropping the dependency on CONFIG_CC_CAN_LINK,
there are new instances of -Wunaligned-access when building with clang
targeting ARCH=arm in a few headers:
In file included from <built-in>:1:
./usr/include/linux/hyperv.h:361:2: error: field within 'struct hv_kvp_exchg_msg_value' is less aligned than 'union hv_kvp_exchg_msg_value::(anonymous at ./usr/include/linux/hyperv.h:361:2)' and is usually due to 'struct hv_kvp_exchg_msg_value' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
361 | union {
| ^
1 error generated.
In file included from <built-in>:1:
In file included from ./usr/include/linux/vboxguest.h:14:
usr/include/linux/vbox_vmmdev_types.h:239:4: error: field u within 'struct vmmdev_hgcm_function_parameter32' is less aligned than 'union (unnamed union at usr/include/linux/vbox_vmmdev_types.h:223:2)' and is usually due to 'struct vmmdev_hgcm_function_parameter32' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
239 | } u;
| ^
usr/include/linux/vbox_vmmdev_types.h:254:6: error: field u within 'struct vmmdev_hgcm_function_parameter64::(unnamed at usr/include/linux/vbox_vmmdev_types.h:249:3)' is less aligned than 'union (unnamed union at usr/include/linux/vbox_vmmdev_types.h:251:4)' and is usually due to 'struct vmmdev_hgcm_function_parameter64::(unnamed at usr/include/linux/vbox_vmmdev_types.h:249:3)' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
254 | } u;
| ^
2 errors generated.
These warnings are now fatal after commit 3788d69db18d ("kbuild: uapi:
fail header test on compiler warnings"). -Wunaligned-access is only
enabled at W=1 for the rest of the kernel because of numerous instances
of it.
To keep the build working while the root cause of the warnings is
investigated and resolved, disable testing these header files for
ARCH=arm when building with clang. This should be a minimal loss of
coverage; if the issue pointed out by this warning existed in the wild,
it should have been noticed in real testing at this point since some of
these structures have been around for many years. It is likely the case
that since these structures are for specialized applications, they have
never been used on an ARM platform that does not support unaligned
access.
Fixes: e3970d77ec50 ("kbuild: uapi: drop dependency on CC_CAN_LINK")
Link: https://github.com/ClangBuiltLinux/linux/issues/1576
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
| 6 ++++++
1 file changed, 6 insertions(+)
--git a/usr/include/Makefile b/usr/include/Makefile
index 6d86a53c6f0a..d23a0c0363bd 100644
--- a/usr/include/Makefile
+++ b/usr/include/Makefile
@@ -52,6 +52,12 @@ ifeq ($(SRCARCH),arc)
no-header-test += linux/bpf_perf_event.h
endif
+ifeq ($(SRCARCH)_$(CONFIG_CC_IS_CLANG),arm_y)
+no-header-test += linux/hyperv.h
+no-header-test += linux/vboxguest.h
+no-header-test += linux/vbox_vmmdev_types.h
+endif
+
ifeq ($(SRCARCH),openrisc)
no-header-test += linux/bpf_perf_event.h
endif
---
base-commit: e3970d77ec504e54c3f91a48b2125775c16ba4c0
change-id: 20260110-uapi-test-disable-headers-arm-clang-unaligned-access-a2e104a20a1e
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kbuild: uapi: Avoid testing certain headers on ARCH=arm with CC=clang
2026-01-11 0:52 [PATCH] kbuild: uapi: Avoid testing certain headers on ARCH=arm with CC=clang Nathan Chancellor
@ 2026-01-11 10:29 ` Arnd Bergmann
2026-01-12 22:53 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2026-01-11 10:29 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Thomas Weißschuh
Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kbuild, llvm,
patches
On Sun, Jan 11, 2026, at 01:52, Nathan Chancellor wrote:
>
> To keep the build working while the root cause of the warnings is
> investigated and resolved, disable testing these header files for
> ARCH=arm when building with clang.
I think we can just safely mark the internal unions as __packed as
well. The (untested) change below would annotate all of them
as being potentially misaligned so they can be stored at an
odd start offset, and correctly produce warnings when someone
takes the address of a member.
Arnd
diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h
index aaa502a7bff4..02ea5f2e43d4 100644
--- a/include/uapi/linux/hyperv.h
+++ b/include/uapi/linux/hyperv.h
@@ -362,7 +362,7 @@ struct hv_kvp_exchg_msg_value {
__u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
__u32 value_u32;
__u64 value_u64;
- };
+ } __packed;
} __attribute__((packed));
struct hv_kvp_msg_enumerate {
diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h
index 6073858d52a2..15ccfb5d624c 100644
--- a/include/uapi/linux/vbox_vmmdev_types.h
+++ b/include/uapi/linux/vbox_vmmdev_types.h
@@ -229,14 +229,14 @@ struct vmmdev_hgcm_function_parameter32 {
__u32 phys_addr;
__u32 linear_addr;
} u;
- } pointer;
+ } __packed pointer;
struct {
/** Size of the buffer described by the page list. */
__u32 size;
/** Relative to the request header. */
__u32 offset;
- } page_list;
- } u;
+ } __packed page_list;
+ } __packed u;
} __packed;
VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter32, 4 + 8);
@@ -251,14 +251,14 @@ struct vmmdev_hgcm_function_parameter64 {
union {
__u64 phys_addr;
__u64 linear_addr;
- } u;
+ } __packed u;
} __packed pointer;
struct {
/** Size of the buffer described by the page list. */
__u32 size;
/** Relative to the request header. */
__u32 offset;
- } page_list;
+ } __packed page_list;
} __packed u;
} __packed;
VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter64, 4 + 12);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kbuild: uapi: Avoid testing certain headers on ARCH=arm with CC=clang
2026-01-11 10:29 ` Arnd Bergmann
@ 2026-01-12 22:53 ` Nathan Chancellor
0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2026-01-12 22:53 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Nicolas Schier, Thomas Weißschuh, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-kbuild, llvm, patches
On Sun, Jan 11, 2026 at 11:29:31AM +0100, Arnd Bergmann wrote:
> On Sun, Jan 11, 2026, at 01:52, Nathan Chancellor wrote:
> >
> > To keep the build working while the root cause of the warnings is
> > investigated and resolved, disable testing these header files for
> > ARCH=arm when building with clang.
>
> I think we can just safely mark the internal unions as __packed as
> well. The (untested) change below would annotate all of them
> as being potentially misaligned so they can be stored at an
> odd start offset, and correctly produce warnings when someone
> takes the address of a member.
Yeah, this diff appears to avoid those warnings in my testing. Would you
want to send these changes as formal patches so we can get formal acks
from the maintainers of these files to take them via the kbuild tree
with Thomas's UAPI testing changes?
> diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h
> index aaa502a7bff4..02ea5f2e43d4 100644
> --- a/include/uapi/linux/hyperv.h
> +++ b/include/uapi/linux/hyperv.h
> @@ -362,7 +362,7 @@ struct hv_kvp_exchg_msg_value {
> __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
> __u32 value_u32;
> __u64 value_u64;
> - };
> + } __packed;
> } __attribute__((packed));
>
> struct hv_kvp_msg_enumerate {
> diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h
> index 6073858d52a2..15ccfb5d624c 100644
> --- a/include/uapi/linux/vbox_vmmdev_types.h
> +++ b/include/uapi/linux/vbox_vmmdev_types.h
> @@ -229,14 +229,14 @@ struct vmmdev_hgcm_function_parameter32 {
> __u32 phys_addr;
> __u32 linear_addr;
> } u;
> - } pointer;
> + } __packed pointer;
> struct {
> /** Size of the buffer described by the page list. */
> __u32 size;
> /** Relative to the request header. */
> __u32 offset;
> - } page_list;
> - } u;
> + } __packed page_list;
> + } __packed u;
> } __packed;
> VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter32, 4 + 8);
>
> @@ -251,14 +251,14 @@ struct vmmdev_hgcm_function_parameter64 {
> union {
> __u64 phys_addr;
> __u64 linear_addr;
> - } u;
> + } __packed u;
> } __packed pointer;
> struct {
> /** Size of the buffer described by the page list. */
> __u32 size;
> /** Relative to the request header. */
> __u32 offset;
> - } page_list;
> + } __packed page_list;
> } __packed u;
> } __packed;
> VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter64, 4 + 12);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-12 22:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-11 0:52 [PATCH] kbuild: uapi: Avoid testing certain headers on ARCH=arm with CC=clang Nathan Chancellor
2026-01-11 10:29 ` Arnd Bergmann
2026-01-12 22:53 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox