1 Star 0 Fork 121

lijian/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vdpa-Remove-shadow-CVQ-command-check.patch 2.95 KB
一键复制 编辑 原始数据 按行查看 历史
From 6cb9e17dcc07d6fc1467a585fb015991191a92da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
Date: Thu, 20 Oct 2022 10:02:30 +0200
Subject: [PATCH] vdpa: Remove shadow CVQ command check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: fangyi <eric.fangyi@huawei.com>
---
net/vhost-vdpa.c | 48 ------------------------------------------------
1 file changed, 48 deletions(-)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index f4f6b8587f..c8c433002d 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -469,48 +469,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.
*
@@ -534,16 +492,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.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jianli-97/qemu.git
git@gitee.com:jianli-97/qemu.git
jianli-97
qemu
qemu
master

搜索帮助