1 Star 0 Fork 121

liyunfei/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Revert-vfio-Introduce-hostwin_from_range-helper.patch 2.84 KB
一键复制 编辑 原始数据 按行查看 历史
yezengruan 提交于 2022-11-22 17:45 . Qemu update to version 6.2.0-59
From 66fce3f7e9754345cf53afe3efd1b5bb5e322399 Mon Sep 17 00:00:00 2001
From: Kunkun Jiang <jiangkunkun@huawei.com>
Date: Fri, 18 Nov 2022 15:22:46 +0800
Subject: [PATCH 25/36] Revert "vfio: Introduce hostwin_from_range helper"
This reverts commit 85232739b4852f1a51dde58c9007ed0deb17c2f2.
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
---
hw/vfio/common.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index d358789f19..d7533637c9 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -909,19 +909,6 @@ static void vfio_unregister_ram_discard_listener(VFIOContainer *container,
g_free(vrdl);
}
-static VFIOHostDMAWindow *
-hostwin_from_range(VFIOContainer *container, hwaddr iova, hwaddr end)
-{
- VFIOHostDMAWindow *hostwin;
-
- QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
- if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
- return hostwin;
- }
- }
- return NULL;
-}
-
static void vfio_listener_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -931,6 +918,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
void *vaddr;
int ret;
VFIOHostDMAWindow *hostwin;
+ bool hostwin_found;
Error *err = NULL;
if (vfio_listener_skipped_section(section)) {
@@ -1023,8 +1011,15 @@ static void vfio_listener_region_add(MemoryListener *listener,
#endif
}
- hostwin = hostwin_from_range(container, iova, end);
- if (!hostwin) {
+ hostwin_found = false;
+ QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
+ if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
+ hostwin_found = true;
+ break;
+ }
+ }
+
+ if (!hostwin_found) {
error_setg(&err, "Container %p can't map guest IOVA region"
" 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx, container, iova, end);
goto fail;
@@ -1216,9 +1211,16 @@ static void vfio_listener_region_del(MemoryListener *listener,
if (memory_region_is_ram_device(section->mr)) {
hwaddr pgmask;
- VFIOHostDMAWindow *hostwin = hostwin_from_range(container, iova, end);
+ VFIOHostDMAWindow *hostwin;
+ bool hostwin_found = false;
- assert(hostwin); /* or region_add() would have failed */
+ QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
+ if (hostwin->min_iova <= iova && end <= hostwin->max_iova) {
+ hostwin_found = true;
+ break;
+ }
+ }
+ assert(hostwin_found); /* or region_add() would have failed */
pgmask = (1ULL << ctz64(hostwin->iova_pgsizes)) - 1;
try_unmap = !((iova & pgmask) || (int128_get64(llsize) & pgmask));
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liyunfei33/qemu.git
git@gitee.com:liyunfei33/qemu.git
liyunfei33
qemu
qemu
master

搜索帮助