Skip to contentSkip to conversation

vfio: selftests: only build tests on arm64 and x86_64

PATCH Applied Ted Logan 6 participants 14 messages Feb 3 – Apr 28

Subsystems (4)
lore
Share & tools
lore

Ted Logan

author
#0 lore raw

PATCH v2 1/1 vfio: selftests: only build tests on arm64 and x86_64

Only build vfio self-tests on arm64 and x86_64; these are the only architectures where the vfio self-tests are run. Addresses compiler warnings for format and conversions on i386.

---
Do not build vfio self-tests for 32-bit architectures, where they're untested and unmaintained. Only build these tests for arm64 and x86_64, where they're regularly tested.

Compiler warning fixed by patch:

In file included from tools/testing/selftests/vfio/lib/include/libvfio.h:6:
tools/testing/selftests/vfio/lib/include/libvfio/iommu.h:49:2: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]

      49 |         VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:32:37: note: expanded from macro 'VFIO_ASSERT_EQ'
      32 | #define VFIO_ASSERT_EQ(_a, _b, ...) VFIO_ASSERT_OP(_a, _b, ==, ##__VA_ARGS__)
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:27:22: note: expanded from macro 'VFIO_ASSERT_OP'
      26 |         fprintf(stderr, "  Observed: %#lx %s %#lx\n",                           \
         |                                              ~~~~
      27 |                         (u64)__lhs, #_op, (u64)__rhs);                          \
         |                                           ^~~~~~~~~~

---
Changes in v2:
- Add white space around arch checks
- Clean up uname command
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tools/testing/selftests/vfio/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/testing/selftests/vfio/Makefile +9 -0
index ead27892ab65..8e90e409e91d 100644
@@ -1,3 +1,10 @@
+ARCH ?= $(shell uname -m)
+
+ifeq (,$(filter $(ARCH),arm64 x86_64))
+# Do nothing on unsupported architectures
+include ../lib.mk
+else
+
 CFLAGS = $(KHDR_INCLUDES)
 TEST_GEN_PROGS += vfio_dma_mapping_test
 TEST_GEN_PROGS += vfio_dma_mapping_mmio_test
@@ -28,3 +35,5 @@ TEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_PROGS_O) $(LIBVFIO_O))
 -include $(TEST_DEP_FILES)
 
 EXTRA_CLEAN += $(TEST_GEN_PROGS_O) $(TEST_DEP_FILES)
+
+endif

---
base-commit: c3cbc276c2a33b04fc78a86cdb2ddce094cb3614
change-id: 20260130-vfio-selftest-only-64bit-422518bdeba7

Best regards,

Signature · 1 line
Ted Logan <[email protected]>
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Ted Logan

Only build vfio self-tests on arm64 and x86_64; these are the only architectures where the vfio self-tests are run. Addresses compiler warnings for format and conversions on i386.

maintainer Applied
#2 lore raw
In reply to Ted Logan
Quoted 61 lines · On Mon, 2 Feb 2026 17:23:53 -0800 Ted Logan <[email protected]> wrote:

Only build vfio self-tests on arm64 and x86_64; these are the only architectures where the vfio self-tests are run. Addresses compiler warnings for format and conversions on i386.

---
Do not build vfio self-tests for 32-bit architectures, where they're untested and unmaintained. Only build these tests for arm64 and x86_64, where they're regularly tested.

Compiler warning fixed by patch:

   In file included from tools/testing/selftests/vfio/lib/include/libvfio.h:6:
   tools/testing/selftests/vfio/lib/include/libvfio/iommu.h:49:2: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
      49 |         VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:32:37: note: expanded from macro 'VFIO_ASSERT_EQ'
      32 | #define VFIO_ASSERT_EQ(_a, _b, ...) VFIO_ASSERT_OP(_a, _b, ==, ##__VA_ARGS__)
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:27:22: note: expanded from macro 'VFIO_ASSERT_OP'
      26 |         fprintf(stderr, "  Observed: %#lx %s %#lx\n",                           \
         |                                              ~~~~
      27 |                         (u64)__lhs, #_op, (u64)__rhs);                          \
         |                                           ^~~~~~~~~~

---
Changes in v2:
- Add white space around arch checks
- Clean up uname command
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tools/testing/selftests/vfio/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/testing/selftests/vfio/Makefile +9 -1
index ead27892ab65..8e90e409e91d 100644
@@ -1,3 +1,10 @@
+ARCH ?= $(shell uname -m)
+
+ifeq (,$(filter $(ARCH),arm64 x86_64))
+# Do nothing on unsupported architectures
+include ../lib.mk
+else
+
 CFLAGS = $(KHDR_INCLUDES)
 TEST_GEN_PROGS += vfio_dma_mapping_test
 TEST_GEN_PROGS += vfio_dma_mapping_mmio_test
@@ -28,3 +35,5 @@ TEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_PROGS_O) $(LIBVFIO_O))
 -include $(TEST_DEP_FILES)
 
 EXTRA_CLEAN += $(TEST_GEN_PROGS_O) $(TEST_DEP_FILES)
+
+endif
 
---

base-commit: c3cbc276c2a33b04fc78a86cdb2ddce094cb3614
change-id: 20260130-vfio-selftest-only-64bit-422518bdeba7

Quoted 1 line

Best regards,

Applied to vfio next branch for v7.0/6.20. Thanks,

Alex

#3 lore raw
In reply to Ted Logan

Hi Ted,

Quoted 40 lines · Ted Logan

Only build vfio self-tests on arm64 and x86_64; these are the only architectures where the vfio self-tests are run. Addresses compiler warnings for format and conversions on i386.

---
Do not build vfio self-tests for 32-bit architectures, where they're untested and unmaintained. Only build these tests for arm64 and x86_64, where they're regularly tested.

Compiler warning fixed by patch:

   In file included from tools/testing/selftests/vfio/lib/include/libvfio.h:6:
   tools/testing/selftests/vfio/lib/include/libvfio/iommu.h:49:2: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
      49 |         VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:32:37: note: expanded from macro 'VFIO_ASSERT_EQ'
      32 | #define VFIO_ASSERT_EQ(_a, _b, ...) VFIO_ASSERT_OP(_a, _b, ==, ##__VA_ARGS__)
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:27:22: note: expanded from macro 'VFIO_ASSERT_OP'
      26 |         fprintf(stderr, "  Observed: %#lx %s %#lx\n",                           \
         |                                              ~~~~
      27 |                         (u64)__lhs, #_op, (u64)__rhs);                          \
         |                                           ^~~~~~~~~~

---
Changes in v2:
- Add white space around arch checks
- Clean up uname command
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tools/testing/selftests/vfio/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/testing/selftests/vfio/Makefile +0 -0
index ead27892ab65..8e90e409e91d 100644

tools/testing/selftests/vfio/Makefile line 3

Quoted 3 lines
tools/testing/selftests/vfio/Makefile +3 -0
@@ -1,3 +1,10 @@
+ARCH ?= $(shell uname -m)
+
+ifeq (,$(filter $(ARCH),arm64 x86_64))

This fails to build (i.e. elides the build) on my local arm64 machine, because uname -m returns 'aarch64', not 'arm64'.

Are you seeing an arm64 (Linux! [1]) machine where uname -m is 'arm64'...?

This patch needs some translation, of the sort in
tools/testing/selftests/mm/Makefile:15

-Matt

[1] Note on macOS/M-Mac, uname -m is indeed 'arm64', but not so on Linux.

Quoted 19 lines
tools/testing/selftests/vfio/Makefile +6 -1
+# Do nothing on unsupported architectures
+include ../lib.mk
+else
+
 CFLAGS = $(KHDR_INCLUDES)
 TEST_GEN_PROGS += vfio_dma_mapping_test
 TEST_GEN_PROGS += vfio_dma_mapping_mmio_test
@@ -28,3 +35,5 @@ TEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_PROGS_O) $(LIBVFIO_O))
 -include $(TEST_DEP_FILES)
 
 EXTRA_CLEAN += $(TEST_GEN_PROGS_O) $(TEST_DEP_FILES)
+
+endif
 
---

base-commit: c3cbc276c2a33b04fc78a86cdb2ddce094cb3614
change-id: 20260130-vfio-selftest-only-64bit-422518bdeba7

Best regards,

author
#4 lore raw
Quoted 15 lines · Matt Evans

tools/testing/selftests/vfio/Makefile line 3

Quoted 8 lines · Ted Logan
tools/testing/selftests/vfio/Makefile +3 -0
index ead27892ab65..8e90e409e91d 100644
@@ -1,3 +1,10 @@
+ARCH ?= $(shell uname -m)
+
+ifeq (,$(filter $(ARCH),arm64 x86_64))

This fails to build (i.e. elides the build) on my local arm64 machine, because uname -m returns 'aarch64', not 'arm64'.

Are you seeing an arm64 (Linux! [1]) machine where uname -m is 'arm64'...?

Quoted 7 lines

This patch needs some translation, of the sort in
tools/testing/selftests/mm/Makefile:15

-Matt

[1] Note on macOS/M-Mac, uname -m is indeed 'arm64', but not so on Linux.

I didn't have an aarch64 system handy to test when I sent my first patch, so I went with David's comment in an earlier thread that x86_64 and arm64 are supported. I did just fire up a Linux VM on my Mac and I see it does indeed report the arch as aarch64, and that it builds the self-tests without warnings. I'll mail a patch to translate the architecture as you suggest.

- Ted

#5 lore raw
In reply to Matt Evans
Quoted 38 lines · Matt Evans

Hi Ted,

Quoted 35 lines · Ted Logan

Only build vfio self-tests on arm64 and x86_64; these are the only architectures where the vfio self-tests are run. Addresses compiler warnings for format and conversions on i386.

---
Do not build vfio self-tests for 32-bit architectures, where they're untested and unmaintained. Only build these tests for arm64 and x86_64, where they're regularly tested.

Compiler warning fixed by patch:

   In file included from tools/testing/selftests/vfio/lib/include/libvfio.h:6:
   tools/testing/selftests/vfio/lib/include/libvfio/iommu.h:49:2: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
      49 |         VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:32:37: note: expanded from macro 'VFIO_ASSERT_EQ'
      32 | #define VFIO_ASSERT_EQ(_a, _b, ...) VFIO_ASSERT_OP(_a, _b, ==, ##__VA_ARGS__)
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:27:22: note: expanded from macro 'VFIO_ASSERT_OP'
      26 |         fprintf(stderr, "  Observed: %#lx %s %#lx\n",                           \
         |                                              ~~~~
      27 |                         (u64)__lhs, #_op, (u64)__rhs);                          \
         |                                           ^~~~~~~~~~

---
Changes in v2:
- Add white space around arch checks
- Clean up uname command
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tools/testing/selftests/vfio/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 11 lines

tools/testing/selftests/vfio/Makefile line 3

Quoted 8 lines
tools/testing/selftests/vfio/Makefile +3 -0
index ead27892ab65..8e90e409e91d 100644
@@ -1,3 +1,10 @@
+ARCH ?= $(shell uname -m)
+
+ifeq (,$(filter $(ARCH),arm64 x86_64))

This fails to build (i.e. elides the build) on my local arm64 machine, because uname -m returns 'aarch64', not 'arm64'.

I have the same issue on x86! The kernel uses x86 is the ARCH when you run it straight from the top level make

make[4]: Entering directory '/home/jgg/oss/wip/mlx5st/tools/testing/selftests/vfio' Makefile:1: "Saw ARCH=x86"

Even though this is a 64 bit build.

Jason

#6 lore raw
Quoted 51 lines · Jason Gunthorpe
Quoted 38 lines · Matt Evans

Hi Ted,

Quoted 35 lines · Ted Logan

Only build vfio self-tests on arm64 and x86_64; these are the only architectures where the vfio self-tests are run. Addresses compiler warnings for format and conversions on i386.

---
Do not build vfio self-tests for 32-bit architectures, where they're untested and unmaintained. Only build these tests for arm64 and x86_64, where they're regularly tested.

Compiler warning fixed by patch:

   In file included from tools/testing/selftests/vfio/lib/include/libvfio.h:6:
   tools/testing/selftests/vfio/lib/include/libvfio/iommu.h:49:2: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
      49 |         VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:32:37: note: expanded from macro 'VFIO_ASSERT_EQ'
      32 | #define VFIO_ASSERT_EQ(_a, _b, ...) VFIO_ASSERT_OP(_a, _b, ==, ##__VA_ARGS__)
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:27:22: note: expanded from macro 'VFIO_ASSERT_OP'
      26 |         fprintf(stderr, "  Observed: %#lx %s %#lx\n",                           \
         |                                              ~~~~
      27 |                         (u64)__lhs, #_op, (u64)__rhs);                          \
         |                                           ^~~~~~~~~~

---
Changes in v2:
- Add white space around arch checks
- Clean up uname command
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tools/testing/selftests/vfio/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 11 lines

tools/testing/selftests/vfio/Makefile line 3

Quoted 8 lines
tools/testing/selftests/vfio/Makefile +3 -0
index ead27892ab65..8e90e409e91d 100644
@@ -1,3 +1,10 @@
+ARCH ?= $(shell uname -m)
+
+ifeq (,$(filter $(ARCH),arm64 x86_64))

This fails to build (i.e. elides the build) on my local arm64 machine, because uname -m returns 'aarch64', not 'arm64'.

Quoted 7 lines

I have the same issue on x86! The kernel uses x86 is the ARCH when you run it straight from the top level make

make[4]: Entering directory '/home/jgg/oss/wip/mlx5st/tools/testing/selftests/vfio' Makefile:1: "Saw ARCH=x86"

Even though this is a 64 bit build.

Heh, it's much funnier when it's happening to someone else. :-)

KVM selftests went through these exact pains. I'm pretty sure these are the relevant commits (the empty targets one may or may not apply to VFIO).

9af04539d474dda4984ff4909d4568e6123c8cba KVM: selftests: Override ARCH for x86_64 instead of using ARCH_DIR 67730e6c53d70fb31618230f81c4acee9f72eaa3 KVM: selftests: Use canonical $(ARCH) paths for KVM selftests directories 43fbd8cd389faa9760c5152b1c58e893c812953b KVM: selftests: Provide empty 'all' and 'clean' targets for unsupported ARCHs

maintainer
#7 lore raw
Quoted 60 lines · Sean Christopherson
Quoted 51 lines · Jason Gunthorpe
Quoted 38 lines · Matt Evans

Hi Ted,

Quoted 35 lines · Ted Logan

Only build vfio self-tests on arm64 and x86_64; these are the only architectures where the vfio self-tests are run. Addresses compiler warnings for format and conversions on i386.

---
Do not build vfio self-tests for 32-bit architectures, where they're untested and unmaintained. Only build these tests for arm64 and x86_64, where they're regularly tested.

Compiler warning fixed by patch:

   In file included from tools/testing/selftests/vfio/lib/include/libvfio.h:6:
   tools/testing/selftests/vfio/lib/include/libvfio/iommu.h:49:2: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
      49 |         VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:32:37: note: expanded from macro 'VFIO_ASSERT_EQ'
      32 | #define VFIO_ASSERT_EQ(_a, _b, ...) VFIO_ASSERT_OP(_a, _b, ==, ##__VA_ARGS__)
         |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   tools/testing/selftests/vfio/lib/include/libvfio/assert.h:27:22: note: expanded from macro 'VFIO_ASSERT_OP'
      26 |         fprintf(stderr, "  Observed: %#lx %s %#lx\n",                           \
         |                                              ~~~~
      27 |                         (u64)__lhs, #_op, (u64)__rhs);                          \
         |                                           ^~~~~~~~~~

---
Changes in v2:
- Add white space around arch checks
- Clean up uname command
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tools/testing/selftests/vfio/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 11 lines

tools/testing/selftests/vfio/Makefile line 3

Quoted 8 lines
tools/testing/selftests/vfio/Makefile +3 -0
index ead27892ab65..8e90e409e91d 100644
@@ -1,3 +1,10 @@
+ARCH ?= $(shell uname -m)
+
+ifeq (,$(filter $(ARCH),arm64 x86_64))

This fails to build (i.e. elides the build) on my local arm64 machine, because uname -m returns 'aarch64', not 'arm64'.

Quoted 7 lines

I have the same issue on x86! The kernel uses x86 is the ARCH when you run it straight from the top level make

make[4]: Entering directory '/home/jgg/oss/wip/mlx5st/tools/testing/selftests/vfio' Makefile:1: "Saw ARCH=x86"

Even though this is a 64 bit build.

Quoted 8 lines

Heh, it's much funnier when it's happening to someone else. :-)

KVM selftests went through these exact pains. I'm pretty sure these are the relevant commits (the empty targets one may or may not apply to VFIO).

9af04539d474dda4984ff4909d4568e6123c8cba KVM: selftests: Override ARCH for x86_64 instead of using ARCH_DIR 67730e6c53d70fb31618230f81c4acee9f72eaa3 KVM: selftests: Use canonical $(ARCH) paths for KVM selftests directories 43fbd8cd389faa9760c5152b1c58e893c812953b KVM: selftests: Provide empty 'all' and 'clean' targets for unsupported ARCHs

KVM selftests don't prevent 32-bit x86 builds though, which is part of what we're trying to do here.

For example running...

  $ make -C tools/testing/selftests/kvm ARCH=x86 CC="gcc -m32"

...produces a lot of -Wformat errors that were also seeing in VFIO selftests from the kernel test robot.

I think something like this would fix your issue Jason. I haven't tested it on ARM yet:

tools/testing/selftests/vfio/Makefile +6 -1
index 0684932d91bf..db71aef6bfb2 100644
@@ -1,6 +1,11 @@
 ARCH ?= $(shell uname -m)
 
-ifeq (,$(filter $(ARCH),aarch64 arm64 x86_64))
+# VFIO selftests are currently only supported on 64-bit x86 and ARM.
+ifneq (,$(filter $(ARCH),x86 x86_64 aarch64 arm64))
+SUPPORTED_ARCH := $(shell echo __LP64__ | $(CC) $(CFLAGS) -E -x c - | tail -n 1)
+endif
+
+ifneq ($(SUPPORTED_ARCH),1)
 # Do nothing on unsupported architectures
 include ../lib.mk
 else
#8 lore raw
Quoted 6 lines · David Matlack
Quoted 5 lines · Sean Christopherson
Quoted 1 line · Jason Gunthorpe

Even though this is a 64 bit build.

Heh, it's much funnier when it's happening to someone else. :-)

Quoted 8 lines
Quoted 6 lines

KVM selftests went through these exact pains. I'm pretty sure these are the relevant commits (the empty targets one may or may not apply to VFIO).

9af04539d474dda4984ff4909d4568e6123c8cba KVM: selftests: Override ARCH for x86_64 instead of using ARCH_DIR 67730e6c53d70fb31618230f81c4acee9f72eaa3 KVM: selftests: Use canonical $(ARCH) paths for KVM selftests directories 43fbd8cd389faa9760c5152b1c58e893c812953b KVM: selftests: Provide empty 'all' and 'clean' targets for unsupported ARCHs

KVM selftests don't prevent 32-bit x86 builds though,

Yes they do? x86 is an alias for x86_64 (or vice versa), and so the i386 target gets binned into the empty target provided by tools/testing/selftests/kvm/Makefile. And KVM selftests most definitely don't play nice with 32-bit.

Quoted 8 lines

which is part of what we're trying to do here.

For example running...

  $ make -C tools/testing/selftests/kvm ARCH=x86 CC="gcc -m32"

...produces a lot of -Wformat errors that were also seeing in VFIO selftests from the kernel test robot.

Uh, don't do that? KVM selftests can't even get past the preprocessor with -m32. Either the kernel test robot is trolling y'all, or there's something missing in the VFIO configuration, because I'm not seeing any magic in KVM to guard against the above.

maintainer
#9 lore raw
Quoted 15 lines · Sean Christopherson
Quoted 13 lines · David Matlack
Quoted 11 lines · Sean Christopherson
Quoted 1 line · Jason Gunthorpe

Even though this is a 64 bit build.

Heh, it's much funnier when it's happening to someone else. :-)

KVM selftests went through these exact pains. I'm pretty sure these are the relevant commits (the empty targets one may or may not apply to VFIO).

9af04539d474dda4984ff4909d4568e6123c8cba KVM: selftests: Override ARCH for x86_64 instead of using ARCH_DIR 67730e6c53d70fb31618230f81c4acee9f72eaa3 KVM: selftests: Use canonical $(ARCH) paths for KVM selftests directories 43fbd8cd389faa9760c5152b1c58e893c812953b KVM: selftests: Provide empty 'all' and 'clean' targets for unsupported ARCHs

Quoted 5 lines
Quoted 1 line

KVM selftests don't prevent 32-bit x86 builds though,

Yes they do? x86 is an alias for x86_64 (or vice versa), and so the i386 target gets binned into the empty target provided by tools/testing/selftests/kvm/Makefile. And KVM selftests most definitely don't play nice with 32-bit.

Are you sure that x86 is an alias for x86_64? If it is then we don't even need the __LP64__ stuff I posted.

But when I look at the top-level Makefile and imagine running make without setting ARCH on the command line on a 32-bit x86 host, ARCH will be set to SUBARCH, which will be x86.

#10 lore raw
Quoted 16 lines · David Matlack
Quoted 15 lines · Sean Christopherson
Quoted 13 lines · David Matlack
Quoted 11 lines · Sean Christopherson
Quoted 1 line · Jason Gunthorpe

Even though this is a 64 bit build.

Heh, it's much funnier when it's happening to someone else. :-)

KVM selftests went through these exact pains. I'm pretty sure these are the relevant commits (the empty targets one may or may not apply to VFIO).

9af04539d474dda4984ff4909d4568e6123c8cba KVM: selftests: Override ARCH for x86_64 instead of using ARCH_DIR 67730e6c53d70fb31618230f81c4acee9f72eaa3 KVM: selftests: Use canonical $(ARCH) paths for KVM selftests directories 43fbd8cd389faa9760c5152b1c58e893c812953b KVM: selftests: Provide empty 'all' and 'clean' targets for unsupported ARCHs

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

KVM selftests don't prevent 32-bit x86 builds though,

Yes they do? x86 is an alias for x86_64 (or vice versa), and so the i386 target gets binned into the empty target provided by tools/testing/selftests/kvm/Makefile. And KVM selftests most definitely don't play nice with 32-bit.

Are you sure that x86 is an alias for x86_64?

Well, I was quite sure :-) But scripts/subarch.include disagrees:

  SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \

as does attempting to build KVM selftests on a 32-bit host.

Quoted 5 lines

If it is then we don't even need the __LP64__ stuff I posted.

But when I look at the top-level Makefile and imagine running make without setting ARCH on the command line on a 32-bit x86 host, ARCH will be set to SUBARCH, which will be x86.

Yep. So the big question is, why doesn't anyone complain about KVM selftests not building on 32-bit? Because they most definitely don't build.

maintainer
#11 lore raw
Quoted 24 lines · Sean Christopherson
Quoted 22 lines · David Matlack
Quoted 20 lines · Sean Christopherson
Quoted 6 lines · David Matlack
Quoted 5 lines · Sean Christopherson
Quoted 1 line · Jason Gunthorpe

Even though this is a 64 bit build.

Heh, it's much funnier when it's happening to someone else. :-)

Quoted 8 lines
Quoted 6 lines

KVM selftests went through these exact pains. I'm pretty sure these are the relevant commits (the empty targets one may or may not apply to VFIO).

9af04539d474dda4984ff4909d4568e6123c8cba KVM: selftests: Override ARCH for x86_64 instead of using ARCH_DIR 67730e6c53d70fb31618230f81c4acee9f72eaa3 KVM: selftests: Use canonical $(ARCH) paths for KVM selftests directories 43fbd8cd389faa9760c5152b1c58e893c812953b KVM: selftests: Provide empty 'all' and 'clean' targets for unsupported ARCHs

KVM selftests don't prevent 32-bit x86 builds though,

Yes they do? x86 is an alias for x86_64 (or vice versa), and so the i386 target gets binned into the empty target provided by tools/testing/selftests/kvm/Makefile. And KVM selftests most definitely don't play nice with 32-bit.

Quoted 7 lines
Quoted 1 line

Are you sure that x86 is an alias for x86_64?

Well, I was quite sure :-) But scripts/subarch.include disagrees:

  SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \

as does attempting to build KVM selftests on a 32-bit host.

Yeah that's what I was seeing as well. With that cleared up I'll send a fix for VFIO selftests to allow ARCH=x86 if __LP64__ is defined, which will fix Jason's issue.

Quoted 8 lines
Quoted 5 lines

If it is then we don't even need the __LP64__ stuff I posted.

But when I look at the top-level Makefile and imagine running make without setting ARCH on the command line on a 32-bit x86 host, ARCH will be set to SUBARCH, which will be x86.

Yep. So the big question is, why doesn't anyone complain about KVM selftests not building on 32-bit? Because they most definitely don't build.

I guess no one's building on 32-bit hosts anymore? :)

#12 lore raw
Quoted 10 lines · David Matlack
Quoted 8 lines
Quoted 5 lines

If it is then we don't even need the __LP64__ stuff I posted.

But when I look at the top-level Makefile and imagine running make without setting ARCH on the command line on a 32-bit x86 host, ARCH will be set to SUBARCH, which will be x86.

Yep. So the big question is, why doesn't anyone complain about KVM selftests not building on 32-bit? Because they most definitely don't build.

I guess no one's building on 32-bit hosts anymore? :)

Well, if that's the case and kvm is broken too, then just ignore it and turn on vfio for x86 like kvm does?

No sense in just fixing it for VFIO..

<sigh wishes to have a better build system for userspace selftests>

Jason

maintainer
#13 lore raw
Quoted 10 lines · Jason Gunthorpe
Quoted 9 lines · David Matlack
Quoted 8 lines
Quoted 5 lines

If it is then we don't even need the __LP64__ stuff I posted.

But when I look at the top-level Makefile and imagine running make without setting ARCH on the command line on a 32-bit x86 host, ARCH will be set to SUBARCH, which will be x86.

Yep. So the big question is, why doesn't anyone complain about KVM selftests not building on 32-bit? Because they most definitely don't build.

Quoted 6 lines
Quoted 1 line

I guess no one's building on 32-bit hosts anymore? :)

Well, if that's the case and kvm is broken too, then just ignore it and turn on vfio for x86 like kvm does?

No sense in just fixing it for VFIO..

That's fair... So something like this?

From: David Matlack <[email protected]>
Date: Tue, 28 Apr 2026 22:57:48 +0000
Subject: [PATCH] vfio: selftests: Allow builds when ARCH=x86

Allow builds when ARCH=x86 since the top-level Makefile can set ARCH=x86 even for 64-bit x86 builds. ARCH=x86 can also be set if the host is 32-bit x86, but based on the fact that KVM selftests allow ARCH=x86 but also don't build for 32-bit x86, this isn't an issue in practice.

tools/testing/selftests/vfio/Makefile +1 -1
index 0684932d91bf..40165d087a0b 100644
@@ -1,6 +1,6 @@
 ARCH ?= $(shell uname -m)
 
-ifeq (,$(filter $(ARCH),aarch64 arm64 x86_64))
+ifeq (,$(filter $(ARCH),aarch64 arm64 x86 x86_64))
 # Do nothing on unsupported architectures
 include ../lib.mk
 else

/usr/local/google/home/dmatlack/kernel/trees/vfio