[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets dis
From: |
Eric Auger |
Subject: |
Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled |
Date: |
Tue, 21 Jan 2025 08:15:30 +0100 |
User-agent: |
Mozilla Thunderbird |
Hi Jason,
On 1/21/25 4:27 AM, Jason Wang wrote:
> On Tue, Jan 21, 2025 at 1:33 AM Eric Auger <eric.auger@redhat.com> wrote:
>> When a guest exposed with a vhost device and protected by an
>> intel IOMMU gets rebooted, we sometimes observe a spurious warning:
>>
>> Fail to lookup the translated address ffffe000
>>
>> We observe that the IOMMU gets disabled through a write to the global
>> command register (CMAR_GCMD.TE) before the vhost device gets stopped.
>> When this warning happens it can be observed an inflight IOTLB
>> miss occurs after the IOMMU disable and before the vhost stop. In
>> that case a flat translation occurs and the check in
>> vhost_memory_region_lookup() fails.
>>
>> Let's disable the IOTLB callbacks when all IOMMU MRs have been
>> unregistered.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>> hw/virtio/vhost.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>> index 6aa72fd434..128c2ab094 100644
>> --- a/hw/virtio/vhost.c
>> +++ b/hw/virtio/vhost.c
>> @@ -931,6 +931,10 @@ static void vhost_iommu_region_del(MemoryListener
>> *listener,
>> break;
>> }
>> }
>> + if (QLIST_EMPTY(&dev->iommu_list) &&
>> + dev->vhost_ops->vhost_set_iotlb_callback) {
>> + dev->vhost_ops->vhost_set_iotlb_callback(dev, false);
>> + }
> So the current code assumes:
>
> 1) IOMMU is enabled before vhost starts
> 2) IOMMU is disabled after vhost stops
>
> This patch seems to fix 2) but not 1). Do we need to deal with the
> IOMMU enabled after vhost starts?
This patch handles the case where the IOMMU is disabled *before* vhost
stops (not 2). This is what I concretely observe on guest reboot.
But maybe I misunderstood your comments/questions?
Thanks
Eric
>
> Thanks
>
>> }
>>
>> void vhost_toggle_device_iotlb(VirtIODevice *vdev)
>> --
>> 2.47.1
>>
- [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Eric Auger, 2025/01/20
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Jason Wang, 2025/01/20
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled,
Eric Auger <=
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Eric Auger, 2025/01/21
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Jason Wang, 2025/01/22
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Eric Auger, 2025/01/22
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Jason Wang, 2025/01/22
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Eric Auger, 2025/01/23
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Jason Wang, 2025/01/23
- RE: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Duan, Zhenzhong, 2025/01/23
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Jason Wang, 2025/01/23
- Re: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Jason Wang, 2025/01/23
- RE: [PATCH] hw/virtio/vhost: Disable IOTLB callbacks when IOMMU gets disabled, Duan, Zhenzhong, 2025/01/23