All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Pawel Moll <pawel.moll@arm.com>,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio_pci_modern: validate features
Date: Thu, 15 Jan 2015 20:19:20 +0200	[thread overview]
Message-ID: <20150115181920.GA30932@redhat.com> (raw)
In-Reply-To: <1421345588-30805-1-git-send-email-mst@redhat.com>

On Thu, Jan 15, 2015 at 08:13:44PM +0200, Michael S. Tsirkin wrote:
> Spec says devices must set VIRTIO_1 feature bit.
> Fail gracefully if they don't.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Oops, this is not needed: we already have this in finalize_features

        if (!__virtio_test_bit(vdev, VIRTIO_F_VERSION_1)) {
                dev_err(&vdev->dev, "virtio: device uses modern interface "
                        "but does not have VIRTIO_F_VERSION_1\n");
                return -EINVAL;
        }

Pls disregard this patch.


> ---
>  drivers/virtio/virtio_pci_modern.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index 17f0228..a8fd267 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -570,6 +570,7 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
>  	int err, common, isr, notify, device;
>  	u32 notify_length;
>  	u32 notify_offset;
> +	u64 features;
>  
>  	check_offsets();
>  
> @@ -676,12 +677,19 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
>  		vp_dev->vdev.config = &virtio_pci_config_nodev_ops;
>  	}
>  
> +	features = vp_get_features(vdev);
> +	if (!features & (1ULL << VIRTIO_F_VERSION_1))
> +		goto err_valid_features;
> +
>  	vp_dev->config_vector = vp_config_vector;
>  	vp_dev->setup_vq = setup_vq;
>  	vp_dev->del_vq = del_vq;
>  
>  	return 0;
>  
> +err_valid_features:
> +	if (vp_dev->device)
> +		pci_iounmap(pci_dev, vp_dev->device);
>  err_map_device:
>  	if (vp_dev->notify_base)
>  		pci_iounmap(pci_dev, vp_dev->notify_base);
> -- 
> MST

WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	virtualization@lists.linux-foundation.org,
	Pawel Moll <pawel.moll@arm.com>
Subject: Re: [PATCH] virtio_pci_modern: validate features
Date: Thu, 15 Jan 2015 20:19:20 +0200	[thread overview]
Message-ID: <20150115181920.GA30932@redhat.com> (raw)
In-Reply-To: <1421345588-30805-1-git-send-email-mst@redhat.com>

On Thu, Jan 15, 2015 at 08:13:44PM +0200, Michael S. Tsirkin wrote:
> Spec says devices must set VIRTIO_1 feature bit.
> Fail gracefully if they don't.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Oops, this is not needed: we already have this in finalize_features

        if (!__virtio_test_bit(vdev, VIRTIO_F_VERSION_1)) {
                dev_err(&vdev->dev, "virtio: device uses modern interface "
                        "but does not have VIRTIO_F_VERSION_1\n");
                return -EINVAL;
        }

Pls disregard this patch.


> ---
>  drivers/virtio/virtio_pci_modern.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index 17f0228..a8fd267 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -570,6 +570,7 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
>  	int err, common, isr, notify, device;
>  	u32 notify_length;
>  	u32 notify_offset;
> +	u64 features;
>  
>  	check_offsets();
>  
> @@ -676,12 +677,19 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
>  		vp_dev->vdev.config = &virtio_pci_config_nodev_ops;
>  	}
>  
> +	features = vp_get_features(vdev);
> +	if (!features & (1ULL << VIRTIO_F_VERSION_1))
> +		goto err_valid_features;
> +
>  	vp_dev->config_vector = vp_config_vector;
>  	vp_dev->setup_vq = setup_vq;
>  	vp_dev->del_vq = del_vq;
>  
>  	return 0;
>  
> +err_valid_features:
> +	if (vp_dev->device)
> +		pci_iounmap(pci_dev, vp_dev->device);
>  err_map_device:
>  	if (vp_dev->notify_base)
>  		pci_iounmap(pci_dev, vp_dev->notify_base);
> -- 
> MST

  reply	other threads:[~2015-01-15 18:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15 18:13 [PATCH] virtio_pci_modern: validate features Michael S. Tsirkin
2015-01-15 18:13 ` Michael S. Tsirkin
2015-01-15 18:19 ` Michael S. Tsirkin [this message]
2015-01-15 18:19   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150115181920.GA30932@redhat.com \
    --to=mst@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawel.moll@arm.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.