[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 39/40] target/i386/sev: Use local variable for kvm_sev_launch_meas
From: |
Paolo Bonzini |
Subject: |
[PULL 39/40] target/i386/sev: Use local variable for kvm_sev_launch_measure |
Date: |
Wed, 13 Oct 2021 11:07:27 +0200 |
From: Dov Murik <dovmurik@linux.ibm.com>
The struct kvm_sev_launch_measure 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-3-dovmurik@linux.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/sev.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 0062566c71..eede07f11d 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -729,7 +729,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
SevGuestState *sev = sev_guest;
int ret, error;
g_autofree guchar *data = NULL;
- g_autofree struct kvm_sev_launch_measure *measurement = NULL;
+ struct kvm_sev_launch_measure measurement = {};
if (!sev_check_state(sev, SEV_STATE_LAUNCH_UPDATE)) {
return;
@@ -743,23 +743,21 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
}
}
- measurement = g_new0(struct kvm_sev_launch_measure, 1);
-
/* query the measurement blob length */
ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_MEASURE,
- measurement, &error);
- if (!measurement->len) {
+ &measurement, &error);
+ if (!measurement.len) {
error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
__func__, ret, error, fw_error_to_str(errno));
return;
}
- data = g_new0(guchar, measurement->len);
- measurement->uaddr = (unsigned long)data;
+ data = g_new0(guchar, measurement.len);
+ measurement.uaddr = (unsigned long)data;
/* get the measurement blob */
ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_MEASURE,
- measurement, &error);
+ &measurement, &error);
if (ret) {
error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
__func__, ret, error, fw_error_to_str(errno));
@@ -769,7 +767,7 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
sev_set_guest_state(sev, SEV_STATE_LAUNCH_SECRET);
/* encode the measurement value and emit the event */
- sev->measurement = g_base64_encode(data, measurement->len);
+ sev->measurement = g_base64_encode(data, measurement.len);
trace_kvm_sev_launch_measurement(sev->measurement);
}
--
2.31.1
- [PULL 28/40] MAINTAINERS: Cover SEV-related files with X86/KVM section, (continued)
- [PULL 28/40] MAINTAINERS: Cover SEV-related files with X86/KVM section, Paolo Bonzini, 2021/10/13
- [PULL 29/40] qapi: Make some ObjectTypes depend on the build settings, Paolo Bonzini, 2021/10/13
- [PULL 30/40] tests: tcg: Fix PVH test with binutils 2.36+, Paolo Bonzini, 2021/10/13
- [PULL 12/40] target/i386/cpu: Add missing 'qapi/error.h' header, Paolo Bonzini, 2021/10/13
- [PULL 13/40] target/i386/sev_i386.h: Remove unused headers, Paolo Bonzini, 2021/10/13
- [PULL 18/40] target/i386/sev: Restrict SEV to system emulation, Paolo Bonzini, 2021/10/13
- [PULL 16/40] target/i386/sev: sev_get_attestation_report use g_autofree, Paolo Bonzini, 2021/10/13
- [PULL 24/40] target/i386/sev: Move qmp_query_sev_capabilities() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 27/40] monitor: Reduce hmp_info_sev() declaration, Paolo Bonzini, 2021/10/13
- [PULL 23/40] target/i386/sev: Move qmp_sev_inject_launch_secret() to sev.c, Paolo Bonzini, 2021/10/13
- [PULL 39/40] target/i386/sev: Use local variable for kvm_sev_launch_measure,
Paolo Bonzini <=
- [PULL 34/40] hw/i386/sgx: Move qmp_query_sgx_capabilities() to hw/i386/sgx.c, Paolo Bonzini, 2021/10/13
- [PULL 35/40] hw/i386/sgx: Move qmp_query_sgx() and hmp_info_sgx() to hw/i386/sgx.c, Paolo Bonzini, 2021/10/13
- [PULL 31/40] hvf: Determine slot count from struct layout, Paolo Bonzini, 2021/10/13
- [PULL 37/40] monitor: Tidy up find_device_state(), Paolo Bonzini, 2021/10/13
- Re: [PULL 37/40] monitor: Tidy up find_device_state(), Markus Armbruster, 2021/10/18
- Re: [PULL 37/40] monitor: Tidy up find_device_state(), Markus Armbruster, 2021/10/19