9 Star 0 Fork 38

src-anolis-os/qemu-kvm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1127-target-i386-csv-The-CSV2-guest-running-on-the-recipi.patch 2.99 KB
一键复制 编辑 原始数据 按行查看 历史
Xuchun Shang 提交于 2025-01-09 14:02 +08:00 . [Feature] Sync Patch form source repo
From 4b103bfc7b873bc070a6d714341f6b25b2d251c1 Mon Sep 17 00:00:00 2001
From: hanliyang <hanliyang@hygon.cn>
Date: Fri, 26 Apr 2024 21:17:35 +0800
Subject: [PATCH 3/4] target/i386/csv: The CSV2 guest running on the recipient
side is not resettable
Currently, both CSV2 guest running on the recipient side and CSV3
guest are not resettable. Provide a new global variable
kvm_csv_reset_inhibit to indicate the resettable state if the VM
is using CSV technologies.
Signed-off-by: hanliyang <hanliyang@hygon.cn>
---
target/i386/csv.c | 2 ++
target/i386/csv.h | 2 ++
target/i386/kvm/kvm.c | 4 +++-
target/i386/kvm/sev-stub.c | 2 ++
target/i386/sev.c | 3 +++
5 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/target/i386/csv.c b/target/i386/csv.c
index 770ea7d5bf..12e2cc16be 100644
--- a/target/i386/csv.c
+++ b/target/i386/csv.c
@@ -93,6 +93,8 @@ csv_init(uint32_t policy, int fd, void *state, struct sev_ops *ops)
qemu_mutex_init(&csv_guest.dma_map_regions_list_mutex);
csv_guest.sev_send_start = ops->sev_send_start;
csv_guest.sev_receive_start = ops->sev_receive_start;
+
+ kvm_csv_reset_inhibit = true;
}
return 0;
}
diff --git a/target/i386/csv.h b/target/i386/csv.h
index 485534d2d6..cc02ba83a4 100644
--- a/target/i386/csv.h
+++ b/target/i386/csv.h
@@ -18,6 +18,8 @@
#include "qemu/thread.h"
#include "qemu/queue.h"
+extern bool kvm_csv_reset_inhibit;
+
#ifdef CONFIG_SEV
#include "cpu.h"
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 469349420c..a14debcfc2 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -5383,7 +5383,9 @@ bool kvm_has_waitpkg(void)
bool kvm_arch_cpu_check_are_resettable(void)
{
- return !(sev_es_enabled() && !is_hygon_cpu()) && !csv_enabled();
+ if (is_hygon_cpu())
+ return !kvm_csv_reset_inhibit;
+ return !sev_es_enabled();
}
#define ARCH_REQ_XCOMP_GUEST_PERM 0x1025
diff --git a/target/i386/kvm/sev-stub.c b/target/i386/kvm/sev-stub.c
index 6080c007a2..0651502f1c 100644
--- a/target/i386/kvm/sev-stub.c
+++ b/target/i386/kvm/sev-stub.c
@@ -20,3 +20,5 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
/* If we get here, cgs must be some non-SEV thing */
return 0;
}
+
+bool kvm_csv_reset_inhibit;
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 484e6e7509..3f25d2b6d7 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -219,6 +219,7 @@ static struct ConfidentialGuestMemoryEncryptionOps sev_memory_encryption_ops = {
};
bool kvm_has_msr_ghcb;
+bool kvm_csv_reset_inhibit;
static int
sev_ioctl(int fd, int cmd, void *data, int *error)
@@ -1275,6 +1276,8 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
error_setg(errp, "%s: failed to create encryption context", __func__);
goto err;
}
+ } else if (is_hygon_cpu() && sev_es_enabled()) {
+ kvm_csv_reset_inhibit = true;
}
/* CSV guest needs no notifier to reg/unreg memory */
--
2.39.3
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/qemu-kvm.git
git@gitee.com:src-anolis-os/qemu-kvm.git
src-anolis-os
qemu-kvm
qemu-kvm
a8-virt-stream-an

搜索帮助

371d5123 14472233 46e8bd33 14472233