- 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>
171 lines
5.6 KiB
Diff
171 lines
5.6 KiB
Diff
From 8125145bcd3b8348e69686e26f482cf16b16ec98 Mon Sep 17 00:00:00 2001
|
|
From: fangbaoshun <fangbaoshun@hygon.cn>
|
|
Date: Mon, 2 Aug 2021 13:49:48 +0800
|
|
Subject: [PATCH] target/i386: csv: add support to queue the incoming page into
|
|
a list
|
|
|
|
The csv_queue_incoming_page() provide the implementation to queue the
|
|
guest private pages during transmission. The routines queues the incoming
|
|
socket which contains the guest private pages into a list then uses the
|
|
COMMAND_BATCH command to load the encrypted pages into the guest memory.
|
|
|
|
Signed-off-by: hanliyang <hanliyang@hygon.cn>
|
|
---
|
|
include/exec/confidential-guest-support.h | 3 +
|
|
target/i386/csv.h | 1 +
|
|
target/i386/sev.c | 92 +++++++++++++++++++++++
|
|
3 files changed, 96 insertions(+)
|
|
|
|
diff --git a/include/exec/confidential-guest-support.h b/include/exec/confidential-guest-support.h
|
|
index c84f8c1efc..101cc5220a 100644
|
|
--- a/include/exec/confidential-guest-support.h
|
|
+++ b/include/exec/confidential-guest-support.h
|
|
@@ -84,6 +84,9 @@ struct ConfidentialGuestMemoryEncryptionOps {
|
|
/* Write the list queued with encrypted pages and metadata associated
|
|
* with them */
|
|
int (*save_queued_outgoing_pages)(QEMUFile *f, uint64_t *bytes_sent);
|
|
+
|
|
+ /* Queue the incoming encrypted page into a list */
|
|
+ int (*queue_incoming_page)(QEMUFile *f, uint8_t *ptr);
|
|
};
|
|
|
|
typedef struct ConfidentialGuestSupportClass {
|
|
diff --git a/target/i386/csv.h b/target/i386/csv.h
|
|
index 2a3a3119d9..d1bcc8bc16 100644
|
|
--- a/target/i386/csv.h
|
|
+++ b/target/i386/csv.h
|
|
@@ -55,5 +55,6 @@ struct CsvBatchCmdList {
|
|
|
|
int csv_queue_outgoing_page(uint8_t *ptr, uint32_t sz, uint64_t addr);
|
|
int csv_save_queued_outgoing_pages(QEMUFile *f, uint64_t *bytes_sent);
|
|
+int csv_queue_incoming_page(QEMUFile *f, uint8_t *ptr);
|
|
|
|
#endif
|
|
diff --git a/target/i386/sev.c b/target/i386/sev.c
|
|
index 1e2bbafe36..606aaad328 100644
|
|
--- a/target/i386/sev.c
|
|
+++ b/target/i386/sev.c
|
|
@@ -192,6 +192,7 @@ static struct ConfidentialGuestMemoryEncryptionOps sev_memory_encryption_ops = {
|
|
.load_incoming_shared_regions_list = sev_load_incoming_shared_regions_list,
|
|
.queue_outgoing_page = csv_queue_outgoing_page,
|
|
.save_queued_outgoing_pages = csv_save_queued_outgoing_pages,
|
|
+ .queue_incoming_page = csv_queue_incoming_page,
|
|
};
|
|
|
|
static int
|
|
@@ -1941,6 +1942,15 @@ static void send_update_data_free(void *data)
|
|
g_free(update);
|
|
}
|
|
|
|
+static void receive_update_data_free(void *data)
|
|
+{
|
|
+ struct kvm_sev_receive_update_data *update =
|
|
+ (struct kvm_sev_receive_update_data *)data;
|
|
+ g_free((guchar *)update->hdr_uaddr);
|
|
+ g_free((guchar *)update->trans_uaddr);
|
|
+ g_free(update);
|
|
+}
|
|
+
|
|
static int
|
|
csv_send_queue_data(SevGuestState *s, uint8_t *ptr,
|
|
uint32_t size, uint64_t addr)
|
|
@@ -2013,6 +2023,66 @@ err:
|
|
return ret;
|
|
}
|
|
|
|
+static int
|
|
+csv_receive_queue_data(SevGuestState *s, QEMUFile *f, uint8_t *ptr)
|
|
+{
|
|
+ int ret = 0;
|
|
+ gchar *hdr = NULL, *trans = NULL;
|
|
+ struct kvm_sev_receive_update_data *update;
|
|
+ struct kvm_csv_batch_list_node *new_node = NULL;
|
|
+
|
|
+ update = g_new0(struct kvm_sev_receive_update_data, 1);
|
|
+ /* get packet header */
|
|
+ update->hdr_len = qemu_get_be32(f);
|
|
+ hdr = g_new(gchar, update->hdr_len);
|
|
+ qemu_get_buffer(f, (uint8_t *)hdr, update->hdr_len);
|
|
+ update->hdr_uaddr = (unsigned long)hdr;
|
|
+
|
|
+ /* get transport buffer */
|
|
+ update->trans_len = qemu_get_be32(f);
|
|
+ trans = g_new(gchar, update->trans_len);
|
|
+ update->trans_uaddr = (unsigned long)trans;
|
|
+ qemu_get_buffer(f, (uint8_t *)update->trans_uaddr, update->trans_len);
|
|
+
|
|
+ /* set guest address,guest len is page_size */
|
|
+ update->guest_uaddr = (uint64_t)ptr;
|
|
+ update->guest_len = TARGET_PAGE_SIZE;
|
|
+
|
|
+ new_node = csv_batch_cmd_list_node_create((uint64_t)update, 0);
|
|
+ if (!new_node) {
|
|
+ ret = -ENOMEM;
|
|
+ goto err;
|
|
+ }
|
|
+
|
|
+ if (s->csv_batch_cmd_list == NULL) {
|
|
+ s->csv_batch_cmd_list = csv_batch_cmd_list_create(new_node,
|
|
+ receive_update_data_free);
|
|
+ if (s->csv_batch_cmd_list == NULL) {
|
|
+ ret = -ENOMEM;
|
|
+ goto err;
|
|
+ }
|
|
+ } else {
|
|
+ /* Add new_node's command address to the last_node */
|
|
+ csv_batch_cmd_list_add_after(s->csv_batch_cmd_list, new_node);
|
|
+ }
|
|
+
|
|
+ trace_kvm_sev_receive_update_data(trans, (void *)ptr, update->guest_len,
|
|
+ (void *)hdr, update->hdr_len);
|
|
+
|
|
+ return ret;
|
|
+
|
|
+err:
|
|
+ g_free(trans);
|
|
+ g_free(update);
|
|
+ g_free(hdr);
|
|
+ g_free(new_node);
|
|
+ if (s->csv_batch_cmd_list) {
|
|
+ csv_batch_cmd_list_destroy(s->csv_batch_cmd_list);
|
|
+ s->csv_batch_cmd_list = NULL;
|
|
+ }
|
|
+ return ret;
|
|
+}
|
|
+
|
|
static int
|
|
csv_command_batch(uint32_t cmd_id, uint64_t head_uaddr, int *fw_err)
|
|
{
|
|
@@ -2090,6 +2160,28 @@ csv_queue_outgoing_page(uint8_t *ptr, uint32_t sz, uint64_t addr)
|
|
return csv_send_queue_data(s, ptr, sz, addr);
|
|
}
|
|
|
|
+int csv_queue_incoming_page(QEMUFile *f, uint8_t *ptr)
|
|
+{
|
|
+ SevGuestState *s = sev_guest;
|
|
+
|
|
+ /* Only support for HYGON CSV */
|
|
+ if (!is_hygon_cpu()) {
|
|
+ error_report("Only support enqueue received pages for HYGON CSV");
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ /*
|
|
+ * If this is first buffer and SEV is not in recieiving state then
|
|
+ * use RECEIVE_START command to create a encryption context.
|
|
+ */
|
|
+ if (!sev_check_state(s, SEV_STATE_RECEIVE_UPDATE) &&
|
|
+ sev_receive_start(s, f)) {
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
+ return csv_receive_queue_data(s, f, ptr);
|
|
+}
|
|
+
|
|
int
|
|
csv_save_queued_outgoing_pages(QEMUFile *f, uint64_t *bytes_sent)
|
|
{
|
|
--
|
|
2.41.0.windows.1
|
|
|