qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument


Recommended Posts

Looking for a push in the right direction. I've had GPU passthrough working for quite a while until today. I swapped GPUs for a bit and reinstalled the original. The GPU i tested sucked so I rolled back to my original, AMD RX570X. I was able to boot a VM successfully once. Now unraid is complaining about VFIO_MAP_DMA failed: Invalid argument

 

What I've done so far:

Rebooted

Bind/Unbind GPU

Reseated GPU

 

 

I've searched a bit but couldn't find a solution to this problem. Any ideas?

 

I've attached my diagnostics

Current GPU: AMD RX570x

Error: qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument 

Unraid 6.12.1

unraid-vm-log.png

 

Edit: Attached additional error msg

unraid-vm-autostart-error.png.7c53f2e8af425b4e837a695d4b43e314.png

ashla-234-diagnostics-20230626-1718.zip

Edited by darthkielbasa
Link to comment
1 hour ago, mackid1993 said:

I'm seeing this as well but my VM starts and my GPU passes through just fine. I'm wondering if this is a bug. I'm seeing this with a Quadro P400 on Win 11.

I'm passing through an AMD Dell RX570x w/ windows 10. I had a few Linux VMs passing thorugh the same GPU w/ no problem. 

 

I rolled back to 6.11.5 now i'm all good.

Link to comment
  • 3 weeks later...
  • 2 months later...
  • 1 month later...
  • 2 weeks later...
18 hours ago, Evolze said:

My thought process is: If I'm able to transfer these older OVMF files from 6.11.5 to 6.12.6, along with pointing them to my NVIDIA-specific VMs, perhaps these errors will go away?

Please remove your guide if possible! This will certainly cause issues for users if they upgrade or modify the libvirt.img in any way, instead I would recommend that you install the files which ship with Unraid 6.11.x via this method, please make sure that you first stop all of your VMs in the first place and then execute these commands from a terminal:

mkdir -p /tmp/edk2
cd /tmp/edk2
wget -O /tmp/edk2/edk2.txz https://github.com/ich777/edk2-unraid/releases/download/edk2-stable202305/ovmf-stable202305-x86_64-3.txz
installpkg /tmp/edk2/edk2.txz
rm -rf /tmp/edk2

 

This will install the edk2 firmware files from 6.11.5 (should be the build from 202305 - build 3).

BTW, you can find all the builds from edk2 over here.

  • Like 2
  • Thanks 1
Link to comment
On 12/23/2023 at 1:02 AM, ich777 said:
mkdir -p /tmp/edk2
cd /tmp/edk2
wget -O /tmp/edk2/edk2.txz https://github.com/ich777/edk2-unraid/releases/download/edk2-stable202305/ovmf-stable202305-x86_64-3.txz
installpkg /tmp/edk2/edk2.txz
rm -rf /tmp/edk2

 

@ich777 Removed my temporary workaround guide above. I had no idea it could cause issues to the libvirt.img, so I appreciate you mentioning this! Out of curiosity, what would happen to the libvirt image using the temp fix I mentioned? Curious as I don't believe I encountered any issues, but then again, I only tested this with one test GPU passthrough VM. 😀

 

I haven't tried these commands yet, but I am wondering -- does this override the default 6.12.x OVMF files in /usr/share/qemu? Or does it create a separate directory and all affected VMs would need to be updated to point to those edk2 OVMF files?

 

I also ask as in my workaround, I mentioned copying the 6.11.x files to that directory as this issue only seemed to impact GPU-based VMs as others using VNC didn't seem to be impacted. That way, both OVMF file versions could co-exist at once (if that makes sense). 😀

 

Nonetheless, thanks again for this! Looking forward to trying this out in the coming days. 

 

-----

@SimonF thanks for this too! I've only installed plugins and extensions via the CA, so I was curious how manually plugin installs would persist across reboots.

  • Like 1
Link to comment
24 minutes ago, Evolze said:

 

@ich777 Removed my temporary workaround guide above. I had no idea it could cause issues to the libvirt.img, so I appreciate you mentioning this! Out of curiosity, what would happen to the libvirt image using the temp fix I mentioned? Curious as I don't believe I encountered any issues, but then again, I only tested this with one test GPU passthrough VM. 😀

 

I haven't tried these commands yet, but I am wondering -- does this override the default 6.12.x OVMF files in /usr/share/qemu? Or does it create a separate directory and all affected VMs would need to be updated to point to those edk2 OVMF files?

 

I also ask as in my workaround, I mentioned copying the 6.11.x files to that directory as this issue only seemed to impact GPU-based VMs as others using VNC didn't seem to be impacted. That way, both OVMF file versions could co-exist at once (if that makes sense). 😀

 

Nonetheless, thanks again for this! Looking forward to trying this out in the coming days. 

 

-----

@SimonF thanks for this too! I've only installed plugins and extensions via the CA, so I was curious how manually plugin installs would persist across reboots.

If you install the package into /boot/extra it will install into the /usr/share/qemu at boot overwriting  the existing files.

 

libvirt image is just a persistent storage location that is mapped to /etc/libvirt in the file system.

  • Thanks 1
Link to comment
13 hours ago, Evolze said:

That way, both OVMF file versions could co-exist at once (if that makes sense). 😀

You don‘t have to do that because the VMs should work fine even if you i stall the older version.

 

However it seems really strange to me that you have issues with the new version since nothing should have changed, but I haven‘t gone through the source from the files what could cause this and haven‘t got a chnce to look into the conversation that you‘ve linked above (Christmas and holidays…).

Link to comment
On 12/25/2023 at 12:30 AM, ich777 said:

However it seems really strange to me that you have issues with the new version since nothing should have changed, but I haven‘t gone through the source from the files what could cause this and haven‘t got a chnce to look into the conversation that you‘ve linked above (Christmas and holidays…).

 

Understood, sounds good. Thanks again for taking a look at this - especially during this time of the year! I deleted my original temp workaround a few days ago, but did manage to save a copy of the Arch Linux bug report and Tianocore GitHub discussion (Oct 2022) I had mentioned, if that's what you were referring to?

 

I also had a chance to look at your edk2-unraid repo w/looking at the compile shell script, and I see what you mean. Hopefully, nothing too drastic was changed between the newer versions.

-------------------------

On a completely separate note, out of curiosity regarding your compile.sh script, where are these variables stored or fetched from? Are they set in GitHub, your personal system, or via the tianocore repo? I'm able to follow most of it but am a bit lost on where the directory locations are being called and stored. 😀

 

${DATA_DIR}

${LAT_V}

${LAT_V##*-}

Edited by Evolze
Link to comment
1 hour ago, Evolze said:

if that's what you were referring to?

Yes, but I haven't looked into that yet.

 

1 hour ago, Evolze said:

regarding your compile.sh script

1 hour ago, Evolze said:

${DATA_DIR}

This is just the main directory where you want to compile in, doesn't matter where.

 

1 hour ago, Evolze said:

${LAT_V}

This is just the tag from here.

 

2 hours ago, Evolze said:

${LAT_V##*-}

This is just a shell expansion from the version from above.

  • Thanks 1
Link to comment

I have the same error message (qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument) on my Win11 VM with Nvidia 4070 passthrough. Nothing else passed through. I'm on 6.12.6. However, the VM seems fine, except that recently (and I don't think I changed anything) it pauses (sleeps?) soon after I disconnect my Remote Desktop and today I woke it up but couldn't get back into it from Remote Desktop except via Force Stop and then Start.

Link to comment

Any update on this?

 

While I can't be sure that this issue is the cause, I'm now unable to Remote Desktop in to my Win11 VM. The VM tab in the GUI claims the VM is running, but the error log has many lines with that error message, and the (isolated) VM CPUs show 0% activity on the GUI Dashboard. So it seems to me that the VM is not actually running.

Link to comment

My bad. I found that the SSD cache drive with the VM was full (thanks to a Fix Common Problems notification - I'd been ignoring the disk utilisation messages). Once I cleared some space the VM worked fine again (although the error message still appears in the log).

Link to comment
  • 1 month later...

I am on unraid 6.12.6 and am seeing this same error in my windows 11 vm logs when passing through a 3060ti gpu on and Intel 13900k system.  I have the gpu stubbed out and the vm starts but have no idea how to fix the vm so the errors don't occur. @ich777 and @SimonF, I tried the below and it did not resolve the issue, any ideas?

On 12/23/2023 at 1:02 AM, ich777 said:

Please remove your guide if possible! This will certainly cause issues for users if they upgrade or modify the libvirt.img in any way, instead I would recommend that you install the files which ship with Unraid 6.11.x via this method, please make sure that you first stop all of your VMs in the first place and then execute these commands from a terminal:

mkdir -p /tmp/edk2
cd /tmp/edk2
wget -O /tmp/edk2/edk2.txz https://github.com/ich777/edk2-unraid/releases/download/edk2-stable202305/ovmf-stable202305-x86_64-3.txz
installpkg /tmp/edk2/edk2.txz
rm -rf /tmp/edk2

 

This will install the edk2 firmware files from 6.11.5 (should be the build from 202305 - build 3).

BTW, you can find all the builds from edk2 over here.

 

Update:

If I use the commands above and install OVMF for QEMU - edk2-stable202208, the errors in the log go away. I did this working my way back from the newest version and all of the other versions did produce the errors in the log.

Edited by lzrdking71
update
Link to comment
On 12/23/2023 at 12:02 AM, ich777 said:

I would recommend that you install the files which ship with Unraid 6.11.x via this method, please make sure that you first stop all of your VMs in the first place and then execute these commands from a terminal:

mkdir -p /tmp/edk2
cd /tmp/edk2
wget -O /tmp/edk2/edk2.txz https://github.com/ich777/edk2-unraid/releases/download/edk2-stable202305/ovmf-stable202305-x86_64-3.txz
installpkg /tmp/edk2/edk2.txz
rm -rf /tmp/edk2

 

This will install the edk2 firmware files from 6.11.5 (should be the build from 202305 - build 3).

Ok I installed the edk2 firmware from 6.11.5 as directed above, however I am still getting the same VFIO_MAP_DMA errors. I've attached my diagnostics but the basic situation is I have a 12600k and am trying to pass through the iGPU to a windows 10 VM. I am using the SR-IOV plug in currently under development here. The author of that plug in has said the issue is not related to SR-IOV.

 

text  error  warn  system  array  login  

2024-02-20T05:20:41.404687Z qemu-system-x86_64: vfio_dma_map(0x1483cec48800, 0x381000000000, 0x20000000, 0x1483aca00000) = -22 (Invalid argument)
2024-02-20T05:20:42.966784Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T05:20:42.966833Z qemu-system-x86_64: vfio_dma_map(0x1483cec48800, 0x381000000000, 0x20000000, 0x1483aca00000) = -22 (Invalid argument)
2024-02-20T05:20:43.017611Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T05:20:43.017651Z qemu-system-x86_64: vfio_dma_map(0x1483cec48800, 0x381000000000, 0x20000000, 0x1483aca00000) = -22 (Invalid argument)
2024-02-20T05:20:43.072592Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T05:20:43.072615Z qemu-system-x86_64: vfio_dma_map(0x1483cec48800, 0x381000000000, 0x20000000, 0x1483aca00000) = -22 (Invalid argument)
2024-02-20T05:20:43.108840Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T05:20:43.108863Z qemu-system-x86_64: vfio_dma_map(0x1483cec48800, 0x381000000000, 0x20000000, 0x1483aca00000) = -22 (Invalid argument)
2024-02-20T05:20:44.578237Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T05:20:44.578261Z qemu-system-x86_64: vfio_dma_map(0x1483cec48800, 0x381000000000, 0x20000000, 0x1483aca00000) = -22 (Invalid argument)
2024-02-20T05:21:43.977750Z qemu-system-x86_64: terminating on signal 15 from pid 18602 (/usr/sbin/libvirtd)
2024-02-20 05:21:44.402+0000: shutting down, reason=shutdown
2024-02-20 17:53:18.103+0000: starting up libvirt version: 8.7.0, qemu version: 7.2.0, kernel: 6.1.64-Unraid, hostname: HAL9000
LC_ALL=C \
PATH=/bin:/sbin:/usr/bin:/usr/sbin \
HOME='/var/lib/libvirt/qemu/domain-8-Windows 10' \
XDG_DATA_HOME='/var/lib/libvirt/qemu/domain-8-Windows 10/.local/share' \
XDG_CACHE_HOME='/var/lib/libvirt/qemu/domain-8-Windows 10/.cache' \
XDG_CONFIG_HOME='/var/lib/libvirt/qemu/domain-8-Windows 10/.config' \
/usr/local/sbin/qemu \
-name 'guest=Windows 10,debug-threads=on' \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-8-Windows 10/master-key.aes"}' \
-blockdev '{"driver":"file","filename":"/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}' \
-blockdev '{"driver":"file","filename":"/etc/libvirt/qemu/nvram/9ff111d8-9ac0-34f8-4fdf-cbc8b866a6fa_VARS-pure-efi.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \
-machine pc-i440fx-7.2,usb=off,dump-guest-core=off,mem-merge=off,memory-backend=pc.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format \
-accel kvm \
-cpu host,migratable=on,hv-time=on,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x1fff,hv-vendor-id=none,host-cache-info=on,l3-cache=off \
-m 16384 \
-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":17179869184}' \
-overcommit mem-lock=off \
-smp 8,sockets=1,dies=1,cores=4,threads=2 \
-uuid 9ff111d8-9ac0-34f8-4fdf-cbc8b866a6fa \
-display none \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=35,server=on,wait=off \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=localtime \
-no-hpet \
-no-shutdown \
-boot strict=on \
-device '{"driver":"pci-bridge","chassis_nr":1,"id":"pci.1","bus":"pci.0","addr":"0x3"}' \
-device '{"driver":"pci-bridge","chassis_nr":2,"id":"pci.2","bus":"pci.0","addr":"0x6"}' \
-device '{"driver":"pci-bridge","chassis_nr":3,"id":"pci.3","bus":"pci.0","addr":"0xb"}' \
-device '{"driver":"pci-bridge","chassis_nr":4,"id":"pci.4","bus":"pci.0","addr":"0x8"}' \
-device '{"driver":"pci-bridge","chassis_nr":5,"id":"pci.5","bus":"pci.0","addr":"0x9"}' \
-device '{"driver":"pci-bridge","chassis_nr":6,"id":"pci.6","bus":"pci.0","addr":"0xa"}' \
-device '{"driver":"ich9-usb-ehci1","id":"usb","bus":"pci.0","addr":"0x7.0x7"}' \
-device '{"driver":"ich9-usb-uhci1","masterbus":"usb.0","firstport":0,"bus":"pci.0","multifunction":true,"addr":"0x7"}' \
-device '{"driver":"ich9-usb-uhci2","masterbus":"usb.0","firstport":2,"bus":"pci.0","addr":"0x7.0x1"}' \
-device '{"driver":"ich9-usb-uhci3","masterbus":"usb.0","firstport":4,"bus":"pci.0","addr":"0x7.0x2"}' \
-device '{"driver":"ahci","id":"sata0","bus":"pci.0","addr":"0x4"}' \
-device '{"driver":"virtio-serial-pci","id":"virtio-serial0","bus":"pci.0","addr":"0x5"}' \
-blockdev '{"driver":"file","filename":"/mnt/user/domains/Windows 10/vdisk1.img","node-name":"libvirt-3-storage","cache":{"direct":false,"no-flush":false},"auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-3-format","read-only":false,"cache":{"direct":false,"no-flush":false},"driver":"raw","file":"libvirt-3-storage"}' \
-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0xc","drive":"libvirt-3-format","id":"virtio-disk2","bootindex":1,"write-cache":"on","serial":"vdisk1"}' \
-blockdev '{"driver":"file","filename":"/mnt/user/isos/Win10_22H2_English_x64v1.iso","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw","file":"libvirt-2-storage"}' \
-device '{"driver":"ide-cd","bus":"sata0.0","drive":"libvirt-2-format","id":"sata0-0-0","bootindex":2}' \
-blockdev '{"driver":"file","filename":"/mnt/user/isos/virtio-win-0.1.240-1.iso","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-1-format","read-only":true,"driver":"raw","file":"libvirt-1-storage"}' \
-device '{"driver":"ide-cd","bus":"sata0.1","drive":"libvirt-1-format","id":"sata0-0-1"}' \
-netdev tap,fd=36,id=hostnet0 \
-device '{"driver":"virtio-net","netdev":"hostnet0","id":"net0","mac":"52:54:00:73:76:08","bus":"pci.0","addr":"0x2"}' \
-chardev pty,id=charserial0 \
-device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-chardev socket,id=charchannel0,fd=34,server=on,wait=off \
-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}' \
-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-device '{"driver":"vfio-pci","host":"0000:00:02.1","id":"hostdev0","bus":"pci.6","addr":"0x10"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on
char device redirected to /dev/pts/0 (label charserial0)
2024-02-20T17:54:01.680257Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T17:54:01.687495Z qemu-system-x86_64: vfio_dma_map(0x14f69d048800, 0x381000000000, 0x20000000, 0x14f67ae00000) = -2 (No such file or directory)
2024-02-20T17:54:01.745119Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T17:54:01.745135Z qemu-system-x86_64: vfio_dma_map(0x14f69d048800, 0x381000000000, 0x20000000, 0x14f67ae00000) = -22 (Invalid argument)
2024-02-20T17:54:03.650076Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T17:54:03.650107Z qemu-system-x86_64: vfio_dma_map(0x14f69d048800, 0x381000000000, 0x20000000, 0x14f67ae00000) = -22 (Invalid argument)
2024-02-20T17:54:03.679258Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T17:54:03.679274Z qemu-system-x86_64: vfio_dma_map(0x14f69d048800, 0x381000000000, 0x20000000, 0x14f67ae00000) = -22 (Invalid argument)
2024-02-20T17:54:03.732239Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T17:54:03.732283Z qemu-system-x86_64: vfio_dma_map(0x14f69d048800, 0x381000000000, 0x20000000, 0x14f67ae00000) = -22 (Invalid argument)
2024-02-20T17:54:03.764302Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T17:54:03.764316Z qemu-system-x86_64: vfio_dma_map(0x14f69d048800, 0x381000000000, 0x20000000, 0x14f67ae00000) = -22 (Invalid argument)
2024-02-20T17:54:05.426380Z qemu-system-x86_64: VFIO_MAP_DMA failed: Invalid argument
2024-02-20T17:54:05.426401Z qemu-system-x86_64: vfio_dma_map(0x14f69d048800, 0x381000000000, 0x20000000, 0x14f67ae00000) = -22 (Invalid argument)

 

hal9000-diagnostics-20240220-0955.zip

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.