qemu/target-i386-csv-add-support-to-load-incoming-encrypt.patch
Jiabo Feng 4f059b938c 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:23:53 +08:00

108 lines
3.8 KiB
Diff

From cb5c1c9c70110639eda0ff50c8dfcf24b0be561d Mon Sep 17 00:00:00 2001
From: fangbaoshun <fangbaoshun@hygon.cn>
Date: Mon, 2 Aug 2021 14:11:43 +0800
Subject: [PATCH] target/i386: csv: add support to load incoming encrypted
pages queued in the CMD list
The csv_load_queued_incoming_pages() provide the implementation to read the
incoming guest private pages from the socket queued in the CMD list and load
them into the guest memory. The routines uses the RECEIVE_START command to
create the incoming encryption context on the first call then uses the
COMMAND_BATCH carried with RECEIEVE_UPDATE_DATA commands to load the encrypted
pages into the guest memory. After migration is completed, we issue the
RECEIVE_FINISH command to transition the SEV guest to the runnable state
so that it can be executed.
Signed-off-by: hanliyang <hanliyang@hygon.cn>
---
include/exec/confidential-guest-support.h | 3 +++
target/i386/csv.h | 1 +
target/i386/sev.c | 32 +++++++++++++++++++++++
3 files changed, 36 insertions(+)
diff --git a/include/exec/confidential-guest-support.h b/include/exec/confidential-guest-support.h
index 101cc5220a..cb14b815cb 100644
--- a/include/exec/confidential-guest-support.h
+++ b/include/exec/confidential-guest-support.h
@@ -87,6 +87,9 @@ struct ConfidentialGuestMemoryEncryptionOps {
/* Queue the incoming encrypted page into a list */
int (*queue_incoming_page)(QEMUFile *f, uint8_t *ptr);
+
+ /* Load the incoming encrypted pages queued in list into guest memory */
+ int (*load_queued_incoming_pages)(QEMUFile *f);
};
typedef struct ConfidentialGuestSupportClass {
diff --git a/target/i386/csv.h b/target/i386/csv.h
index d1bcc8bc16..977f08b982 100644
--- a/target/i386/csv.h
+++ b/target/i386/csv.h
@@ -56,5 +56,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);
+int csv_load_queued_incoming_pages(QEMUFile *f);
#endif
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 606aaad328..2dee46d852 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -193,6 +193,7 @@ static struct ConfidentialGuestMemoryEncryptionOps sev_memory_encryption_ops = {
.queue_outgoing_page = csv_queue_outgoing_page,
.save_queued_outgoing_pages = csv_save_queued_outgoing_pages,
.queue_incoming_page = csv_queue_incoming_page,
+ .load_queued_incoming_pages = csv_load_queued_incoming_pages,
};
static int
@@ -2146,6 +2147,24 @@ err:
return ret;
}
+static int
+csv_receive_update_data_batch(SevGuestState *s)
+{
+ int ret;
+ int fw_error;
+
+ ret = csv_command_batch(KVM_SEV_RECEIVE_UPDATE_DATA,
+ (uint64_t)s->csv_batch_cmd_list->head, &fw_error);
+ if (ret) {
+ error_report("%s: csv_command_batch ret=%d fw_error=%d '%s'",
+ __func__, ret, fw_error, fw_error_to_str(fw_error));
+ }
+
+ csv_batch_cmd_list_destroy(s->csv_batch_cmd_list);
+ s->csv_batch_cmd_list = NULL;
+ return ret;
+}
+
int
csv_queue_outgoing_page(uint8_t *ptr, uint32_t sz, uint64_t addr)
{
@@ -2206,6 +2225,19 @@ csv_save_queued_outgoing_pages(QEMUFile *f, uint64_t *bytes_sent)
return csv_send_update_data_batch(s, f, bytes_sent);
}
+int csv_load_queued_incoming_pages(QEMUFile *f)
+{
+ SevGuestState *s = sev_guest;
+
+ /* Only support for HYGON CSV */
+ if (!is_hygon_cpu()) {
+ error_report("Only support load queued pages for HYGON CSV");
+ return -EINVAL;
+ }
+
+ return csv_receive_update_data_batch(s);
+}
+
static const QemuUUID sev_hash_table_header_guid = {
.data = UUID_LE(0x9438d606, 0x4f22, 0x4cc9, 0xb4, 0x79, 0xa7, 0x93,
0xd4, 0x11, 0xfd, 0x21)
--
2.41.0.windows.1