qemu/target-i386-csv-Add-CSV3-context.patch
Jiabo Feng dddaf7aa9e QEMU update to version 8.2.0-26:
- vdpa-dev: Fix initialisation order to restore VDUSE compatibility
- tcg: Allow top bit of SIMD_DATA_BITS to be set in simd_desc()
- migration: fix-possible-int-overflow
- target/m68k: Map FPU exceptions to FPSR register
- qemu-options: Fix CXL Fixed Memory Window interleave-granularity typo
- hvf: arm: Fix encodings for ID_AA64PFR1_EL1 and debug System registers
- hw/intc/arm_gic: Fix handling of NS view of GICC_APR<n>
- qio: Inherit follow_coroutine_ctx across TLS
- target/riscv: Fix the element agnostic function problem
- accel/tcg: Fix typo causing tb->page_addr[1] to not be recorded
- tcg/loongarch64: Fix tcg_out_movi vs some pcrel pointers
- migration: Fix file migration with fdset
- ui/vnc: don't return an empty SASL mechlist to the client
- target/arm: Fix FJCVTZS vs flush-to-zero
- hw/ppc/e500: Prefer QOM cast
- sphinx/qapidoc: Fix to generate doc for explicit, unboxed arguments
- hw/ppc/e500: Remove unused "irqs" parameter
- hw/ppc/e500: Add missing device tree properties to i2c controller node
- hw/i386/amd_iommu: Don't leak memory in amdvi_update_iotlb()
- hw/arm/mps2-tz.c: fix RX/TX interrupts order
- target/i386: csv: Add support to migrate the incoming context for CSV3 guest
- target/i386: csv: Add support to migrate the outgoing context for CSV3 guest
- target/i386: csv: Add support to migrate the incoming page for CSV3 guest
- target/i386: csv: Add support to migrate the outgoing page for CSV3 guest
- linux-headers: update kernel headers to include CSV3 migration cmds
- vfio: Only map shared region for CSV3 virtual machine
- vga: Force full update for CSV3 guest
- target/i386: csv: Load initial image to private memory for CSV3 guest
- target/i386: csv: Do not register/unregister guest secure memory for CSV3 guest
- target/i386: cpu: Populate CPUID 0x8000_001F when CSV3 is active
- target/i386: csv: Add command to load vmcb to CSV3 guest memory
- target/i386: csv: Add command to load data to CSV3 guest memory
- target/i386: csv: Add command to initialize CSV3 context
- target/i386: csv: Add CSV3 context
- next-kbd: convert to use qemu_input_handler_register()
- qemu/bswap: Undefine CPU_CONVERT() once done
- exec/memop: Remove unused memop_big_endian() helper
- hw/nvme: fix handling of over-committed queues
- 9pfs: fix crash on 'Treaddir' request
- hw/misc/psp: Pin the hugepage memory specified by mem2 during use for psp
- hw/misc: support tkm use mem2 memory
- hw/i386: add mem2 option for qemu
- kvm: add support for guest physical bits
- target/i386: add guest-phys-bits cpu property

Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
(cherry picked from commit f45f35e88509a4ffa9f62332ee9601e9fe1f8d09)
2024-12-12 17:39:01 +08:00

86 lines
2.0 KiB
Diff

From 54648e0e5a45acf2e472430ee83bb8dfa057fb30 Mon Sep 17 00:00:00 2001
From: jiangxin <jiangxin@hygon.cn>
Date: Tue, 24 Aug 2021 14:57:28 +0800
Subject: [PATCH] target/i386: csv: Add CSV3 context
CSV/CSV2/CSV3 are the secure virtualization features on Hygon CPUs.
The CSV and CSV2 are compatible with the AMD SEV and SEV-ES,
respectively. From CSV3, we introduced more secure features to
protect the guest, users can bit 6 of the guest policy to run a
CSV3 guest.
Add the context and the build option.
Signed-off-by: Xin Jiang <jiangxin@hygon.cn>
Signed-off-by: hanliyang <hanliyang@hygon.cn>
---
target/i386/csv.c | 11 +++++++++++
target/i386/csv.h | 17 +++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/target/i386/csv.c b/target/i386/csv.c
index 88fb05ac37..9a1de04db7 100644
--- a/target/i386/csv.c
+++ b/target/i386/csv.c
@@ -18,3 +18,14 @@
#include "csv.h"
bool csv_kvm_cpu_reset_inhibit;
+
+Csv3GuestState csv3_guest = { 0 };
+
+bool
+csv3_enabled(void)
+{
+ if (!is_hygon_cpu())
+ return false;
+
+ return sev_es_enabled() && (csv3_guest.policy & GUEST_POLICY_CSV3_BIT);
+}
diff --git a/target/i386/csv.h b/target/i386/csv.h
index 05e7fd8dc1..ea87c1ba27 100644
--- a/target/i386/csv.h
+++ b/target/i386/csv.h
@@ -14,6 +14,9 @@
#ifndef I386_CSV_H
#define I386_CSV_H
+#include "qapi/qapi-commands-misc-target.h"
+
+#define GUEST_POLICY_CSV3_BIT (1 << 6)
#define GUEST_POLICY_REUSE_ASID (1 << 7)
#ifdef CONFIG_CSV
@@ -40,9 +43,12 @@ static bool __attribute__((unused)) is_hygon_cpu(void)
return false;
}
+bool csv3_enabled(void);
+
#else
#define is_hygon_cpu() (false)
+#define csv3_enabled() (false)
#endif
@@ -66,4 +72,15 @@ int csv_load_queued_incoming_pages(QEMUFile *f);
int csv_save_outgoing_cpu_state(QEMUFile *f, uint64_t *bytes_sent);
int csv_load_incoming_cpu_state(QEMUFile *f);
+/* CSV3 */
+struct Csv3GuestState {
+ uint32_t policy;
+ int sev_fd;
+ void *state;
+};
+
+typedef struct Csv3GuestState Csv3GuestState;
+
+extern struct Csv3GuestState csv3_guest;
+
#endif
--
2.41.0.windows.1