RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2124856 - VM with virtio interface and iommu=on will crash when try to migrate
Summary: VM with virtio interface and iommu=on will crash when try to migrate
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: qemu-kvm
Version: 9.1
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: rc
: 9.2
Assignee: Eric Auger
QA Contact: Lei Yang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-07 09:54 UTC by yalzhang@redhat.com
Modified: 2023-05-09 07:44 UTC (History)
14 users (show)

Fixed In Version: qemu-kvm-7.2.0-5.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:20:04 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
The output from "coredumpctl info" (25.68 KB, text/plain)
2022-09-07 09:54 UTC, yalzhang@redhat.com
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Gitlab redhat/centos-stream/src qemu-kvm merge_requests 134 0 None opened vhost: fix vq dirty bitmap syncing when vIOMMU is enabled 2023-01-12 10:54:27 UTC
Red Hat Issue Tracker RHELPLAN-133419 0 None None None 2022-09-07 10:32:41 UTC
Red Hat Product Errata RHSA-2023:2162 0 None None None 2023-05-09 07:20:28 UTC

Description yalzhang@redhat.com 2022-09-07 09:54:49 UTC
Created attachment 1910093 [details]
The output from "coredumpctl  info"

Description of problem:
VM with virtio interface and iommu=on will crash when try to migrate

Version-Release number of selected component (if applicable):
# rpm -q libvirt qemu-kvm
libvirt-8.5.0-6.el9.x86_64
qemu-kvm-7.0.0-12.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start a vm with virtio iommu and interface with iommu=on:
# virsh dumpxml rhel 
<interface type="network">
  <mac address="52:54:00:20:64:8c"/>
  <source network="default"/>
  <model type="virtio"/>
  <driver iommu="on"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>
<iommu model="virtio">
  <address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
</iommu>

# virsh start rhel
Domain 'rhel' started

2. Try to migrate the guest:
# virsh migrate rhel --live --verbose qemu+ssh://xxx/system  --p2p --persistent --undefinesource
error: operation failed: domain is not running

The qemu log says:
qemu-kvm: ../hw/virtio/vhost.c:81: void vhost_dev_sync_region(struct vhost_dev *, MemoryRegionSection *, uint64_t, uint64_t, uint64_t, uint64_t): Assertion `end / VHOST_LOG_CHUNK < dev->log_size' failed.
2022-09-07 09:11:49.022+0000: shutting down, reason=crashed

Actual results:
The vm will be crashed when we tried to migrate it with interface iommu=on and virtio iommu

Expected results:
The vm should not crashed

Additional info:

Comment 6 jinl 2022-09-15 07:35:43 UTC
Additional Info:
based on Description env, the memory of vm is 1024
but when I try install vm with -m 4096 in the same host, the vm will migrate successfully

Comment 7 Eric Auger 2022-11-09 07:40:37 UTC
Hi Lei,

I've started working on this. At the moment I fail to reproduce unfortunately, at least on ARM. I am testing at qemu level, using -m 1G and vhost-net. At the moment I try to migrate on the same host. Do you get the error also when migrating on the same host? In case you do, may I have access to your setup?

Thank you in advance

Eric

Comment 8 Lei Yang 2022-11-09 08:31:56 UTC
(In reply to Eric Auger from comment #7)
> Hi Lei,
> 
> I've started working on this. At the moment I fail to reproduce
> unfortunately, at least on ARM. I am testing at qemu level, using -m 1G and
> vhost-net. At the moment I try to migrate on the same host. Do you get the
> error also when migrating on the same host? In case you do, may I have
> access to your setup?
> 
> Thank you in advance
> 
> Eric

hello Eric

I tried to test this bug on QE's env, When the guest using -m 1G, it can not start up. QE not sure is this a new issue, if yes, please let me know, I will file a new bug.

Host ip: 10.73.210.76
Host passwd: redhat
script: /root/src.sh /root/dst.sh

Best Regards
Lei

Comment 9 Eric Auger 2022-11-09 09:28:53 UTC
(In reply to Lei Yang from comment #8)
> (In reply to Eric Auger from comment #7)
> > Hi Lei,
> > 
> > I've started working on this. At the moment I fail to reproduce
> > unfortunately, at least on ARM. I am testing at qemu level, using -m 1G and
> > vhost-net. At the moment I try to migrate on the same host. Do you get the
> > error also when migrating on the same host? In case you do, may I have
> > access to your setup?
> > 
> > Thank you in advance
> > 
> > Eric
> 
> hello Eric
> 
> I tried to test this bug on QE's env, When the guest using -m 1G, it can not
> start up. QE not sure is this a new issue, if yes, please let me know, I
> will file a new bug.
> 
> Host ip: 10.73.210.76
> Host passwd: redhat
> script: /root/src.sh /root/dst.sh
> 
> Best Regards
> Lei

So you mean this is a regression? You were able to run with 1G before. What has changed since your last attempt? Are you running on ARM or x86?

Comment 10 Lei Yang 2022-11-09 10:08:57 UTC
(In reply to Eric Auger from comment #9)
> (In reply to Lei Yang from comment #8)
> > (In reply to Eric Auger from comment #7)
> > > Hi Lei,
> > > 
> > > I've started working on this. At the moment I fail to reproduce
> > > unfortunately, at least on ARM. I am testing at qemu level, using -m 1G and
> > > vhost-net. At the moment I try to migrate on the same host. Do you get the
> > > error also when migrating on the same host? In case you do, may I have
> > > access to your setup?
> > > 
> > > Thank you in advance
> > > 
> > > Eric
> > 
> > hello Eric
> > 
> > I tried to test this bug on QE's env, When the guest using -m 1G, it can not
> > start up. QE not sure is this a new issue, if yes, please let me know, I
> > will file a new bug.
> > 
> > Host ip: 10.73.210.76
> > Host passwd: redhat
> > script: /root/src.sh /root/dst.sh
> > 
> > Best Regards
> > Lei
> 
> So you mean this is a regression? You were able to run with 1G before. What
> has changed since your last attempt? Are you running on ARM or x86?

I am not sure whether is a regression bug. But after testing it can be determined that this is not caused by separate qemu and kernel。 I tried to test it "-m 2G", guest can start up succeed. This makes me have to confirm a question, 1G or 2G whether can meet the minimum memory used by rhel?

Comment 11 Lei Yang 2022-11-09 10:40:15 UTC
Accordnig to this doc [1], the rhel9 required minimum memory is 1.5G. So first of all this bug is not a valid usage, on the other hands, QE tried to test it on the latest version with "-m 1.5", there is no issues any more.

Test Version:
qemu-kvm-7.1.0-4.el9.x86_64
kernel-5.14.0-187.el9.x86_64
edk2-ovmf-20220826gitba0e0e4c6a-1.el9.noarch

qemu cmd:
/usr/libexec/qemu-kvm \
-name 'avocado-vt-vm1'  \
-sandbox on  \
-blockdev node-name=file_ovmf_code,driver=file,filename=/usr/share/OVMF/OVMF_CODE.secboot.fd,auto-read-only=on,discard=unmap \
-blockdev node-name=drive_ovmf_code,driver=raw,read-only=on,file=file_ovmf_code \
-blockdev node-name=file_ovmf_vars,driver=file,filename=/root/avocado/data/avocado-vt/avocado-vt-vm1_rhel920-64-virtio-scsi_qcow2_filesystem_VARS.fd,auto-read-only=on,discard=unmap \
-blockdev node-name=drive_ovmf_vars,driver=raw,read-only=off,file=file_ovmf_vars \
-machine q35,memory-backend=mem-machine_mem,pflash0=drive_ovmf_code,pflash1=drive_ovmf_vars \
-device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,chassis=1 \
-device pcie-pci-bridge,id=pcie-pci-bridge-0,addr=0x0,bus=pcie-root-port-0  \
-nodefaults \
-device VGA,bus=pcie.0,addr=0x2 \
-device '{"driver":"virtio-iommu","bus":"pcie.0","addr":"0x4"}' \
-m 1536 \
-object '{"qom-type": "memory-backend-ram", "size": 1610612736, "id": "mem-machine_mem"}'  \
-smp 16,maxcpus=16,cores=8,threads=1,dies=1,sockets=2  \
-cpu 'Cascadelake-Server',ss=on,vmx=on,pdcm=on,hypervisor=on,tsc-adjust=on,umip=on,pku=on,md-clear=on,stibp=on,arch-capabilities=on,xsaves=on,ibpb=on,ibrs=on,amd-stibp=on,amd-ssbd=on,rdctl-no=on,ibrs-all=on,skip-l1dfl-vmentry=on,mds-no=on,pschange-mc-no=on,tsx-ctrl=on,hle=off,rtm=off,kvm_pv_unhalt=on \
-device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2 \
-device qemu-xhci,id=usb1,bus=pcie-root-port-1,addr=0x0 \
-device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
-device pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x1.0x2,bus=pcie.0,chassis=3 \
-device '{"id": "virtio_scsi_pci0", "driver": "virtio-scsi-pci", "bus": "pcie-root-port-2", "addr": "0x0"}' \
-blockdev '{"node-name": "file_image1", "driver": "file", "auto-read-only": true, "discard": "unmap", "aio": "threads", "filename": "/home/kvm_autotest_root/images/rhel920-64-virtio-scsi.qcow2", "cache": {"direct": true, "no-flush": false}}' \
-blockdev '{"node-name": "drive_image1", "driver": "qcow2", "read-only": false, "cache": {"direct": true, "no-flush": false}, "file": "file_image1"}' \
-device '{"driver": "scsi-hd", "id": "image1", "drive": "drive_image1", "write-cache": "on"}' \
-device pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x1.0x3,bus=pcie.0,chassis=4 \
-device virtio-net-pci,mac=9a:d8:c1:96:c2:8c,id=idepUy49,netdev=id2UOOFL,bus=pcie-root-port-3,addr=0x0  \
-netdev tap,id=id2UOOFL,vhost=on \
-vnc :0  \
-rtc base=utc,clock=host,driftfix=slew  \
-boot menu=off,order=cdn,once=c,strict=off \
-enable-kvm \
-device pcie-root-port,id=pcie_extra_root_port_0,multifunction=on,bus=pcie.0,addr=0x3,chassis=5 \
-monitor stdio \
-qmp tcp:0:5555,server,nowait \

==>Additional info:
QE also tried to downgrade the qemu to qemu-kvm-7.0.0-12.el9.x86_64, and the other env exactly same as above, guest can live migration successfully.

[1]https://access.redhat.com/articles/rhel-limits#minimum-required-memory-3

Comment 12 Lei Yang 2022-11-09 10:52:20 UTC
Hello Eric

Based on the comment 11, whether continue to debug this bug? If continue, QE will reinstall test host to the rhel9.1, then test it again. If not, maybe this bug should be close as "NOTABUG", since the bug usage method is a invalid case. Please let me know if there are any testing need be done from the QE.

Thanks
Lei

Comment 13 Eric Auger 2022-11-15 07:41:39 UTC
Hi Lei,

I would prefer we try to reproduce the issue again on rhel9.1. 

To summarize, with vhost=on and 1GB guest we got:

qemu-kvm: ../hw/virtio/vhost.c:81: void vhost_dev_sync_region(struct vhost_dev *, MemoryRegionSection *, uint64_t, uint64_t, uint64_t, uint64_t): Assertion `end / VHOST_LOG_CHUNK < dev->log_size' failed.
2022-09-07 09:11:49.022+0000: shutting down, reason=crashed

Without vhost we got:
(qemu) qemu-kvm: virtio_iommu_translate no mapping for 0x34b49002 for sid=1024
qemu-kvm: VQ 0 size 0x100 Guest index 0x0 inconsistent with Host index 0x99a: delta 0xf666
qemu-kvm: VQ 1 size 0x100 Guest index 0x0 inconsistent with Host index 0x584: delta 0xfa7c

If this can be reproduced again, I would be grateful to you if you could let me access the machine.

Thank you in advance

Eric

Comment 14 Lei Yang 2022-11-15 13:53:53 UTC
(In reply to Eric Auger from comment #13)
> Hi Lei,
> 
> I would prefer we try to reproduce the issue again on rhel9.1. 
> 
> To summarize, with vhost=on and 1GB guest we got:
> 
> qemu-kvm: ../hw/virtio/vhost.c:81: void vhost_dev_sync_region(struct
> vhost_dev *, MemoryRegionSection *, uint64_t, uint64_t, uint64_t, uint64_t):
> Assertion `end / VHOST_LOG_CHUNK < dev->log_size' failed.
> 2022-09-07 09:11:49.022+0000: shutting down, reason=crashed
> 
> Without vhost we got:
> (qemu) qemu-kvm: virtio_iommu_translate no mapping for 0x34b49002 for
> sid=1024
> qemu-kvm: VQ 0 size 0x100 Guest index 0x0 inconsistent with Host index
> 0x99a: delta 0xf666
> qemu-kvm: VQ 1 size 0x100 Guest index 0x0 inconsistent with Host index
> 0x584: delta 0xfa7c
> 
> If this can be reproduced again, I would be grateful to you if you could let
> me access the machine.
> 
> Thank you in advance
> 
> Eric

Hello Eric

I can got the above test result in the past, since I can reproduced in the past,which like be mention on Comment 1. However, when I tried to install a machine with rhel9.1 and boot up this guest with 1G memory, which can not boot up successfully. en, I can not sure which component block it, could you please help review it? 

Host IP: 10.73.210.48
Host passwd: kvmautotest
Guest script: /root/src.sh && /root/dst.sh

Thanks
Lei

Comment 15 Lei Yang 2022-11-16 02:39:14 UTC
Hello Eric

Now, QE can reproduced this problem again,QE found that only using "Q35 + Seabios" can start the guest with 1G memory.This is also the reason why it has been unable to start successfully before, because the default ovmf on rhel9 has been used before.

Thanks
Lei

Comment 16 Eric Auger 2022-11-16 08:26:34 UTC
(In reply to Lei Yang from comment #14)
> (In reply to Eric Auger from comment #13)
> > Hi Lei,
> > 
> > I would prefer we try to reproduce the issue again on rhel9.1. 
> > 
> > To summarize, with vhost=on and 1GB guest we got:
> > 
> > qemu-kvm: ../hw/virtio/vhost.c:81: void vhost_dev_sync_region(struct
> > vhost_dev *, MemoryRegionSection *, uint64_t, uint64_t, uint64_t, uint64_t):
> > Assertion `end / VHOST_LOG_CHUNK < dev->log_size' failed.
> > 2022-09-07 09:11:49.022+0000: shutting down, reason=crashed
> > 
> > Without vhost we got:
> > (qemu) qemu-kvm: virtio_iommu_translate no mapping for 0x34b49002 for
> > sid=1024
> > qemu-kvm: VQ 0 size 0x100 Guest index 0x0 inconsistent with Host index
> > 0x99a: delta 0xf666
> > qemu-kvm: VQ 1 size 0x100 Guest index 0x0 inconsistent with Host index
> > 0x584: delta 0xfa7c
> > 
> > If this can be reproduced again, I would be grateful to you if you could let
> > me access the machine.
> > 
> > Thank you in advance
> > 
> > Eric
> 
> Hello Eric
> 
> I can got the above test result in the past, since I can reproduced in the
> past,which like be mention on Comment 1. However, when I tried to install a
> machine with rhel9.1 and boot up this guest with 1G memory, which can not
> boot up successfully. en, I can not sure which component block it, could you
> please help review it? 
> 
> Host IP: 10.73.210.48
> Host passwd: kvmautotest
> Guest script: /root/src.sh && /root/dst.sh
> 
> Thanks
> Lei

Hi Lei, I mistakenly altered the src.sh. Do you have means to restore? What is the root pwd of the guest? Are you using virt-install when installing the guest. Can you paste your cmd line? Thanks. Eric

Comment 17 Eric Auger 2022-11-16 08:27:31 UTC
(In reply to Lei Yang from comment #15)
> Hello Eric
> 
> Now, QE can reproduced this problem again,QE found that only using "Q35 +
> Seabios" can start the guest with 1G memory.This is also the reason why it
> has been unable to start successfully before, because the default ovmf on
> rhel9 has been used before.
> 
> Thanks
> Lei

Can you paste the associated cmd line please. Is it on the same machine?

Comment 18 Lei Yang 2022-11-16 08:39:05 UTC
(In reply to Eric Auger from comment #17)
> (In reply to Lei Yang from comment #15)
> > Hello Eric
> > 
> > Now, QE can reproduced this problem again,QE found that only using "Q35 +
> > Seabios" can start the guest with 1G memory.This is also the reason why it
> > has been unable to start successfully before, because the default ovmf on
> > rhel9 has been used before.
> > 
> > Thanks
> > Lei
> 
> Can you paste the associated cmd line please. Is it on the same machine?

Sure, they are use the same environment. Now the src.sh has been restore. And vm passwd same as host.

qemu cmd:
/usr/libexec/qemu-kvm \
-name 'avocado-vt-vm1'  \
-sandbox on  \
-machine q35,memory-backend=mem-machine_mem \
-device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,chassis=1 \
-device pcie-pci-bridge,id=pcie-pci-bridge-0,addr=0x0,bus=pcie-root-port-0  \
-nodefaults \
-device '{"driver":"virtio-iommu","bus":"pcie.0","addr":"0x4"}' \
-device VGA,bus=pcie.0,addr=0x2 \
-m 1024 \
-object memory-backend-ram,size=1024M,id=mem-machine_mem  \
-smp 6,maxcpus=6,cores=3,threads=1,dies=1,sockets=2  \
-cpu 'Haswell-noTSX-IBRS',vme=on,ss=on,vmx=on,pdcm=on,f16c=on,rdrand=on,hypervisor=on,arat=on,tsc-adjust=on,umip=on,md-clear=on,stibp=on,arch-capabilities=on,ssbd=on,xsaveopt=on,pdpe1gb=on,abm=on,ibpb=on,ibrs=on,amd-stibp=on,amd-ssbd=on,skip-l1dfl-vmentry=on,pschange-mc-no=on,kvm_pv_unhalt=on \
-device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2 \
-device qemu-xhci,id=usb1,bus=pcie-root-port-1,addr=0x0 \
-device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
-device pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x1.0x2,bus=pcie.0,chassis=3 \
-device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pcie-root-port-2,addr=0x0 \
-blockdev node-name=file_image1,driver=file,auto-read-only=on,discard=unmap,aio=threads,filename=/home/kvm_autotest_root/images/rhel910-64-virtio-scsi.qcow2,cache.direct=on,cache.no-flush=off \
-blockdev node-name=drive_image1,driver=qcow2,read-only=off,cache.direct=on,cache.no-flush=off,file=file_image1 \
-device scsi-hd,id=image1,drive=drive_image1,write-cache=on \
-device pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x1.0x3,bus=pcie.0,chassis=4 \
-device virtio-net-pci,iommu_platform=on,mac=9a:ac:5a:d7:18:8e,id=id0DVAMO,netdev=id4Im3rr,bus=pcie-root-port-3,addr=0x0  \
-netdev tap,id=id4Im3rr,vhost=on \
-vnc :0 \
-rtc base=utc,clock=host,driftfix=slew  \
-boot menu=off,order=cdn,once=c,strict=off \
-enable-kvm \
-device pcie-root-port,id=pcie_extra_root_port_0,multifunction=on,bus=pcie.0,addr=0x3,chassis=5 \
-monitor stdio \
-qmp tcp:0:5555,server,nowait \

Comment 19 Eric Auger 2022-11-16 08:51:23 UTC
(In reply to Lei Yang from comment #18)
> (In reply to Eric Auger from comment #17)
> > (In reply to Lei Yang from comment #15)
> > > Hello Eric
> > > 
> > > Now, QE can reproduced this problem again,QE found that only using "Q35 +
> > > Seabios" can start the guest with 1G memory.This is also the reason why it
> > > has been unable to start successfully before, because the default ovmf on
> > > rhel9 has been used before.
> > > 
> > > Thanks
> > > Lei
> > 
> > Can you paste the associated cmd line please. Is it on the same machine?
> 
> Sure, they are use the same environment. Now the src.sh has been restore.
> And vm passwd same as host.
> 
> qemu cmd:
> /usr/libexec/qemu-kvm \
> -name 'avocado-vt-vm1'  \
> -sandbox on  \
> -machine q35,memory-backend=mem-machine_mem \
> -device
> pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,
> chassis=1 \
> -device pcie-pci-bridge,id=pcie-pci-bridge-0,addr=0x0,bus=pcie-root-port-0  \
> -nodefaults \
> -device '{"driver":"virtio-iommu","bus":"pcie.0","addr":"0x4"}' \
> -device VGA,bus=pcie.0,addr=0x2 \
> -m 1024 \
> -object memory-backend-ram,size=1024M,id=mem-machine_mem  \
> -smp 6,maxcpus=6,cores=3,threads=1,dies=1,sockets=2  \
> -cpu
> 'Haswell-noTSX-IBRS',vme=on,ss=on,vmx=on,pdcm=on,f16c=on,rdrand=on,
> hypervisor=on,arat=on,tsc-adjust=on,umip=on,md-clear=on,stibp=on,arch-
> capabilities=on,ssbd=on,xsaveopt=on,pdpe1gb=on,abm=on,ibpb=on,ibrs=on,amd-
> stibp=on,amd-ssbd=on,skip-l1dfl-vmentry=on,pschange-mc-no=on,
> kvm_pv_unhalt=on \
> -device
> pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,
> chassis=2 \
> -device qemu-xhci,id=usb1,bus=pcie-root-port-1,addr=0x0 \
> -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
> -device
> pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x1.0x2,bus=pcie.0,
> chassis=3 \
> -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pcie-root-port-2,addr=0x0 \
> -blockdev
> node-name=file_image1,driver=file,auto-read-only=on,discard=unmap,
> aio=threads,filename=/home/kvm_autotest_root/images/rhel910-64-virtio-scsi.
> qcow2,cache.direct=on,cache.no-flush=off \
> -blockdev
> node-name=drive_image1,driver=qcow2,read-only=off,cache.direct=on,cache.no-
> flush=off,file=file_image1 \
> -device scsi-hd,id=image1,drive=drive_image1,write-cache=on \
> -device
> pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x1.0x3,bus=pcie.0,
> chassis=4 \
> -device
> virtio-net-pci,iommu_platform=on,mac=9a:ac:5a:d7:18:8e,id=id0DVAMO,
> netdev=id4Im3rr,bus=pcie-root-port-3,addr=0x0  \
> -netdev tap,id=id4Im3rr,vhost=on \
> -vnc :0 \
> -rtc base=utc,clock=host,driftfix=slew  \
> -boot menu=off,order=cdn,once=c,strict=off \
> -enable-kvm \
> -device
> pcie-root-port,id=pcie_extra_root_port_0,multifunction=on,bus=pcie.0,
> addr=0x3,chassis=5 \
> -monitor stdio \
> -qmp tcp:0:5555,server,nowait \

OK Thanks! Working on it today. So I can start the guest successfully with src.sh

Comment 20 Eric Auger 2022-11-16 11:34:42 UTC
Hi Lei, can I have access to the console of this machine. I would like to update the kernel and reboot. I confirm that it is not related to qemu because I hit the same issue with an upstream qemu.

Comment 25 Eric Auger 2022-11-18 09:39:12 UTC
I can reproduce the issue with virtio-iommu and vhost-net. With intel-iommu and without any iommu I do not hit the issue. However I am not sure this is virtio-iommu related.

I observe the following:

Last time vhost_get_log_size() is called it takes into account 2 regions when computing the log_size:
qemu-system-x86_64: vhost_get_log_size region 0 last=0x9ffff updated log_size=0x3
qemu-system-x86_64: vhost_get_log_size region 1 last=0x3fffffff updated log_size=0x1000
so in vhost_migration_log() vhost_get_log_size(dev) returns 0x1000

However memory_region_sync_dirty_bitmap() calls vhost listener->log_sync, it does it for more than 2 MemroyRegionSections:
it does it for mem-machine_mem, vga.vram (several times) and eventually on pc.bios. This latter is reponsible for the assertion:

qemu-system-x86_64: vhost_log_sync calls sync_dirty_map on pc.bios for the full range
qemu-system-x86_64: vhost_sync_dirty_bitmap calls vhost_dev_sync_region on region 0
qemu-system-x86_64: vhost_dev_sync_region end=0x9ffff < start=0xfffc0000
qemu-system-x86_64: vhost_sync_dirty_bitmap calls vhost_dev_sync_region on region 1
qemu-system-x86_64: vhost_dev_sync_region end=0x3fffffff < start=0xfffc0000
qemu-system-x86_64: vhost_sync_dirty_bitmap calls vhost_dev_sync_region on vq 0 <-----
qemu-system-x86_64: vhost_dev_sync_region pc.bios mfirst=0xfffc0000 mlast=0xffffffff rfirst=0xfffff240 rlast=0xfffffa45
qemu-system-x86_64: vhost_dev_sync_region pc.bios end=0xfffffa45 VHOST_LOG_CHUNK=0x40000 end/VHOST_LOG_CHUNK=0x3fff dev->log_size=0x1000
qemu-system-x86_64: ../hw/virtio/vhost.c:85: vhost_dev_sync_region: Assertion `end / VHOST_LOG_CHUNK < dev->log_size' failed.

Looks like the 'end' has not been taken into account in log_size computation.

Jason, any idea?



#5  0x0000555555b03425 in vhost_dev_sync_region
    (dev=dev@entry=0x5555565a9530, section=section@entry=0x7ffeaeffc480, mfirst=mfirst@entry=4294705152, mlast=mlast@entry=4294967295, rfirst=<optimized out>, rlast=<optimized out>)
    at ../hw/virtio/vhost.c:84
#6  0x0000555555b03e09 in vhost_sync_dirty_bitmap (dev=dev@entry=0x5555565a9530, section=section@entry=0x7ffeaeffc480, first=first@entry=0, last=last@entry=18446744073709551615)
    at ../hw/virtio/vhost.c:144
#7  0x0000555555b03fc9 in vhost_log_sync (listener=0x5555565a9538, section=0x7ffeaeffc480) at ../hw/virtio/vhost.c:156
#8  0x0000555555b2f830 in memory_region_sync_dirty_bitmap (mr=mr@entry=0x0) at ../softmmu/memory.c:2174
#9  0x0000555555b34587 in memory_global_dirty_log_sync () at ../softmmu/memory.c:2784
#10 0x0000555555b4a16e in migration_bitmap_sync (rs=rs@entry=0x7ffea4001630) at ../migration/ram.c:1183
#11 0x0000555555b4a94c in migration_bitmap_sync_precopy (rs=rs@entry=0x7ffea4001630) at ../migration/ram.c:1230
#12 0x0000555555b4be62 in ram_init_bitmaps (rs=0x7ffea4001630) at ../migration/ram.c:3077
#13 ram_init_all (rsp=<optimized out>) at ../migration/ram.c:3101
#14 ram_save_setup (f=0x5555568fe1b0, opaque=<optimized out>) at ../migration/ram.c:3214

Comment 26 Eric Auger 2022-11-18 09:41:22 UTC
with intel-iommu, vhost_dev_sync_region is also called on ps-bios MRS but in vhost_dev_sync_region() we enter the
if (end < start) {
    return;
}
so we do not hit the assert.

Comment 27 jason wang 2022-11-21 06:04:53 UTC
(In reply to Eric Auger from comment #25)
> I can reproduce the issue with virtio-iommu and vhost-net. With intel-iommu
> and without any iommu I do not hit the issue. However I am not sure this is
> virtio-iommu related.
> 
> I observe the following:
> 
> Last time vhost_get_log_size() is called it takes into account 2 regions
> when computing the log_size:
> qemu-system-x86_64: vhost_get_log_size region 0 last=0x9ffff updated
> log_size=0x3
> qemu-system-x86_64: vhost_get_log_size region 1 last=0x3fffffff updated
> log_size=0x1000
> so in vhost_migration_log() vhost_get_log_size(dev) returns 0x1000
> 
> However memory_region_sync_dirty_bitmap() calls vhost listener->log_sync, it
> does it for more than 2 MemroyRegionSections:
> it does it for mem-machine_mem, vga.vram (several times) and eventually on
> pc.bios. This latter is reponsible for the assertion:
> 
> qemu-system-x86_64: vhost_log_sync calls sync_dirty_map on pc.bios for the
> full range
> qemu-system-x86_64: vhost_sync_dirty_bitmap calls vhost_dev_sync_region on
> region 0
> qemu-system-x86_64: vhost_dev_sync_region end=0x9ffff < start=0xfffc0000
> qemu-system-x86_64: vhost_sync_dirty_bitmap calls vhost_dev_sync_region on
> region 1
> qemu-system-x86_64: vhost_dev_sync_region end=0x3fffffff < start=0xfffc0000
> qemu-system-x86_64: vhost_sync_dirty_bitmap calls vhost_dev_sync_region on
> vq 0 <-----
> qemu-system-x86_64: vhost_dev_sync_region pc.bios mfirst=0xfffc0000
> mlast=0xffffffff rfirst=0xfffff240 rlast=0xfffffa45
> qemu-system-x86_64: vhost_dev_sync_region pc.bios end=0xfffffa45
> VHOST_LOG_CHUNK=0x40000 end/VHOST_LOG_CHUNK=0x3fff dev->log_size=0x1000
> qemu-system-x86_64: ../hw/virtio/vhost.c:85: vhost_dev_sync_region:
> Assertion `end / VHOST_LOG_CHUNK < dev->log_size' failed.
> 
> Looks like the 'end' has not been taken into account in log_size computation.
> 
> Jason, any idea?

Looks like the end here is IOVA not GPA. I suspect it is the root cause and why we see it is out of the range of the log.

The vq->used_phys were set during vhost_virtqueue_start():

    vq->used_phys = a = virtio_queue_get_used_addr(vdev, idx);

When vIOMMU is enabled, it is IOVA (I admit the name is confusing).

So when we sync used ring, we should convert it to GPA. I've draft a patch (I can't reproduce this issue by myself, but the patch pass the migration smoking test).

Lei, please give a try, and in order to not lose any dirty pages I suggest to test (assuming we won't hit the assertion any more):

migration while doing an large file scp to the guest, and compare the md5.

Thanks

> 
> 
> 
> #5  0x0000555555b03425 in vhost_dev_sync_region
>     (dev=dev@entry=0x5555565a9530, section=section@entry=0x7ffeaeffc480,
> mfirst=mfirst@entry=4294705152, mlast=mlast@entry=4294967295,
> rfirst=<optimized out>, rlast=<optimized out>)
>     at ../hw/virtio/vhost.c:84
> #6  0x0000555555b03e09 in vhost_sync_dirty_bitmap
> (dev=dev@entry=0x5555565a9530, section=section@entry=0x7ffeaeffc480,
> first=first@entry=0, last=last@entry=18446744073709551615)
>     at ../hw/virtio/vhost.c:144
> #7  0x0000555555b03fc9 in vhost_log_sync (listener=0x5555565a9538,
> section=0x7ffeaeffc480) at ../hw/virtio/vhost.c:156
> #8  0x0000555555b2f830 in memory_region_sync_dirty_bitmap (mr=mr@entry=0x0)
> at ../softmmu/memory.c:2174
> #9  0x0000555555b34587 in memory_global_dirty_log_sync () at
> ../softmmu/memory.c:2784
> #10 0x0000555555b4a16e in migration_bitmap_sync (rs=rs@entry=0x7ffea4001630)
> at ../migration/ram.c:1183
> #11 0x0000555555b4a94c in migration_bitmap_sync_precopy
> (rs=rs@entry=0x7ffea4001630) at ../migration/ram.c:1230
> #12 0x0000555555b4be62 in ram_init_bitmaps (rs=0x7ffea4001630) at
> ../migration/ram.c:3077
> #13 ram_init_all (rsp=<optimized out>) at ../migration/ram.c:3101
> #14 ram_save_setup (f=0x5555568fe1b0, opaque=<optimized out>) at
> ../migration/ram.c:3214

Comment 29 Eric Auger 2022-11-21 08:09:42 UTC
Hi Jason, thanks for the analysis and the patch. After applying this latter I do not hit the assert. However the migration does not seem to converge but this may link to another setup issue. Lei, please let us know if it removes the assert and if you are able to converge. Maybe I need to change the migration settings on my end ...

Comment 30 Eric Auger 2022-11-21 08:16:18 UTC
Yep, so the migration convergence issue was a problem in the destination script I think. Now I see the migration completing and no assertion. So it looks good from my side.

Comment 31 Lei Yang 2022-11-21 09:00:17 UTC
Hello Eric & Jason

After applied Jason provided patch, I can not reproduced this bug again. The follwoing is my test steps:

==Test Steps:
1. Compile upstream qemu
# git clone git://git.qemu.org/qemu.git
# mkdir build
# vim root/qemu/hw/virtio/vhost.c
# ../configure --target-list=x86_64-softmmu --enable-debug
# make

2. Boot src & dst guest
src:
/root/qemu/build/x86_64-softmmu/qemu-system-x86_64 \
-name 'avocado-vt-vm1'  \
-sandbox on  \
-machine q35,memory-backend=mem-machine_mem \
-device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,chassis=1 \
-device pcie-pci-bridge,id=pcie-pci-bridge-0,addr=0x0,bus=pcie-root-port-0  \
-nodefaults \
-device '{"driver":"virtio-iommu","bus":"pcie.0","addr":"0x4"}' \
-device VGA,bus=pcie.0,addr=0x2 \
-m 1024 \
-object memory-backend-ram,size=1024M,id=mem-machine_mem  \
-smp 6,maxcpus=6,cores=3,threads=1,dies=1,sockets=2  \
-cpu 'Haswell-noTSX-IBRS',vme=on,ss=on,vmx=on,pdcm=on,f16c=on,rdrand=on,hypervisor=on,arat=on,tsc-adjust=on,umip=on,md-clear=on,stibp=on,arch-capabilities=on,ssbd=on,xsaveopt=on,pdpe1gb=on,abm=on,ibpb=on,ibrs=on,amd-stibp=on,amd-ssbd=on,skip-l1dfl-vmentry=on,pschange-mc-no=on,kvm_pv_unhalt=on \
-device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2 \
-device qemu-xhci,id=usb1,bus=pcie-root-port-1,addr=0x0 \
-device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
-device pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x1.0x2,bus=pcie.0,chassis=3 \
-device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pcie-root-port-2,addr=0x0 \
-blockdev node-name=file_image1,driver=file,auto-read-only=on,discard=unmap,aio=threads,filename=/home/kvm_autotest_root/images/rhel910-64-virtio-scsi.qcow2,cache.direct=on,cache.no-flush=off \
-blockdev node-name=drive_image1,driver=qcow2,read-only=off,cache.direct=on,cache.no-flush=off,file=file_image1 \
-device scsi-hd,id=image1,drive=drive_image1,write-cache=on \
-device pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x1.0x3,bus=pcie.0,chassis=4 \
-device virtio-net-pci,iommu_platform=on,mac=9a:ac:5a:d7:18:8e,id=id0DVAMO,netdev=id4Im3rr,bus=pcie-root-port-3,addr=0x0  \
-netdev tap,id=id4Im3rr,vhost=on,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown \
-vnc :0 \
-rtc base=utc,clock=host,driftfix=slew  \
-boot menu=off,order=cdn,once=c,strict=off \
-enable-kvm \
-device pcie-root-port,id=pcie_extra_root_port_0,multifunction=on,bus=pcie.0,addr=0x3,chassis=5 \
-monitor stdio \
-qmp tcp:0:5555,server,nowait \

dst:
-qmp tcp:0:5556,server,nowait \
-incoming defer 

3.Create large file and check the md5 value
# dd if=/dev/zero of=/root/large_file count=8000 bs=1M
8000+0 records in
8000+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 18.2483 s, 460 MB/s
[root@dell-per730-29 ~]# md5sum large_file 
1760505701fd1bbcece9e4038f29fb0d  large_file

4.migration while doing an large file scp to the guest
host:
# scp large_file  root.210.221:/root
root.210.221's password: 
large_file                                                         100% 8000MB  41.0MB/s   03:15  
 
src:
$ telnet 10.73.210.48 5555
Trying 10.73.210.48...
Connected to 10.73.210.48.
Escape character is '^]'.
{"QMP": {"version": {"qemu": {"micro": 91, "minor": 1, "major": 7}, "package": "v7.2.0-rc1-7-ga082fab9d2-dirty"}, "capabilities": ["oob"]}}
{'execute': 'qmp_capabilities'}
{"return": {}}
{'execute': 'migrate', 'arguments': {'uri': 'tcp:localhost:5272', 'blk': false, 'inc': false}}
{"return": {}}
{"execute":"query-migrate"}
{"return": {"expected-downtime": 300, "status": "active", "setup-time": 3, "total-time": 1522, "ram": {"total": 1091379200, "postcopy-requests": 0, "dirty-sync-count": 1, "multifd-bytes": 0, "pages-per-second": 41930, "downtime-bytes": 0, "page-size": 4096, "remaining": 825643008, "postcopy-bytes": 0, "mbps": 1073.9448, "transferred": 214781202, "dirty-sync-missed-zero-copy": 0, "precopy-bytes": 214781202, "duplicate": 12570, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 214249472, "normal": 52307}}}
{"execute":"query-migrate"}
{"return": {"expected-downtime": 435, "status": "active", "setup-time": 3, "total-time": 6124, "ram": {"total": 1091379200, "postcopy-requests": 0, "dirty-sync-count": 3, "multifd-bytes": 0, "pages-per-second": 35420, "downtime-bytes": 0, "page-size": 4096, "remaining": 28213248, "postcopy-bytes": 0, "mbps": 1073.80368, "transferred": 832284109, "dirty-sync-missed-zero-copy": 0, "precopy-bytes": 832284109, "duplicate": 117240, "dirty-pages-rate": 8928, "skipped": 0, "normal-bytes": 829607936, "normal": 202541}}}
{"timestamp": {"seconds": 1669020533, "microseconds": 68338}, "event": "STOP"}
{"execute":"query-migrate"}
{"return": {"status": "completed", "setup-time": 3, "downtime": 60, "total-time": 6365, "ram": {"total": 1091379200, "postcopy-requests": 0, "dirty-sync-count": 6, "multifd-bytes": 0, "pages-per-second": 109590, "downtime-bytes": 18195138, "page-size": 4096, "remaining": 0, "postcopy-bytes": 0, "mbps": 1086.7500458975164, "transferred": 863903016, "dirty-sync-missed-zero-copy": 0, "precopy-bytes": 845707878, "duplicate": 126091, "dirty-pages-rate": 0, "skipped": 0, "normal-bytes": 861085696, "normal": 210226}}}

dst:
$ telnet 10.73.210.48 5556
Trying 10.73.210.48...
Connected to 10.73.210.48.
Escape character is '^]'.
{"QMP": {"version": {"qemu": {"micro": 91, "minor": 1, "major": 7}, "package": "v7.2.0-rc1-7-ga082fab9d2-dirty"}, "capabilities": ["oob"]}}
{'execute': 'qmp_capabilities'}
{"return": {}}
{'execute': 'migrate-incoming', 'arguments': {'uri': 'tcp:[::]:5272'}}
{"timestamp": {"seconds": 1669020520, "microseconds": 631386}, "event": "MIGRATION", "data": {"status": "setup"}}
{"return": {}}
{"timestamp": {"seconds": 1669020533, "microseconds": 179083}, "event": "RESUME"}

5.After migration and scp completed, then chenck the file md5 value inside guest
# md5sum large_file 
1760505701fd1bbcece9e4038f29fb0d  large_file

Thanks
Lei

Comment 32 Eric Auger 2022-11-21 09:37:16 UTC
Hi Lei, Jason, 

Excellent. So I guess the next step is for Jason to send his PATCH upstream for qemu 8.0 (I don't think this is candidate for 7.2.0 rc unfortunately) and then to backport the patch...

Thanks

Eric

Comment 33 jason wang 2022-11-22 03:02:01 UTC
(In reply to Eric Auger from comment #32)
> Hi Lei, Jason, 
> 
> Excellent. So I guess the next step is for Jason to send his PATCH upstream
> for qemu 8.0 (I don't think this is candidate for 7.2.0 rc unfortunately)
> and then to backport the patch...
> 
> Thanks
> 
> Eric

Right, I've sent the patch. But I'm not sure if it can go for 7.2 or not. Let's see.

Thanks

Comment 34 jason wang 2022-11-25 06:02:26 UTC
Hi Lei:

Here's an updated version of this patch, it passes my migration smoking test. Please test to see if it works for you.

Thanks

Comment 36 Lei Yang 2022-11-25 08:43:43 UTC
(In reply to jason wang from comment #34)
> Hi Lei:
> 
> Here's an updated version of this patch, it passes my migration smoking
> test. Please test to see if it works for you.
> 
> Thanks

Hi Jason

QE applied this patch and do the same test as Comment 31.It also works well.

Best Regards
Lei

Comment 37 Eric Auger 2022-12-13 12:41:47 UTC
Jason sent "[PATCH for 7.2? V2] vhost: fix vq dirty bitmap syncing when vIOMMU is enabled" upstream

Comment 40 Laurent Vivier 2023-01-03 16:20:54 UTC
(In reply to Eric Auger from comment #37)
> Jason sent "[PATCH for 7.2? V2] vhost: fix vq dirty bitmap syncing when
> vIOMMU is enabled" upstream

V3: https://patchew.org/QEMU/20221216033552.77087-1-jasowang@redhat.com/

Patch is now merged upstream but not in 7.2:

https://git.qemu.org/?p=qemu.git;a=commit;h=345cc1cbcbce2bab00abc2b88338d7d89c702d6b

Comment 45 Lei Yang 2023-01-19 05:56:43 UTC
Based on Comment 42, move to VERIFIED.

Comment 47 errata-xmlrpc 2023-05-09 07:20:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: qemu-kvm security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2162


Note You need to log in before you can comment on or make changes to this bug.