[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 2/8] i386/sev: Replace INIT and ES_INIT ioctls with sev libra
From: |
Tyler Fanelli |
Subject: |
[RFC PATCH 2/8] i386/sev: Replace INIT and ES_INIT ioctls with sev library equivalents |
Date: |
Thu, 14 Sep 2023 13:58:29 -0400 |
The sev library offers APIs for SEV_INIT and SEV_ES_INIT, both taking
the file descriptors of the encrypting VM and /dev/sev 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 | 14 +++++++++-----
target/i386/trace-events | 1 +
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/target/i386/sev.c b/target/i386/sev.c
index fe2144c038..f0fd291e68 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -18,6 +18,8 @@
#include <sys/ioctl.h>
+#include <sev/sev.h>
+
#include "qapi/error.h"
#include "qom/object_interfaces.h"
#include "qemu/base64.h"
@@ -27,6 +29,7 @@
#include "crypto/hash.h"
#include "sysemu/kvm.h"
#include "sev.h"
+#include "sysemu/kvm_int.h"
#include "sysemu/sysemu.h"
#include "sysemu/runstate.h"
#include "trace.h"
@@ -911,10 +914,11 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error
**errp)
SevGuestState *sev
= (SevGuestState *)object_dynamic_cast(OBJECT(cgs), TYPE_SEV_GUEST);
char *devname;
- int ret, fw_error, cmd;
+ int ret, fw_error;
uint32_t ebx;
uint32_t host_cbitpos;
struct sev_user_data_status status = {};
+ KVMState *s = kvm_state;
if (!sev) {
return 0;
@@ -990,13 +994,13 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error
**errp)
__func__);
goto err;
}
- cmd = KVM_SEV_ES_INIT;
+ trace_kvm_sev_es_init();
+ ret = sev_es_init(s->vmfd, sev->sev_fd, &fw_error);
} else {
- cmd = KVM_SEV_INIT;
+ trace_kvm_sev_init();
+ ret = sev_init(s->vmfd, sev->sev_fd, &fw_error);
}
- trace_kvm_sev_init();
- ret = sev_ioctl(sev->sev_fd, cmd, NULL, &fw_error);
if (ret) {
error_setg(errp, "%s: failed to initialize ret=%d fw_error=%d '%s'",
__func__, ret, fw_error, fw_error_to_str(fw_error));
diff --git a/target/i386/trace-events b/target/i386/trace-events
index 2cd8726eeb..2dca4ee117 100644
--- a/target/i386/trace-events
+++ b/target/i386/trace-events
@@ -2,6 +2,7 @@
# sev.c
kvm_sev_init(void) ""
+kvm_sev_es_init(void) ""
kvm_memcrypt_register_region(void *addr, size_t len) "addr %p len 0x%zx"
kvm_memcrypt_unregister_region(void *addr, size_t len) "addr %p len 0x%zx"
kvm_sev_change_state(const char *old, const char *new) "%s -> %s"
--
2.40.1
- [RFC PATCH 0/8] i386/sev: Use C API of Rust SEV library, Tyler Fanelli, 2023/09/14
- [RFC PATCH 2/8] i386/sev: Replace INIT and ES_INIT ioctls with sev library equivalents,
Tyler Fanelli <=
- [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
- Re: [RFC PATCH 0/8] i386/sev: Use C API of Rust SEV library, Daniel P . Berrangé, 2023/09/15