[kvm-unit-tests GIT PULL 9/9] s390x: cpumodel: FMT2 and FMT4 SCLP test

Janosch Frank
2021-05-26T14:56:08Z

SCLP is also part of the cpumodel, so we need to make sure that the
features indicated via read info / read cpu info are correct.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
---
s390x/cpumodel.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c
index 4dd8b96f..67bb6543 100644
--- a/s390x/cpumodel.c
+++ b/s390x/cpumodel.c
@@ -2,14 +2,81 @@
/*
* Test the known dependencies for facilities
*
- * Copyright 2019 IBM Corp.
+ * Copyright 2019, 2021 IBM Corp.
*
* Authors:
* Christian Borntraeger <borntraeger@de.ibm.com>
+ * Janosch Frank <frankja@linux.ibm.com>
*/

#include <asm/facility.h>
#include <vm.h>
+#include <sclp.h>
+#include <uv.h>
+#include <asm/uv.h>
+
+static void test_sclp_missing_sief2_implications(void)
+{
+ /* Virtualization related facilities */
+ report(!sclp_facilities.has_64bscao, "!64bscao");
+ report(!sclp_facilities.has_pfmfi, "!pfmfi");
+ report(!sclp_facilities.has_gsls, "!gsls");
+ report(!sclp_facilities.has_cmma, "!cmma");
+ report(!sclp_facilities.has_esca, "!esca");
+ report(!sclp_facilities.has_kss, "!kss");
+ report(!sclp_facilities.has_ibs, "!ibs");
+
+ /* Virtualization related facilities reported via CPU entries */
+ report(!sclp_facilities.has_sigpif, "!sigpif");
+ report(!sclp_facilities.has_sief2, "!sief2");
+ report(!sclp_facilities.has_skeyi, "!skeyi");
+ report(!sclp_facilities.has_siif, "!siif");
+ report(!sclp_facilities.has_cei, "!cei");
+ report(!sclp_facilities.has_ib, "!ib");
+}
+
+static void test_sclp_features_fmt4(void)
+{
+ /*
+ * STFLE facilities are handled by the Ultravisor but SCLP
+ * facilities are advertised by the hypervisor.
+ */
+ report_prefix_push("PV guest implies");
+
+ /* General facilities */
+ report(!sclp_facilities.has_diag318, "!diag318");
+
+ /*
+ * Virtualization related facilities, all of which are
+ * unavailable because there's no virtualization support in a
+ * protected guest.
+ */
+ test_sclp_missing_sief2_implications();
+
+ report_prefix_pop();
+}
+
+static void test_sclp_features_fmt2(void)
+{
+ if (sclp_facilities.has_sief2)
+ return;
+
+ report_prefix_push("!sief2 implies");
+ test_sclp_missing_sief2_implications();
+ report_prefix_pop();
+}
+
+static void test_sclp_features(void)
+{
+ report_prefix_push("sclp");
+
+ if (uv_os_is_guest())
+ test_sclp_features_fmt4();
+ else
+ test_sclp_features_fmt2();
+
+ report_prefix_pop();
+}

static struct {
int facility;
@@ -60,6 +127,8 @@ int main(void)
}
report_prefix_pop();

+ test_sclp_features();
+
report_prefix_pop();
return report_summary();
}
--
2.31.1