Skip to contentSkip to conversation

s390x/cpumodel: The missing DFP facility on TCG is expected

PATCH Superseded Thomas Huth 2 participants 3 messages Jul 7, 2020 KVM

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x/cpumodel: The missing DFP facility on TCG is expected

When running the kvm-unit-tests with TCG on s390x, the cpumodel test always reports the error about the missing DFP (decimal floating point) facility. This is kind of expected, since DFP is not required for running Linux and thus nobody is really interested in implementing this facility in TCG. Thus let's mark this as an expected error instead, so that we can run the kvm-unit-tests also with TCG without getting test failures that we do not care about.

---
 s390x/cpumodel.c | 51 ++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 6 deletions(-)
s390x/cpumodel.c +45 -6
index 5d232c6..4310b92 100644
@@ -11,6 +11,7 @@
  */
 
 #include <asm/facility.h>
+#include <alloc_page.h>
 
 static int dep[][2] = {
 	/* from SA22-7832-11 4-98 facility indications */
@@ -38,6 +39,49 @@ static int dep[][2] = {
 	{ 155,  77 },
 };
 
+/*
+ * A hack to detect TCG (instead of KVM): QEMU uses "TCGguest" as guest
+ * name by default when we are running with TCG (otherwise it's "KVMguest")
+ */
+static bool is_tcg(void)
+{
+	bool ret = false;
+	uint8_t *buf;
+
+	buf = alloc_page();
+	if (!buf)
+		return false;
+
+	if (stsi(buf, 3, 2, 2)) {
+		goto out;
+	}
+
+	/* Does the name start with "TCG" in EBCDIC? */
+	if (buf[2048] == 0x54 && buf[2049] == 0x43 && buf[2050] == 0x47)
+		ret = true;
+
+out:
+	free_page(buf);
+	return ret;
+}
+
+static void check_dependency(int dep1, int dep2)
+{
+	if (test_facility(dep1)) {
+		if (dep1 == 37) {
+			/* TCG does not have DFP and is unlikely to
+			 * get it implemented soon. */
+			report_xfail(is_tcg(), test_facility(dep2),
+				     "%d implies %d", dep1, dep2);
+		} else {
+			report(test_facility(dep2), "%d implies %d",
+			       dep1, dep2);
+		}
+	} else {
+		report_skip("facility %d not present", dep1);
+	}
+}
+
 int main(void)
 {
 	int i;
@@ -46,12 +90,7 @@ int main(void)
 
 	report_prefix_push("dependency");
 	for (i = 0; i < ARRAY_SIZE(dep); i++) {
-		if (test_facility(dep[i][0])) {
-			report(test_facility(dep[i][1]), "%d implies %d",
-				dep[i][0], dep[i][1]);
-		} else {
-			report_skip("facility %d not present", dep[i][0]);
-		}
+		check_dependency(dep[i][0], dep[i][1]);
 	}
 	report_prefix_pop();
 
Signature · 1 line
2.18.1
#1 lore raw
Quoted 7 lines · On Tue, 7 Jul 2020 07:56:19 +0200 Thomas Huth <[email protected]> wrote:

When running the kvm-unit-tests with TCG on s390x, the cpumodel test always reports the error about the missing DFP (decimal floating point) facility. This is kind of expected, since DFP is not required for running Linux and thus nobody is really interested in implementing this facility in TCG. Thus let's mark this as an expected error instead, so that we can run the kvm-unit-tests also with TCG without getting test failures that we do not care about.

Checking for tcg seems reasonable.

Quoted 19 lines
---
 s390x/cpumodel.c | 51 ++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 6 deletions(-)
s390x/cpumodel.c +1 -0
index 5d232c6..4310b92 100644
@@ -11,6 +11,7 @@
  */
 
 #include <asm/facility.h>
+#include <alloc_page.h>
 
 static int dep[][2] = {
 	/* from SA22-7832-11 4-98 facility indications */

s390x/cpumodel.c static int dep[][2] = { · line 44

Quoted 6 lines
s390x/cpumodel.c +3 -0
@@ -38,6 +39,49 @@ static int dep[][2] = {
 	{ 155,  77 },
 };
 
+/*
+ * A hack to detect TCG (instead of KVM): QEMU uses "TCGguest" as guest
+ * name by default when we are running with TCG (otherwise it's "KVMguest")

The guest name can be overwritten; I think it would be better to check for something hardcoded.

Maybe the manufacturer name in SYSIB 1.1.1? When running under tcg, it's always 'QEMU' (it's 'IBM' when running under KVM).

Quoted 14 lines
s390x/cpumodel.c +14 -0
+ */
+static bool is_tcg(void)
+{
+	bool ret = false;
+	uint8_t *buf;
+
+	buf = alloc_page();
+	if (!buf)
+		return false;
+
+	if (stsi(buf, 3, 2, 2)) {
+		goto out;
+	}
+

s390x/cpumodel.c static int dep[][2] = { · line 68

Quoted 10 lines
s390x/cpumodel.c +10 -0
+	/* Does the name start with "TCG" in EBCDIC? */
+	if (buf[2048] == 0x54 && buf[2049] == 0x43 && buf[2050] == 0x47)
+		ret = true;
+
+out:
+	free_page(buf);
+	return ret;
+}
+
+static void check_dependency(int dep1, int dep2)

<bikeshed>
Can we find more speaking parameter names? facility/implied? </bikeshed>

Quoted 33 lines
s390x/cpumodel.c +17 -6
+{
+	if (test_facility(dep1)) {
+		if (dep1 == 37) {
+			/* TCG does not have DFP and is unlikely to
+			 * get it implemented soon. */
+			report_xfail(is_tcg(), test_facility(dep2),
+				     "%d implies %d", dep1, dep2);
+		} else {
+			report(test_facility(dep2), "%d implies %d",
+			       dep1, dep2);
+		}
+	} else {
+		report_skip("facility %d not present", dep1);
+	}
+}
+
 int main(void)
 {
 	int i;
@@ -46,12 +90,7 @@ int main(void)
 
 	report_prefix_push("dependency");
 	for (i = 0; i < ARRAY_SIZE(dep); i++) {
-		if (test_facility(dep[i][0])) {
-			report(test_facility(dep[i][1]), "%d implies %d",
-				dep[i][0], dep[i][1]);
-		} else {
-			report_skip("facility %d not present", dep[i][0]);
-		}
+		check_dependency(dep[i][0], dep[i][1]);
 	}
 	report_prefix_pop();
 
#2 lore raw
Quoted 42 lines · Cornelia Huck
Quoted 7 lines · On Tue, 7 Jul 2020 07:56:19 +0200 Thomas Huth <[email protected]> wrote:

When running the kvm-unit-tests with TCG on s390x, the cpumodel test always reports the error about the missing DFP (decimal floating point) facility. This is kind of expected, since DFP is not required for running Linux and thus nobody is really interested in implementing this facility in TCG. Thus let's mark this as an expected error instead, so that we can run the kvm-unit-tests also with TCG without getting test failures that we do not care about.

Checking for tcg seems reasonable.

Quoted 19 lines
---
 s390x/cpumodel.c | 51 ++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 6 deletions(-)
s390x/cpumodel.c +1 -0
index 5d232c6..4310b92 100644
@@ -11,6 +11,7 @@
  */
 
 #include <asm/facility.h>
+#include <alloc_page.h>
 
 static int dep[][2] = {
 	/* from SA22-7832-11 4-98 facility indications */

s390x/cpumodel.c static int dep[][2] = { · line 44

Quoted 6 lines
s390x/cpumodel.c +3 -0
@@ -38,6 +39,49 @@ static int dep[][2] = {
 	{ 155,  77 },
 };
 
+/*
+ * A hack to detect TCG (instead of KVM): QEMU uses "TCGguest" as guest
+ * name by default when we are running with TCG (otherwise it's "KVMguest")

The guest name can be overwritten; I think it would be better to check for something hardcoded.

Quoted 2 lines

Maybe the manufacturer name in SYSIB 1.1.1? When running under tcg, it's always 'QEMU' (it's 'IBM' when running under KVM).

OK, I'll have a try.

Quoted 20 lines
Quoted 20 lines
s390x/cpumodel.c +20 -0
+ */
+static bool is_tcg(void)
+{
+	bool ret = false;
+	uint8_t *buf;
+
+	buf = alloc_page();
+	if (!buf)
+		return false;
+
+	if (stsi(buf, 3, 2, 2)) {
+		goto out;
+	}
+
+	/* Does the name start with "TCG" in EBCDIC? */
+	if (buf[2048] == 0x54 && buf[2049] == 0x43 && buf[2050] == 0x47)
+		ret = true;
+
+out:
+	free_page(buf);
Quoted 8 lines

s390x/cpumodel.c static int dep[][2] = { · line 68

Quoted 4 lines
s390x/cpumodel.c +4 -0
+	return ret;
+}
+
+static void check_dependency(int dep1, int dep2)

<bikeshed>
Can we find more speaking parameter names? facility/implied? </bikeshed>

That makes sense, indeed.

Thanks,
Thomas