[SeaBIOS] [PATCH] virtio: IOMMU support

Michael S. Tsirkin mst at redhat.com
Wed Jul 5 14:56:50 CEST 2017


On Wed, Jul 05, 2017 at 03:49:51PM +0800, Jason Wang wrote:
> Since we don't enable IOMMU at all, we can then simply enable the
> IOMMU support by claiming the support of VIRITO_F_IOMMU_PLATFORM. This
> fixes booting failure when iommu_platform is set from qemu cli.
> 
> Signed-off-by: Jason Wang <jasowang at redhat.com>

Acked-by: Michael S. Tsirkin <mst at redhat.com>

> ---
>  src/hw/virtio-blk.c  | 3 ++-
>  src/hw/virtio-ring.h | 1 +
>  src/hw/virtio-scsi.c | 3 ++-
>  3 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c
> index dca7855..901b8f5 100644
> --- a/src/hw/virtio-blk.c
> +++ b/src/hw/virtio-blk.c
> @@ -118,13 +118,14 @@ init_virtio_blk(void *data)
>          struct vp_device *vp = &vdrive->vp;
>          u64 features = vp_get_features(vp);
>          u64 version1 = 1ull << VIRTIO_F_VERSION_1;
> +        u64 iommu_platform = 1ull << VIRTIO_F_IOMMU_PLATFORM;
>          u64 blk_size = 1ull << VIRTIO_BLK_F_BLK_SIZE;
>          if (!(features & version1)) {
>              dprintf(1, "modern device without virtio_1 feature bit: %pP\n", pci);
>              goto fail;
>          }
>  
> -        features = features & (version1 | blk_size);
> +        features = features & (version1 | iommu_platform | blk_size);
>          vp_set_features(vp, features);
>          status |= VIRTIO_CONFIG_S_FEATURES_OK;
>          vp_set_status(vp, status);
> diff --git a/src/hw/virtio-ring.h b/src/hw/virtio-ring.h
> index 7665fd5..8604a01 100644
> --- a/src/hw/virtio-ring.h
> +++ b/src/hw/virtio-ring.h
> @@ -18,6 +18,7 @@
>  
>  /* v1.0 compliant. */
>  #define VIRTIO_F_VERSION_1              32
> +#define VIRTIO_F_IOMMU_PLATFORM         33
>  
>  #define MAX_QUEUE_NUM      (128)
>  
> diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c
> index 7490ec0..4eea5c3 100644
> --- a/src/hw/virtio-scsi.c
> +++ b/src/hw/virtio-scsi.c
> @@ -163,12 +163,13 @@ init_virtio_scsi(void *data)
>      if (vp->use_modern) {
>          u64 features = vp_get_features(vp);
>          u64 version1 = 1ull << VIRTIO_F_VERSION_1;
> +        u64 iommu_platform = 1ull << VIRTIO_F_IOMMU_PLATFORM;
>          if (!(features & version1)) {
>              dprintf(1, "modern device without virtio_1 feature bit: %pP\n", pci);
>              goto fail;
>          }
>  
> -        vp_set_features(vp, version1);
> +        vp_set_features(vp, features & (version1 | iommu_platform));
>          status |= VIRTIO_CONFIG_S_FEATURES_OK;
>          vp_set_status(vp, status);
>          if (!(vp_get_status(vp) & VIRTIO_CONFIG_S_FEATURES_OK)) {
> -- 
> 2.7.4



More information about the SeaBIOS mailing list