[PATCH v4 15/15] vfio/common: Block migration with vIOMMUs without address width limits

Joao Martins posted 15 patches 2 years, 7 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Peter Xu <peterx@redhat.com>, Jason Wang <jasowang@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
[PATCH v4 15/15] vfio/common: Block migration with vIOMMUs without address width limits
Posted by Joao Martins 2 years, 7 months ago
Only block the case when the underlying vIOMMU model does not report any
address space limits, in addition to DMA translation being off or no
vIOMMU present. The limits are needed such that can define the IOVA limits
that arm the device dirty tracker.

Additionally, reword the migration blocker error message to clarify that
we the configured vIOMMU does not support migration, as opposed to
implying that just being there blocks migration.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
 hw/vfio/common.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 62f91e8e102d..c3cc0dd47044 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -449,15 +449,18 @@ static int vfio_viommu_get_max_iova(hwaddr *max_iova)
 
 int vfio_block_giommu_migration(Error **errp)
 {
+    hwaddr max;
     int ret;
 
     if (giommu_migration_blocker ||
-        !vfio_viommu_preset()) {
+        !vfio_viommu_preset() ||
+        (vfio_viommu_preset() && !vfio_viommu_get_max_iova(&max))) {
         return 0;
     }
 
     error_setg(&giommu_migration_blocker,
-               "Migration is currently not supported with vIOMMU enabled");
+               "Migration with vIOMMU is currently not supported "
+               "without vIOMMU address space boundaries");
     ret = migrate_add_blocker(giommu_migration_blocker, errp);
     if (ret < 0) {
         error_free(giommu_migration_blocker);
-- 
2.17.2
Re: [PATCH v4 15/15] vfio/common: Block migration with vIOMMUs without address width limits
Posted by Duan, Zhenzhong 2 years, 5 months ago
On 6/23/2023 5:48 AM, Joao Martins wrote:
> Only block the case when the underlying vIOMMU model does not report any
> address space limits, in addition to DMA translation being off or no
> vIOMMU present. The limits are needed such that can define the IOVA limits
> that arm the device dirty tracker.
>
> Additionally, reword the migration blocker error message to clarify that
> we the configured vIOMMU does not support migration, as opposed to
> implying that just being there blocks migration.
>
> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
> ---
>   hw/vfio/common.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 62f91e8e102d..c3cc0dd47044 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -449,15 +449,18 @@ static int vfio_viommu_get_max_iova(hwaddr *max_iova)
>   
>   int vfio_block_giommu_migration(Error **errp)
>   {
> +    hwaddr max;
>       int ret;
>   
>       if (giommu_migration_blocker ||
> -        !vfio_viommu_preset()) {
> +        !vfio_viommu_preset() ||
> +        (vfio_viommu_preset() && !vfio_viommu_get_max_iova(&max))) {

Could be simplified as below:

+        !vfio_viommu_preset() || !vfio_viommu_get_max_iova(&max))) {

Thanks
Zhenzhong
Re: [PATCH v4 15/15] vfio/common: Block migration with vIOMMUs without address width limits
Posted by Joao Martins 2 years, 5 months ago

On 08/09/2023 07:28, Duan, Zhenzhong wrote:
> 
> On 6/23/2023 5:48 AM, Joao Martins wrote:
>> Only block the case when the underlying vIOMMU model does not report any
>> address space limits, in addition to DMA translation being off or no
>> vIOMMU present. The limits are needed such that can define the IOVA limits
>> that arm the device dirty tracker.
>>
>> Additionally, reword the migration blocker error message to clarify that
>> we the configured vIOMMU does not support migration, as opposed to
>> implying that just being there blocks migration.
>>
>> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
>> ---
>>   hw/vfio/common.c | 7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>> index 62f91e8e102d..c3cc0dd47044 100644
>> --- a/hw/vfio/common.c
>> +++ b/hw/vfio/common.c
>> @@ -449,15 +449,18 @@ static int vfio_viommu_get_max_iova(hwaddr *max_iova)
>>     int vfio_block_giommu_migration(Error **errp)
>>   {
>> +    hwaddr max;
>>       int ret;
>>         if (giommu_migration_blocker ||
>> -        !vfio_viommu_preset()) {
>> +        !vfio_viommu_preset() ||
>> +        (vfio_viommu_preset() && !vfio_viommu_get_max_iova(&max))) {
> 
> Could be simplified as below:
> 
> +        !vfio_viommu_preset() || !vfio_viommu_get_max_iova(&max))) {
> 

True.