2018-02-22 23:01:24 +01:00
|
|
|
From b4998b726af3a1da2dc346cac8796ca8fd6b88cd Mon Sep 17 00:00:00 2001
|
2018-02-08 20:55:31 +01:00
|
|
|
From: Brijesh Singh <brijesh.singh@amd.com>
|
2018-02-22 23:01:24 +01:00
|
|
|
Date: Thu, 15 Feb 2018 09:03:24 -0600
|
|
|
|
Subject: [PATCH] sev/i386: add support to KVM_SEV_GUEST_STATUS
|
2018-02-08 20:55:31 +01:00
|
|
|
|
|
|
|
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>
|
2018-02-22 23:01:24 +01:00
|
|
|
Cc: Richard Henderson <rth@twiddle.net>
|
|
|
|
Cc: Eduardo Habkost <ehabkost@redhat.com>
|
2018-02-08 20:55:31 +01:00
|
|
|
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
|
|
|
|
[BR: FATE#322124]
|
|
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
|
|
---
|
2018-02-22 23:01:24 +01:00
|
|
|
target/i386/sev.c | 16 ++++++++++++++++
|
|
|
|
1 file changed, 16 insertions(+)
|
2018-02-08 20:55:31 +01:00
|
|
|
|
2018-02-22 23:01:24 +01:00
|
|
|
diff --git a/target/i386/sev.c b/target/i386/sev.c
|
|
|
|
index e3236f5bb7..559881084d 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)
|
2018-02-08 20:55:31 +01:00
|
|
|
void
|
|
|
|
sev_get_policy(uint32_t *policy)
|
|
|
|
{
|
|
|
|
+ struct kvm_sev_guest_status status = {};
|
|
|
|
+ int r, err;
|
|
|
|
+
|
2018-02-22 23:01:24 +01:00
|
|
|
+ if (current_sev_guest_state == SEV_STATE_UNINIT) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
2018-02-08 20:55:31 +01:00
|
|
|
+ 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
|