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: <4470fdac-89fb-1216-78d7-6335c3bfeb22@redhat.com>
Date:   Mon, 23 Aug 2021 14:31:16 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Xie Yongji <xieyongji@...edance.com>, mst@...hat.com,
        stefanha@...hat.com, sgarzare@...hat.com, parav@...dia.com,
        hch@...radead.org, christian.brauner@...onical.com,
        rdunlap@...radead.org, willy@...radead.org,
        viro@...iv.linux.org.uk, axboe@...nel.dk, bcrl@...ck.org,
        corbet@....net, mika.penttila@...tfour.com,
        dan.carpenter@...cle.com, joro@...tes.org,
        gregkh@...uxfoundation.org, zhe.he@...driver.com,
        xiaodong.liu@...el.com, joe@...ches.com, robin.murphy@....com
Cc:     songmuchun@...edance.com,
        virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
        kvm@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v11 04/12] vdpa: Add reset callback in vdpa_config_ops


在 2021/8/18 下午8:06, Xie Yongji 写道:
> This adds a new callback to support device specific reset
> behavior. The vdpa bus driver will call the reset function
> instead of setting status to zero during resetting if device
> driver supports the new callback.
>
> Signed-off-by: Xie Yongji <xieyongji@...edance.com>
> ---
>   drivers/vhost/vdpa.c |  9 +++++++--
>   include/linux/vdpa.h | 11 ++++++++++-
>   2 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index b07aa161f7ad..b1c91b4db0ba 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -157,7 +157,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
>   	struct vdpa_device *vdpa = v->vdpa;
>   	const struct vdpa_config_ops *ops = vdpa->config;
>   	u8 status, status_old;
> -	int nvqs = v->nvqs;
> +	int ret, nvqs = v->nvqs;
>   	u16 i;
>   
>   	if (copy_from_user(&status, statusp, sizeof(status)))
> @@ -172,7 +172,12 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
>   	if (status != 0 && (ops->get_status(vdpa) & ~status) != 0)
>   		return -EINVAL;
>   
> -	ops->set_status(vdpa, status);
> +	if (status == 0 && ops->reset) {
> +		ret = ops->reset(vdpa);
> +		if (ret)
> +			return ret;
> +	} else
> +		ops->set_status(vdpa, status);
>   
>   	if ((status & VIRTIO_CONFIG_S_DRIVER_OK) && !(status_old & VIRTIO_CONFIG_S_DRIVER_OK))
>   		for (i = 0; i < nvqs; i++)
> diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
> index 8a645f8f4476..af7ea5ad795f 100644
> --- a/include/linux/vdpa.h
> +++ b/include/linux/vdpa.h
> @@ -196,6 +196,9 @@ struct vdpa_iova_range {
>    *				@vdev: vdpa device
>    *				Returns the iova range supported by
>    *				the device.
> + * @reset:			Reset device (optional)
> + *				@vdev: vdpa device
> + *				Returns integer: success (0) or error (< 0)


It looks to me we'd better make this mandatory. This help to reduce the 
confusion for the parent driver.

Thanks


>    * @set_map:			Set device memory mapping (optional)
>    *				Needed for device that using device
>    *				specific DMA translation (on-chip IOMMU)
> @@ -263,6 +266,7 @@ struct vdpa_config_ops {
>   			   const void *buf, unsigned int len);
>   	u32 (*get_generation)(struct vdpa_device *vdev);
>   	struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev);
> +	int (*reset)(struct vdpa_device *vdev);
>   
>   	/* DMA ops */
>   	int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb);
> @@ -351,12 +355,17 @@ 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)
> +static inline int vdpa_reset(struct vdpa_device *vdev)
>   {
>   	const struct vdpa_config_ops *ops = vdev->config;
>   
>   	vdev->features_valid = false;
> +	if (ops->reset)
> +		return ops->reset(vdev);
> +
>   	ops->set_status(vdev, 0);
> +
> +	return 0;
>   }
>   
>   static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ