- 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>
121 lines
4.3 KiB
Diff
121 lines
4.3 KiB
Diff
From 0f85e3a486c2d0130cb3be322900aa839d77d4bd Mon Sep 17 00:00:00 2001
|
|
From: Brijesh Singh <brijesh.singh@amd.com>
|
|
Date: Tue, 27 Jul 2021 16:31:36 +0000
|
|
Subject: [PATCH] migration: add support to migrate shared regions list
|
|
|
|
cherry-picked from https://github.com/AMDESE/qemu/commit/9236f522e48b6.
|
|
|
|
When memory encryption is enabled, the hypervisor maintains a shared
|
|
regions list which is referred by hypervisor during migration to check
|
|
if page is private or shared. This list is built during the VM bootup and
|
|
must be migrated to the target host so that hypervisor on target host can
|
|
use it for future migration.
|
|
|
|
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
|
|
Co-developed-by: Ashish Kalra <ashish.kalra@amd.com>
|
|
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
|
|
[ Fix conflicts. ]
|
|
Signed-off-by: hanliyang <hanliyang@hygon.cn>
|
|
---
|
|
include/exec/confidential-guest-support.h | 2 +-
|
|
target/i386/sev.c | 45 +++++++++++++++++++++++
|
|
target/i386/sev.h | 2 +
|
|
3 files changed, 48 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/include/exec/confidential-guest-support.h b/include/exec/confidential-guest-support.h
|
|
index 343f686fc2..dd4887f65f 100644
|
|
--- a/include/exec/confidential-guest-support.h
|
|
+++ b/include/exec/confidential-guest-support.h
|
|
@@ -73,7 +73,7 @@ struct ConfidentialGuestMemoryEncryptionOps {
|
|
bool (*is_gfn_in_unshared_region)(unsigned long gfn);
|
|
|
|
/* Write the shared regions list */
|
|
- int (*save_outgoing_shared_regions_list)(QEMUFile *f);
|
|
+ int (*save_outgoing_shared_regions_list)(QEMUFile *f, uint64_t *bytes_sent);
|
|
|
|
/* Load the shared regions list */
|
|
int (*load_incoming_shared_regions_list)(QEMUFile *f);
|
|
diff --git a/target/i386/sev.c b/target/i386/sev.c
|
|
index 8525a7351f..92aedf0503 100644
|
|
--- a/target/i386/sev.c
|
|
+++ b/target/i386/sev.c
|
|
@@ -176,10 +176,15 @@ static const char *const sev_fw_errlist[] = {
|
|
|
|
#define SEV_FW_BLOB_MAX_SIZE 0x4000 /* 16KB */
|
|
|
|
+#define SHARED_REGION_LIST_CONT 0x1
|
|
+#define SHARED_REGION_LIST_END 0x2
|
|
+
|
|
static struct ConfidentialGuestMemoryEncryptionOps sev_memory_encryption_ops = {
|
|
.save_setup = sev_save_setup,
|
|
.save_outgoing_page = sev_save_outgoing_page,
|
|
.load_incoming_page = sev_load_incoming_page,
|
|
+ .save_outgoing_shared_regions_list = sev_save_outgoing_shared_regions_list,
|
|
+ .load_incoming_shared_regions_list = sev_load_incoming_shared_regions_list,
|
|
};
|
|
|
|
static int
|
|
@@ -1777,6 +1782,46 @@ int sev_add_shared_regions_list(unsigned long start, unsigned long end)
|
|
return 1;
|
|
}
|
|
|
|
+int sev_save_outgoing_shared_regions_list(QEMUFile *f, uint64_t *bytes_sent)
|
|
+{
|
|
+ SevGuestState *s = sev_guest;
|
|
+ struct shared_region *pos;
|
|
+
|
|
+ QTAILQ_FOREACH(pos, &s->shared_regions_list, list) {
|
|
+ qemu_put_be32(f, SHARED_REGION_LIST_CONT);
|
|
+ qemu_put_be32(f, pos->gfn_start);
|
|
+ qemu_put_be32(f, pos->gfn_end);
|
|
+ *bytes_sent += 12;
|
|
+ }
|
|
+
|
|
+ qemu_put_be32(f, SHARED_REGION_LIST_END);
|
|
+ *bytes_sent += 4;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int sev_load_incoming_shared_regions_list(QEMUFile *f)
|
|
+{
|
|
+ SevGuestState *s = sev_guest;
|
|
+ struct shared_region *shrd_region;
|
|
+ int status;
|
|
+
|
|
+ status = qemu_get_be32(f);
|
|
+ while (status == SHARED_REGION_LIST_CONT) {
|
|
+
|
|
+ shrd_region = g_malloc0(sizeof(*shrd_region));
|
|
+ if (!shrd_region) {
|
|
+ return 0;
|
|
+ }
|
|
+ shrd_region->gfn_start = qemu_get_be32(f);
|
|
+ shrd_region->gfn_end = qemu_get_be32(f);
|
|
+
|
|
+ QTAILQ_INSERT_TAIL(&s->shared_regions_list, shrd_region, list);
|
|
+
|
|
+ status = qemu_get_be32(f);
|
|
+ }
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static const QemuUUID sev_hash_table_header_guid = {
|
|
.data = UUID_LE(0x9438d606, 0x4f22, 0x4cc9, 0xb4, 0x79, 0xa7, 0x93,
|
|
0xd4, 0x11, 0xfd, 0x21)
|
|
diff --git a/target/i386/sev.h b/target/i386/sev.h
|
|
index acf69d4e6f..5b4231c859 100644
|
|
--- a/target/i386/sev.h
|
|
+++ b/target/i386/sev.h
|
|
@@ -64,6 +64,8 @@ void sev_es_set_reset_vector(CPUState *cpu);
|
|
int sev_remove_shared_regions_list(unsigned long gfn_start,
|
|
unsigned long gfn_end);
|
|
int sev_add_shared_regions_list(unsigned long gfn_start, unsigned long gfn_end);
|
|
+int sev_save_outgoing_shared_regions_list(QEMUFile *f, uint64_t *bytes_sent);
|
|
+int sev_load_incoming_shared_regions_list(QEMUFile *f);
|
|
|
|
int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp);
|
|
|
|
--
|
|
2.41.0.windows.1
|
|
|