[PATCH v2] hw/vfio/migration: Check base architecture at runtime

Philippe Mathieu-Daudé posted 1 patch 3 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251021161707.8324-1-philmd@linaro.org
Maintainers: Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>
hw/vfio/vfio-helpers.h      |  2 --
hw/vfio/helpers.c           | 17 -----------------
hw/vfio/migration-multifd.c | 12 +++++++++++-
3 files changed, 11 insertions(+), 20 deletions(-)
[PATCH v2] hw/vfio/migration: Check base architecture at runtime
Posted by Philippe Mathieu-Daudé 3 months, 2 weeks ago
Inline vfio_arch_wants_loading_config_after_iter() and
replace the compile time check of the TARGET_ARM definition
by a runtime call to target_base_arm().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
Supersedes: <20251020222315.68963-1-philmd@linaro.org>
Based-on: <20251020220941.65269-1-philmd@linaro.org>
https://lore.kernel.org/qemu-devel/20251020221508.67413-5-philmd@linaro.org/
---
 hw/vfio/vfio-helpers.h      |  2 --
 hw/vfio/helpers.c           | 17 -----------------
 hw/vfio/migration-multifd.c | 12 +++++++++++-
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h
index ce317580800..54a327ffbc0 100644
--- a/hw/vfio/vfio-helpers.h
+++ b/hw/vfio/vfio-helpers.h
@@ -32,6 +32,4 @@ struct vfio_device_info *vfio_get_device_info(int fd);
 int vfio_kvm_device_add_fd(int fd, Error **errp);
 int vfio_kvm_device_del_fd(int fd, Error **errp);
 
-bool vfio_arch_wants_loading_config_after_iter(void);
-
 #endif /* HW_VFIO_VFIO_HELPERS_H */
diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
index 23d13e5db5f..9a5f6215455 100644
--- a/hw/vfio/helpers.c
+++ b/hw/vfio/helpers.c
@@ -209,20 +209,3 @@ retry:
 
     return info;
 }
-
-bool vfio_arch_wants_loading_config_after_iter(void)
-{
-    /*
-     * Starting the config load only after all iterables were loaded (during
-     * non-iterables loading phase) is required for ARM64 due to this platform
-     * VFIO dependency on interrupt controller being loaded first.
-     *
-     * 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
-}
diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c
index e4785031a73..b0eea0de678 100644
--- a/hw/vfio/migration-multifd.c
+++ b/hw/vfio/migration-multifd.c
@@ -16,6 +16,7 @@
 #include "qemu/error-report.h"
 #include "qemu/lockable.h"
 #include "qemu/main-loop.h"
+#include "qemu/target-info.h"
 #include "qemu/thread.h"
 #include "io/channel-buffer.h"
 #include "migration/qemu-file.h"
@@ -44,7 +45,16 @@ bool vfio_load_config_after_iter(VFIODevice *vbasedev)
     }
 
     assert(vbasedev->migration_load_config_after_iter == ON_OFF_AUTO_AUTO);
-    return vfio_arch_wants_loading_config_after_iter();
+
+    /*
+     * Starting the config load only after all iterables were loaded (during
+     * non-iterables loading phase) is required for ARM64 due to this platform
+     * VFIO dependency on interrupt controller being loaded first.
+     *
+     * See commit d329f5032e17 ("vfio: Move the saving of the config space to
+     * the right place in VFIO migration").
+     */
+    return target_base_arm();
 }
 
 /* type safety */
-- 
2.51.0


Re: [PATCH v2] hw/vfio/migration: Check base architecture at runtime
Posted by Zhao Liu 3 weeks, 4 days ago
On Tue, Oct 21, 2025 at 06:17:07PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Tue, 21 Oct 2025 18:17:07 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v2] hw/vfio/migration: Check base architecture at runtime
> X-Mailer: git-send-email 2.51.0
> 
> Inline vfio_arch_wants_loading_config_after_iter() and
> replace the compile time check of the TARGET_ARM definition
> by a runtime call to target_base_arm().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> Supersedes: <20251020222315.68963-1-philmd@linaro.org>
> Based-on: <20251020220941.65269-1-philmd@linaro.org>
> https://lore.kernel.org/qemu-devel/20251020221508.67413-5-philmd@linaro.org/
> ---
>  hw/vfio/vfio-helpers.h      |  2 --
>  hw/vfio/helpers.c           | 17 -----------------
>  hw/vfio/migration-multifd.c | 12 +++++++++++-
>  3 files changed, 11 insertions(+), 20 deletions(-)

(Checked with 20251020221508.67413-5-philmd@linaro.org)

LGTM, so,

Zhao Liu <zhao1.liu@intel.com>
Re: [PATCH v2] hw/vfio/migration: Check base architecture at runtime
Posted by Cédric Le Goater 4 weeks ago
Maciej,

Could we have a Ack from you ?

Thanks,

C.


On 10/21/25 18:17, Philippe Mathieu-Daudé wrote:
> Inline vfio_arch_wants_loading_config_after_iter() and
> replace the compile time check of the TARGET_ARM definition
> by a runtime call to target_base_arm().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> Supersedes: <20251020222315.68963-1-philmd@linaro.org>
> Based-on: <20251020220941.65269-1-philmd@linaro.org>
> https://lore.kernel.org/qemu-devel/20251020221508.67413-5-philmd@linaro.org/
> ---
>   hw/vfio/vfio-helpers.h      |  2 --
>   hw/vfio/helpers.c           | 17 -----------------
>   hw/vfio/migration-multifd.c | 12 +++++++++++-
>   3 files changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h
> index ce317580800..54a327ffbc0 100644
> --- a/hw/vfio/vfio-helpers.h
> +++ b/hw/vfio/vfio-helpers.h
> @@ -32,6 +32,4 @@ struct vfio_device_info *vfio_get_device_info(int fd);
>   int vfio_kvm_device_add_fd(int fd, Error **errp);
>   int vfio_kvm_device_del_fd(int fd, Error **errp);
>   
> -bool vfio_arch_wants_loading_config_after_iter(void);
> -
>   #endif /* HW_VFIO_VFIO_HELPERS_H */
> diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
> index 23d13e5db5f..9a5f6215455 100644
> --- a/hw/vfio/helpers.c
> +++ b/hw/vfio/helpers.c
> @@ -209,20 +209,3 @@ retry:
>   
>       return info;
>   }
> -
> -bool vfio_arch_wants_loading_config_after_iter(void)
> -{
> -    /*
> -     * Starting the config load only after all iterables were loaded (during
> -     * non-iterables loading phase) is required for ARM64 due to this platform
> -     * VFIO dependency on interrupt controller being loaded first.
> -     *
> -     * 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
> -}
> diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c
> index e4785031a73..b0eea0de678 100644
> --- a/hw/vfio/migration-multifd.c
> +++ b/hw/vfio/migration-multifd.c
> @@ -16,6 +16,7 @@
>   #include "qemu/error-report.h"
>   #include "qemu/lockable.h"
>   #include "qemu/main-loop.h"
> +#include "qemu/target-info.h"
>   #include "qemu/thread.h"
>   #include "io/channel-buffer.h"
>   #include "migration/qemu-file.h"
> @@ -44,7 +45,16 @@ bool vfio_load_config_after_iter(VFIODevice *vbasedev)
>       }
>   
>       assert(vbasedev->migration_load_config_after_iter == ON_OFF_AUTO_AUTO);
> -    return vfio_arch_wants_loading_config_after_iter();
> +
> +    /*
> +     * Starting the config load only after all iterables were loaded (during
> +     * non-iterables loading phase) is required for ARM64 due to this platform
> +     * VFIO dependency on interrupt controller being loaded first.
> +     *
> +     * See commit d329f5032e17 ("vfio: Move the saving of the config space to
> +     * the right place in VFIO migration").
> +     */
> +    return target_base_arm();
>   }
>   
>   /* type safety */


Re: [PATCH v2] hw/vfio/migration: Check base architecture at runtime
Posted by Maciej S. Szmigiero 4 weeks ago
On 9.01.2026 15:40, Cédric Le Goater wrote:
> Maciej,
> 
> Could we have a Ack from you ?

Sure:
Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>

> Thanks,
> 
> C.
> 
Thanks,
Maciej


Re: [PATCH v2] hw/vfio/migration: Check base architecture at runtime
Posted by Cédric Le Goater 3 months, 2 weeks ago
On 10/21/25 18:17, Philippe Mathieu-Daudé wrote:
> Inline vfio_arch_wants_loading_config_after_iter() and
> replace the compile time check of the TARGET_ARM definition
> by a runtime call to target_base_arm().

What's the value of a runtime check of target ARM ? Please explain.

> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> Supersedes: <20251020222315.68963-1-philmd@linaro.org>
> Based-on: <20251020220941.65269-1-philmd@linaro.org>


OK. Will consider when this is merged.

Thanks,

C.



> https://lore.kernel.org/qemu-devel/20251020221508.67413-5-philmd@linaro.org/
> ---
>   hw/vfio/vfio-helpers.h      |  2 --
>   hw/vfio/helpers.c           | 17 -----------------
>   hw/vfio/migration-multifd.c | 12 +++++++++++-
>   3 files changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h
> index ce317580800..54a327ffbc0 100644
> --- a/hw/vfio/vfio-helpers.h
> +++ b/hw/vfio/vfio-helpers.h
> @@ -32,6 +32,4 @@ struct vfio_device_info *vfio_get_device_info(int fd);
>   int vfio_kvm_device_add_fd(int fd, Error **errp);
>   int vfio_kvm_device_del_fd(int fd, Error **errp);
>   
> -bool vfio_arch_wants_loading_config_after_iter(void);
> -
>   #endif /* HW_VFIO_VFIO_HELPERS_H */
> diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
> index 23d13e5db5f..9a5f6215455 100644
> --- a/hw/vfio/helpers.c
> +++ b/hw/vfio/helpers.c
> @@ -209,20 +209,3 @@ retry:
>   
>       return info;
>   }
> -
> -bool vfio_arch_wants_loading_config_after_iter(void)
> -{
> -    /*
> -     * Starting the config load only after all iterables were loaded (during
> -     * non-iterables loading phase) is required for ARM64 due to this platform
> -     * VFIO dependency on interrupt controller being loaded first.
> -     *
> -     * 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
> -}
> diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c
> index e4785031a73..b0eea0de678 100644
> --- a/hw/vfio/migration-multifd.c
> +++ b/hw/vfio/migration-multifd.c
> @@ -16,6 +16,7 @@
>   #include "qemu/error-report.h"
>   #include "qemu/lockable.h"
>   #include "qemu/main-loop.h"
> +#include "qemu/target-info.h"
>   #include "qemu/thread.h"
>   #include "io/channel-buffer.h"
>   #include "migration/qemu-file.h"
> @@ -44,7 +45,16 @@ bool vfio_load_config_after_iter(VFIODevice *vbasedev)
>       }
>   
>       assert(vbasedev->migration_load_config_after_iter == ON_OFF_AUTO_AUTO);
> -    return vfio_arch_wants_loading_config_after_iter();
> +
> +    /*
> +     * Starting the config load only after all iterables were loaded (during
> +     * non-iterables loading phase) is required for ARM64 due to this platform
> +     * VFIO dependency on interrupt controller being loaded first.
> +     *
> +     * See commit d329f5032e17 ("vfio: Move the saving of the config space to
> +     * the right place in VFIO migration").
> +     */
> +    return target_base_arm();
>   }
>   
>   /* type safety */


Re: [PATCH v2] hw/vfio/migration: Check base architecture at runtime
Posted by Philippe Mathieu-Daudé 4 weeks ago
On 21/10/25 18:31, Cédric Le Goater wrote:
> On 10/21/25 18:17, Philippe Mathieu-Daudé wrote:
>> Inline vfio_arch_wants_loading_config_after_iter() and
>> replace the compile time check of the TARGET_ARM definition
>> by a runtime call to target_base_arm().
> 
> What's the value of a runtime check of target ARM ? Please explain.

target_base_arm() returns %true when the ARM and AArch64 targets
are used.

Runtime check allow compiling this file once for all targets,
allowing to eventually have a single binary targetting them once.

Still I expect this function to be problematic on heterogenous
emulation, but we are not quite there yet.

> 
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> Supersedes: <20251020222315.68963-1-philmd@linaro.org>
>> Based-on: <20251020220941.65269-1-philmd@linaro.org>
> 
> 
> OK. Will consider when this is merged.
> 
> Thanks,
> 
> C.
> 
> 
> 
>> https://lore.kernel.org/qemu-devel/20251020221508.67413-5- 
>> philmd@linaro.org/
>> ---
>>   hw/vfio/vfio-helpers.h      |  2 --
>>   hw/vfio/helpers.c           | 17 -----------------
>>   hw/vfio/migration-multifd.c | 12 +++++++++++-
>>   3 files changed, 11 insertions(+), 20 deletions(-)
>>
>> diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h
>> index ce317580800..54a327ffbc0 100644
>> --- a/hw/vfio/vfio-helpers.h
>> +++ b/hw/vfio/vfio-helpers.h
>> @@ -32,6 +32,4 @@ struct vfio_device_info *vfio_get_device_info(int fd);
>>   int vfio_kvm_device_add_fd(int fd, Error **errp);
>>   int vfio_kvm_device_del_fd(int fd, Error **errp);
>> -bool vfio_arch_wants_loading_config_after_iter(void);
>> -
>>   #endif /* HW_VFIO_VFIO_HELPERS_H */
>> diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
>> index 23d13e5db5f..9a5f6215455 100644
>> --- a/hw/vfio/helpers.c
>> +++ b/hw/vfio/helpers.c
>> @@ -209,20 +209,3 @@ retry:
>>       return info;
>>   }
>> -
>> -bool vfio_arch_wants_loading_config_after_iter(void)
>> -{
>> -    /*
>> -     * Starting the config load only after all iterables were loaded 
>> (during
>> -     * non-iterables loading phase) is required for ARM64 due to this 
>> platform
>> -     * VFIO dependency on interrupt controller being loaded first.
>> -     *
>> -     * 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
>> -}
>> diff --git a/hw/vfio/migration-multifd.c b/hw/vfio/migration-multifd.c
>> index e4785031a73..b0eea0de678 100644
>> --- a/hw/vfio/migration-multifd.c
>> +++ b/hw/vfio/migration-multifd.c
>> @@ -16,6 +16,7 @@
>>   #include "qemu/error-report.h"
>>   #include "qemu/lockable.h"
>>   #include "qemu/main-loop.h"
>> +#include "qemu/target-info.h"
>>   #include "qemu/thread.h"
>>   #include "io/channel-buffer.h"
>>   #include "migration/qemu-file.h"
>> @@ -44,7 +45,16 @@ bool vfio_load_config_after_iter(VFIODevice *vbasedev)
>>       }
>>       assert(vbasedev->migration_load_config_after_iter == 
>> ON_OFF_AUTO_AUTO);
>> -    return vfio_arch_wants_loading_config_after_iter();
>> +
>> +    /*
>> +     * Starting the config load only after all iterables were loaded 
>> (during
>> +     * non-iterables loading phase) is required for ARM64 due to this 
>> platform
>> +     * VFIO dependency on interrupt controller being loaded first.
>> +     *
>> +     * See commit d329f5032e17 ("vfio: Move the saving of the config 
>> space to
>> +     * the right place in VFIO migration").
>> +     */
>> +    return target_base_arm();
>>   }
>>   /* type safety */
> 


Re: [PATCH v2] hw/vfio/migration: Check base architecture at runtime
Posted by Cédric Le Goater 4 weeks ago
On 1/9/26 16:08, Philippe Mathieu-Daudé wrote:
> On 21/10/25 18:31, Cédric Le Goater wrote:
>> On 10/21/25 18:17, Philippe Mathieu-Daudé wrote:
>>> Inline vfio_arch_wants_loading_config_after_iter() and
>>> replace the compile time check of the TARGET_ARM definition
>>> by a runtime call to target_base_arm().
>>
>> What's the value of a runtime check of target ARM ? Please explain.
> 
> target_base_arm() returns %true when the ARM and AArch64 targets
> are used.
> 
> Runtime check allow compiling this file once for all targets,
> allowing to eventually have a single binary targetting them once.

Do you want to update the commit log ?

> Still I expect this function to be problematic on heterogenous
> emulation, but we are not quite there yet.

ok. So we can still take the patch I guess.

Thanks,


C.