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 <lersek@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
> ---
> 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
<http://mid.mail-archive.com/841bec5f-6f6e-8b1f-25ba-0fd37a915b72@redhat.com>,
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
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel