After investigating a little, looks like tools/include/linux/compiler.h already defines __packed correctly. While UAPI headers (e.g. linux/kvm.h) use __packed but don't include it themselves, the include ordering looks fine for this to be handled by the build system.
I'll drop this patch and investigate further why the tools infrastructure isn't working correctly in my setup. Thanks for the feedback! -- Aqib Faruqui Software Dev Intern (Embedded) | EC2 Accelerated Nitro | AWS +44 7763104413 On 29/08/2025, 23:48, "Sean Christopherson" <sea...@google.com <mailto:sea...@google.com>> wrote: CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. On Fri, Aug 29, 2025, Aqib Faruqui wrote: > Kernel UAPI headers use __packed but don't provide the definition in > userspace builds. > > Add a fallback definition matching the kernel's implementation. This > follows the same pattern used by BPF and SGX selftests. Ugh. No, this needs to be fixed in a central location, not splattered all over random subsystem selftests. My first choice would be to copy (and keep synchronize) all of the include/linux/compiler*.h headers to tools/include/linux/. If for some reason that's not a viable option, we should yank the __packed and similar #defines out of tools/include/linux/compiler-gcc.h and place them in tools/include/linux/compiler.h. AFAICT, none of them are actually GCC-only. > Signed-off-by: Aqib Faruqui <aqi...@amazon.com <mailto:aqi...@amazon.com>> > --- > tools/testing/selftests/kvm/include/kvm_util.h | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/testing/selftests/kvm/include/kvm_util.h > b/tools/testing/selftests/kvm/include/kvm_util.h > index 23a506d7e..7fae7f5e7 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util.h > +++ b/tools/testing/selftests/kvm/include/kvm_util.h > @@ -5,6 +5,10 @@ > #ifndef SELFTEST_KVM_UTIL_H > #define SELFTEST_KVM_UTIL_H > > +#ifndef __packed > +#define __packed __attribute__((__packed__)) > +#endif > + > #include "test_util.h" > > #include <linux/compiler.h> > -- > 2.47.3 >