lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9e47d227-f220-4651-dcb9-7a11f059a715@redhat.com>
Date:   Wed, 5 Aug 2020 14:14:07 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     "Michael S. Tsirkin" <mst@...hat.com>, linux-kernel@...r.kernel.org
Cc:     virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v2 19/24] vdpa: make sure set_features in invoked for
 legacy


On 2020/8/4 上午5:00, Michael S. Tsirkin wrote:
> Some legacy guests just assume features are 0 after reset.
> We detect that config space is accessed before features are
> set and set features to 0 automatically.
> Note: some legacy guests might not even access config space, if this is
> reported in the field we might need to catch a kick to handle these.


I wonder whether it's easier to just support modern device?

Thanks


>
> Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
> ---
>   drivers/vdpa/vdpa.c  |  1 +
>   include/linux/vdpa.h | 34 ++++++++++++++++++++++++++++++++++
>   2 files changed, 35 insertions(+)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index de211ef3738c..7105265e4793 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -96,6 +96,7 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
>   	vdev->dev.release = vdpa_release_dev;
>   	vdev->index = err;
>   	vdev->config = config;
> +	vdev->features_valid = false;
>   
>   	err = dev_set_name(&vdev->dev, "vdpa%u", vdev->index);
>   	if (err)
> diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
> index 239db794357c..29b8296f1414 100644
> --- a/include/linux/vdpa.h
> +++ b/include/linux/vdpa.h
> @@ -33,12 +33,14 @@ struct vdpa_notification_area {
>    * @dma_dev: the actual device that is performing DMA
>    * @config: the configuration ops for this device.
>    * @index: device index
> + * @features_valid: were features initialized? for legacy guests
>    */
>   struct vdpa_device {
>   	struct device dev;
>   	struct device *dma_dev;
>   	const struct vdpa_config_ops *config;
>   	unsigned int index;
> +	bool features_valid;
>   };
>   
>   /**
> @@ -266,4 +268,36 @@ static inline struct device *vdpa_get_dma_dev(struct vdpa_device *vdev)
>   {
>   	return vdev->dma_dev;
>   }
> +
> +static inline void vdpa_reset(struct vdpa_device *vdev)
> +{
> +        const struct vdpa_config_ops *ops = vdev->config;
> +
> +	vdev->features_valid = false;
> +        ops->set_status(vdev, 0);
> +}
> +
> +static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features)
> +{
> +        const struct vdpa_config_ops *ops = vdev->config;
> +
> +	vdev->features_valid = true;
> +        return ops->set_features(vdev, features);
> +}
> +
> +
> +static inline void vdpa_get_config(struct vdpa_device *vdev, unsigned offset,
> +				   void *buf, unsigned int len)
> +{
> +        const struct vdpa_config_ops *ops = vdev->config;
> +
> +	/*
> +	 * Config accesses aren't supposed to trigger before features are set.
> +	 * If it does happen we assume a legacy guest.
> +	 */
> +	if (!vdev->features_valid)
> +		vdpa_set_features(vdev, 0);
> +	ops->get_config(vdev, offset, buf, len);
> +}
> +
>   #endif /* _LINUX_VDPA_H */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ