From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"kernel test robot" <lkp@intel.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Wei Liu (Microsoft)" <wei.liu@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Sasha Levin" <sashal@kernel.org>,
kys@microsoft.com, haiyangz@microsoft.com, decui@microsoft.com,
longli@microsoft.com, linux-hyperv@vger.kernel.org,
llvm@lists.linux.dev
Subject: [PATCH AUTOSEL 6.19-5.10] hyper-v: Mark inner union in hv_kvp_exchg_msg_value as packed
Date: Fri, 13 Feb 2026 19:59:01 -0500 [thread overview]
Message-ID: <20260214010245.3671907-61-sashal@kernel.org> (raw)
In-Reply-To: <20260214010245.3671907-1-sashal@kernel.org>
From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
[ Upstream commit 1e5271393d777f6159d896943b4c44c4f3ecff52 ]
The unpacked union within a packed struct generates alignment warnings
on clang for 32-bit ARM:
./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 {
| ^
With the recent changes to compile-test the UAPI headers in more cases,
this warning in combination with CONFIG_WERROR breaks the build.
Fix the warning.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512140314.DzDxpIVn-lkp@intel.com/
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/linux-kbuild/20260110-uapi-test-disable-headers-arm-clang-unaligned-access-v1-1-b7b0fa541daa@kernel.org/
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/linux-kbuild/29b2e736-d462-45b7-a0a9-85f8d8a3de56@app.fastmail.com/
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Wei Liu (Microsoft) <wei.liu@kernel.org>
Tested-by: Nicolas Schier <nsc@kernel.org>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/20260115-kbuild-alignment-vbox-v1-1-076aed1623ff@linutronix.de
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Analysis
### Commit Message Analysis
This commit fixes a build error caused by an unpacked union within a
packed struct in a UAPI header (`include/uapi/linux/hyperv.h`). The
issue manifests as a `-Werror,-Wunaligned-access` error on clang for
32-bit ARM, which **breaks the build** when `CONFIG_WERROR` is enabled.
Key signals:
- **Two separate "Reported-by:" tags** — kernel test robot and Nathan
Chancellor (a prominent kernel build/clang developer)
- **Multiple "Closes:" links** to actual build failure reports
- **Tested-by** and **Reviewed-by** from Nicolas Schier
- **Acked-by** from subsystem maintainer (Wei Liu) and Greg Kroah-
Hartman himself
- Commit message explicitly says "breaks the build"
### Code Change Analysis
The change is a single-line modification:
```c
- };
+ } __attribute__((packed));
```
This adds the `packed` attribute to an anonymous union inside the
already-packed struct `hv_kvp_exchg_msg_value`. The outer struct is
already `__attribute__((packed))`, so adding `packed` to the inner union
aligns it with the containing struct's packing requirement, silencing
the clang warning.
**Functional impact**: This union contains `__u8 value[...]`, `__u32
value_u32`, and `__u64 value_u64`. Since the union is inside a packed
struct, the compiler should already be treating accesses as potentially
unaligned. Adding `packed` to the union itself makes this explicit and
resolves the inconsistency that triggers the warning. There is **no
change to the actual memory layout** — the struct was already packed,
and the union within it was already at whatever offset the packing
dictated. This just makes the annotation consistent.
### Classification
This is a **build fix** — one of the explicitly allowed categories for
stable backporting. It prevents compilation failure on a specific (and
common) configuration: clang + 32-bit ARM + CONFIG_WERROR.
### Scope and Risk Assessment
- **Lines changed**: 1 (literally changing `};` to `}
__attribute__((packed));`)
- **Files changed**: 1 UAPI header
- **Risk**: Extremely low. The packed attribute on the inner union is
semantically correct (the outer struct is already packed), and this
doesn't change the ABI or memory layout
- **Subsystem**: Hyper-V UAPI header, but the fix is really about build
correctness
### User Impact
- **Who is affected**: Anyone building the kernel with clang on 32-bit
ARM (or potentially other architectures in the future) with
`CONFIG_WERROR=y`
- **Severity**: Build breakage — users literally cannot compile the
kernel in this configuration
- **Frequency**: 100% reproducible in the affected configuration
### Stability Indicators
- Acked by Greg Kroah-Hartman (stable tree maintainer)
- Acked by Wei Liu (Hyper-V maintainer)
- Tested and reviewed by Nicolas Schier
- The fix is trivially correct — adding packed to a union inside a
packed struct
### Dependency Check
This commit is self-contained. It references "recent changes to compile-
test the UAPI headers in more cases" as the trigger that exposed this
warning, but the fix itself (adding packed to the union) is valid
regardless of whether those compile-test changes are present. The
underlying warning condition exists in any version of this header
compiled with clang on ARM.
However, I should check if the struct in question exists in older stable
trees.
The struct `hv_kvp_exchg_msg_value` with this union has been in
`include/uapi/linux/hyperv.h` for a very long time (it's part of the
Hyper-V KVP userspace interface). The fix would apply cleanly to any
stable tree that has this header.
### Conclusion
This is a textbook stable backport candidate:
- **Fixes a real build breakage** (not just a warning — it errors out
with CONFIG_WERROR)
- **Trivially small and obviously correct** — one attribute addition
- **Zero risk of regression** — no behavioral change, no ABI change
- **Well-reviewed** — acked by GKH, subsystem maintainer, tested and
reviewed
- **Multiple reporters** — real-world problem encountered by kernel test
infrastructure and developers
- Build fixes are explicitly listed as appropriate stable material
**YES**
include/uapi/linux/hyperv.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h
index aaa502a7bff46..1749b35ab2c21 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;
- };
+ } __attribute__((packed));
} __attribute__((packed));
struct hv_kvp_msg_enumerate {
--
2.51.0
next parent reply other threads:[~2026-02-14 1:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260214010245.3671907-1-sashal@kernel.org>
2026-02-14 0:59 ` Sasha Levin [this message]
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-5.10] media: solo6x10: Check for out of bounds chip_id Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-5.10] virt: vbox: uapi: Mark inner unions in packed structs as packed Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260214010245.3671907-61-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=arnd@arndb.de \
--cc=decui@microsoft.com \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=longli@microsoft.com \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox