|
|
97168e |
From 760236b3633a8f532631256a899cab969e772196 Mon Sep 17 00:00:00 2001
|
|
|
97168e |
From: Janosch Frank <frankja@linux.ibm.com>
|
|
|
97168e |
Date: Mon, 17 Oct 2022 08:38:19 +0000
|
|
|
97168e |
Subject: [PATCH 38/42] s390x: Introduce PV query interface
|
|
|
97168e |
MIME-Version: 1.0
|
|
|
97168e |
Content-Type: text/plain; charset=UTF-8
|
|
|
97168e |
Content-Transfer-Encoding: 8bit
|
|
|
97168e |
|
|
|
97168e |
RH-Author: Cédric Le Goater <clg@redhat.com>
|
|
|
97168e |
RH-MergeRequest: 226: s390: Enhanced Interpretation for PCI Functions and Secure Execution guest dump
|
|
|
97168e |
RH-Bugzilla: 1664378 2043909
|
|
|
97168e |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
97168e |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
97168e |
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
97168e |
RH-Commit: [38/41] 3090615d81ec6b9e4c306f7fc3709e1935ff5a79
|
|
|
97168e |
|
|
|
97168e |
Introduce an interface over which we can get information about UV data.
|
|
|
97168e |
|
|
|
97168e |
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
|
|
|
97168e |
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
|
|
|
97168e |
Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
|
|
|
97168e |
Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
97168e |
Message-Id: <20221017083822.43118-8-frankja@linux.ibm.com>
|
|
|
97168e |
(cherry picked from commit 03d83ecfae46bf5e0074cb5808043b30df34064b)
|
|
|
97168e |
Signed-off-by: Cédric Le Goater <clg@redhat.com>
|
|
|
97168e |
---
|
|
|
97168e |
hw/s390x/pv.c | 61 ++++++++++++++++++++++++++++++++++++++
|
|
|
97168e |
hw/s390x/s390-virtio-ccw.c | 6 ++++
|
|
|
97168e |
include/hw/s390x/pv.h | 10 +++++++
|
|
|
97168e |
3 files changed, 77 insertions(+)
|
|
|
97168e |
|
|
|
97168e |
diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
|
|
|
97168e |
index 401b63d6cb..4c012f2eeb 100644
|
|
|
97168e |
--- a/hw/s390x/pv.c
|
|
|
97168e |
+++ b/hw/s390x/pv.c
|
|
|
97168e |
@@ -20,6 +20,11 @@
|
|
|
97168e |
#include "exec/confidential-guest-support.h"
|
|
|
97168e |
#include "hw/s390x/ipl.h"
|
|
|
97168e |
#include "hw/s390x/pv.h"
|
|
|
97168e |
+#include "target/s390x/kvm/kvm_s390x.h"
|
|
|
97168e |
+
|
|
|
97168e |
+static bool info_valid;
|
|
|
97168e |
+static struct kvm_s390_pv_info_vm info_vm;
|
|
|
97168e |
+static struct kvm_s390_pv_info_dump info_dump;
|
|
|
97168e |
|
|
|
97168e |
static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
|
|
|
97168e |
{
|
|
|
97168e |
@@ -56,6 +61,42 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
|
|
|
97168e |
} \
|
|
|
97168e |
}
|
|
|
97168e |
|
|
|
97168e |
+int s390_pv_query_info(void)
|
|
|
97168e |
+{
|
|
|
97168e |
+ struct kvm_s390_pv_info info = {
|
|
|
97168e |
+ .header.id = KVM_PV_INFO_VM,
|
|
|
97168e |
+ .header.len_max = sizeof(info.header) + sizeof(info.vm),
|
|
|
97168e |
+ };
|
|
|
97168e |
+ int rc;
|
|
|
97168e |
+
|
|
|
97168e |
+ /* Info API's first user is dump so they are bundled */
|
|
|
97168e |
+ if (!kvm_s390_get_protected_dump()) {
|
|
|
97168e |
+ return 0;
|
|
|
97168e |
+ }
|
|
|
97168e |
+
|
|
|
97168e |
+ rc = s390_pv_cmd(KVM_PV_INFO, &info;;
|
|
|
97168e |
+ if (rc) {
|
|
|
97168e |
+ error_report("KVM PV INFO cmd %x failed: %s",
|
|
|
97168e |
+ info.header.id, strerror(-rc));
|
|
|
97168e |
+ return rc;
|
|
|
97168e |
+ }
|
|
|
97168e |
+ memcpy(&info_vm, &info.vm, sizeof(info.vm));
|
|
|
97168e |
+
|
|
|
97168e |
+ info.header.id = KVM_PV_INFO_DUMP;
|
|
|
97168e |
+ info.header.len_max = sizeof(info.header) + sizeof(info.dump);
|
|
|
97168e |
+ rc = s390_pv_cmd(KVM_PV_INFO, &info;;
|
|
|
97168e |
+ if (rc) {
|
|
|
97168e |
+ error_report("KVM PV INFO cmd %x failed: %s",
|
|
|
97168e |
+ info.header.id, strerror(-rc));
|
|
|
97168e |
+ return rc;
|
|
|
97168e |
+ }
|
|
|
97168e |
+
|
|
|
97168e |
+ memcpy(&info_dump, &info.dump, sizeof(info.dump));
|
|
|
97168e |
+ info_valid = true;
|
|
|
97168e |
+
|
|
|
97168e |
+ return rc;
|
|
|
97168e |
+}
|
|
|
97168e |
+
|
|
|
97168e |
int s390_pv_vm_enable(void)
|
|
|
97168e |
{
|
|
|
97168e |
return s390_pv_cmd(KVM_PV_ENABLE, NULL);
|
|
|
97168e |
@@ -114,6 +155,26 @@ void s390_pv_inject_reset_error(CPUState *cs)
|
|
|
97168e |
env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV;
|
|
|
97168e |
}
|
|
|
97168e |
|
|
|
97168e |
+uint64_t kvm_s390_pv_dmp_get_size_cpu(void)
|
|
|
97168e |
+{
|
|
|
97168e |
+ return info_dump.dump_cpu_buffer_len;
|
|
|
97168e |
+}
|
|
|
97168e |
+
|
|
|
97168e |
+uint64_t kvm_s390_pv_dmp_get_size_completion_data(void)
|
|
|
97168e |
+{
|
|
|
97168e |
+ return info_dump.dump_config_finalize_len;
|
|
|
97168e |
+}
|
|
|
97168e |
+
|
|
|
97168e |
+uint64_t kvm_s390_pv_dmp_get_size_mem_state(void)
|
|
|
97168e |
+{
|
|
|
97168e |
+ return info_dump.dump_config_mem_buffer_per_1m;
|
|
|
97168e |
+}
|
|
|
97168e |
+
|
|
|
97168e |
+bool kvm_s390_pv_info_basic_valid(void)
|
|
|
97168e |
+{
|
|
|
97168e |
+ return info_valid;
|
|
|
97168e |
+}
|
|
|
97168e |
+
|
|
|
97168e |
#define TYPE_S390_PV_GUEST "s390-pv-guest"
|
|
|
97168e |
OBJECT_DECLARE_SIMPLE_TYPE(S390PVGuest, S390_PV_GUEST)
|
|
|
97168e |
|
|
|
97168e |
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
|
|
|
97168e |
index bd80e72cf8..a9617ab79f 100644
|
|
|
97168e |
--- a/hw/s390x/s390-virtio-ccw.c
|
|
|
97168e |
+++ b/hw/s390x/s390-virtio-ccw.c
|
|
|
97168e |
@@ -365,6 +365,12 @@ static int s390_machine_protect(S390CcwMachineState *ms)
|
|
|
97168e |
|
|
|
97168e |
ms->pv = true;
|
|
|
97168e |
|
|
|
97168e |
+ /* Will return 0 if API is not available since it's not vital */
|
|
|
97168e |
+ rc = s390_pv_query_info();
|
|
|
97168e |
+ if (rc) {
|
|
|
97168e |
+ goto out_err;
|
|
|
97168e |
+ }
|
|
|
97168e |
+
|
|
|
97168e |
/* Set SE header and unpack */
|
|
|
97168e |
rc = s390_ipl_prepare_pv_header();
|
|
|
97168e |
if (rc) {
|
|
|
97168e |
diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h
|
|
|
97168e |
index 1f1f545bfc..e5ea0eca16 100644
|
|
|
97168e |
--- a/include/hw/s390x/pv.h
|
|
|
97168e |
+++ b/include/hw/s390x/pv.h
|
|
|
97168e |
@@ -38,6 +38,7 @@ static inline bool s390_is_pv(void)
|
|
|
97168e |
return ccw->pv;
|
|
|
97168e |
}
|
|
|
97168e |
|
|
|
97168e |
+int s390_pv_query_info(void);
|
|
|
97168e |
int s390_pv_vm_enable(void);
|
|
|
97168e |
void s390_pv_vm_disable(void);
|
|
|
97168e |
int s390_pv_set_sec_parms(uint64_t origin, uint64_t length);
|
|
|
97168e |
@@ -46,8 +47,13 @@ void s390_pv_prep_reset(void);
|
|
|
97168e |
int s390_pv_verify(void);
|
|
|
97168e |
void s390_pv_unshare(void);
|
|
|
97168e |
void s390_pv_inject_reset_error(CPUState *cs);
|
|
|
97168e |
+uint64_t kvm_s390_pv_dmp_get_size_cpu(void);
|
|
|
97168e |
+uint64_t kvm_s390_pv_dmp_get_size_mem_state(void);
|
|
|
97168e |
+uint64_t kvm_s390_pv_dmp_get_size_completion_data(void);
|
|
|
97168e |
+bool kvm_s390_pv_info_basic_valid(void);
|
|
|
97168e |
#else /* CONFIG_KVM */
|
|
|
97168e |
static inline bool s390_is_pv(void) { return false; }
|
|
|
97168e |
+static inline int s390_pv_query_info(void) { return 0; }
|
|
|
97168e |
static inline int s390_pv_vm_enable(void) { return 0; }
|
|
|
97168e |
static inline void s390_pv_vm_disable(void) {}
|
|
|
97168e |
static inline int s390_pv_set_sec_parms(uint64_t origin, uint64_t length) { return 0; }
|
|
|
97168e |
@@ -56,6 +62,10 @@ static inline void s390_pv_prep_reset(void) {}
|
|
|
97168e |
static inline int s390_pv_verify(void) { return 0; }
|
|
|
97168e |
static inline void s390_pv_unshare(void) {}
|
|
|
97168e |
static inline void s390_pv_inject_reset_error(CPUState *cs) {};
|
|
|
97168e |
+static inline uint64_t kvm_s390_pv_dmp_get_size_cpu(void) { return 0; }
|
|
|
97168e |
+static inline uint64_t kvm_s390_pv_dmp_get_size_mem_state(void) { return 0; }
|
|
|
97168e |
+static inline uint64_t kvm_s390_pv_dmp_get_size_completion_data(void) { return 0; }
|
|
|
97168e |
+static inline bool kvm_s390_pv_info_basic_valid(void) { return false; }
|
|
|
97168e |
#endif /* CONFIG_KVM */
|
|
|
97168e |
|
|
|
97168e |
int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp);
|
|
|
97168e |
--
|
|
|
97168e |
2.37.3
|
|
|
97168e |
|