From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2308C21D2E65C for ; Mon, 21 Aug 2017 08:38:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA5BE8B13D; Mon, 21 Aug 2017 15:40:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA5BE8B13D Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-165.phx2.redhat.com [10.3.116.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FB9877D55; Mon, 21 Aug 2017 15:40:47 +0000 (UTC) To: Brijesh Singh , edk2-devel@lists.01.org Cc: Jordan Justen , Tom Lendacky , Ard Biesheuvel References: <1502710605-8058-1-git-send-email-brijesh.singh@amd.com> <1502710605-8058-24-git-send-email-brijesh.singh@amd.com> From: Laszlo Ersek Message-ID: <82cb5dda-f02d-9e38-c47e-3723184dea08@redhat.com> Date: Mon, 21 Aug 2017 17:40:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1502710605-8058-24-git-send-email-brijesh.singh@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 21 Aug 2017 15:40:57 +0000 (UTC) Subject: Re: [PATCH v2 23/23] OvmfPkg/Virtio: define VIRITO_F_IOMMU_PLATFORM feature bit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 15:38:26 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 08/14/17 13:36, Brijesh Singh wrote: > This feature indicates that the device is behind an IOMMU that translates > bus addresses from the device into physical addresses in memory. If this > feature bit is set to 0, then the device emits physical addresses which > are not translated further, even though an IOMMU may be present. > see [1] for more infromation > > [1] https://lists.oasis-open.org/archives/virtio-dev/201610/msg00121.html > > In previous patches, we have implemented IOMMU-like member functions in > VIRTIO_DEVICE_PROTOCOL to translate the physical address to bus address > and virtio drivers are updated to use those member functions. We do not > need to do anything special when VIRTIO_F_IOMMU_PLATFORM bit is present > hence treat it in parallel with VIRTIO_F_VERSION_1. > > Suggested-by: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Tom Lendacky > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Brijesh Singh > --- > OvmfPkg/Include/IndustryStandard/Virtio10.h | 5 +++++ > OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 3 ++- > OvmfPkg/VirtioNetDxe/SnpInitialize.c | 3 ++- > OvmfPkg/VirtioRngDxe/VirtioRng.c | 2 +- > OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 3 ++- > 5 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/OvmfPkg/Include/IndustryStandard/Virtio10.h b/OvmfPkg/Include/IndustryStandard/Virtio10.h > index 4c9b62a3cf59..c62429d94432 100644 > --- a/OvmfPkg/Include/IndustryStandard/Virtio10.h > +++ b/OvmfPkg/Include/IndustryStandard/Virtio10.h > @@ -83,4 +83,9 @@ typedef struct { > // > #define VIRTIO_F_VERSION_1 BIT32 > > +// > +// VirtIo 1.0 reserved iommu platform feature bits > +// > +#define VIRTIO_F_IOMMU_PLATFORM BIT33 > + > #endif // _VIRTIO_1_0_H_ (1) The comment is not necessary. Namely, the comment that you see just above the VIRTIO_F_VERSION_1 macro: // // VirtIo 1.0 reserved (device-independent) feature bits // is meant as the introduction for the *full set* of such bits. Given that VIRTIO_F_IOMMU_PLATFORM is just another bit in that set, please just add it right below VIRTIO_F_VERSION_1. (2) Please update the whitespace for VIRTIO_F_VERSION_1 as well, so that the replacement texts (BIT32, BIT33) line up nicely. (3) Please split this change out to a separate patch. > diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c > index 57baceb20a19..a78ec0df9c7b 100644 > --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c > +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c > @@ -773,7 +773,8 @@ VirtioBlkInit ( > } > > Features &= VIRTIO_BLK_F_BLK_SIZE | VIRTIO_BLK_F_TOPOLOGY | VIRTIO_BLK_F_RO | > - VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1; > + VIRTIO_BLK_F_FLUSH | VIRTIO_F_VERSION_1 | > + VIRTIO_F_IOMMU_PLATFORM; > > // > // In virtio-1.0, feature negotiation is expected to complete before queue (4) The modifications for this file (VirtioBlk.c) are incomplete. Namely, in message , points (3) and (5.3), I requested that > [...] VIRTIO_F_IOMMU_PLATFORM should be treated in OVMF *precisely* in > parallel with VIRTIO_F_VERSION_1. Therefore please locate *all* occurrences of VIRTIO_F_VERSION_1, and act accordingly. In particular, in addition to the above location, we also have: // // step 5 -- Report understood features. // if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) { Features &= ~(UINT64)VIRTIO_F_VERSION_1; Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features); if (EFI_ERROR (Status)) { goto ReleaseQueue; } } which should now be changed to: Features &= ~(UINT64)(VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM); Same for all the other drivers. (5) Please split each VIRTIO_F_IOMMU_PLATFORM change to a separate patch. (That is, one patch per driver.) - OvmfPkg/Virtio10: define VIRITO_F_IOMMU_PLATFORM feature bit - OvmfPkg/VirtioBlkDxe: negotiate VIRITO_F_IOMMU_PLATFORM - OvmfPkg/VirtioNetDxe: negotiate VIRITO_F_IOMMU_PLATFORM - ... Thanks, Laszlo > diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/SnpInitialize.c > index 9bac19f8e3d1..b389f6243661 100644 > --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c > +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c > @@ -536,7 +536,8 @@ VirtioNetInitialize ( > ASSERT (Dev->Snm.MediaPresentSupported == > !!(Features & VIRTIO_NET_F_STATUS)); > > - Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_1; > + Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_1 | > + VIRTIO_F_IOMMU_PLATFORM; > > // > // In virtio-1.0, feature negotiation is expected to complete before queue > diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/VirtioRng.c > index b19d90901430..81d8c7facc10 100644 > --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c > +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c > @@ -273,7 +273,7 @@ VirtioRngInit ( > goto Failed; > } > > - Features &= VIRTIO_F_VERSION_1; > + Features &= VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM; > > // > // In virtio-1.0, feature negotiation is expected to complete before queue > diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c > index 65e9bda0827a..286b005c994c 100644 > --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c > +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c > @@ -903,7 +903,8 @@ VirtioScsiInit ( > goto Failed; > } > > - Features &= VIRTIO_SCSI_F_INOUT | VIRTIO_F_VERSION_1; > + Features &= VIRTIO_SCSI_F_INOUT | VIRTIO_F_VERSION_1 | > + VIRTIO_F_IOMMU_PLATFORM; > > // > // In virtio-1.0, feature negotiation is expected to complete before queue >