Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp357005pxb; Tue, 3 Nov 2020 01:09:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFH59ZzLeb6IRXBzxrB6kYvGhoKyGJg2gBt6EHm977VL6JSW9MOXyW6yJ6UJmaaplfr0Rk X-Received: by 2002:a17:906:a186:: with SMTP id s6mr7543334ejy.193.1604394565505; Tue, 03 Nov 2020 01:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604394565; cv=none; d=google.com; s=arc-20160816; b=R8sdxeZNgSrQSPepZQwdOHdv5K1GiyWUUfK4nIB2qjOBKQwX+NBIs9JVRQph5nn97J 7HnD+k+w5RDgdlqms5ARxX0wzs/IEUhyi0lr3+1NbuIpczjARKDN0hgG2FxIu4SfgmoN dnCUFRVHem85QH5ELiL5pDw1zBdLJUyw55TknWvyfK5JFFxaN+eelsZpQuwr/FfB7mK2 fM2lS/MrnJnmPNxBaRmPo5ghNeR8Py7X7XyRktKR21GbX1l36TJ7hoSaLdbw1WGxSs5L tuQ+3U7lLivI5YTmvfrSVGJhLkfph2vUFVBXxudHnYqxdvZkBhQaGpkKLk9Y89HY9v2w N8Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=NCLuRFwSBz7lCHK9Xxh7qpGQtAw7uNBdQ5Y4F/GcLRE=; b=yACR2f9gZgT8YJHl7KAJoWjk0n/69ZBAMv/KO4TzxxIqH7sKRbv3UOWFKPCxcMAGA+ HM9cVGIJzWZFXvD8INGz9Uu4eWXsNxTXCC6NFIzy5/zi+U+YVP9pXu6VA7gYGpuOwMtY Yp89po2uwbktvumdL2eLwZvtVvmWdwD7Wp/I43M7KvVY1U9m1daaiNAEtxSwg3DE4eDJ DTucpA/SA93yJijnFAGmdSw/ohgYV8uJokQ9mcQZSbNIl6Xt4gn1ndgoM/DRC8iCsoQC nSzq+mdsTnFPCrpJQ/Y88H2cJymIhFX/B5sZXSpM0gzErDRI2X7Tk4sV/QU5dVG1H8BC MLsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d8PdvZrw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu23si11727990ejb.83.2020.11.03.01.09.03; Tue, 03 Nov 2020 01:09:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d8PdvZrw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726013AbgKCJFQ (ORCPT + 99 others); Tue, 3 Nov 2020 04:05:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25534 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbgKCJFO (ORCPT ); Tue, 3 Nov 2020 04:05:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604394312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NCLuRFwSBz7lCHK9Xxh7qpGQtAw7uNBdQ5Y4F/GcLRE=; b=d8PdvZrwMnI4pZm4SxbUhTosGou6pqV+AmCUYDPNtSFuGGMvaoroa34w5Lx4pkF5Zl5Aq4 K7bv1w3YBkViM+x9OU4fubHwRdiiwY8MXTAPhpJoM+hDhmXcnlk0NRFbHROivCGyQKQ2nm X0Gu4jb5ozi8o6dZE6uffpfha1lwtwc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-547-QnBW_FxePh-2eshNLH4Rrw-1; Tue, 03 Nov 2020 04:05:09 -0500 X-MC-Unique: QnBW_FxePh-2eshNLH4Rrw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23D0C106B816; Tue, 3 Nov 2020 09:05:08 +0000 (UTC) Received: from [10.72.13.208] (ovpn-13-208.pek2.redhat.com [10.72.13.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F47D21E97; Tue, 3 Nov 2020 09:04:32 +0000 (UTC) Subject: Re: [PATCH] vhost/vsock: add IOTLB API support To: Stefano Garzarella Cc: mst@redhat.com, netdev@vger.kernel.org, Stefan Hajnoczi , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Peter Xu References: <20201029174351.134173-1-sgarzare@redhat.com> <751cc074-ae68-72c8-71de-a42458058761@redhat.com> <20201030105422.ju2aj2bmwsckdufh@steredhat> <278f4732-e561-2b4f-03ee-b26455760b01@redhat.com> <20201102171104.eiovmkj23fle5ioj@steredhat> From: Jason Wang Message-ID: <8648a2e3-1052-3b5b-11ce-87628ac8dd33@redhat.com> Date: Tue, 3 Nov 2020 17:04:23 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201102171104.eiovmkj23fle5ioj@steredhat> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/11/3 上午1:11, Stefano Garzarella wrote: > On Fri, Oct 30, 2020 at 07:44:43PM +0800, Jason Wang wrote: >> >> On 2020/10/30 下午6:54, Stefano Garzarella wrote: >>> On Fri, Oct 30, 2020 at 06:02:18PM +0800, Jason Wang wrote: >>>> >>>> On 2020/10/30 上午1:43, Stefano Garzarella wrote: >>>>> This patch enables the IOTLB API support for vhost-vsock devices, >>>>> allowing the userspace to emulate an IOMMU for the guest. >>>>> >>>>> These changes were made following vhost-net, in details this patch: >>>>> - exposes VIRTIO_F_ACCESS_PLATFORM feature and inits the iotlb >>>>>   device if the feature is acked >>>>> - implements VHOST_GET_BACKEND_FEATURES and >>>>>   VHOST_SET_BACKEND_FEATURES ioctls >>>>> - calls vq_meta_prefetch() before vq processing to prefetch vq >>>>>   metadata address in IOTLB >>>>> - provides .read_iter, .write_iter, and .poll callbacks for the >>>>>   chardev; they are used by the userspace to exchange IOTLB messages >>>>> >>>>> This patch was tested with QEMU and a patch applied [1] to fix a >>>>> simple issue: >>>>>     $ qemu -M q35,accel=kvm,kernel-irqchip=split \ >>>>>            -drive file=fedora.qcow2,format=qcow2,if=virtio \ >>>>>            -device intel-iommu,intremap=on \ >>>>>            -device vhost-vsock-pci,guest-cid=3,iommu_platform=on >>>> >>>> >>>> Patch looks good, but a question: >>>> >>>> It looks to me you don't enable ATS which means vhost won't get any >>>> invalidation request or did I miss anything? >>>> >>> >>> You're right, I didn't see invalidation requests, only miss and >>> updates. >>> Now I have tried to enable 'ats' and 'device-iotlb' but I still >>> don't see any invalidation. >>> >>> How can I test it? (Sorry but I don't have much experience yet with >>> vIOMMU) >> >> >> I guess it's because the batched unmap. Maybe you can try to use >> "intel_iommu=strict" in guest kernel command line to see if it works. >> >> Btw, make sure the qemu contains the patch [1]. Otherwise ATS won't >> be enabled for recent Linux Kernel in the guest. > > The problem was my kernel, it was built with a tiny configuration. > Using fedora stock kernel I can see the 'invalidate' requests, but I > also had the following issues. > > Do they make you ring any bells? > > $ ./qemu -m 4G -smp 4 -M q35,accel=kvm,kernel-irqchip=split \ >     -drive file=fedora.qcow2,format=qcow2,if=virtio \ >     -device intel-iommu,intremap=on,device-iotlb=on \ >     -device vhost-vsock-pci,guest-cid=6,iommu_platform=on,ats=on,id=v1 > >     qemu-system-x86_64: vtd_iova_to_slpte: detected IOVA overflow     > (iova=0x1d40000030c0) It's a hint that IOVA exceeds the AW. It might be worth to check whether the missed IOVA reported from IOTLB is legal. Thanks > qemu-system-x86_64: vtd_iommu_translate: detected translation failure > (dev=00:03:00, iova=0x1d40000030c0) >     qemu-system-x86_64: New fault is not recorded due to compression > of     faults > > Guest kernel messages: >     [   44.940872] DMAR: DRHD: handling fault status reg 2 >     [   44.941989] DMAR: [DMA Read] Request device [00:03.0] PASID     > ffffffff fault addr ffff88W >     [   49.785884] DMAR: DRHD: handling fault status reg 2 >     [   49.788874] DMAR: [DMA Read] Request device [00:03.0] PASID     > ffffffff fault addr ffff88W > > > QEMU: b149dea55c Merge remote-tracking branch > 'remotes/cschoenebeck/tags/pull-9p-20201102' into staging > > Linux guest: 5.8.16-200.fc32.x86_64 > > > Thanks, > Stefano >