qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Tyler Fanelli <tfanelli@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mtosatti@redhat.com, stefanha@redhat.com,
	philmd@linaro.org, berrange@redhat.com,
	marcandre.lureau@gmail.com, Tyler Fanelli <tfanelli@redhat.com>
Subject: [RFC PATCH v2 4/9] i386/sev: Replace UPDATE_DATA ioctl with sev library equivalent
Date: Wed,  4 Oct 2023 16:34:13 -0400	[thread overview]
Message-ID: <20231004203418.56508-5-tfanelli@redhat.com> (raw)
In-Reply-To: <20231004203418.56508-1-tfanelli@redhat.com>

UPDATE_DATA takes the VM's file descriptor, a guest memory region to
be encrypted, as well as the size of the aforementioned guest memory
region.

If this API ioctl call fails, fw_error will be set accordingly.

Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
---
 target/i386/sev.c | 31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/target/i386/sev.c b/target/i386/sev.c
index 4c888fa77f..73d3820364 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -715,29 +715,6 @@ sev_read_file_base64(const char *filename, guchar **data, gsize *len)
     return 0;
 }
 
-static int
-sev_launch_update_data(SevGuestState *sev, uint8_t *addr, uint64_t len)
-{
-    int ret, fw_error;
-    struct kvm_sev_launch_update_data update;
-
-    if (!addr || !len) {
-        return 1;
-    }
-
-    update.uaddr = (__u64)(unsigned long)addr;
-    update.len = len;
-    trace_kvm_sev_launch_update_data(addr, len);
-    ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_UPDATE_DATA,
-                    &update, &fw_error);
-    if (ret) {
-        error_report("%s: LAUNCH_UPDATE ret=%d fw_error=%d '%s'",
-                __func__, ret, fw_error, fw_error_to_str(fw_error));
-    }
-
-    return ret;
-}
-
 static int
 sev_launch_update_vmsa(SevGuestState *sev)
 {
@@ -1009,15 +986,19 @@ out:
 int
 sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp)
 {
+    KVMState *s = kvm_state;
+    int fw_error;
+
     if (!sev_guest) {
         return 0;
     }
 
     /* if SEV is in update state then encrypt the data else do nothing */
     if (sev_check_state(sev_guest, SEV_STATE_LAUNCH_UPDATE)) {
-        int ret = sev_launch_update_data(sev_guest, ptr, len);
+        int ret = sev_launch_update_data(s->vmfd, (__u64) ptr, len, &fw_error);
         if (ret < 0) {
-            error_setg(errp, "SEV: Failed to encrypt pflash rom");
+            error_setg(errp, "SEV: Failed to encrypt pflash rom fw_err=%d",
+                       fw_error);
             return ret;
         }
     }
-- 
2.40.1



  parent reply	other threads:[~2023-10-04 20:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 20:34 [RFC PATCH v2 0/9] i386/sev: Use C API of Rust SEV library Tyler Fanelli
2023-10-04 20:34 ` [RFC PATCH v2 1/9] Add Rust SEV library as subproject Tyler Fanelli
2023-10-05  6:03   ` Philippe Mathieu-Daudé
2023-10-05 23:41     ` Tyler Fanelli
2023-10-11  3:05     ` Tyler Fanelli
2023-10-05 15:54   ` Stefan Hajnoczi
2023-10-11  3:10     ` Tyler Fanelli
2023-10-13 18:09       ` Manos Pitsidianakis
2023-10-13 18:20         ` Tyler Fanelli
2023-10-16  9:16           ` Daniel P. Berrangé
2023-10-16 13:38             ` Philippe Mathieu-Daudé
2023-10-16 13:51             ` Stefan Hajnoczi
2024-03-05 13:47   ` Daniel P. Berrangé
2024-03-05 15:40     ` Philippe Mathieu-Daudé
2023-10-04 20:34 ` [RFC PATCH v2 2/9] i386/sev: Replace INIT and ES_INIT ioctls with sev library equivalents Tyler Fanelli
2023-10-04 20:34 ` [RFC PATCH v2 3/9] i386/sev: Replace LAUNCH_START ioctl with sev library equivalent Tyler Fanelli
2023-10-04 20:34 ` Tyler Fanelli [this message]
2023-10-04 20:34 ` [RFC PATCH v2 5/9] i386/sev: Replace LAUNCH_UPDATE_VMSA " Tyler Fanelli
2023-10-04 20:34 ` [RFC PATCH v2 6/9] i386/sev: Replace LAUNCH_MEASURE " Tyler Fanelli
2023-10-04 20:34 ` [RFC PATCH v2 7/9] i386/sev: Replace LAUNCH_SECRET " Tyler Fanelli
2023-10-04 20:34 ` [RFC PATCH v2 8/9] i386/sev: Replace LAUNCH_FINISH " Tyler Fanelli
2023-10-04 20:34 ` [RFC PATCH v2 9/9] i386/sev: Replace SEV_ATTESTATION_REPORT " Tyler Fanelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231004203418.56508-5-tfanelli@redhat.com \
    --to=tfanelli@redhat.com \
    --cc=berrange@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).