mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
virtio, vhost: fixes
A small number of fixes.
virtgpu is exempt from reset shutdown fow now -
a more complete fix is in the works
spec compliance fixes in:
virtio-pci cap commands
vhost_scsi_send_bad_target
virtio console resize
missing locking fix in vhost-scsi
virtio ring - a KCSAN false positive fix
VHOST_*_OWNER documentation fix
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-----BEGIN PGP SIGNATURE-----
iQFDBAABCgAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmgIi3cPHG1zdEByZWRo
YXQuY29tAAoJECgfDbjSjVRpGU8H/1Fq8pH+irGvyH4E21O03qx0wiM+lcYVhNH5
2a3rjOwuJBiLvscZTJG/w07hIpx0O4WrbygdT0BTll4Uen2C+OpGn/Y1LfhW6wsr
3yyeBpTr5hKiY8sOD08rMTHTCM4mD8UdYr13RcNq+eUxNZ6bA+kiGaXpIk0AiRPR
5pdbx16cTZM7k+/9aXp68hRO7yHnyilGzAJG1hHmfx1L5Mt++RVKsf2KI+3YHWcI
0ZZj/NP3iZfNm57+QpKX6zYikH4IFIer1r9wotMaR74brpuq8w7HKZUqe3VfG11Y
TBgq6NfDZVq8G8bCGPv+C+DfDnpYMFVYqytCLn4/AyOhLNCRDs8=
=m8wk
-----END PGP SIGNATURE-----
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin:
"A small number of fixes:
- virtgpu is exempt from reset shutdown fow now - a more complete fix
is in the works
- spec compliance fixes in:
- virtio-pci cap commands
- vhost_scsi_send_bad_target
- virtio console resize
- missing locking fix in vhost-scsi
- virtio ring - a KCSAN false positive fix
- VHOST_*_OWNER documentation fix"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
vhost-scsi: Fix vhost_scsi_send_status()
vhost-scsi: Fix vhost_scsi_send_bad_target()
vhost-scsi: protect vq->log_used with vq->mutex
vhost_task: fix vhost_task_create() documentation
virtio_console: fix order of fields cols and rows
virtio_console: fix missing byte order handling for cols and rows
virtgpu: don't reset on shutdown
virtio_ring: Fix data race by tagging event_triggered as racy for KCSAN
vhost: fix VHOST_*_OWNER documentation
virtio_pci: Use self group type for cap commands
This commit is contained in:
commit
0251ddbffb
|
|
@ -1576,8 +1576,8 @@ static void handle_control_message(struct virtio_device *vdev,
|
|||
break;
|
||||
case VIRTIO_CONSOLE_RESIZE: {
|
||||
struct {
|
||||
__u16 rows;
|
||||
__u16 cols;
|
||||
__virtio16 cols;
|
||||
__virtio16 rows;
|
||||
} size;
|
||||
|
||||
if (!is_console_port(port))
|
||||
|
|
@ -1585,7 +1585,8 @@ static void handle_control_message(struct virtio_device *vdev,
|
|||
|
||||
memcpy(&size, buf->buf + buf->offset + sizeof(*cpkt),
|
||||
sizeof(size));
|
||||
set_console_size(port, size.rows, size.cols);
|
||||
set_console_size(port, virtio16_to_cpu(vdev, size.rows),
|
||||
virtio16_to_cpu(vdev, size.cols));
|
||||
|
||||
port->cons.hvc->irq_requested = 1;
|
||||
resize_console(port);
|
||||
|
|
|
|||
|
|
@ -128,6 +128,14 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
|
|||
drm_dev_put(dev);
|
||||
}
|
||||
|
||||
static void virtio_gpu_shutdown(struct virtio_device *vdev)
|
||||
{
|
||||
/*
|
||||
* drm does its own synchronization on shutdown.
|
||||
* Do nothing here, opt out of device reset.
|
||||
*/
|
||||
}
|
||||
|
||||
static void virtio_gpu_config_changed(struct virtio_device *vdev)
|
||||
{
|
||||
struct drm_device *dev = vdev->priv;
|
||||
|
|
@ -162,6 +170,7 @@ static struct virtio_driver virtio_gpu_driver = {
|
|||
.id_table = id_table,
|
||||
.probe = virtio_gpu_probe,
|
||||
.remove = virtio_gpu_remove,
|
||||
.shutdown = virtio_gpu_shutdown,
|
||||
.config_changed = virtio_gpu_config_changed
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -627,6 +627,9 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work)
|
|||
int ret;
|
||||
|
||||
llnode = llist_del_all(&svq->completion_list);
|
||||
|
||||
mutex_lock(&svq->vq.mutex);
|
||||
|
||||
llist_for_each_entry_safe(cmd, t, llnode, tvc_completion_list) {
|
||||
se_cmd = &cmd->tvc_se_cmd;
|
||||
|
||||
|
|
@ -660,6 +663,8 @@ static void vhost_scsi_complete_cmd_work(struct vhost_work *work)
|
|||
vhost_scsi_release_cmd_res(se_cmd);
|
||||
}
|
||||
|
||||
mutex_unlock(&svq->vq.mutex);
|
||||
|
||||
if (signal)
|
||||
vhost_signal(&svq->vs->dev, &svq->vq);
|
||||
}
|
||||
|
|
@ -994,39 +999,66 @@ static void vhost_scsi_target_queue_cmd(struct vhost_scsi_nexus *nexus,
|
|||
|
||||
static void
|
||||
vhost_scsi_send_status(struct vhost_scsi *vs, struct vhost_virtqueue *vq,
|
||||
int head, unsigned int out, u8 status)
|
||||
struct vhost_scsi_ctx *vc, u8 status)
|
||||
{
|
||||
struct virtio_scsi_cmd_resp __user *resp;
|
||||
struct virtio_scsi_cmd_resp rsp;
|
||||
struct iov_iter iov_iter;
|
||||
int ret;
|
||||
|
||||
memset(&rsp, 0, sizeof(rsp));
|
||||
rsp.status = status;
|
||||
resp = vq->iov[out].iov_base;
|
||||
ret = __copy_to_user(resp, &rsp, sizeof(rsp));
|
||||
if (!ret)
|
||||
vhost_add_used_and_signal(&vs->dev, vq, head, 0);
|
||||
|
||||
iov_iter_init(&iov_iter, ITER_DEST, &vq->iov[vc->out], vc->in,
|
||||
sizeof(rsp));
|
||||
|
||||
ret = copy_to_iter(&rsp, sizeof(rsp), &iov_iter);
|
||||
|
||||
if (likely(ret == sizeof(rsp)))
|
||||
vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0);
|
||||
else
|
||||
pr_err("Faulted on virtio_scsi_cmd_resp\n");
|
||||
}
|
||||
|
||||
#define TYPE_IO_CMD 0
|
||||
#define TYPE_CTRL_TMF 1
|
||||
#define TYPE_CTRL_AN 2
|
||||
|
||||
static void
|
||||
vhost_scsi_send_bad_target(struct vhost_scsi *vs,
|
||||
struct vhost_virtqueue *vq,
|
||||
int head, unsigned out)
|
||||
struct vhost_scsi_ctx *vc, int type)
|
||||
{
|
||||
struct virtio_scsi_cmd_resp __user *resp;
|
||||
struct virtio_scsi_cmd_resp rsp;
|
||||
union {
|
||||
struct virtio_scsi_cmd_resp cmd;
|
||||
struct virtio_scsi_ctrl_tmf_resp tmf;
|
||||
struct virtio_scsi_ctrl_an_resp an;
|
||||
} rsp;
|
||||
struct iov_iter iov_iter;
|
||||
size_t rsp_size;
|
||||
int ret;
|
||||
|
||||
memset(&rsp, 0, sizeof(rsp));
|
||||
rsp.response = VIRTIO_SCSI_S_BAD_TARGET;
|
||||
resp = vq->iov[out].iov_base;
|
||||
ret = __copy_to_user(resp, &rsp, sizeof(rsp));
|
||||
if (!ret)
|
||||
vhost_add_used_and_signal(&vs->dev, vq, head, 0);
|
||||
|
||||
if (type == TYPE_IO_CMD) {
|
||||
rsp_size = sizeof(struct virtio_scsi_cmd_resp);
|
||||
rsp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET;
|
||||
} else if (type == TYPE_CTRL_TMF) {
|
||||
rsp_size = sizeof(struct virtio_scsi_ctrl_tmf_resp);
|
||||
rsp.tmf.response = VIRTIO_SCSI_S_BAD_TARGET;
|
||||
} else {
|
||||
rsp_size = sizeof(struct virtio_scsi_ctrl_an_resp);
|
||||
rsp.an.response = VIRTIO_SCSI_S_BAD_TARGET;
|
||||
}
|
||||
|
||||
iov_iter_init(&iov_iter, ITER_DEST, &vq->iov[vc->out], vc->in,
|
||||
rsp_size);
|
||||
|
||||
ret = copy_to_iter(&rsp, rsp_size, &iov_iter);
|
||||
|
||||
if (likely(ret == rsp_size))
|
||||
vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0);
|
||||
else
|
||||
pr_err("Faulted on virtio_scsi_cmd_resp\n");
|
||||
pr_err("Faulted on virtio scsi type=%d\n", type);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1390,9 +1422,9 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
|
|||
if (ret == -ENXIO)
|
||||
break;
|
||||
else if (ret == -EIO)
|
||||
vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out);
|
||||
vhost_scsi_send_bad_target(vs, vq, &vc, TYPE_IO_CMD);
|
||||
else if (ret == -ENOMEM)
|
||||
vhost_scsi_send_status(vs, vq, vc.head, vc.out,
|
||||
vhost_scsi_send_status(vs, vq, &vc,
|
||||
SAM_STAT_TASK_SET_FULL);
|
||||
} while (likely(!vhost_exceeds_weight(vq, ++c, 0)));
|
||||
out:
|
||||
|
|
@ -1432,8 +1464,11 @@ static void vhost_scsi_tmf_resp_work(struct vhost_work *work)
|
|||
else
|
||||
resp_code = VIRTIO_SCSI_S_FUNCTION_REJECTED;
|
||||
|
||||
mutex_lock(&tmf->svq->vq.mutex);
|
||||
vhost_scsi_send_tmf_resp(tmf->vhost, &tmf->svq->vq, tmf->in_iovs,
|
||||
tmf->vq_desc, &tmf->resp_iov, resp_code);
|
||||
mutex_unlock(&tmf->svq->vq.mutex);
|
||||
|
||||
vhost_scsi_release_tmf_res(tmf);
|
||||
}
|
||||
|
||||
|
|
@ -1623,7 +1658,10 @@ vhost_scsi_ctl_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
|
|||
if (ret == -ENXIO)
|
||||
break;
|
||||
else if (ret == -EIO)
|
||||
vhost_scsi_send_bad_target(vs, vq, vc.head, vc.out);
|
||||
vhost_scsi_send_bad_target(vs, vq, &vc,
|
||||
v_req.type == VIRTIO_SCSI_T_TMF ?
|
||||
TYPE_CTRL_TMF :
|
||||
TYPE_CTRL_AN);
|
||||
} while (likely(!vhost_exceeds_weight(vq, ++c, 0)));
|
||||
out:
|
||||
mutex_unlock(&vq->mutex);
|
||||
|
|
|
|||
|
|
@ -407,6 +407,12 @@ static void virtio_dev_shutdown(struct device *_d)
|
|||
if (!drv)
|
||||
return;
|
||||
|
||||
/* If the driver has its own shutdown method, use that. */
|
||||
if (drv->shutdown) {
|
||||
drv->shutdown(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some devices get wedged if you kick them after they are
|
||||
* reset. Mark all vqs as broken to make sure we don't.
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ virtio_pci_admin_cmd_dev_parts_objects_enable(struct virtio_device *virtio_dev)
|
|||
sg_init_one(&data_sg, get_data, sizeof(*get_data));
|
||||
sg_init_one(&result_sg, result, sizeof(*result));
|
||||
cmd.opcode = cpu_to_le16(VIRTIO_ADMIN_CMD_DEVICE_CAP_GET);
|
||||
cmd.group_type = cpu_to_le16(VIRTIO_ADMIN_GROUP_TYPE_SRIOV);
|
||||
cmd.group_type = cpu_to_le16(VIRTIO_ADMIN_GROUP_TYPE_SELF);
|
||||
cmd.data_sg = &data_sg;
|
||||
cmd.result_sg = &result_sg;
|
||||
ret = vp_modern_admin_cmd_exec(virtio_dev, &cmd);
|
||||
|
|
@ -305,7 +305,7 @@ static void virtio_pci_admin_cmd_cap_init(struct virtio_device *virtio_dev)
|
|||
|
||||
sg_init_one(&result_sg, data, sizeof(*data));
|
||||
cmd.opcode = cpu_to_le16(VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY);
|
||||
cmd.group_type = cpu_to_le16(VIRTIO_ADMIN_GROUP_TYPE_SRIOV);
|
||||
cmd.group_type = cpu_to_le16(VIRTIO_ADMIN_GROUP_TYPE_SELF);
|
||||
cmd.result_sg = &result_sg;
|
||||
|
||||
ret = vp_modern_admin_cmd_exec(virtio_dev, &cmd);
|
||||
|
|
|
|||
|
|
@ -2650,7 +2650,7 @@ bool virtqueue_enable_cb_delayed(struct virtqueue *_vq)
|
|||
struct vring_virtqueue *vq = to_vvq(_vq);
|
||||
|
||||
if (vq->event_triggered)
|
||||
vq->event_triggered = false;
|
||||
data_race(vq->event_triggered = false);
|
||||
|
||||
return vq->packed_ring ? virtqueue_enable_cb_delayed_packed(_vq) :
|
||||
virtqueue_enable_cb_delayed_split(_vq);
|
||||
|
|
|
|||
|
|
@ -220,6 +220,8 @@ size_t virtio_max_dma_size(const struct virtio_device *vdev);
|
|||
* occurs.
|
||||
* @reset_done: optional function to call after transport specific reset
|
||||
* operation has finished.
|
||||
* @shutdown: synchronize with the device on shutdown. If provided, replaces
|
||||
* the virtio core implementation.
|
||||
*/
|
||||
struct virtio_driver {
|
||||
struct device_driver driver;
|
||||
|
|
@ -237,6 +239,7 @@ struct virtio_driver {
|
|||
int (*restore)(struct virtio_device *dev);
|
||||
int (*reset_prepare)(struct virtio_device *dev);
|
||||
int (*reset_done)(struct virtio_device *dev);
|
||||
void (*shutdown)(struct virtio_device *dev);
|
||||
};
|
||||
|
||||
#define drv_to_virtio(__drv) container_of_const(__drv, struct virtio_driver, driver)
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
/* Set current process as the (exclusive) owner of this file descriptor. This
|
||||
* must be called before any other vhost command. Further calls to
|
||||
* VHOST_OWNER_SET fail until VHOST_OWNER_RESET is called. */
|
||||
* VHOST_SET_OWNER fail until VHOST_RESET_OWNER is called. */
|
||||
#define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01)
|
||||
/* Give up ownership, and reset the device to default values.
|
||||
* Allows subsequent call to VHOST_OWNER_SET to succeed. */
|
||||
* Allows subsequent call to VHOST_SET_OWNER to succeed. */
|
||||
#define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02)
|
||||
|
||||
/* Set up/modify memory layout */
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ struct virtio_pci_cfg_cap {
|
|||
#define VIRTIO_ADMIN_CMD_LIST_USE 0x1
|
||||
|
||||
/* Admin command group type. */
|
||||
#define VIRTIO_ADMIN_GROUP_TYPE_SELF 0x0
|
||||
#define VIRTIO_ADMIN_GROUP_TYPE_SRIOV 0x1
|
||||
|
||||
/* Transitional device admin command. */
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ EXPORT_SYMBOL_GPL(vhost_task_stop);
|
|||
* @arg: data to be passed to fn and handled_kill
|
||||
* @name: the thread's name
|
||||
*
|
||||
* This returns a specialized task for use by the vhost layer or NULL on
|
||||
* This returns a specialized task for use by the vhost layer or ERR_PTR() on
|
||||
* failure. The returned task is inactive, and the caller must fire it up
|
||||
* through vhost_task_start().
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user