diff mbox

[v9,25/29] sev/i386: add support to KVM_SEV_GUEST_STATUS

Message ID 20180215153955.3253-26-brijesh.singh@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Brijesh Singh Feb. 15, 2018, 3:39 p.m. UTC
The command is used to query the current SEV guest status. We use this
command to query the guest policy for QMP query-sev command.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
---
 target/i386/sev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox

Patch

diff --git a/target/i386/sev.c b/target/i386/sev.c
index e3236f5bb7b6..559881084d50 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -437,6 +437,22 @@  sev_get_fw_version(uint8_t *major, uint8_t *minor, uint8_t *build)
 void
 sev_get_policy(uint32_t *policy)
 {
+    struct kvm_sev_guest_status status = {};
+    int r, err;
+
+    if (current_sev_guest_state == SEV_STATE_UNINIT) {
+        return;
+    }
+
+    r = sev_ioctl(KVM_SEV_GUEST_STATUS, &status, &err);
+    if (r) {
+        error_report("%s: failed to get platform status ret=%d "
+                     "fw_error='%d: %s'", __func__, r, err,
+                     fw_error_to_str(err));
+        return;
+    }
+
+    *policy = status.policy;
 }
 
 static int