Bug 1044815

Summary: vfio initfn succeeds even if IOMMU mappings fail
Product: Red Hat Enterprise Linux 7 Reporter: Alex Williamson <alex.williamson>
Component: qemu-kvmAssignee: Alex Williamson <alex.williamson>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, chao.zhou, chayang, juzhang, knoel, laine, michen, Robert.Hu, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-45.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 11:24:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 616415    

Description Alex Williamson 2013-12-19 04:10:34 UTC
Description of problem:
If we assign a device with VFIO and the IOMMU mappings fail, the initfn still succeeds making it look like the device was fully attached.  When this happens the device is only able to DMA to whatever fraction of memory managed to get mapped, so it's still fully isolated, but it likely doesn't work.  A better experience would be to fail the initfn.  This can be seen if the locked memory limit for the process is set too low, allowing only a portion of memory to be pinned.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Miroslav Rezanina 2014-02-05 08:53:51 UTC
Fix included in qemu-kvm-1.5.3-45.el7

Comment 4 Chao Yang 2014-02-10 09:02:32 UTC
Reproduced on qemu-kvm-1.5.3-36.el7.x86_64. 

Steps:
1. start a guest with unprivileged user:
$  /usr/libexec/qemu-kvm -M pc -enable-kvm -drive file=/home/win7-32-virtio.qcow2,if=none,id=drive-virtio-disk0,format=qcow2 -device virtio-blk-pci,scsi=off,bus=pci.0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -net none -monitor stdio -spice port=9000,disable-ticketing -vga qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=67108864 -boot menu=on -m 256M -smp 2 -device vfio-pci,host=0000:28:01.0,id=vf



Actual Result:

Guest started successfully even through there were logs as bellow:

QEMU 1.5.3 monitor - type 'help' for more information
(qemu) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6e35f7cb50, 0x0, 0xa0000, 0x7f6e08000000) = -12 (Cannot allocate memory)
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x20000, 0x7f6e07c00000) = -12 (Cannot allocate memory)
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6e35f7cb50, 0x100000, 0xff00000, 0x7f6e08100000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc8000, 0x18000, 0x7f6e07c08000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xd0000, 0x10000, 0x7f6e07c10000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x18000, 0x7f6e080c0000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x20000, 0x7f6e080c0000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x28000, 0x7f6e080c0000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xe8000, 0x18000, 0x7f6e07e08000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0x30000, 0x7f6e080c0000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xf0000, 0x10000, 0x7f6e07e10000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xc0000, 0xff40000, 0x7f6e080c0000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xf4000000, 0x4000000, 0x7f6e03a00000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xf8000000, 0x4000000, 0x7f6dfe800000) = -12 (Cannot allocate memory)
qemu-kvm: vfio_dma_map(0x7f6e35f7cb50, 0xfc000000, 0x10000, 0x7f6dfde00000) = -12 (Cannot allocate memory)




Verified on qemu-img-1.5.3-45.el7.x86_64. Guest rejected to start on error:

QEMU 1.5.3 monitor - type 'help' for more information
(qemu) qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6eec1f4700, 0x0, 0xa0000, 0x7f6eb8000000) = -12 (Cannot allocate memory)
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6eec1f4700, 0xc0000, 0x20000, 0x7f6ed6c00000) = -12 (Cannot allocate memory)
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio_dma_map(0x7f6eec1f4700, 0x100000, 0xff00000, 0x7f6eb8100000) = -12 (Cannot allocate memory)
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio: memory listener initialization failed for container

qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio: failed to setup container for group 22
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: vfio: failed to get group 22
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: Device initialization failed.
qemu-kvm: -device vfio-pci,host=0000:28:01.0,id=vf: Device 'vfio-pci' could not be initialized




As per above, this issue has been fixed.

Comment 6 Ludek Smid 2014-06-13 11:24:08 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.