target/i386/sev: Use local variable for kvm_sev_launch_start
The struct kvm_sev_launch_start has a constant and small size, and therefore we can use a regular local variable for it instead of allocating and freeing heap memory for it. Signed-off-by: Dov Murik <dovmurik@linux.ibm.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20211011173026.2454294-2-dovmurik@linux.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
6952026120
commit
eb8257a261
@ -647,31 +647,29 @@ sev_launch_start(SevGuestState *sev)
|
|||||||
gsize sz;
|
gsize sz;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
int fw_error, rc;
|
int fw_error, rc;
|
||||||
struct kvm_sev_launch_start *start;
|
struct kvm_sev_launch_start start = {
|
||||||
|
.handle = sev->handle, .policy = sev->policy
|
||||||
|
};
|
||||||
guchar *session = NULL, *dh_cert = NULL;
|
guchar *session = NULL, *dh_cert = NULL;
|
||||||
|
|
||||||
start = g_new0(struct kvm_sev_launch_start, 1);
|
|
||||||
|
|
||||||
start->handle = sev->handle;
|
|
||||||
start->policy = sev->policy;
|
|
||||||
if (sev->session_file) {
|
if (sev->session_file) {
|
||||||
if (sev_read_file_base64(sev->session_file, &session, &sz) < 0) {
|
if (sev_read_file_base64(sev->session_file, &session, &sz) < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
start->session_uaddr = (unsigned long)session;
|
start.session_uaddr = (unsigned long)session;
|
||||||
start->session_len = sz;
|
start.session_len = sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sev->dh_cert_file) {
|
if (sev->dh_cert_file) {
|
||||||
if (sev_read_file_base64(sev->dh_cert_file, &dh_cert, &sz) < 0) {
|
if (sev_read_file_base64(sev->dh_cert_file, &dh_cert, &sz) < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
start->dh_uaddr = (unsigned long)dh_cert;
|
start.dh_uaddr = (unsigned long)dh_cert;
|
||||||
start->dh_len = sz;
|
start.dh_len = sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_kvm_sev_launch_start(start->policy, session, dh_cert);
|
trace_kvm_sev_launch_start(start.policy, session, dh_cert);
|
||||||
rc = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_START, start, &fw_error);
|
rc = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_START, &start, &fw_error);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
error_report("%s: LAUNCH_START ret=%d fw_error=%d '%s'",
|
error_report("%s: LAUNCH_START ret=%d fw_error=%d '%s'",
|
||||||
__func__, ret, fw_error, fw_error_to_str(fw_error));
|
__func__, ret, fw_error, fw_error_to_str(fw_error));
|
||||||
@ -679,11 +677,10 @@ sev_launch_start(SevGuestState *sev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sev_set_guest_state(sev, SEV_STATE_LAUNCH_UPDATE);
|
sev_set_guest_state(sev, SEV_STATE_LAUNCH_UPDATE);
|
||||||
sev->handle = start->handle;
|
sev->handle = start.handle;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free(start);
|
|
||||||
g_free(session);
|
g_free(session);
|
||||||
g_free(dh_cert);
|
g_free(dh_cert);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user