From: "Eugenio Pérez" <eperezma@redhat.com>
To: qemu-devel@nongnu.org
Cc: Si-Wei Liu <si-wei.liu@oracle.com>,
Laurent Vivier <lvivier@redhat.com>, Eli Cohen <eli@mellanox.com>,
Gautam Dawar <gdawar@xilinx.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Zhu Lingshan <lingshan.zhu@intel.com>,
Harpreet Singh Anand <hanand@xilinx.com>,
Liuxiangdong <liuxiangdong5@huawei.com>,
Cindy Lu <lulu@redhat.com>, Parav Pandit <parav@mellanox.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Jason Wang <jasowang@redhat.com>
Subject: [RFC PATCH 2/5] vdpa: Remove shadow CVQ command check
Date: Tue, 18 Oct 2022 17:53:18 +0200 [thread overview]
Message-ID: <20221018155321.145135-3-eperezma@redhat.com> (raw)
In-Reply-To: <20221018155321.145135-1-eperezma@redhat.com>
The guest will see undefined behavior if it issue not negotiate
commands, bit it is expected somehow.
Simplify code deleting this check.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
net/vhost-vdpa.c | 48 ------------------------------------------------
1 file changed, 48 deletions(-)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 787e34ed99..19d4dbe94a 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -462,48 +462,6 @@ static NetClientInfo net_vhost_vdpa_cvq_info = {
.check_peer_type = vhost_vdpa_check_peer_type,
};
-/**
- * Do not forward commands not supported by SVQ. Otherwise, the device could
- * accept it and qemu would not know how to update the device model.
- */
-static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len)
-{
- struct virtio_net_ctrl_hdr ctrl;
-
- if (unlikely(len < sizeof(ctrl))) {
- qemu_log_mask(LOG_GUEST_ERROR,
- "%s: invalid legnth of out buffer %zu\n", __func__, len);
- return false;
- }
-
- memcpy(&ctrl, out_buf, sizeof(ctrl));
- switch (ctrl.class) {
- case VIRTIO_NET_CTRL_MAC:
- switch (ctrl.cmd) {
- case VIRTIO_NET_CTRL_MAC_ADDR_SET:
- return true;
- default:
- qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mac cmd %u\n",
- __func__, ctrl.cmd);
- };
- break;
- case VIRTIO_NET_CTRL_MQ:
- switch (ctrl.cmd) {
- case VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET:
- return true;
- default:
- qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mq cmd %u\n",
- __func__, ctrl.cmd);
- };
- break;
- default:
- qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid control class %u\n",
- __func__, ctrl.class);
- };
-
- return false;
-}
-
/**
* Validate and copy control virtqueue commands.
*
@@ -527,16 +485,10 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
.iov_len = sizeof(status),
};
ssize_t dev_written = -EINVAL;
- bool ok;
out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0,
s->cvq_cmd_out_buffer,
vhost_vdpa_net_cvq_cmd_len());
- ok = vhost_vdpa_net_cvq_validate_cmd(s->cvq_cmd_out_buffer, out.iov_len);
- if (unlikely(!ok)) {
- goto out;
- }
-
dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
if (unlikely(dev_written < 0)) {
goto out;
--
2.31.1
next prev parent reply other threads:[~2022-10-18 16:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 15:53 [RFC PATCH 0/5] Guest announce feature emulation using Shadow VirtQueue Eugenio Pérez
2022-10-18 15:53 ` [RFC PATCH 1/5] vdpa: Save emulated features list in vhost_vdpa Eugenio Pérez
2022-10-18 15:53 ` Eugenio Pérez [this message]
2022-10-18 15:53 ` [RFC PATCH 3/5] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail Eugenio Pérez
2022-10-18 15:53 ` [RFC PATCH 4/5] vhost_net: return VIRTIO_NET_S_ANNOUNCE is device model has it set Eugenio Pérez
2022-10-18 15:53 ` [RFC PATCH 5/5] vdpa: Offer VIRTIO_NET_F_GUEST_ANNOUNCE feature if SVQ is enabled Eugenio Pérez
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=20221018155321.145135-3-eperezma@redhat.com \
--to=eperezma@redhat.com \
--cc=eli@mellanox.com \
--cc=gdawar@xilinx.com \
--cc=hanand@xilinx.com \
--cc=jasowang@redhat.com \
--cc=lingshan.zhu@intel.com \
--cc=liuxiangdong5@huawei.com \
--cc=lulu@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=parav@mellanox.com \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=si-wei.liu@oracle.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).