Bug 1894101

Summary: IOMMU enable failed on "vhost-vsock-pci" device (kernel)
Product: Red Hat Enterprise Linux 8 Reporter: Stefano Garzarella <sgarzare>
Component: kernelAssignee: Stefano Garzarella <sgarzare>
kernel sub component: KVM QA Contact: Qinghua Cheng <qcheng>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: high CC: ailan, brdeoliv, coli, jinzhao, juzhang, ngu, qcheng, qzhang, sgarzare, smitterl, virt-maint, zhenyzha
Version: 8.4Keywords: RFE, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: kernel-4.18.0-307.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1879052 Environment:
Last Closed: 2021-11-09 18:59:28 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1879052    

Description Stefano Garzarella 2020-11-03 14:47:09 UTC
+++ This bug was initially created as a clone of Bug #1879052 +++

Description of problem:
When set 'iommu_platform=on' on "vhost-vsock-pci" device, the following error is encountered:
(qemu) qemu-kvm: vhost_set_features failed: Operation not supported (95)
qemu-kvm: Error starting vhost: 95


Version-Release number of selected component (if applicable):
Host name: ibm-x3850x6-04.lab.eng.pek2.redhat.com
Host Distro: RHEL-8.3.0-20200912.n.0 BaseOS x86_64 
Host Kernel: 4.18.0-236.el8.x86_64
Guest Kernel: 4.18.0-236.el8.x86_64
Qemu-kvm: qemu-kvm-5.1.0-6.module+el8.3.0+8041+42ff16b8


How reproducible:
100%

Steps to Reproduce:
1. boot guest enable IOMMU:
/usr/libexec/qemu-kvm \
-name 'avocado-vt-vm1'  \
-sandbox on  \
-machine q35 \
-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 \
-m 30720  \
-smp 40,maxcpus=40,cores=20,threads=1,dies=1,sockets=2  \
-cpu 'IvyBridge',+kvm_pv_unhalt \
-chardev socket,server,nowait,id=qmp_id_qmpmonitor1,path=/var/tmp/monitor-qmpmonitor1  \
-mon chardev=qmp_id_qmpmonitor1,mode=control \
-device pvpanic,ioport=0x505,id=idnEJdcf \
-chardev socket,server,nowait,id=chardev_serial0,path=/var/tmp/serial-serial0 \
-device isa-serial,id=serial0,chardev=chardev_serial0  \
-chardev socket,id=seabioslog_id_20200915-055422-8y4xDLCa,path=/var/tmp/seabios,server,nowait \
-device isa-debugcon,chardev=seabioslog_id_20200915-055422-8y4xDLCa,iobase=0x402 \
-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,aio=threads,filename=/home/test/os.qcow2,cache.direct=on,cache.no-flush=off \
-blockdev node-name=drive_image1,driver=qcow2,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,mac=9a:af:90:80:2a:4f,id=idxXK3e9,netdev=idbkX3jT,bus=pcie-root-port-3,addr=0x0  \
-netdev tap,id=idbkX3jT,vhost=on \
-device pcie-root-port,id=pcie-root-port-4,port=0x4,addr=0x1.0x4,bus=pcie.0,chassis=5 \
-device vhost-vsock-pci,id=vhost_vsock0,guest-cid=3,bus=pcie-root-port-4,addr=0x0,iommu_platform=on  \
-vnc :20  \
-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=6

2. Hit this issue:
qemu-kvm: vhost_set_features failed: Operation not supported (95)
qemu-kvm: Error starting vhost: 95

3. Login guest:
[root@vm-74-49 home]# lsmod|grep vsock 
vmw_vsock_virtio_transport    16384  0
vmw_vsock_virtio_transport_common    32768  1 vmw_vsock_virtio_transport
vsock                  45056  2 vmw_vsock_virtio_transport_common,vmw_vsock_virtio_transport

[root@vm-74-49 home]# gcc -o nc-vsock nc-vsock.c
gcc: error: nc-vsock.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.


Actual results:
IOMMU enable failed on "vhost-vsock-pci" device

Expected results:
IOMMU can be enabled on the "vhost-vsock-pci" device

Additional info:

--- Additional comment from Amnon Ilan on 2020-09-25 12:31:13 UTC ---

Jon, should it be triaged by someone working on vsock?

--- Additional comment from John Ferlan on 2020-09-25 13:55:52 UTC ---

Stefano - is there any relationship to bug 1868449 here? or is this something new?

--- Additional comment from Stefano Garzarella on 2020-09-28 08:21:38 UTC ---

(In reply to John Ferlan from comment #2)
> Stefano - is there any relationship to bug 1868449 here? or is this
> something new?

No, I think it is not related. It seems that vhost-vsock doesn't support iommu-platform=on since the very beginning:
https://patchew.org/QEMU/20200226094357.25061-1-jasowang@redhat.com

I'll take a closer look!

--- Additional comment from RHEL Program Management on 2020-10-29 18:34:46 UTC ---

pm_ack is no longer used for this product. The flag has been reset.

See https://issues.redhat.com/browse/PTT-1821 for additional details or contact lmiksik if you have any questions.

--- Additional comment from Stefano Garzarella on 2020-11-03 14:44:35 UTC ---

QEMU should work as is, but I found a little issue that I fixed upstream:
https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg09077.html

The patch was already merged: 384c2561bd ("vhost-vsock: set vhostfd to non-blocking mode")

The issue is mainly related to the vhost-vsock kernel module that doesn't have IOTLB API support, so I'll create a new BZ for kernel.

Comment 1 Stefano Garzarella 2020-11-03 14:54:27 UTC
I sent a tentative patch upstream, but I'm still testing to see if everything works.

https://lore.kernel.org/kvm/20201029174351.134173-1-sgarzare@redhat.com/#t

Comment 2 Ademar Reis 2021-01-15 16:36:56 UTC
The patch merged upstream: e13a6915a03ffc3ce332d28c141a335e25187fa3 (vhost/vsock: add IOTLB API support)

Backport should not be difficult, but given it's a new feature, leaving it to the next release.

Comment 14 errata-xmlrpc 2021-11-09 18:59:28 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: kernel 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-2021:4356