1 Star 0 Fork 120

卫少坤/qemu_src

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
virtio-bugfix-add-rcu_read_lock-when-vring_avail_idx.patch 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
Jiabo Feng 提交于 2024-04-07 10:21 . QEMU update to version 8.2.0-5
From 7b4a9547e68147291e68258db9415ef5a20fe06b Mon Sep 17 00:00:00 2001
From: Jinhua Cao <caojinhua1@huawei.com>
Date: Thu, 10 Feb 2022 11:16:26 +0800
Subject: [PATCH] virtio: bugfix: add rcu_read_lock when vring_avail_idx is
called
viring_avail_idx should be called within rcu_read_lock(),
or may get NULL caches in vring_get_region_caches() and
trigger assert().
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
---
hw/virtio/virtio.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 27ceab92be..ec09d515c2 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2801,6 +2801,7 @@ static void check_vring_avail_num(VirtIODevice *vdev, int index)
{
uint16_t nheads;
+ rcu_read_lock();
/* Check it isn't doing strange things with descriptor numbers. */
nheads = vring_avail_idx(&vdev->vq[index]) - vdev->vq[index].last_avail_idx;
if (nheads > vdev->vq[index].vring.num) {
@@ -2811,6 +2812,7 @@ static void check_vring_avail_num(VirtIODevice *vdev, int index)
vring_avail_idx(&vdev->vq[index]),
vdev->vq[index].last_avail_idx, nheads);
}
+ rcu_read_unlock();
}
int virtio_save(VirtIODevice *vdev, QEMUFile *f)
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/weishaokun/qemu_src.git
git@gitee.com:weishaokun/qemu_src.git
weishaokun
qemu_src
qemu_src
master

搜索帮助