Received: from eggs.gnu.org ([2001:4830:134:3::10]:41776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTpRB-0004DC-5F for qemu-devel@nongnu.org; Sun, 31 Jul 2016 08:01:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTpR8-0008Ra-0J for qemu-devel@nongnu.org; Sun, 31 Jul 2016 08:01:45 -0400 Received: from mout.web.de ([212.227.17.12]:58625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTpR7-0008RS-MF for qemu-devel@nongnu.org; Sun, 31 Jul 2016 08:01:41 -0400 References: <1469123413-20809-1-git-send-email-mst@redhat.com> <1469123413-20809-27-git-send-email-mst@redhat.com> <53c0af03-7841-91c2-2eac-55a42b4971db@web.de> <20160731035903.GA6207@pxdev.xzpeter.org> From: Jan Kiszka Message-ID: <49d9598a-9d37-5d57-9b75-753544a6cdaf@web.de> Date: Sun, 31 Jul 2016 14:01:26 +0200 MIME-Version: 1.0 In-Reply-To: <20160731035903.GA6207@pxdev.xzpeter.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pAp0wtUQjSqRDS3o5L12vTegXDw5eeOAl" Subject: Re: [Qemu-devel] [PULL v5 26/57] x86-iommu: introduce IEC notifiers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, Peter Maydell , Richard Henderson , Eduardo Habkost , Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pAp0wtUQjSqRDS3o5L12vTegXDw5eeOAl From: Jan Kiszka To: Peter Xu Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, Peter Maydell , Richard Henderson , Eduardo Habkost , Paolo Bonzini Message-ID: <49d9598a-9d37-5d57-9b75-753544a6cdaf@web.de> Subject: Re: [PULL v5 26/57] x86-iommu: introduce IEC notifiers References: <1469123413-20809-1-git-send-email-mst@redhat.com> <1469123413-20809-27-git-send-email-mst@redhat.com> <53c0af03-7841-91c2-2eac-55a42b4971db@web.de> <20160731035903.GA6207@pxdev.xzpeter.org> In-Reply-To: <20160731035903.GA6207@pxdev.xzpeter.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2016-07-31 05:59, Peter Xu wrote: > On Sat, Jul 30, 2016 at 09:52:48AM +0200, Jan Kiszka wrote: >=20 > [...] >=20 >>> +/** >>> + * x86_iommu_iec_notify_all - Notify IEC invalidations >>> + * @iommu: IOMMU device that sends the notification >>> + * @global: whether this is a global invalidation. If true, @index >>> + * and @mask are undefined. >>> + * @index: starting index of interrupt entry to invalidate >>> + * @mask: index mask for the invalidation >> >> This is Intel'ish: index and mask refer to the single Intel IR table. >> AMD has per-device tables. >=20 > Actually I was trying to consider this before when designing about the > interface... >=20 >> >> But even for Intel: Would the index make any sense to the callbacks? K= VM >> uses (virtual and real) GSIs to address its routing entries, no? >> >> I suspect we will have to redesign this once we want to make use of >> non-global invalidation. >=20 > IIUC here the problem is how we should manage the mapping between GSI > routes and IRTE index (or device IDs, but let's talk later about > device IDs, since we can map a device-id invalidation into several > standalone index invalidations)? Or say, who should maintain this? IEC > invalidation consumers (e.g., IRQFD logic, IOAPIC, ...), or IOMMU? >=20 > IMHO, I would prefer the consumers to maintain this, not IOMMU. So I > would prefer a raw notification interface (index, mask, device-id, > etc. rather than GSI route index), and the consumers are responsible > to translate this message for their own sake. >=20 > The reason is simple: what if we have some other components (besides > GSI routes) that will register to this notifier? Though I am not sure > whether there would be one in the future, but letting IOMMU knowing > about something like GSI route index is a little bit odd to me. >=20 > Take irqfd as an example, currently MSIRouteEntry is defined as: >=20 > struct MSIRouteEntry { > PCIDevice *dev; /* Device pointer */ > int vector; /* MSI/MSIX vector index */ > int virq; /* Virtual IRQ index */ > QLIST_ENTRY(MSIRouteEntry) list; > }; >=20 > When we want to support explicit IEC invalidation, we may need an > extra field like: >=20 > uint32_t index; /* IRTE index */ >=20 > So when MSI routes are invalidated, we can translated the raw index > information into virq by simply looking up the MSIRouteEntry list. >=20 > Regarding to AMD's device-id interface... >=20 > I see that AMD IOMMUs do not have a global IRTE index table, not sure > whether we can "define" one? E.g. IIUC AMD IOMMU IRTE will have 13 > bits index for each device, so how about making a global index like: >=20 > device-id (16 bits) + 000b (3 bits) + index_per_device (13 bits) >=20 > to form a 32 bit index. So when AMD IOMMUs got a invalidation request, > IOMMU can translate this per-device invalidation into several > invalidations for specific IRTE entries? Not sure whether this would > work. Yes, there has to be a generic handle for each translation result an IOMMU generated. This handle can be stored on the consumer side along with the translation request. How a handle is generated should be completely up to the IOMMU. The consumer should receive a 32-bit (or more) opaque value with each translation request (separate parameter) and then again on specific invalidation. The latter case may also report a range of handles, to make things more efficient (provided the consumer store those handles close to each other). Jan --pAp0wtUQjSqRDS3o5L12vTegXDw5eeOAl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAled6JYACgkQitSsb3rl5xTNVQCfUfKQ+DiDFcoZthcQuXyO9lSW CFgAoLcML5nZB2GChLS4jica3garBxaV =/T/a -----END PGP SIGNATURE----- --pAp0wtUQjSqRDS3o5L12vTegXDw5eeOAl--