Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3269547pxk; Mon, 28 Sep 2020 12:52:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlcsGiW0NVxXfB8tB5SZWSjfO4j0PiuNeHNJO2ON3KLEEf8MaWbGx3Ho/v9iYCHSi04NHd X-Received: by 2002:a17:906:4941:: with SMTP id f1mr366992ejt.417.1601322755518; Mon, 28 Sep 2020 12:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601322755; cv=none; d=google.com; s=arc-20160816; b=QYjDjz+DkNDIwZk5SzODnq3/Jdxu2TMFqTWDODgFEtXbw4/mZtBSvhOoA8q6TrlRG4 DGmnWJEBB5ZLkBtnKB6giC0WCxXXqJoBTxbC1geX/v4ohNLpbpFErRSYLTUNF+doKag0 1ZT6ws6w0oMa0y0OG8LhDGnqecKPk8YDir/kaQYqjq0WEuKlb/QkjKnaQZUcXU5wELlt nAMtHRYQ2qKOj2oeMu27R4gZGmq/s6O3KclzNggkMEJor5DvoiwmkVQidH9IK/AIGOZf P8UHqzz6WukyoIfdpZ/o6qNlD2Dv4nVrzd5sl0DRs0TEqjeWbOJtQr6RXS9Sb+iMdQ2x mTfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=iNKAwz7MdlqRrpBvwDfW+Xi4s3UXuDJ7jQBLRXyHSRk=; b=G9WBasaJ1XG1MbTNNNWKxqqf9LvcVUUPGFoygYO9hsrKAzkdk+Y+1CgcoacjIJ3KUn 39lA0GlSLsEcibltJ7M38ezjtX/H3EtSwVJXjcMPf67hcVb9HwDWYXHwchB1TF9nNFRi /pHwWMG4xjGX7Ba5FJbQugflBiWQFmbLdZXM0r4rIq042l2S+mtCAhzK40EIw0MeJoB5 grGgId1/sJY+cg0M9qSRhCxL0k+63JJsoiKzCxyGCEsyIKqAGCLEQNXNAbQwiY2+zh+g IMaMf1XvNMkS52PCaMR+IGGo2IlCSDNChuaHJ49A54II7j9ZUpEwVZkeKIgkbJPKSSS2 4IAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dzqruOhw; 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 j17si1266962ejs.0.2020.09.28.12.52.13; Mon, 28 Sep 2020 12:52:35 -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=dzqruOhw; 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 S1726773AbgI1TvF (ORCPT + 99 others); Mon, 28 Sep 2020 15:51:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36445 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726228AbgI1TvF (ORCPT ); Mon, 28 Sep 2020 15:51:05 -0400 Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601322664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=iNKAwz7MdlqRrpBvwDfW+Xi4s3UXuDJ7jQBLRXyHSRk=; b=dzqruOhwFjP9xbjIq53ssHZsNiccSgOSUYvUjNv5RgQ8DVS8+85jqNuMxfNgDBNoyJUmrM XSJWCnIMzc5K3VewVQWKWBpAfFrABFKZiRrAUMCjpIstGlRTXKgB02CvMLzu2gFvpfltH7 7ugBsvipmAWG6/nW3l280UVcAS1Kiz4= 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-182-bmWu5N4PNQq4bQk8g_S4mw-1; Mon, 28 Sep 2020 15:50:58 -0400 X-MC-Unique: bmWu5N4PNQq4bQk8g_S4mw-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 C86A7420EA; Mon, 28 Sep 2020 19:50:55 +0000 (UTC) Received: from laptop.redhat.com (ovpn-113-210.ams2.redhat.com [10.36.113.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F07E614F5; Mon, 28 Sep 2020 19:50:46 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, joro@8bytes.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, will.deacon@arm.com, robin.murphy@arm.com, dwmw2@infradead.org, alex.williamson@redhat.com Cc: baolu.lu@linux.intel.com, shameerali.kolothum.thodi@huawei.com, jean-philippe.brucker@arm.com Subject: [RFC 0/3] iommu: Reserved regions for IOVAs beyond dma_mask and iommu aperture Date: Mon, 28 Sep 2020 21:50:34 +0200 Message-Id: <20200928195037.22654-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org VFIO currently exposes the usable IOVA regions through the VFIO_IOMMU_GET_INFO ioctl / VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE capability. However it fails to take into account the dma_mask of the devices within the container. The top limit currently is defined by the iommu aperture. So, for instance, if the IOMMU supports up to 48bits, it may give the impression the max IOVA is 48b while a device may have a dma_mask of 42b. So this API cannot really be used to compute the max usable IOVA. This patch removes the IOVA region beyond the dma_mask's. As we start to expose this reserved region in the sysfs file /sys/kernel/iommu_groups//reserved_regions, we also need to handle the IOVA range beyond the IOMMU aperture to handle the case where the dma_mask would have a higher number of bits than the iommu max input address. This is a change to the ABI as this reserved region was not yet exposed in sysfs /sys/kernel/iommu_groups//reserved_regions or through the VFIO ioctl. At VFIO level we increment the version of the VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE capability to advertise that change. Best Regards Eric This series can be found at: https://github.com/eauger/qemu/tree/dma_mask_rfc Eric Auger (3): iommu: Fix merging in iommu_insert_resv_region iommu: Account for dma_mask and iommu aperture in IOVA reserved regions vfio/type1: Increase the version of VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE .../ABI/testing/sysfs-kernel-iommu_groups | 7 ++++ drivers/iommu/iommu.c | 41 ++++++++++++++++++- drivers/vfio/vfio_iommu_type1.c | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) -- 2.21.3