Skip to contentSkip to conversation

build: fix sparc64 host

PATCH In review Pierrick Bouvier 4 participants 11 messages Jul 20 – Jul 21 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover build: fix sparc64 host

It was reported that build on sparc64 host is currently broken, due to inclusion of asm/kvm.h, which is not present on this platform:
https://lore.kernel.org/qemu-devel/[email protected]/

Problem is that we assumed in Kconfig that VFIO is available for all linux hosts, which is wrong. It is limited to linux hosts having kvm support. Since we already have a meson.build section identifying those hosts, just define a new CONFIG_KVM_HOST in host configuration.

Pierrick Bouvier (2):
meson.build: define CONFIG_KVM_HOST
hw/vfio: restrict to kvm hosts

 Kconfig.host    | 3 +++
 hw/vfio/Kconfig | 8 ++++----
 meson.build     | 4 ++++
 3 files changed, 11 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 meson.build: define CONFIG_KVM_HOST

True if we are on a host providing kvm acceleration. To the opposite of CONFIG_KVM, it will be enabled for all targets.

We used that in next commit to enable hw/vfio on kvm hosts only.

---
 Kconfig.host | 3 +++
 meson.build  | 4 ++++
 2 files changed, 7 insertions(+)
Kconfig.host +3 -0
index 933425c74b4..a7d8baaf723 100644
@@ -64,3 +64,6 @@ config HAVE_RUST
 
 config MAC_PVG
     bool
+
+config KVM_HOST
+    bool
meson.build +4 -0
index 164328ded83..632650e7d09 100644
@@ -274,6 +274,7 @@ else
   host_arch = cpu
 endif
 
+kvm_host = true
 if cpu == 'x86_64'
   kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
 elif cpu == 'aarch64'
@@ -288,6 +289,7 @@ elif cpu == 'loongarch64'
   kvm_targets = ['loongarch64-softmmu']
 else
   kvm_targets = []
+  kvm_host = false
 endif
 accelerator_targets = { 'CONFIG_KVM': kvm_targets }
 
@@ -2255,6 +2257,8 @@ endif
 
 config_host_data = configuration_data()
 
+config_host_data.set('CONFIG_KVM_HOST', kvm_host)
+
 config_host_data.set('CONFIG_HAVE_RUST', have_rust)
 audio_drivers_selected = []
 if have_system
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 hw/vfio: restrict to kvm hosts

In reply to Pierrick Bouvier

sparc64, which is one of our linux hosts, does no support kvm, thus vfio. As a result, it fails to build on this platform.

Thus, limit hw/vfio inclusion to kvm hosts, which provide vfio support.

---
 hw/vfio/Kconfig | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/vfio/Kconfig +4 -4
index 27de24e4db1..1329f8a2caa 100644
@@ -2,26 +2,26 @@
 
 config VFIO
     bool
-    depends on LINUX
+    depends on LINUX && KVM_HOST
 
 config VFIO_PCI
     bool
     default y
     select VFIO
     select EDID
-    depends on LINUX && PCI
+    depends on LINUX && PCI && KVM_HOST
 
 config VFIO_CCW
     bool
     default y
     select VFIO
-    depends on LINUX && S390_CCW_VIRTIO
+    depends on LINUX && S390_CCW_VIRTIO && KVM_HOST
 
 config VFIO_AP
     bool
     default y
     select VFIO
-    depends on LINUX && S390_CCW_VIRTIO
+    depends on LINUX && S390_CCW_VIRTIO && KVM_HOST
 
 config VFIO_IGD
     bool
Signature · 1 line
2.43.0
#3 lore raw
In reply to Pierrick Bouvier
Quoted 3 lines · On Mon, 20 Jul 2026 22:17:13 +0000 Pierrick Bouvier…

It was reported that build on sparc64 host is currently broken, due to inclusion of asm/kvm.h, which is not present on this platform:
https://lore.kernel.org/qemu-devel/[email protected]/

Isn't is sufficient just to remove the stale <linux/kvm.h> include?

I don't know of a case that fails, platforms that support vfio might actually be a sub-set of those that support KVM, but being dependent on a KVM supported host has no technical basis. KVM and VFIO are independent features where neither should have a hard dependency on the other. Thanks,

Alex

Quoted 14 lines

Problem is that we assumed in Kconfig that VFIO is available for all linux hosts, which is wrong. It is limited to linux hosts having kvm support. Since we already have a meson.build section identifying those hosts, just define a new CONFIG_KVM_HOST in host configuration.

Pierrick Bouvier (2):
meson.build: define CONFIG_KVM_HOST
hw/vfio: restrict to kvm hosts

 Kconfig.host    | 3 +++
 hw/vfio/Kconfig | 8 ++++----
 meson.build     | 4 ++++
 3 files changed, 11 insertions(+), 4 deletions(-)
#4 lore raw
Quoted 7 lines · Alex Williamson
Quoted 3 lines · On Mon, 20 Jul 2026 22:17:13 +0000 Pierrick Bouvier…

It was reported that build on sparc64 host is currently broken, due to inclusion of asm/kvm.h, which is not present on this platform:
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 8 lines

Isn't is sufficient just to remove the stale <linux/kvm.h> include?

I don't know of a case that fails, platforms that support vfio might actually be a sub-set of those that support KVM, but being dependent on a KVM supported host has no technical basis. KVM and VFIO are independent features where neither should have a hard dependency on the other. Thanks,

It's related to a recent change that was made to get rid of CONFIG_KVM in the file to deduplicate hw/vfio/listener.c between targets. So it's now unconditionally included, thus the regression.

Limit inclusion from the build system is the right way to deal with this, thus CONFIG_VFIO, thus why we need to do something to control through Kconfig.

Quoted 17 lines

Alex

Quoted 14 lines

Problem is that we assumed in Kconfig that VFIO is available for all linux hosts, which is wrong. It is limited to linux hosts having kvm support. Since we already have a meson.build section identifying those hosts, just define a new CONFIG_KVM_HOST in host configuration.

Pierrick Bouvier (2):
meson.build: define CONFIG_KVM_HOST
hw/vfio: restrict to kvm hosts

 Kconfig.host    | 3 +++
 hw/vfio/Kconfig | 8 ++++----
 meson.build     | 4 ++++
 3 files changed, 11 insertions(+), 4 deletions(-)
#5 lore raw
Quoted 17 lines · Pierrick Bouvier
Quoted 7 lines · Alex Williamson
Quoted 3 lines · On Mon, 20 Jul 2026 22:17:13 +0000 Pierrick Bouvier…

It was reported that build on sparc64 host is currently broken, due to inclusion of asm/kvm.h, which is not present on this platform:
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 8 lines

Isn't is sufficient just to remove the stale <linux/kvm.h> include?

I don't know of a case that fails, platforms that support vfio might actually be a sub-set of those that support KVM, but being dependent on a KVM supported host has no technical basis. KVM and VFIO are independent features where neither should have a hard dependency on the other. Thanks,

Quoted 3 lines

It's related to a recent change that was made to get rid of CONFIG_KVM in the file to deduplicate hw/vfio/listener.c between targets. So it's now unconditionally included, thus the regression.

I understand. I'm suggesting the fix is simply:

hw/vfio/listener.c +0 -1
index c19600e980a8..008f488a3e7d 100644
@@ -20,7 +20,6 @@
 
 #include "qemu/osdep.h"
 #include <sys/ioctl.h>
-#include <linux/kvm.h>
 #include <linux/vfio.h>
 
 #include "exec/target_page.h"

This builds in both a native amd64 environment and a cross-compiled sparc64 environment.

Quoted 3 lines

Limit inclusion from the build system is the right way to deal with this, thus CONFIG_VFIO, thus why we need to do something to control through Kconfig.

The right way to deal with the regression is to fix the regression, as done above. If you further want to avoid building vfio on sparc64, that's a separate discussion and should have nothing whatsoever to do with whether the host supports KVM. Thanks,

Alex

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines

Problem is that we assumed in Kconfig that VFIO is available for all linux hosts, which is wrong. It is limited to linux hosts having kvm support. Since we already have a meson.build section identifying those hosts, just define a new CONFIG_KVM_HOST in host configuration.

Pierrick Bouvier (2):
meson.build: define CONFIG_KVM_HOST
hw/vfio: restrict to kvm hosts

 Kconfig.host    | 3 +++
 hw/vfio/Kconfig | 8 ++++----
 meson.build     | 4 ++++
 3 files changed, 11 insertions(+), 4 deletions(-)
#6 lore raw
Quoted 37 lines · Alex Williamson
Quoted 17 lines · Pierrick Bouvier
Quoted 7 lines · Alex Williamson
Quoted 3 lines · On Mon, 20 Jul 2026 22:17:13 +0000 Pierrick Bouvier…

It was reported that build on sparc64 host is currently broken, due to inclusion of asm/kvm.h, which is not present on this platform:
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 8 lines

Isn't is sufficient just to remove the stale <linux/kvm.h> include?

I don't know of a case that fails, platforms that support vfio might actually be a sub-set of those that support KVM, but being dependent on a KVM supported host has no technical basis. KVM and VFIO are independent features where neither should have a hard dependency on the other. Thanks,

Quoted 3 lines

It's related to a recent change that was made to get rid of CONFIG_KVM in the file to deduplicate hw/vfio/listener.c between targets. So it's now unconditionally included, thus the regression.

I understand. I'm suggesting the fix is simply:

hw/vfio/listener.c +0 -1
index c19600e980a8..008f488a3e7d 100644
@@ -20,7 +20,6 @@
 
  #include "qemu/osdep.h"
  #include <sys/ioctl.h>
-#include <linux/kvm.h>
  #include <linux/vfio.h>
 
  #include "exec/target_page.h"
Quoted 1 line

This builds in both a native amd64 environment and a cross-compiled sparc64 environment.

This leaves linux/kvm.h included only in the following VFIO files:

hw/vfio/kvm-spapr.c
hw/vfio/kvm-helpers.c

Looks clean to me.

Thanks,

C.

#7 lore raw
Quoted 38 lines · Cédric Le Goater
Quoted 37 lines · Alex Williamson
Quoted 19 lines · Pierrick Bouvier
Quoted 9 lines · Alex Williamson
Quoted 5 lines · On Mon, 20 Jul 2026 22:17:13 +0000 Pierrick Bouvier…

It was reported that build on sparc64 host is currently broken, due to inclusion
of asm/kvm.h, which is not present on this platform:
https://lore.kernel.org/qemu-devel/c3a7cd83-7666-40c5-9baa-
[email protected]/

Quoted 8 lines

Isn't is sufficient just to remove the stale <linux/kvm.h> include?

I don't know of a case that fails, platforms that support vfio might actually be a sub-set of those that support KVM, but being dependent on a KVM supported host has no technical basis.  KVM and VFIO are independent features where neither should have a hard dependency on the other.  Thanks,

Quoted 3 lines

It's related to a recent change that was made to get rid of CONFIG_KVM in the file to deduplicate hw/vfio/listener.c between targets. So it's now unconditionally included, thus the regression.

I understand.  I'm suggesting the fix is simply:

hw/vfio/listener.c +0 -1
index c19600e980a8..008f488a3e7d 100644
@@ -20,7 +20,6 @@
     #include "qemu/osdep.h"
   #include <sys/ioctl.h>
-#include <linux/kvm.h>
   #include <linux/vfio.h>
     #include "exec/target_page.h"
 
Quoted 3 lines
Quoted 2 lines

This builds in both a native amd64 environment and a cross-compiled sparc64 environment.

Thanks, I'm ok with this.
Do you have instructions (or better, a Dockerfile) for the cross compile sparc64 environment you use?
It's the only host we don't have cross compilation environment at the moment.

Quoted 11 lines

This leaves linux/kvm.h included only in the following VFIO files:

  hw/vfio/kvm-spapr.c
  hw/vfio/kvm-helpers.c

Looks clean to me.

Thanks,

C.

#8 lore raw
Quoted 43 lines · Pierrick Bouvier
Quoted 38 lines · Cédric Le Goater
Quoted 37 lines · Alex Williamson
Quoted 19 lines · Pierrick Bouvier
Quoted 9 lines · Alex Williamson
Quoted 5 lines · On Mon, 20 Jul 2026 22:17:13 +0000 Pierrick Bouvier…

It was reported that build on sparc64 host is currently broken, due to inclusion
of asm/kvm.h, which is not present on this platform:
https://lore.kernel.org/qemu-devel/c3a7cd83-7666-40c5-9baa-
[email protected]/

Quoted 8 lines

Isn't is sufficient just to remove the stale <linux/kvm.h> include?

I don't know of a case that fails, platforms that support vfio might actually be a sub-set of those that support KVM, but being dependent on a KVM supported host has no technical basis.  KVM and VFIO are independent features where neither should have a hard dependency on the other.  Thanks,

Quoted 3 lines

It's related to a recent change that was made to get rid of CONFIG_KVM in the file to deduplicate hw/vfio/listener.c between targets. So it's now unconditionally included, thus the regression.

I understand.  I'm suggesting the fix is simply:

hw/vfio/listener.c +0 -1
index c19600e980a8..008f488a3e7d 100644
@@ -20,7 +20,6 @@
     #include "qemu/osdep.h"
   #include <sys/ioctl.h>
-#include <linux/kvm.h>
   #include <linux/vfio.h>
     #include "exec/target_page.h"
 
Quoted 3 lines
Quoted 2 lines

This builds in both a native amd64 environment and a cross-compiled sparc64 environment.

Quoted 12 lines

Thanks, I'm ok with this.
Do you have instructions (or better, a Dockerfile) for the cross compile sparc64 environment you use?
It's the only host we don't have cross compilation environment at the moment.

Quoted 6 lines

This leaves linux/kvm.h included only in the following VFIO files:

  hw/vfio/kvm-spapr.c
  hw/vfio/kvm-helpers.c

Looks clean to me.

With this fix, QEMU (sparc-softmmu,sparc64-softmmu) builds on a UltraSparc T5 running debian sid with linux 7.1.3.1-sparc64-smp.

For the record, make check passes.

I will send a patch.

Thanks,

C.

#9 lore raw
In reply to Alex Williamson
Quoted 13 lines · Alex Williamson
hw/vfio/listener.c +0 -1
index c19600e980a8..008f488a3e7d 100644
@@ -20,7 +20,6 @@
 
  #include "qemu/osdep.h"
  #include <sys/ioctl.h>
-#include <linux/kvm.h>
  #include <linux/vfio.h>
 
  #include "exec/target_page.h"
Quoted 1 line

This builds in both a native amd64 environment and a cross-compiled sparc64 environment.

Building it on native sparc64 (and on all other targets) on debian right now:
https://buildd.debian.org/status/package.php?p=qemu&suite=experimental

It's - drum roll - finishing building, so I guess it will be fine, let's see in a few minutes.

An unrelated note: we've very frequent failure of test qemu:io-qcow2-161
on ppc64 host:

stderr:

build/reproducible-path/qemu-11.1.0~rc0+ds/b/qemu/scratch/qcow2-file-161/161.out.bad renamed from build/reproducible-path/qemu-11.1.0~rc0+ds/tests/qemu-iotests/161.out +2 -0
@@ -34,6 +34,8 @@
 *** Commit and then change an option on the backing file
 
 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=1048576
+qemu-img: TEST_DIR/t.IMGFMT.base: Failed to get "write" lock
+Is another process using the image [TEST_DIR/t.IMGFMT.base]?
 Formatting 'TEST_DIR/t.IMGFMT.int', fmt=IMGFMT size=1048576 

backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
backing_file=TEST_DIR/t.IMGFMT.int backing_fmt=IMGFMT
{ 'execute': 'qmp_capabilities' }

Retrying several times makes it work in the end.
So far this happens on ppc64 debian buildds only.

Thanks,

/mjt

#10 lore raw
Quoted 13 lines · Michael Tokarev
Quoted 11 lines · Alex Williamson
hw/vfio/listener.c +0 -1
index c19600e980a8..008f488a3e7d 100644
@@ -20,7 +20,6 @@
   #include "qemu/osdep.h"
   #include <sys/ioctl.h>
-#include <linux/kvm.h>
   #include <linux/vfio.h>
   #include "exec/target_page.h"
 
Quoted 7 lines
Quoted 1 line

This builds in both a native amd64 environment and a cross-compiled sparc64 environment.

Building it on native sparc64 (and on all other targets) on debian right now:
https://buildd.debian.org/status/package.php?p=qemu&suite=experimental

It's - drum roll - finishing building, so I guess it will be fine, let's see in a few minutes.

With this change, everything is now green on the debian side.

Thanks,

/mjt