Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3287270pxy; Mon, 3 May 2021 21:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxifrlSiZWVIYGJxXwLk04yvCMiaMn/x9Z/GYjYf0JfWsDMGx24y/Zcoa1RWGh/Zd5QKNJD X-Received: by 2002:aa7:d74c:: with SMTP id a12mr11024702eds.257.1620102122870; Mon, 03 May 2021 21:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620102122; cv=none; d=google.com; s=arc-20160816; b=KNNXY6W6jfu3O+QTxSLrDZFU1CUBYGrV3pk4WEjzb9/xy9EsRoW094WdiCnIjb9iJA dDT5291B0jlec+bOm+yNI8Nt6D8EyiyVXfCeCAw/9c3Uo5EOGOz7Q8VmHvlButUzcN8s MmfkhC/b49Z2NJOtoH2o5k61jZPiTQnOPxktz3T9oJDfUnAe/rBZyryvUzyStp8lTIar dDFXurOB0hXEwmvHX6unyC34NYiKoV6Ndx+l6zLD98gP1Z2Aub1MNvyyo/ZKh0nSJyYJ xGGVn2dzZbxUhd3fzkwIqmlea3jyhEm2XaejE6Ru7uj+aWa4JmIAXkwSExpiHn/VPxTH eGew== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aWftvp7n/4qO+u15RfyglDUEGLlCeVt8TPgGzVw6fiI=; b=wDD/E2ICyGG2nbPM9qiURBkLMN1B8rLokWD4tf0pEPb5eNwSyr/w9VvfS/nxGm3iL6 g0bTntrnGFWbbkalnmfLWBUnDAfZ8NXvtqrEZvXFT7ux2pAQDUgtNjE1L9x2w/sMOcGb LOeJdpjUI4sI0BCVldskvmpBvmlhQoHIXnYibff/awtUwHtbYKBqdIh3BmoFBTTC/lll YZqMG0sQlb1ObBO/gukRY1tmjVpyRwaTjR09K/VFmBnFOvIJtRir6/vocWxyhQDx9YWf zoFXaOjTqp6Pacw009kg+si0D7JqX0qmaRC7bR2Uh8Cti2av/jNgrxQojyBzek3Yq6NY isEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=FFVVpB9W; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka4si1629586ejc.440.2021.05.03.21.21.39; Mon, 03 May 2021 21:22:02 -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=@gibson.dropbear.id.au header.s=201602 header.b=FFVVpB9W; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbhEDETQ (ORCPT + 99 others); Tue, 4 May 2021 00:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbhEDETP (ORCPT ); Tue, 4 May 2021 00:19:15 -0400 Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86DD6C061574; Mon, 3 May 2021 21:18:21 -0700 (PDT) Received: by ozlabs.org (Postfix, from userid 1007) id 4FZ65j4PK5z9sSs; Tue, 4 May 2021 14:18:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1620101897; bh=GF4kY9gVsGuwV9dXBjYISsLPpgjK/7dHag6l9MAWxKg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FFVVpB9WNCZN/OHDK7EFnFAqgxNmT0o6j8dz6VB4dGaDgHpoypxvLCGbts5YHK+rc /0GWhCoUlX/gdFz9pMVsCPN56Kbv7o9hKTFl972XyyuWKzbIa3TPAw6YsykdDcjnop Pv6BeZTFIqQGE9whKr7bxNbIOfV+YYaDGYHwm4S8= Date: Tue, 4 May 2021 13:54:55 +1000 From: David Gibson To: Jason Gunthorpe Cc: Alex Williamson , "Liu, Yi L" , Jacob Pan , Auger Eric , Jean-Philippe Brucker , "Tian, Kevin" , LKML , Joerg Roedel , Lu Baolu , David Woodhouse , "iommu@lists.linux-foundation.org" , "cgroups@vger.kernel.org" , Tejun Heo , Li Zefan , Johannes Weiner , Jean-Philippe Brucker , Jonathan Corbet , "Raj, Ashok" , "Wu, Hao" , "Jiang, Dave" , Alexey Kardashevskiy Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: References: <20210421175203.GN1370958@nvidia.com> <20210421133312.15307c44@redhat.com> <20210421230301.GP1370958@nvidia.com> <20210422111337.6ac3624d@redhat.com> <20210427172432.GE1370958@nvidia.com> <20210429002149.GZ1370958@nvidia.com> <20210503160530.GL1370958@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XJz7RUBFhCVAE36r" Content-Disposition: inline In-Reply-To: <20210503160530.GL1370958@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --XJz7RUBFhCVAE36r Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 03, 2021 at 01:05:30PM -0300, Jason Gunthorpe wrote: > On Thu, Apr 29, 2021 at 01:20:22PM +1000, David Gibson wrote: > > > There is a certain appeal to having some > > > 'PPC_TCE_CREATE_SPECIAL_IOASID' entry point that has a wack of extra > > > information like windows that can be optionally called by the viommu > > > driver and it remains well defined and described. > >=20 > > Windows really aren't ppc specific. They're absolutely there on x86 > > and everything else as well - it's just that people are used to having > > a window at 0.. that you can often get away with > > treating it sloppily. >=20 > My point is this detailed control seems to go on to more than just > windows. As you say the vIOMMU is emulating specific HW that needs to > have kernel interfaces to match it exactly. It's really not that bad. The case of emulating the PAPR vIOMMU on something else is relatively easy, because all updates to the IO page tables go through hypercalls. So, as long as the backend IOMMU can map all the IOVAs that the guest IOMMU can, then qemu's implementation of those hypercalls just needs to put an equivalent mapping in the backend, which it can do with a generic VFIO_DMA_MAP. vIOMMUs with page tables in guest memory are harder, but only really in the usual ways that a vIOMMU of that type is harder (needs cache mode or whatever). At whatever point you need to shadow from the guest IO page tables to the host backend, you can again do that with generic maps, as long as the backend supports the necessary IOVAs, and has an IO page size that's equal to or a submultiple of the vIOMMU page size. > I'm remarking that trying to unify every HW IOMMU implementation that > ever has/will exist into a generic API complete enough to allow the > vIOMMU to be created is likely to result in an API too complicated to > understand.. Maybe not every one, but I think we can get a pretty wide range with a reasonable interface. Explicitly handling IOVA windows does most of it. And we kind of need to handle that anyway to expose what ranges the IOMMU is capable of translating anyway. I think making handling valid IOVA windows explicit makes things simpler than having per-backend-family interfaces to expose the limits of their translation ranges, which is what's likely to happen without it. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --XJz7RUBFhCVAE36r Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmCQxY0ACgkQbDjKyiDZ s5Ja1Q//brgY0BJodmvSW7+qUlkQBKlmerMDnujEgNgBr6cbpA9hN6ywQDlkXit7 xrznyLqBx16060E9F6DQqk1aaAj2+iePxmT97vs7MUHmvuXHgTlmU6T6DDC84ICk cCIfpXsB5R+pDv0JD/j91cPQBZF1Afnf0KhRLpzjcNKgBoFWi23pAYx3E32nPVtb 1UeflnMCMdr/rHfQR9/GoJ5FP/QYvqppU7351C0yFKbI5k0Pg7RvO41pejcNKE2W q4wmfrzPA9/7G+JtQr03lGXLVy4+xN0UPsRtxkhQtaX+YNKBVL3qb+oO4XeCf7zw Zw5vw6Ai8reTK948BEe+S+WJZHHAYBw54ztv7P35XFjR3/avEEPWgSIrba6fAeRZ 0E+RWhYL4c09hGpbJk6FiwTan+2a7EgB90ZuanWFtJ8HCFOFSDI3IRoLVU7k7JLC IQD7LGmsqWzhMf3FtAK++FiVeWu+NpMPGGBx3XXfSl7kWXzf9CUJRFHLv+wPK0vc Fln92Fj3HBM3D7keiZ85teYT6G5SacTcmtJTHTfsqqmVlTdVCconk7/y0wQhMDt5 TAfzd8YH0dq6toDJqOZzqZKwGmgaYe9HviiRWa5+C6Y3QJ0dBBN6cUKKZhTKeicd ifZUPO7PC9KjomC7UWcx6g/pN7eNPSZR2YR+Lb0hATzgCVDkcUg= =OhAa -----END PGP SIGNATURE----- --XJz7RUBFhCVAE36r--