[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/45] i386/sev: Move sev_launch_update to separate class method
From: |
Paolo Bonzini |
Subject: |
[PULL 19/45] i386/sev: Move sev_launch_update to separate class method |
Date: |
Tue, 4 Jun 2024 08:43:43 +0200 |
From: Pankaj Gupta <pankaj.gupta@amd.com>
When sev-snp-guest objects are introduced there will be a number of
differences in how the launch data is handled compared to the existing
sev-guest object. Move sev_launch_start() to a class method to make it
easier to implement SNP-specific launch update functionality later.
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-6-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/sev.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 33e606eea00..b2aa0d6f99b 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -69,6 +69,8 @@ struct SevCommonState {
struct SevCommonStateClass {
X86ConfidentialGuestClass parent_class;
+ /* public */
+ int (*launch_start)(SevCommonState *sev_common);
};
/**
@@ -632,16 +634,16 @@ sev_read_file_base64(const char *filename, guchar **data,
gsize *len)
}
static int
-sev_launch_start(SevGuestState *sev_guest)
+sev_launch_start(SevCommonState *sev_common)
{
gsize sz;
int ret = 1;
int fw_error, rc;
+ SevGuestState *sev_guest = SEV_GUEST(sev_common);
struct kvm_sev_launch_start start = {
.handle = sev_guest->handle, .policy = sev_guest->policy
};
guchar *session = NULL, *dh_cert = NULL;
- SevCommonState *sev_common = SEV_COMMON(sev_guest);
if (sev_guest->session_file) {
if (sev_read_file_base64(sev_guest->session_file, &session, &sz) < 0) {
@@ -862,6 +864,7 @@ static int sev_kvm_init(ConfidentialGuestSupport *cgs,
Error **errp)
uint32_t ebx;
uint32_t host_cbitpos;
struct sev_user_data_status status = {};
+ SevCommonStateClass *klass = SEV_COMMON_GET_CLASS(cgs);
ret = ram_block_discard_disable(true);
if (ret) {
@@ -952,7 +955,7 @@ static int sev_kvm_init(ConfidentialGuestSupport *cgs,
Error **errp)
goto err;
}
- sev_launch_start(SEV_GUEST(sev_common));
+ ret = klass->launch_start(sev_common);
if (ret) {
error_setg(errp, "%s: failed to create encryption context", __func__);
goto err;
@@ -1451,6 +1454,10 @@ static void sev_guest_set_legacy_vm_type(Object *obj,
bool value, Error **errp)
static void
sev_guest_class_init(ObjectClass *oc, void *data)
{
+ SevCommonStateClass *klass = SEV_COMMON_CLASS(oc);
+
+ klass->launch_start = sev_launch_start;
+
object_class_property_add_str(oc, "dh-cert-file",
sev_guest_get_dh_cert_file,
sev_guest_set_dh_cert_file);
--
2.45.1
- [PULL 10/45] target/i386/tcg: Fix RDPID feature check, (continued)
- [PULL 10/45] target/i386/tcg: Fix RDPID feature check, Paolo Bonzini, 2024/06/04
- [PULL 12/45] update-linux-headers: fix forwarding to asm-generic headers, Paolo Bonzini, 2024/06/04
- [PULL 11/45] target/i386: fix xsave.flat from kvm-unit-tests, Paolo Bonzini, 2024/06/04
- [PULL 13/45] update-linux-headers: move pvpanic.h to correct directory, Paolo Bonzini, 2024/06/04
- [PULL 14/45] linux-headers: Update to current kvm/next, Paolo Bonzini, 2024/06/04
- [PULL 15/45] update-linux-headers: import linux/kvm_para.h header, Paolo Bonzini, 2024/06/04
- [PULL 16/45] machine: allow early use of machine_require_guest_memfd, Paolo Bonzini, 2024/06/04
- [PULL 17/45] i386/sev: Replace error_report with error_setg, Paolo Bonzini, 2024/06/04
- [PULL 18/45] i386/sev: Introduce "sev-common" type to encapsulate common SEV state, Paolo Bonzini, 2024/06/04
- [PULL 19/45] i386/sev: Move sev_launch_update to separate class method,
Paolo Bonzini <=
- [PULL 20/45] i386/sev: Move sev_launch_finish to separate class method, Paolo Bonzini, 2024/06/04
- [PULL 21/45] i386/sev: Introduce 'sev-snp-guest' object, Paolo Bonzini, 2024/06/04
- [PULL 22/45] i386/sev: Add a sev_snp_enabled() helper, Paolo Bonzini, 2024/06/04
- [PULL 23/45] i386/sev: Add sev_kvm_init() override for SEV class, Paolo Bonzini, 2024/06/04
- [PULL 24/45] i386/sev: Add snp_kvm_init() override for SNP class, Paolo Bonzini, 2024/06/04
- [PULL 27/45] i386/sev: Add a class method to determine KVM VM type for SNP guests, Paolo Bonzini, 2024/06/04
- [PULL 32/45] hw/i386/sev: Add function to get SEV metadata from OVMF header, Paolo Bonzini, 2024/06/04
- [PULL 41/45] i386/sev: Reorder struct declarations, Paolo Bonzini, 2024/06/04
- [PULL 30/45] i386/sev: Add handling to encrypt/finalize guest launch data, Paolo Bonzini, 2024/06/04