Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp763002pxb; Tue, 3 Nov 2020 11:48:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqbpxRbWHSf8iW059YTCBnQjnnaqs6bmr1yVZ43DZ43FI4O7EYEQdT3OiHJQudXjqY92Ix X-Received: by 2002:a17:906:3541:: with SMTP id s1mr22266138eja.413.1604432894116; Tue, 03 Nov 2020 11:48:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604432894; cv=none; d=google.com; s=arc-20160816; b=UBJ9ue0r/vmb5wcnew/H2lckdMFV2QQZ8ZQgeWLp+5tAvJgSpQ7j71yJxBp9YR2iaU R3/uVz29qoXdQcmyZG0Hj4PnhBPAgUJE/HIjaGrkGkGG7bXyqYtb5U3//Ou7BCIbURkm 8t+a2HuIPh90BjcNAPssJ4KWECknqV3/HrOpZNDwDTb0T2QejXzXrv87VRIIVzAPeJxQ QI1SGutnV4JSDUlMYAluZJdBJF8MWkGQKwc/gVxN38eBbeD0xCM1ihID8CyZW+xstc7V k5HfIjK3YAITm8z0As5+UTcg+UM86Y+aoJ22k2wH1+0/m/z2y8SJ5A6pEvMfmK1Wc9Zr 6Iqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hXGHvDYwh9NMkyXNB/mXiydEr8BiB4sd5uCcFnHHQZg=; b=E5M0SobnPF8cxYLUq8Tw45Wi1jRK/gUAHLbhZNchd6qXVZlkhO6dUT+j6PnRHvAIkk DhHqDIrpk3YB7lEIsa9/hky/7yeB+7SzQ9AZlv/YH+0TxNprDtDetr40JozYHPhIPGIF SRR0DPaSvuOgDUeMAPFVyoytYfUWXnGGdo3gIlQ38W5St3lc74Yt8FaRva4dRwp/fPVL uIJH5MTlJrNGy+C509GedWC2xK9nsRuJ4iJknRZBGfjqQEvPkdAiEs6zkWWiSHdxoE45 va+kv2wUguImvT7Z1JXHOgyW+0csEfcyvhtbFVEiN0mSEeR+2tgVBHedfOO3quxUybm5 ytEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=chwpTUtq; 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 q23si7004213ejs.570.2020.11.03.11.47.50; Tue, 03 Nov 2020 11:48:14 -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=chwpTUtq; 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 S1726232AbgKCTqV (ORCPT + 99 others); Tue, 3 Nov 2020 14:46:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28583 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726660AbgKCTqU (ORCPT ); Tue, 3 Nov 2020 14:46:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604432778; 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=hXGHvDYwh9NMkyXNB/mXiydEr8BiB4sd5uCcFnHHQZg=; b=chwpTUtqHwO02E0vi3/Q7iXNI88a/J1qSQNV/ZpXJ8DOipuh0xSFZjIo4qlN9FlCW1PLof P9mmx6hwaluMP2xkOYijiBlxSyka+bF+ZDW60DaeVcnBWPyeOCMlbg1ZjdPcII361h0IW2 EyJRna6Q14KM5jGfCYZJuhUGVamgCQ8= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-5g9qYqxiPCivhHTXlBBjuQ-1; Tue, 03 Nov 2020 14:46:16 -0500 X-MC-Unique: 5g9qYqxiPCivhHTXlBBjuQ-1 Received: by mail-qk1-f200.google.com with SMTP id u16so11476856qkm.22 for ; Tue, 03 Nov 2020 11:46:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=hXGHvDYwh9NMkyXNB/mXiydEr8BiB4sd5uCcFnHHQZg=; b=n2VHDJnk7g497flgUQ2UzygpC9pFTCzBcBEyKADhflSH/epHmtf2Y5F5WP5wgHWfI7 CZZzGLyZz8ef6PDAS7ELAPm6TOlAtk9y0XNUWXKFxn6ZxHjGNKcAJ1rgnrYSStTPB3c5 Epg4xxwD4+n24/AXM/5SmA2pyxRbLRZCl5FTEdJb6yfwdQ2SyB20UJKIf0TpwbDn8yu9 tew0L3IOmSixPaUx7VLRQe5q8G6j96bFRunX3eMk5PBqcy4MuLnpJIzGOWIcVso1pXc3 pMWK5pBzD/0omSfdzPA2OLGVhpSVSE2xfALTn4Gz3b5oHJfRzSUzF/osNxf/p+Xhg9PR 3fZA== X-Gm-Message-State: AOAM530DJCoCow5P+ZermX6N5mEcxwsXvpbpzMTZc0ZnVjWsTwMHTfs+ 8ONgvNEt6EQfB+tzksiRlEjl04r6lNiP3BbYB0WhAK5Szeo7vLkT1OyoBGMO+jYaEs3ygi+RjVx J8GXWJyRG4IDy9woFV2AmLTEW X-Received: by 2002:ae9:f402:: with SMTP id y2mr20621906qkl.459.1604432776434; Tue, 03 Nov 2020 11:46:16 -0800 (PST) X-Received: by 2002:ae9:f402:: with SMTP id y2mr20621874qkl.459.1604432776110; Tue, 03 Nov 2020 11:46:16 -0800 (PST) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-20-174-93-89-196.dsl.bell.ca. [174.93.89.196]) by smtp.gmail.com with ESMTPSA id i70sm11572985qke.11.2020.11.03.11.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 11:46:15 -0800 (PST) Date: Tue, 3 Nov 2020 14:46:13 -0500 From: Peter Xu To: Jason Wang Cc: Stefano Garzarella , mst@redhat.com, netdev@vger.kernel.org, Stefan Hajnoczi , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vhost/vsock: add IOTLB API support Message-ID: <20201103194613.GK20600@xz-x1> 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> <8648a2e3-1052-3b5b-11ce-87628ac8dd33@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8648a2e3-1052-3b5b-11ce-87628ac8dd33@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 03, 2020 at 05:04:23PM +0800, Jason Wang wrote: > > 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. Yeah. By default the QEMU vIOMMU should only support 39bits width for guest iova address space. To extend it, we can use: -device intel-iommu,aw-bits=48 So we'll enable 4-level iommu pgtable. Here the iova is obvious longer than this, so it'll be interesting to know why that iova is allocated in the guest driver since the driver should know somehow that this iova is beyond what's supported (guest iommu driver should be able to probe viommu capability on this width information too). -- Peter Xu