75 lines
1.9 KiB
Diff
75 lines
1.9 KiB
Diff
|
From 8798ba8f4a4ba43cf7a34960ed70b32cbe69a4f6 Mon Sep 17 00:00:00 2001
|
||
|
From: Brijesh Singh <brijesh.singh@amd.com>
|
||
|
Date: Tue, 6 Feb 2018 19:08:11 -0600
|
||
|
Subject: [PATCH] sev: add support to query PLATFORM_STATUS command
|
||
|
|
||
|
The command is used to query the SEV API version and build id.
|
||
|
|
||
|
Cc: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
Cc: kvm@vger.kernel.org
|
||
|
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
|
||
|
[BR: FATE#322124]
|
||
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
||
|
---
|
||
|
accel/kvm/sev.c | 33 +++++++++++++++++++++++++++++++++
|
||
|
1 file changed, 33 insertions(+)
|
||
|
|
||
|
diff --git a/accel/kvm/sev.c b/accel/kvm/sev.c
|
||
|
index 7b57575e2f..186834364e 100644
|
||
|
--- a/accel/kvm/sev.c
|
||
|
+++ b/accel/kvm/sev.c
|
||
|
@@ -21,6 +21,9 @@
|
||
|
#include "trace.h"
|
||
|
#include "qapi-event.h"
|
||
|
|
||
|
+#include <sys/ioctl.h>
|
||
|
+#include <linux/psp-sev.h>
|
||
|
+
|
||
|
#define DEFAULT_GUEST_POLICY 0x1 /* disable debug */
|
||
|
#define DEFAULT_SEV_DEVICE "/dev/sev"
|
||
|
#define GUEST_POLICY_DBG_BIT 0x1
|
||
|
@@ -91,6 +94,22 @@ sev_ioctl(int cmd, void *data, int *error)
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
+static int
|
||
|
+sev_platform_ioctl(int cmd, void *data, int *error)
|
||
|
+{
|
||
|
+ int r;
|
||
|
+ struct sev_issue_cmd arg;
|
||
|
+
|
||
|
+ arg.cmd = cmd;
|
||
|
+ arg.data = (unsigned long)data;
|
||
|
+ r = ioctl(sev_fd, SEV_ISSUE_CMD, &arg);
|
||
|
+ if (error) {
|
||
|
+ *error = arg.error;
|
||
|
+ }
|
||
|
+
|
||
|
+ return r;
|
||
|
+}
|
||
|
+
|
||
|
static const char *
|
||
|
fw_error_to_str(int code)
|
||
|
{
|
||
|
@@ -380,6 +399,20 @@ sev_enabled(void)
|
||
|
void
|
||
|
sev_get_fw_version(uint8_t *major, uint8_t *minor, uint8_t *build)
|
||
|
{
|
||
|
+ struct sev_user_data_status status = {};
|
||
|
+ int r, err;
|
||
|
+
|
||
|
+ r = sev_platform_ioctl(SEV_PLATFORM_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;
|
||
|
+ }
|
||
|
+
|
||
|
+ *major = status.api_major;
|
||
|
+ *minor = status.api_minor;
|
||
|
+ *build = status.build;
|
||
|
}
|
||
|
|
||
|
void
|