Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2802994pxk; Tue, 15 Sep 2020 02:47:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXiKlha8hlB+Eb4V2Y3U3QKLHX5MAd06LZBrBrN0F4Sy2sPmR/FuKv6nvUET0V3iA1kF7j X-Received: by 2002:aa7:c7da:: with SMTP id o26mr21869778eds.261.1600163234097; Tue, 15 Sep 2020 02:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600163234; cv=none; d=google.com; s=arc-20160816; b=oKSUswXn8/7iK83hjNAMBB53uYwKoBaKRamEMEYFci/DKj2XikuUwfz5MRwD5Gq0Yx ZnKnTC423nGcZoTTkGsR/p9TrrDpEU/Gt4V1wrAAchso6VlJ0ehIUwh8aBS/ibcPIHu4 cWH5hlcERrfPB6MTttCaoTjQe0BR0rb4oiWAJqMq/fPCXPO4937GpHOughcBzl6Mm5tb fwy1koz2CuzBQakvqF6Hh1i0AgnKEYD+KkTzLVhy7mfx5Dhz2fIclIoZv/5s12RrC6E7 erDKC90ekui6ofAWSXDI9/rrbyhQgqhnGQeAjLwq0FQUljRRP2ihLTfk9Eb1nqvjGWj6 pqmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=lbu0S0cU/fsoJ+GJyj5DcLjuEJa0U3NyiPwssHnVX5Q=; b=QScq322bw++tRmzOFuf/72ijM1P0o4pe0OrI2f2vOMeqoyuK96CO8FG76lL+LyoOn9 HKyJeEqjODLV6KVduo/dwN9gjeRoZ9KTEsOJ/ivbtPAREr2HyjIScx88ibv3//lGfKpY RW8GAQLbZii/mUX0g2ma6AaIYAsQBUXZP4RdzP67imiKJDUvn/cgIW3eqUe+EoJbUymH EIRoiDerhYjvHMZDvJ4t1EI6lvoeyPCvDL9vS/+xO1UNS+bEBU/wGcJgLvC2bHPPQJ/y rHpskU8BZhYvfvo87Yh/jdO3NTI6RNDX7RdaXBDzLoYRfUO/DQOqoUXkvDaPTiGnp9eU LmRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MjOfwcCo; 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 u10si8530613ejy.154.2020.09.15.02.46.51; Tue, 15 Sep 2020 02:47:14 -0700 (PDT) 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=MjOfwcCo; 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 S1726475AbgIOJoU (ORCPT + 99 others); Tue, 15 Sep 2020 05:44:20 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:36275 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726437AbgIOJoP (ORCPT ); Tue, 15 Sep 2020 05:44:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600163053; 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=lbu0S0cU/fsoJ+GJyj5DcLjuEJa0U3NyiPwssHnVX5Q=; b=MjOfwcCow00rUxLyBzocmXQDf+5S+tYyc80cbaJc2yiN6/oZWaf+5l7nYo6n00qEWsPC8D +Kc20QPUWj71Kpl75oJ2UM1Rq8GFieL7Wrft5m2wnAnAxI0gGTwBweAx9ceRvEwjwG8SWq u3sxavn7uxfPj5OhOYWtZWseptFws6M= 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-570-OpyvX78FNlm8c7F0Zm2C2Q-1; Tue, 15 Sep 2020 05:44:12 -0400 X-MC-Unique: OpyvX78FNlm8c7F0Zm2C2Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D996218B9ECB; Tue, 15 Sep 2020 09:44:10 +0000 (UTC) Received: from gondolin (ovpn-113-4.ams2.redhat.com [10.36.113.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C667E60BE5; Tue, 15 Sep 2020 09:44:03 +0000 (UTC) Date: Tue, 15 Sep 2020 11:44:01 +0200 From: Cornelia Huck To: Matthew Rosato Cc: alex.williamson@redhat.com, pmorel@linux.ibm.com, schnelle@linux.ibm.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vfio iommu: Add dma available capability Message-ID: <20200915114401.4db5e009.cohuck@redhat.com> In-Reply-To: <1600122331-12181-2-git-send-email-mjrosato@linux.ibm.com> References: <1600122331-12181-1-git-send-email-mjrosato@linux.ibm.com> <1600122331-12181-2-git-send-email-mjrosato@linux.ibm.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Sep 2020 18:25:31 -0400 Matthew Rosato wrote: > Commit 492855939bdb ("vfio/type1: Limit DMA mappings per container") > added the ability to limit the number of memory backed DMA mappings. > However on s390x, when lazy mapping is in use, we use a very large > number of concurrent mappings. Let's provide the current allowable > number of DMA mappings to userspace via the IOMMU info chain so that > userspace can take appropriate mitigation. > > Signed-off-by: Matthew Rosato > --- > drivers/vfio/vfio_iommu_type1.c | 17 +++++++++++++++++ > include/uapi/linux/vfio.h | 16 ++++++++++++++++ > 2 files changed, 33 insertions(+) (...) > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h > index 9204705..a8cc4a5 100644 > --- a/include/uapi/linux/vfio.h > +++ b/include/uapi/linux/vfio.h > @@ -1039,6 +1039,22 @@ struct vfio_iommu_type1_info_cap_migration { > __u64 max_dirty_bitmap_size; /* in bytes */ > }; > > +/* > + * The DMA available capability allows to report the current number of > + * simultaneously outstanding DMA mappings that are allowed. > + * > + * The structures below define version 1 of this capability. "The structure below defines..." ? > + * > + * max: specifies the maximum number of outstanding DMA mappings allowed. I think you forgot to tweak that one: "avail: specifies the current number of outstanding DMA mappings allowed." ? > + */ > +#define VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL 3 > + > +struct vfio_iommu_type1_info_dma_avail { > + struct vfio_info_cap_header header; > + __u32 avail; > +}; > + > + > #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) > > /**