2018-02-22 23:01:24 +01:00
|
|
|
From fea1c51414bedfc61e5ee31b15e58d638acee4fe 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 query PLATFORM_STATUS command
|
2018-02-08 20:55:31 +01:00
|
|
|
|
|
|
|
The command is used to query the SEV API version and build id.
|
|
|
|
|
|
|
|
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 | 33 +++++++++++++++++++++++++++++++++
|
2018-02-08 20:55:31 +01:00
|
|
|
1 file changed, 33 insertions(+)
|
|
|
|
|
2018-02-22 23:01:24 +01:00
|
|
|
diff --git a/target/i386/sev.c b/target/i386/sev.c
|
|
|
|
index 1fbc3beb16..e3236f5bb7 100644
|
|
|
|
--- a/target/i386/sev.c
|
|
|
|
+++ b/target/i386/sev.c
|
2018-02-08 20:55:31 +01:00
|
|
|
@@ -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
|
2018-02-22 23:01:24 +01:00
|
|
|
@@ -84,6 +87,22 @@ sev_ioctl(int cmd, void *data, int *error)
|
2018-02-08 20:55:31 +01:00
|
|
|
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)
|
|
|
|
{
|
2018-02-22 23:01:24 +01:00
|
|
|
@@ -399,6 +418,20 @@ sev_enabled(void)
|
2018-02-08 20:55:31 +01:00
|
|
|
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
|