Skip to contentSkip to conversation

hw/vfio/helpers: Check base architecture at runtime

PATCH Superseded Philippe Mathieu-Daudé 4 participants 5 messages Oct 20, 2025 – Oct 21, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/vfio/helpers: Check base architecture at runtime

Replace the compile time check of the TARGET_ARM definition by a runtime call to target_base_arm().

---
Based-on: <[email protected]>

---
 hw/vfio/helpers.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/vfio/helpers.c +2 -5
index 23d13e5db5f..007c37b28b8 100644
@@ -20,6 +20,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/target-info.h"
 #include <sys/ioctl.h>
 
 #include "system/kvm.h"
@@ -220,9 +221,5 @@ bool vfio_arch_wants_loading_config_after_iter(void)
      * See commit d329f5032e17 ("vfio: Move the saving of the config space to
      * the right place in VFIO migration").
      */
-#if defined(TARGET_ARM)
-    return true;
-#else
-    return false;
-#endif
+    return target_base_arm();
 }
Signature · 1 line
2.51.0
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 23 lines · Philippe Mathieu-Daudé

Replace the compile time check of the TARGET_ARM definition by a runtime call to target_base_arm().

---
Based-on: <[email protected]>

---
  hw/vfio/helpers.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
hw/vfio/helpers.c +1 -0
index 23d13e5db5f..007c37b28b8 100644
@@ -20,6 +20,7 @@
   */
 
  #include "qemu/osdep.h"
+#include "qemu/target-info.h"
  #include <sys/ioctl.h>
 
  #include "system/kvm.h"

hw/vfio/helpers.c bool vfio_arch_wants_loading_config_after_iter(void) · line 224

Quoted 9 lines
hw/vfio/helpers.c +1 -5
@@ -220,9 +221,5 @@ bool vfio_arch_wants_loading_config_after_iter(void)
       * See commit d329f5032e17 ("vfio: Move the saving of the config space to
       * the right place in VFIO migration").
       */
-#if defined(TARGET_ARM)
-    return true;
-#else
-    return false;
-#endif
+    return target_base_arm();

is that a new helper ? I don't see it being used anywhere else.

Thanks,

C.

#3 lore raw
Quoted 26 lines · Cédric Le Goater
Quoted 25 lines · Philippe Mathieu-Daudé

Replace the compile time check of the TARGET_ARM definition by a runtime call to target_base_arm().

---
Based-on: <[email protected]>
---
  hw/vfio/helpers.c | 7 ++-----

  1 file changed, 2 insertions(+), 5 deletions(-)
hw/vfio/helpers.c +1 -1
index 23d13e5db5f..007c37b28b8 100644
@@ -20,6 +20,7 @@
    */
   #include "qemu/osdep.h"
+#include "qemu/target-info.h"
   #include <sys/ioctl.h>
   #include "system/kvm.h"
@@ -220,9 +221,5 @@ bool vfio_arch_wants_loading_config_after_iter(void)
        * See commit d329f5032e17 ("vfio: Move the saving of the config space to
        * the right place in VFIO migration").
        */
-#if defined(TARGET_ARM)
Quoted 8 lines

hw/vfio/helpers.c bool vfio_arch_wants_loading_config_after_iter(void) · line 224

Quoted 5 lines
hw/vfio/helpers.c +1 -4
-    return true;
-#else
-    return false;
-#endif
+    return target_base_arm();

is that a new helper ? I don't see it being used anywhere else.

Linked in the Based-on tag after the S-o-b:
https://lore.kernel.org/qemu-devel/[email protected]/

#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 23 lines · Philippe Mathieu-Daudé

Replace the compile time check of the TARGET_ARM definition by a runtime call to target_base_arm().

---
Based-on: <[email protected]>

---
  hw/vfio/helpers.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
hw/vfio/helpers.c +1 -0
index 23d13e5db5f..007c37b28b8 100644
@@ -20,6 +20,7 @@
   */
 
  #include "qemu/osdep.h"
+#include "qemu/target-info.h"
  #include <sys/ioctl.h>
 
  #include "system/kvm.h"

hw/vfio/helpers.c bool vfio_arch_wants_loading_config_after_iter(void) · line 225

Quoted 10 lines
hw/vfio/helpers.c +1 -5
@@ -220,9 +221,5 @@ bool vfio_arch_wants_loading_config_after_iter(void)
       * See commit d329f5032e17 ("vfio: Move the saving of the config space to
       * the right place in VFIO migration").
       */
-#if defined(TARGET_ARM)
-    return true;
-#else
-    return false;
-#endif
+    return target_base_arm();
  }

The only reason why vfio_arch_wants_loading_config_after_iter() was introduced is that its only caller (vfio_load_config_after_iter()) lives in a target-independent file (migration-multifd.c) so it could not test TARGET_ARM directly, see:
https://lore.kernel.org/qemu-devel/[email protected]/

If target-independent-safe target_base_arm() were to be used instead
I think this helper won't make sense anymore and so this target_base_arm() call (and the associated comment) should be moved to vfio_load_config_after_iter().

Thanks,
Maciej