Net patches
The following changes since commit 5288bee45fbd33203b61f8c76e41b15bb5913e6e:
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-07-21 11:13:01 +0100)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
for you to fetch changes up to 75a8ce64f6e37513698857fb4284170da163ed06:
vdpa: Fix memory listener deletions of iova tree (2022-07-26 16:24:19 +0800)
----------------------------------------------------------------
----------------------------------------------------------------
Ake Koomsin (1):
e1000e: Fix possible interrupt loss when using MSI
Eugenio Pérez (2):
vhost: Get vring base from vq, not svq
vdpa: Fix memory listener deletions of iova tree
hw/net/e1000e_core.c | 2 ++ hw/virtio/vhost-vdpa.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-)
[PULL 1/3] e1000e: Fix possible interrupt loss when using MSI
From: Ake Koomsin <[email protected]>
Commit "e1000e: Prevent MSI/MSI-X storms" introduced msi_causes_pending to prevent interrupt storms problem. It was tested with MSI-X.
In case of MSI, the guest can rely solely on interrupts to clear ICR. Upon clearing all pending interrupts, msi_causes_pending gets cleared. However, when e1000e_itr_should_postpone() in e1000e_send_msi() returns true, MSI never gets fired by e1000e_intrmgr_on_throttling_timer() because msi_causes_pending is still set. This results in interrupt loss.
To prevent this, we need to clear msi_causes_pending when MSI is going to get fired by the throttling timer. The guest can then receive interrupts eventually.
--- hw/net/e1000e_core.c | 2 ++ 1 file changed, 2 insertions(+)
hw/net/e1000e_core.c +2 -0
@@ -159,6 +159,8 @@ e1000e_intrmgr_on_throttling_timer(void *opaque)if (msi_enabled (timer->core->owner)) {trace_e1000e_irq_msi_notify_postponed (); +/* Clear msi_causes_pending to fire MSI eventually */ + timer->core->msi_causes_pending =0 ;e1000e_set_interrupt_cause (timer->core,0 ); }else {trace_e1000e_irq_legacy_notify_postponed ();
Signature · 1 line
2.7.4
[PULL 2/3] vhost: Get vring base from vq, not svq
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
The SVQ vring used idx usually match with the guest visible one, as long as all the guest buffers (GPA) maps to exactly one buffer within qemu's VA. However, as we can see in virtqueue_map_desc, a single guest buffer could map to many buffers in SVQ vring.
Also, its also a mistake to rewind them at the source of migration. Since VirtQueue is able to migrate the inflight descriptors, its responsability of the destination to perform the rewind just in case it cannot report the inflight descriptors to the device.
This makes easier to migrate between backends or to recover them in vhost devices that support set in flight descriptors.
--- hw/virtio/vhost-vdpa.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
hw/virtio/vhost-vdpa.c +12 -12
@@ -1179,7 +1179,18 @@ static int vhost_vdpa_set_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) {struct vhost_vdpa *v = dev->opaque; +VirtQueue *vq =virtio_get_queue (dev->vdev, ring->index); +/* +* vhost-vdpa devices does not support in-flight requests. Set all of them +* as available. +* +* TODO: This is ok for networking, but other kinds of devices might +* have problems with these retransmissions. +*/ +while (virtqueue_rewind (vq,1 )) { +continue ; + }if (v->shadow_vqs_enabled) {/* * Device vring base was set at device start. SVQ base is handled by
@@ -1195,21 +1206,10 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) {struct vhost_vdpa *v = dev->opaque; -int vdpa_idx = ring->index - dev->vq_index;int ret;if (v->shadow_vqs_enabled) { -VhostShadowVirtqueue *svq =g_ptr_array_index (v->shadow_vqs, vdpa_idx); - -/* -* Setting base as last used idx, so destination will see as available -* all the entries that the device did not use, including the in-flight -* processing ones. -* -* TODO: This is ok for networking, but other kinds of devices might -* have problems with these retransmissions. -*/ - ring->num = svq->last_used_idx; + ring->num =virtio_queue_get_last_avail_idx (dev->vdev, ring->index);return 0 ; }
Signature · 1 line
2.7.4
[PULL 3/3] vdpa: Fix memory listener deletions of iova tree
In reply to Jason WangFrom: Eugenio Pérez <[email protected]>
vhost_vdpa_listener_region_del is always deleting the first iova entry of the tree, since it's using the needle iova instead of the result's one.
This was detected using a vga virtual device in the VM using vdpa SVQ. It makes some extra memory adding and deleting, so the wrong one was mapped / unmapped. This was undetected before since all the memory was mappend and unmapped totally without that device, but other conditions could trigger it too:
* mem_region was with .iova = 0, .translated_addr = (correct GPA).
* iova_tree_find_iova returned right result, but does not update mem_region.
* iova_tree_remove always removed region with .iova = 0. Right iova were sent to the device.
* Next map will fill the first region with .iova = 0, causing a mapping with the same iova and device complains, if the next action is a map.
* Next unmap will cause to try to unmap again iova = 0, causing the device to complain that no region was mapped at iova = 0.
--- hw/virtio/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost-vdpa.c +1 -1
@@ -290,7 +290,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, result =vhost_iova_tree_find_iova (v->iova_tree, &mem_region); iova = result->iova; -vhost_iova_tree_remove (v->iova_tree, &mem_region); +vhost_iova_tree_remove (v->iova_tree, result); }vhost_vdpa_iotlb_batch_begin_once (v); ret =vhost_vdpa_dma_unmap (v, iova,int128_get64 (llsize));
Signature · 1 line
2.7.4
Re: [PULL 3/3] vdpa: Fix memory listener deletions of iova tree
I tried to manually changed this line then test this branch on local host. After the migration is successful, the qemu core dump occurs on the shutdown inside guest.
Compiled qemu Steps:
# git clone https://gitlab.com/eperezmartin/qemu-kvm.git # cd qemu-kvm/ # mkdir build # cd build/ # git checkout bd85496c2a8c1ebf34f908fca2be2ab9852fd0e9 # vim /root/qemu-kvm/hw/virtio/vhost-vdpa.c (Chanege "vhost_iova_tree_remove(v->iova_tree, &mem_region);" to "vhost_iova_tree_remove(v->iova_tree, result);") # ../configure --target-list=x86_64-softmmu --enable-debug # make
Core dump messages:
# gdb /root/qemu-kvm/build/x86_64-softmmu/qemu-system-x86_64
core.qemu-system-x86.7419
(gdb) bt full
#0 0x000056107c19afa9 in vhost_vdpa_listener_region_del
(listener=0x7ff9a9c691a0, section=0x7ffd3889ad20)
at ../hw/virtio/vhost-vdpa.c:290
result = 0x0
vaddr = 0x7ff29be00000
mem_region = {iova = 0, translated_addr = 140679973961728, size =
30064771071, perm = IOMMU_NONE}
v = 0x7ff9a9c69190
iova = 4294967296
llend = 34359738368
llsize = 30064771072
ret = 32765
__func__ = "vhost_vdpa_listener_region_del"
#1 0x000056107c1ca915 in listener_del_address_space
(listener=0x7ff9a9c691a0, as=0x56107cccbc00 <address_space_memory>)
at ../softmmu/memory.c:2939
section =
{size = 30064771072, mr = 0x56107e116270, fv = 0x7ff1e02a4090,
offset_within_region = 2147483648, offset_within_address_space =
4294967296, readonly = false, nonvolatile = false}
view = 0x7ff1e02a4090
fr = 0x7ff1e04027f0
#2 0x000056107c1cac39 in memory_listener_unregister
(listener=0x7ff9a9c691a0) at ../softmmu/memory.c:2989
#3 0x000056107c19d007 in vhost_vdpa_dev_start (dev=0x56107e126ea0,
started=false) at ../hw/virtio/vhost-vdpa.c:1134
v = 0x7ff9a9c69190
ok = true
#4 0x000056107c190252 in vhost_dev_stop (hdev=0x56107e126ea0,
vdev=0x56107f40cb50) at ../hw/virtio/vhost.c:1828
i = 32761
__PRETTY_FUNCTION__ = "vhost_dev_stop"
#5 0x000056107bebe26c in vhost_net_stop_one (net=0x56107e126ea0,
dev=0x56107f40cb50) at ../hw/net/vhost_net.c:315
file = {index = 0, fd = -1}
__PRETTY_FUNCTION__ = "vhost_net_stop_one"
#6 0x000056107bebe6bf in vhost_net_stop (dev=0x56107f40cb50,
ncs=0x56107f421850, data_queue_pairs=1, cvq=0)
at ../hw/net/vhost_net.c:425
qbus = 0x56107f40cac8
vbus = 0x56107f40cac8
k = 0x56107df1a220
n = 0x56107f40cb50
peer = 0x7ff9a9c69010
total_notifiers = 2
nvhosts = 1
i = 0
--Type <RET> for more, q to quit, c to continue without paging--
r = 32765
__PRETTY_FUNCTION__ = "vhost_net_stop"
#7 0x000056107c14af24 in virtio_net_vhost_status (n=0x56107f40cb50,
status=15 '\017') at ../hw/net/virtio-net.c:298
vdev = 0x56107f40cb50
nc = 0x56107f421850
queue_pairs = 1
cvq = 0
#8 0x000056107c14b17e in virtio_net_set_status (vdev=0x56107f40cb50,
status=15 '\017') at ../hw/net/virtio-net.c:372
n = 0x56107f40cb50
q = 0x56107f40cb50
i = 32765
queue_status = 137 '\211'
#9 0x000056107c185af2 in virtio_set_status (vdev=0x56107f40cb50, val=15
'\017') at ../hw/virtio/virtio.c:1947
k = 0x56107dfe2c60
#10 0x000056107c188cbb in virtio_vmstate_change (opaque=0x56107f40cb50,
running=false, state=RUN_STATE_SHUTDOWN)
at ../hw/virtio/virtio.c:3195
vdev = 0x56107f40cb50
qbus = 0x56107f40cac8
k = 0x56107df1a220
backend_run = false
#11 0x000056107bfdca5e in vm_state_notify (running=false,
state=RUN_STATE_SHUTDOWN) at ../softmmu/runstate.c:334
e = 0x56107f419950
next = 0x56107f224b80
#12 0x000056107bfd43e6 in do_vm_stop (state=RUN_STATE_SHUTDOWN,
send_stop=false) at ../softmmu/cpus.c:263
ret = 0
#13 0x000056107bfd4420 in vm_shutdown () at ../softmmu/cpus.c:281
#14 0x000056107bfdd584 in qemu_cleanup () at ../softmmu/runstate.c:813
#15 0x000056107bd81a5b in main (argc=65, argv=0x7ffd3889b178,
envp=0x7ffd3889b388) at ../softmmu/main.c:51Thanks
Lei
Quoted 48 lines · Jason Wang <[email protected]> 于2022年7月26日周二 16:51写道:
From: Eugenio Pérez <[email protected]>
vhost_vdpa_listener_region_delis always deleting the first iova entry of the tree, since it's using the needle iova instead of the result's one.This was detected using a vga virtual device in the VM using vdpa SVQ. It makes some extra memory adding and deleting, so the wrong one was mapped / unmapped. This was undetected before since all the memory was mappend and unmapped totally without that device, but other conditions could trigger it too:
*
mem_regionwas with .iova = 0, .translated_addr = (correct GPA).
*iova_tree_find_iovareturned right result, but does not updatemem_region.
*iova_tree_removealways removed region with .iova = 0. Right iova were sent to the device.
* Next map will fill the first region with .iova = 0, causing a mapping with the same iova and device complains, if the next action is a map.
* Next unmap will cause to try to unmap again iova = 0, causing the device to complain that no region was mapped at iova = 0.Fixes 34e3c94edaef ("vdpa: Add custom IOTLB translations to SVQ")Reported-by Lei Yang <[email protected]>Signed-off-by Eugenio Pérez <[email protected]>Signed-off-by Jason Wang <[email protected]>--- hw/virtio/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/vhost-vdpa.c +1
-1@@ -290,7 +290,7 @@ static voidvhost_vdpa_listener_region_del (MemoryListener *listener, result = vhost_iova_tree_find_iova(v->iova_tree, &mem_region); iova = result->iova; -vhost_iova_tree_remove (v->iova_tree, &mem_region); +vhost_iova_tree_remove (v->iova_tree, result); }vhost_vdpa_iotlb_batch_begin_once (v);ret = vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize));--
2.7.4
Re: [PULL 3/3] vdpa: Fix memory listener deletions of iova tree
Quoted 9 lines · Lei Yang
I tried to manually changed this line then test this branch on local host. After the migration is successful, the qemu core dump occurs on the shutdown inside guest.
Compiled qemu Steps:
# git clone https://gitlab.com/eperezmartin/qemu-kvm.git # cd qemu-kvm/ # mkdir build # cd build/ # git checkout bd85496c2a8c1ebf34f908fca2be2ab9852fd0e9
I got this
fatal: reference is not a tree: bd85496c2a8c1ebf34f908fca2be2ab9852fd0e9
and my HEAD is:
commit 7b17a1a841fc2336eba53afade9cadb14bd3dd9a (HEAD -> master, tag:
v7.1.0-rc0, origin/master, origin/HEAD)
Author: Richard Henderson <[email protected]> Date: Tue Jul 26 18:03:16 2022 -0700
Update version for v7.1.0-rc0 release
Quoted 2 lines
# vim /root/qemu-kvm/hw/virtio/vhost-vdpa.c (Chanege "vhost_iova_tree_remove(v->iova_tree, &mem_region);" to "vhost_iova_tree_remove(v->iova_tree, result);")
Any reason you need to manually change the line since it has been merged?
Quoted 2 lines
# ../configure --target-list=x86_64-softmmu --enable-debug # make
So if I understand you correctly, you meant the issue is not fixed?
Thanks
Quoted 123 lines
Core dump messages:
# gdb /root/qemu-kvm/build/x86_64-softmmu/qemu-system-x86_64 core.qemu-system-x86.7419 (gdb) bt full #0 0x000056107c19afa9 in vhost_vdpa_listener_region_del (listener=0x7ff9a9c691a0, section=0x7ffd3889ad20) at ../hw/virtio/vhost-vdpa.c:290 result = 0x0 vaddr = 0x7ff29be00000 mem_region = {iova = 0, translated_addr = 140679973961728, size = 30064771071, perm = IOMMU_NONE} v = 0x7ff9a9c69190 iova = 4294967296 llend = 34359738368 llsize = 30064771072 ret = 32765 __func__ = "vhost_vdpa_listener_region_del" #1 0x000056107c1ca915 in listener_del_address_space (listener=0x7ff9a9c691a0, as=0x56107cccbc00 <address_space_memory>) at ../softmmu/memory.c:2939 section = {size = 30064771072, mr = 0x56107e116270, fv = 0x7ff1e02a4090, offset_within_region = 2147483648, offset_within_address_space = 4294967296, readonly = false, nonvolatile = false} view = 0x7ff1e02a4090 fr = 0x7ff1e04027f0 #2 0x000056107c1cac39 in memory_listener_unregister (listener=0x7ff9a9c691a0) at ../softmmu/memory.c:2989 #3 0x000056107c19d007 in vhost_vdpa_dev_start (dev=0x56107e126ea0, started=false) at ../hw/virtio/vhost-vdpa.c:1134 v = 0x7ff9a9c69190 ok = true #4 0x000056107c190252 in vhost_dev_stop (hdev=0x56107e126ea0, vdev=0x56107f40cb50) at ../hw/virtio/vhost.c:1828 i = 32761 __PRETTY_FUNCTION__ = "vhost_dev_stop" #5 0x000056107bebe26c in vhost_net_stop_one (net=0x56107e126ea0, dev=0x56107f40cb50) at ../hw/net/vhost_net.c:315 file = {index = 0, fd = -1} __PRETTY_FUNCTION__ = "vhost_net_stop_one" #6 0x000056107bebe6bf in vhost_net_stop (dev=0x56107f40cb50, ncs=0x56107f421850, data_queue_pairs=1, cvq=0) at ../hw/net/vhost_net.c:425 qbus = 0x56107f40cac8 vbus = 0x56107f40cac8 k = 0x56107df1a220 n = 0x56107f40cb50 peer = 0x7ff9a9c69010 total_notifiers = 2 nvhosts = 1 i = 0 --Type <RET> for more, q to quit, c to continue without paging-- r = 32765 __PRETTY_FUNCTION__ = "vhost_net_stop" #7 0x000056107c14af24 in virtio_net_vhost_status (n=0x56107f40cb50, status=15 '\017') at ../hw/net/virtio-net.c:298 vdev = 0x56107f40cb50 nc = 0x56107f421850 queue_pairs = 1 cvq = 0 #8 0x000056107c14b17e in virtio_net_set_status (vdev=0x56107f40cb50, status=15 '\017') at ../hw/net/virtio-net.c:372 n = 0x56107f40cb50 q = 0x56107f40cb50 i = 32765 queue_status = 137 '\211' #9 0x000056107c185af2 in virtio_set_status (vdev=0x56107f40cb50, val=15 '\017') at ../hw/virtio/virtio.c:1947 k = 0x56107dfe2c60 #10 0x000056107c188cbb in virtio_vmstate_change (opaque=0x56107f40cb50, running=false, state=RUN_STATE_SHUTDOWN) at ../hw/virtio/virtio.c:3195 vdev = 0x56107f40cb50 qbus = 0x56107f40cac8 k = 0x56107df1a220 backend_run = false #11 0x000056107bfdca5e in vm_state_notify (running=false, state=RUN_STATE_SHUTDOWN) at ../softmmu/runstate.c:334 e = 0x56107f419950 next = 0x56107f224b80 #12 0x000056107bfd43e6 in do_vm_stop (state=RUN_STATE_SHUTDOWN, send_stop=false) at ../softmmu/cpus.c:263 ret = 0 #13 0x000056107bfd4420 in vm_shutdown () at ../softmmu/cpus.c:281 #14 0x000056107bfdd584 in qemu_cleanup () at ../softmmu/runstate.c:813 #15 0x000056107bd81a5b in main (argc=65, argv=0x7ffd3889b178, envp=0x7ffd3889b388) at ../softmmu/main.c:51Thanks
LeiQuoted 47 lines · Jason Wang <[email protected]> 于2022年7月26日周二 16:51写道:
From: Eugenio Pérez <[email protected]>
vhost_vdpa_listener_region_delis always deleting the first iova entry of the tree, since it's using the needle iova instead of the result's one.This was detected using a vga virtual device in the VM using vdpa SVQ. It makes some extra memory adding and deleting, so the wrong one was mapped / unmapped. This was undetected before since all the memory was mappend and unmapped totally without that device, but other conditions could trigger it too:
*
mem_regionwas with .iova = 0, .translated_addr = (correct GPA).
*iova_tree_find_iovareturned right result, but does not updatemem_region.
*iova_tree_removealways removed region with .iova = 0. Right iova were sent to the device.
* Next map will fill the first region with .iova = 0, causing a mapping with the same iova and device complains, if the next action is a map.
* Next unmap will cause to try to unmap again iova = 0, causing the device to complain that no region was mapped at iova = 0.Fixes 34e3c94edaef ("vdpa: Add custom IOTLB translations to SVQ")Reported-by Lei Yang <[email protected]>Signed-off-by Eugenio Pérez <[email protected]>Signed-off-by Jason Wang <[email protected]>--- hw/virtio/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/vhost-vdpa.c +1
-2@@ -290,7 +290,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, result =vhost_iova_tree_find_iova (v->iova_tree, &mem_region); iova = result->iova; -vhost_iova_tree_remove (v->iova_tree, &mem_region); +vhost_iova_tree_remove (v->iova_tree, result); }vhost_vdpa_iotlb_batch_begin_once (v); ret =vhost_vdpa_dma_unmap (v, iova,int128_get64 (llsize)); --2.7.4
Re: [PULL 3/3] vdpa: Fix memory listener deletions of iova tree
Quoted 19 lines · Jason Wang <[email protected]> 于2022年7月28日周四 14:27写道:
Quoted 2 lines · Lei Yang
I tried to manually changed this line then test this branch on local
host. After the migration is successful, the qemu core dump occurs on the shutdown inside guest.
Quoted 7 lines
Compiled qemu Steps:
# git clone https://gitlab.com/eperezmartin/qemu-kvm.git # cd qemu-kvm/ # mkdir build # cd build/ # git checkout bd85496c2a8c1ebf34f908fca2be2ab9852fd0e9I got this
fatal: reference is not a tree:
bd85496c2a8c1ebf34f908fca2be2ab9852fd0e9and my HEAD is:
Quoted 9 lines
commit
7b17a1a841fc2336eba53afade9cadb14bd3dd9a(HEAD -> master, tag:
v7.1.0-rc0, origin/master, origin/HEAD)Author: Richard Henderson <[email protected]> Date: Tue Jul 26 18:03:16 2022 -0700Update version for v7.1.0-rc0 release
Signed-off-by Richard Henderson <[email protected]>
I tried to recompile it use you mentioned commit, but the problem is reproduced again:
# git clone git://git.qemu.org/qemu.git # cd qemu/ # git log # mkdir build # cd build/ # vim /root/qemu/hw/virtio/vhost-vdpa.c # ../configure --target-list=x86_64-softmmu --enable-debug # make
Latest commit:
commit 7b17a1a841fc2336eba53afade9cadb14bd3dd9a (HEAD -> master, tag:
v7.1.0-rc0, origin/master, origin/HEAD)
Author: Richard Henderson <[email protected]> Date: Tue Jul 26 18:03:16 2022 -0700
Update version for v7.1.0-rc0 release
Quoted 12 lines
Quoted 3 lines
# vim /root/qemu-kvm/hw/virtio/vhost-vdpa.c (Chanege "vhost_iova_tree_remove(v->iova_tree, &mem_region);" to"
vhost_iova_tree_remove(v->iova_tree, result);")Any reason you need to manually change the line since it has been merged?
Quoted 2 lines
# ../configure --target-list=x86_64-softmmu --enable-debug # makeSo if I understand you correctly, you meant the issue is not fixed?
From my side, this is a new issue. Because the guest can boot up normally and complete the migration. It is just that after the migration is successful, after shutdown in the guest, a core dump occurs
Thanks
Quoted 147 lines
Thanks
Quoted 3 lines
Core dump messages:
# gdb /root/qemu-kvm/build/x86_64-softmmu/qemu-system-x86_64core.qemu-system-x86.7419
Quoted 2 lines
(gdb) bt full
#00x000056107c19afa9invhost_vdpa_listener_region_del(listener=0x7ff9a9c691a0, section=0x7ffd3889ad20)
Quoted 4 lines
at ../hw/virtio/vhost-vdpa.c:290 result = 0x0 vaddr = 0x7ff29be00000 mem_region = {iova = 0, translated_addr = 140679973961728, size= 30064771071, perm =
IOMMU_NONE}Quoted 7 lines
v = 0x7ff9a9c69190 iova = 4294967296 llend = 34359738368 llsize = 30064771072 ret = 32765 __func__ = "vhost_vdpa_listener_region_del"#1
0x000056107c1ca915inlistener_del_address_space(listener=0x7ff9a9c691a0, as=0x56107cccbc00 <
address_space_memory>)Quoted 3 lines
at ../softmmu/memory.c:2939 section = {size = 30064771072, mr = 0x56107e116270, fv = 0x7ff1e02a4090,
offset_within_region= 2147483648,offset_within_address_space= 4294967296, readonly = false, nonvolatile = false}Quoted 3 lines
view = 0x7ff1e02a4090 fr = 0x7ff1e04027f0#2
0x000056107c1cac39inmemory_listener_unregister(listener=0x7ff9a9c691a0) at
../softmmu/memory.c:2989Quoted 1 line
#3
0x000056107c19d007invhost_vdpa_dev_start(dev=0x56107e126ea0,started=false) at
../hw/virtio/vhost-vdpa.c:1134Quoted 3 lines
v =
0x7ff9a9c69190
ok = true
#40x000056107c190252invhost_dev_stop(hdev=0x56107e126ea0,vdev=0x56107f40cb50) at
../hw/virtio/vhost.c:1828Quoted 3 lines
i = 32761 __PRETTY_FUNCTION__ = "vhost_dev_stop"#5
0x000056107bebe26cinvhost_net_stop_one(net=0x56107e126ea0,dev=0x56107f40cb50) at
../hw/net/vhost_net.c:315Quoted 3 lines
file = {index = 0, fd = -1} __PRETTY_FUNCTION__ = "vhost_net_stop_one"#6
0x000056107bebe6bfinvhost_net_stop(dev=0x56107f40cb50,ncs=0x56107f421850, data_queue_pairs=1, cvq=0)
Quoted 12 lines
at ../hw/net/vhost_net.c:425 qbus = 0x56107f40cac8 vbus = 0x56107f40cac8 k = 0x56107df1a220 n = 0x56107f40cb50 peer = 0x7ff9a9c69010 total_notifiers = 2 nvhosts = 1 i = 0 --Type <RET> for more, q to quit, c to continue without paging-- r = 32765 __PRETTY_FUNCTION__ = "vhost_net_stop"Quoted 1 line
#7
0x000056107c14af24invirtio_net_vhost_status(n=0x56107f40cb50,status=15 '\017') at
../hw/net/virtio-net.c:298Quoted 5 lines
vdev = 0x56107f40cb50 nc = 0x56107f421850 queue_pairs = 1 cvq = 0#8
0x000056107c14b17einvirtio_net_set_status(vdev=0x56107f40cb50,status=15 '\017') at
../hw/net/virtio-net.c:372Quoted 5 lines
n = 0x56107f40cb50 q = 0x56107f40cb50 i = 32765 queue_status = 137 '\211'#9
0x000056107c185af2invirtio_set_status(vdev=0x56107f40cb50, val=15'\017') at
../hw/virtio/virtio.c:1947Quoted 2 lines
k = 0x56107dfe2c60#10
0x000056107c188cbbinvirtio_vmstate_change(opaque=0x56107f40cb50,running=false, state=RUN_STATE_SHUTDOWN)
Quoted 6 lines
at ../hw/virtio/virtio.c:3195 vdev = 0x56107f40cb50 qbus = 0x56107f40cac8 k = 0x56107df1a220 backend_run = false#11
0x000056107bfdca5einvm_state_notify(running=false,state=RUN_STATE_SHUTDOWN) at
../softmmu/runstate.c:334Quoted 3 lines
e = 0x56107f419950 next = 0x56107f224b80#12
0x000056107bfd43e6indo_vm_stop(state=RUN_STATE_SHUTDOWN,send_stop=false) at
../softmmu/cpus.c:263Quoted 4 lines
ret = 0#13
0x000056107bfd4420invm_shutdown() at../softmmu/cpus.c:281#140x000056107bfdd584inqemu_cleanup() at../softmmu/runstate.c:813#150x000056107bd81a5bin main (argc=65, argv=0x7ffd3889b178,envp=0x7ffd3889b388) at
../softmmu/main.c:51Quoted 37 lines
Thanks
LeiQuoted 31 lines · Jason Wang <[email protected]> 于2022年7月26日周二 16:51写道:
From: Eugenio Pérez <[email protected]>
vhost_vdpa_listener_region_delis always deleting the first iova entry of the tree, since it's using the needle iova instead of the result's one.This was detected using a vga virtual device in the VM using vdpa SVQ. It makes some extra memory adding and deleting, so the wrong one was mapped / unmapped. This was undetected before since all the memory was mappend and unmapped totally without that device, but other conditions could trigger it too:
*
mem_regionwas with .iova = 0, .translated_addr = (correct GPA).
*iova_tree_find_iovareturned right result, but does not updatemem_region.
*iova_tree_removealways removed region with .iova = 0. Right iova were sent to the device.
* Next map will fill the first region with .iova = 0, causing a mapping with the same iova and device complains, if the next action is a map.
* Next unmap will cause to try to unmap again iova = 0, causing the device to complain that no region was mapped at iova = 0.Fixes 34e3c94edaef ("vdpa: Add custom IOTLB translations to SVQ")Reported-by Lei Yang <[email protected]>Signed-off-by Eugenio Pérez <[email protected]>Signed-off-by Jason Wang <[email protected]>--- hw/virtio/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 5 lines
hw/virtio/vhost-vdpa.c static void
Quoted 5 lines
hw/virtio/vhost-vdpa.c +0
-0@@ -290,7 +290,7 @@ static voidvhost_vdpa_listener_region_del(MemoryListener *listener,
Quoted 11 lines
Quoted 11 lines
hw/virtio/vhost-vdpa.c +1
-2result =vhost_iova_tree_find_iova (v->iova_tree, &mem_region); iova = result->iova; -vhost_iova_tree_remove (v->iova_tree, &mem_region); +vhost_iova_tree_remove (v->iova_tree, result); }vhost_vdpa_iotlb_batch_begin_once (v); ret =vhost_vdpa_dma_unmap (v, iova,int128_get64 (llsize)); --2.7.4
Peter Maydell
AppliedQuoted 7 lines · Jason Wang
The following changes since commit
5288bee45fbd33203b61f8c76e41b15bb5913e6e:Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-07-21 11:13:01 +0100)
are available in the git repository at:
Quoted 8 lines
https://github.com/jasowang/qemu.git tags/net-pull-request
for you to fetch changes up to
75a8ce64f6e37513698857fb4284170da163ed06:vdpa: Fix memory listener deletions of iova tree (2022-07-26 16:24:19 +0800)
----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.1
for any user-visible changes.
-- PMM