qemu/target-i386-sev-Clear-shared_regions_list-when-reboo.patch

58 lines
1.9 KiB
Diff
Raw Permalink Normal View History

QEMU update to version 8.2.0-18: - hw/loongarch/virt: Fix FDT memory node address width - hw/loongarch: Fix fdt memory node wrong 'reg' - load_elf: fix iterator's type for elf file processing - migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion `!qemu_in_… - target/i386: no single-step exception after MOV or POP SS - char-stdio: Restore blocking mode of stdout on exit - backends/cryptodev-builtin: Fix local_error leaks - target/loongarch: fix a wrong print in cpu dump - virtio-pci: fix use of a released vector - target/arm: Disable SVE extensions when SVE is disabled - hw/misc/bcm2835_property: Fix handling of FRAMEBUFFER_SET_PALETTE - target/i386: Introduce SapphireRapids-v3 to add missing features - virtio-net: Ensure queue index fits with RSS (CVE-2024-6505) - nbd/server: CVE-2024-7409: Avoid use-after-free when closing server - update io/trace-events. Parameters should remain consistent. - update docs/tools/virtfs-proxy-helper.rst. This place is spelled wrong. - kvm: Add support for CSV2 reboot - target/i386/kvm: Fix the resettable info when emulate Hygon CSV2 guest - target/i386: get/set/migrate GHCB state - target/i386: csv: Add support for migrate VMSA for CSV2 guest - migration/ram: Accelerate the loading of CSV guest's encrypted pages - migration/ram: Accelerate the transmission of CSV guest's encrypted pages - target/i386: csv: add support to load incoming encrypted pages queued in the CMD list - target/i386: csv: add support to queue the incoming page into a list - target/i386: csv: add support to encrypt the outgoing pages in the list queued before. - target/i386: csv: add support to queue the outgoing page into a list - target/i386: csv: Read cert chain from file when prepared for CSV live migration - target/i386: Introduce header file csv.h - migration/ram: Fix calculation of gfn correpond to a page in ramblock - target/i386: sev: Clear shared_regions_list when reboot CSV Guest - migration/ram: Force encrypted status for VGA vram - target/i386: sev: Return 0 if sev_send_get_packet_len() fails - kvm: Add support for userspace MSR filtering and handling of MSR_KVM_MIGRATION_CONTROL. - migration/ram: Force encrypted status for flash0 & flash1 devices. - migration/ram: add support to send encrypted pages - migration: add support to migrate shared regions list - kvm: Add support for SEV shared regions list and KVM_EXIT_HYPERCALL. - target/i386: sev: add support to load incoming encrypted page - target/i386: sev: add support to encrypt the outgoing page - target/i386: sev: do not create launch context for an incoming guest - target/i386: sev: provide callback to setup outgoing context - confidential guest support: introduce ConfidentialGuestMemoryEncryptionOps for encrypted VMs - migration.json: add AMD SEV specific migration parameters - doc: update AMD SEV to include Live migration flow - crypto/tlscredspsk: Free username on finalize - hw/nvme: fix leak of uninitialized memory in io_mgmt_recv - hw/display/vhost-user-gpu.c: fix vhost_user_gpu_chr_read() - cvm : Implement command blacklist for cvm security enhancement - crypto: Introduce SM3 hash hmac pbkdf algorithm - virtio-net: Use virtual time for RSC timers - vvfat: Fix bug in writing to middle of file - hw/core/ptimer: fix timer zero period condition for freq > 1GHz - hw/misc: support vpsp Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
2024-09-18 15:20:53 +08:00
From e98147762cb47645c590ee000dbc12c654a6cc2d Mon Sep 17 00:00:00 2001
From: hanliyang <hanliyang@hygon.cn>
Date: Sun, 16 Jan 2022 19:57:58 -0500
Subject: [PATCH] target/i386: sev: Clear shared_regions_list when reboot CSV
Guest
Also fix memory leak in sev_remove_shared_regions_list().
Signed-off-by: hanliyang <hanliyang@hygon.cn>
---
target/i386/kvm/kvm.c | 5 +++++
target/i386/sev.c | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index a5a755db01..5730d0e0c0 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2270,6 +2270,11 @@ void kvm_arch_reset_vcpu(X86CPU *cpu)
env->mp_state = KVM_MP_STATE_RUNNABLE;
}
+ if (cpu_is_bsp(cpu) &&
+ sev_enabled() && has_map_gpa_range) {
+ sev_remove_shared_regions_list(0, -1);
+ }
+
/* enabled by default */
env->poll_control_msr = 1;
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 6ccb22c00a..0b0f589aee 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -1694,9 +1694,9 @@ int sev_load_incoming_page(QEMUFile *f, uint8_t *ptr)
int sev_remove_shared_regions_list(unsigned long start, unsigned long end)
{
SevGuestState *s = sev_guest;
- struct shared_region *pos;
+ struct shared_region *pos, *next_pos;
- QTAILQ_FOREACH(pos, &s->shared_regions_list, list) {
+ QTAILQ_FOREACH_SAFE(pos, &s->shared_regions_list, list, next_pos) {
unsigned long l, r;
unsigned long curr_gfn_end = pos->gfn_end;
@@ -1710,6 +1710,7 @@ int sev_remove_shared_regions_list(unsigned long start, unsigned long end)
if (l <= r) {
if (pos->gfn_start == l && pos->gfn_end == r) {
QTAILQ_REMOVE(&s->shared_regions_list, pos, list);
+ g_free(pos);
} else if (l == pos->gfn_start) {
pos->gfn_start = r;
} else if (r == pos->gfn_end) {
--
2.41.0.windows.1