[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 5/8] i386/sev: Replace LAUNCH_UPDATE_VMSA ioctl with sev libr
From: |
Tyler Fanelli |
Subject: |
[RFC PATCH 5/8] i386/sev: Replace LAUNCH_UPDATE_VMSA ioctl with sev library equivalent |
Date: |
Thu, 14 Sep 2023 12:33:56 -0400 |
The LAUNCH_UPDATE_VMSA API takes the VM's file descriptor, as well as a
field for any firmware errors as input.
If this API ioctl call fails, fw_error will be set accordingly.
Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
---
target/i386/sev.c | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 615021a1a3..adb35291e8 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -715,27 +715,14 @@ sev_read_file_base64(const char *filename, guchar **data,
gsize *len)
return 0;
}
-static int
-sev_launch_update_vmsa(SevGuestState *sev)
-{
- int ret, fw_error;
-
- ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_UPDATE_VMSA, NULL, &fw_error);
- if (ret) {
- error_report("%s: LAUNCH_UPDATE_VMSA ret=%d fw_error=%d '%s'",
- __func__, ret, fw_error, fw_error_to_str(fw_error));
- }
-
- return ret;
-}
-
static void
sev_launch_get_measure(Notifier *notifier, void *unused)
{
SevGuestState *sev = sev_guest;
- int ret, error;
+ int ret, fw_error;
g_autofree guchar *data = NULL;
struct kvm_sev_launch_measure measurement = {};
+ KVMState *s = kvm_state;
if (!sev_check_state(sev, SEV_STATE_LAUNCH_UPDATE)) {
return;
@@ -743,18 +730,20 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
if (sev_es_enabled()) {
/* measure all the VM save areas before getting launch_measure */
- ret = sev_launch_update_vmsa(sev);
+ ret = sev_launch_update_vmsa(s->vmfd, &fw_error);
if (ret) {
+ error_report("%s: LAUNCH_UPDATE_VMSA ret=%d fw_error=%d '%s'",
+ __func__, ret, fw_error, fw_error_to_str(fw_error));
exit(1);
}
}
/* query the measurement blob length */
ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_MEASURE,
- &measurement, &error);
+ &measurement, &fw_error);
if (!measurement.len) {
error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
- __func__, ret, error, fw_error_to_str(errno));
+ __func__, ret, fw_error, fw_error_to_str(fw_error));
return;
}
@@ -763,10 +752,10 @@ sev_launch_get_measure(Notifier *notifier, void *unused)
/* get the measurement blob */
ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_MEASURE,
- &measurement, &error);
+ &measurement, &fw_error);
if (ret) {
error_report("%s: LAUNCH_MEASURE ret=%d fw_error=%d '%s'",
- __func__, ret, error, fw_error_to_str(errno));
+ __func__, ret, fw_error, fw_error_to_str(fw_error));
return;
}
--
2.40.1
- [RFC PATCH 1/8] Add SEV Rust library as dependency with CONFIG_SEV, (continued)
- [RFC PATCH 1/8] Add SEV Rust library as dependency with CONFIG_SEV, Tyler Fanelli, 2023/09/14
- [RFC PATCH 3/8] i386/sev: Replace LAUNCH_START ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 4/8] i386/sev: Replace UPDATE_DATA ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 5/8] i386/sev: Replace LAUNCH_UPDATE_VMSA ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 6/8] i386/sev: Replace LAUNCH_MEASURE ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 8/8] i386/sev: Replace LAUNCH_FINISH ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 7/8] i386/sev: Replace LAUNCH_SECRET ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- Re: [RFC PATCH 0/8] i386/sev: Use C API of Rust SEV library, Philippe Mathieu-Daudé, 2023/09/14
- [RFC PATCH 0/8] i386/sev: Use C API of Rust SEV library, Tyler Fanelli, 2023/09/14
- [RFC PATCH 5/8] i386/sev: Replace LAUNCH_UPDATE_VMSA ioctl with sev library equivalent,
Tyler Fanelli <=
- [RFC PATCH 7/8] i386/sev: Replace LAUNCH_SECRET ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 8/8] i386/sev: Replace LAUNCH_FINISH ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 4/8] i386/sev: Replace UPDATE_DATA ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 1/8] Add SEV Rust library as dependency with CONFIG_SEV, Tyler Fanelli, 2023/09/14
- [RFC PATCH 6/8] i386/sev: Replace LAUNCH_MEASURE ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 3/8] i386/sev: Replace LAUNCH_START ioctl with sev library equivalent, Tyler Fanelli, 2023/09/14
- [RFC PATCH 2/8] i386/sev: Replace INIT and ES_INIT ioctls with sev library equivalents, Tyler Fanelli, 2023/09/14