Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2100869ybv; Sun, 23 Feb 2020 22:45:21 -0800 (PST) X-Google-Smtp-Source: APXvYqyf6U4pZ5FhPBBYX+iD111uCgBBfK+B/f6JeQqJsK0TtCXYvzmB2HTU0LWnsc4XzX+JcqFR X-Received: by 2002:a05:6808:b22:: with SMTP id t2mr11346661oij.40.1582526721195; Sun, 23 Feb 2020 22:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582526721; cv=none; d=google.com; s=arc-20160816; b=ue52aMJudiWe2WxEKV89TZyR4jJTcdAyGcJZgF9DILK75bdEGRVySZc12TeGm7UXs8 HTaXHTnpu5pVvDsABaz6NYPYg9uzDhEsIqKytDvhKu7NcRMYZcIseVOMZGlwBQ2mHaRI pl1iEPibZu6ONfuA5suDRq0Dd4l548esP+aixJO6KHfCnOb1n0E0a2chRSRp7drMk2iR zqdJJHS9kQQcvXQFvLFCDr36yL0cZTc9ZvhturjoomdNeI/pyfhylZbFMqqfzi/M4MxQ uoL+KitQ3RvEdoWbcGi/avR9CAj4rQ65UT6qXfZpwRwSDkOYQu2XCdpSp9StZTl1qNY5 CB4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=WKoDnagixkus+9AhxcDkkK9R/bjFiRSIGrqEUwfB3t4=; b=Rg9Qfq23m5K3ptoKwE0JwYC4h0l0o+hasmcGmYO4wG+A96zlczPDOPPORQ7sAGRA5o 4wZ6wt6BdVPkjSwsC84v/WNkFXpVlOuF3WbqPsof2IOfwQPCajDeZmU4Tl4FMSL1Tyzi XaIZSt7zVdEObV/ZsYhXo+BtE79jSx+y+goBb/hM7JLT/mtS0tGTsGNMsoP79Q6cZTJn EZjopGBJdR+N3IUfVVVrJW8q0xZVggAr2uaf4HWywGw0ZPgGu2WyaSIz6WlXF+1R1RC6 a0hau4KE1exinn2KK88YFMRIaIuHCTZUPWs91b72bqwl5E3u5vOTR3xJ+9WLNiGm0MZe Fgpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=A2k8RAOJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20si5712890oti.311.2020.02.23.22.45.09; Sun, 23 Feb 2020 22:45:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=A2k8RAOJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727310AbgBXGnz (ORCPT + 99 others); Mon, 24 Feb 2020 01:43:55 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:55015 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727252AbgBXGny (ORCPT ); Mon, 24 Feb 2020 01:43:54 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 48QswR4QQ9z9sRf; Mon, 24 Feb 2020 17:43:51 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1582526631; bh=htknb17Uk8fVFhFIa11PeQWaB1RywfjrKYh7McPzKaQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A2k8RAOJ4XV3K5TDcE3+viHL40zy7GJhyNz9D6/cqtYvsoczT12lJi12rSZGLEKqH eAt0viVC1lU8zZ+tWxuhqG/z5G/bgs1RHNNRzk7/UZxNDkG0TcszcGlmDtcS8e2MV7 I42zDmdaoGyb9mEQXOol+pq8p2580cV78ael2xg0= Date: Mon, 24 Feb 2020 14:38:53 +1100 From: David Gibson To: Halil Pasic Cc: Jason Wang , "Michael S. Tsirkin" , Marek Szyprowski , Robin Murphy , Christoph Hellwig , linux-s390@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Christian Borntraeger , Janosch Frank , Viktor Mihajlovski , Cornelia Huck , Ram Pai , Thiago Jung Bauermann , "Lendacky, Thomas" , Michael Mueller Subject: Re: [PATCH 0/2] virtio: decouple protected guest RAM form VIRTIO_F_IOMMU_PLATFORM Message-ID: <20200224033853.GE1751@umbus.fritz.box> References: <20200220160606.53156-1-pasic@linux.ibm.com> <426e6972-0565-c931-e171-da0f58fbf856@redhat.com> <20200221155602.4de41fa7.pasic@linux.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="48TaNjbzBVislYPb" Content-Disposition: inline In-Reply-To: <20200221155602.4de41fa7.pasic@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --48TaNjbzBVislYPb Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 21, 2020 at 03:56:02PM +0100, Halil Pasic wrote: > On Fri, 21 Feb 2020 14:22:26 +0800 > Jason Wang wrote: >=20 > >=20 > > On 2020/2/21 =E4=B8=8A=E5=8D=8812:06, Halil Pasic wrote: > > > Currently if one intends to run a memory protection enabled VM with > > > virtio devices and linux as the guest OS, one needs to specify the > > > VIRTIO_F_IOMMU_PLATFORM flag for each virtio device to make the guest > > > linux use the DMA API, which in turn handles the memory > > > encryption/protection stuff if the guest decides to turn itself into > > > a protected one. This however makes no sense due to multiple reasons: > > > * The device is not changed by the fact that the guest RAM is > > > protected. The so called IOMMU bypass quirk is not affected. > > > * This usage is not congruent with standardised semantics of > > > VIRTIO_F_IOMMU_PLATFORM. Guest memory protected is an orthogonal reas= on > > > for using DMA API in virtio (orthogonal with respect to what is > > > expressed by VIRTIO_F_IOMMU_PLATFORM). > > > > > > This series aims to decouple 'have to use DMA API because my (guest) = RAM > > > is protected' and 'have to use DMA API because the device told me > > > VIRTIO_F_IOMMU_PLATFORM'. > > > > > > Please find more detailed explanations about the conceptual aspects in > > > the individual patches. There is however also a very practical problem > > > that is addressed by this series. > > > > > > For vhost-net the feature VIRTIO_F_IOMMU_PLATFORM has the following s= ide > > > effect The vhost code assumes it the addresses on the virtio descript= or > > > ring are not guest physical addresses but iova's, and insists on doin= g a > > > translation of these regardless of what transport is used (e.g. wheth= er > > > we emulate a PCI or a CCW device). (For details see commit 6b1e6cc785= 5b > > > "vhost: new device IOTLB API".) On s390 this results in severe > > > performance degradation (c.a. factor 10). > >=20 > >=20 > > Do you see a consistent degradation on the performance, or it only=20 > > happen when for during the beginning of the test? > >=20 >=20 > AFAIK the degradation is consistent. >=20 > >=20 > > > BTW with ccw I/O there is > > > (architecturally) no IOMMU, so the whole address translation makes no > > > sense in the context of virtio-ccw. > >=20 > >=20 > > I suspect we can do optimization in qemu side. > >=20 > > E.g send memtable entry via IOTLB API when vIOMMU is not enabled. > >=20 > > If this makes sense, I can draft patch to see if there's any difference. >=20 > Frankly I would prefer to avoid IOVAs on the descriptor ring (and the > then necessary translation) for virtio-ccw altogether. But Michael > voiced his opinion that we should mandate F_IOMMU_PLATFORM for devices > that could be used with guests running in protected mode. I don't share > his opinion, but that's an ongoing discussion. I'm a bit confused by this. For the ccw specific case, F_ACCESS_PLATFORM shouldn't have any impact: for you, IOVA =3D=3D GPA so everything is easy. > Should we end up having to do translation from IOVA in vhost, we are > very interested in that translation being fast and efficient. >=20 > In that sense we would be very happy to test any optimization that aim > into that direction. >=20 > Thank you very much for your input! >=20 > Regards, > Halil >=20 > >=20 > > Thanks > >=20 > >=20 > > > > > > Halil Pasic (2): > > > mm: move force_dma_unencrypted() to mem_encrypt.h > > > virtio: let virtio use DMA API when guest RAM is protected > > > > > > drivers/virtio/virtio_ring.c | 3 +++ > > > include/linux/dma-direct.h | 9 --------- > > > include/linux/mem_encrypt.h | 10 ++++++++++ > > > 3 files changed, 13 insertions(+), 9 deletions(-) > > > > > > > > > base-commit: ca7e1fd1026c5af6a533b4b5447e1d2f153e28f2 > >=20 >=20 --=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 --48TaNjbzBVislYPb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAl5TRUwACgkQbDjKyiDZ s5KHhRAAzvCq4VbEVWbiYmB1ioNQU2Zls3KoMhs0PgZRddR+1P85yLT3xnHrw/LQ g2UfyDDlqIqQgVjwHuHBTwoRWvNFm7Q72IUkh/Crwex4MlbvdSA0MIovpx9J3SSq tjQ/No5y2xz2zsksr3T7KRh+w7EM62KyxJU1vnZj1NvlZQmHGG4tMtEpsv+rwa9R 13j0VvV9SqLMCPS7zMFge/kvOg59UqwGpFXIaILBx9TGPHAjjLNt2GZCAPAsOxmO TIqzQwP2pooqNrLVnTvaXP3R4HUi/3V86Cys7oKnStuG95psLjB+2S8wxpfOTXS2 3pPHCTweu2xyQNReRbrjQq0aovnDdioNVFn6auGF0ilCd3xFrd0fYWG0vvW0d8f/ hlyZfoJCTCvKs60OcC7x45FKfpcU4+R8oHxdVJG/DPI6Uxbk9C5T0G/maOMxKLDO 40hJGP2SVIFtdmb8lNhlA4saVYjsR0OqH+Y+fLYi6dsl1S7FFNAhMEOOJrvhfE1O cSSWeq2NsyY0mtTFeAtXv25yZ4t8Ed9oNnVvTXyNKkp8VKmVGz2qmH+sx1wHi4m8 UANxHkrr0V1IzMdE4Bz7TKeOVNdTQQN+0AQlwL6R+XZTpwgPAUXQbV5bLvwX+CEp SqpVVhl9CnKeqyppaXy08CiYwdQIaze77BSX0VHTyIJq4WzI8YY= =FeJg -----END PGP SIGNATURE----- --48TaNjbzBVislYPb--