Skip to contentSkip to conversation

s390x: Add stsi 3.2.2 tests

PATCH Superseded Janosch Frank 3 participants 11 messages Mar 30, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390x: Add stsi 3.2.2 tests

Subcode 3.2.2 is handled by KVM/QEMU and should therefore be tested a bit more thorough.

In this test we set a custom name and uuid through the QEMU command line. Both parameters will be passed to the guest on a stsi subcode 3.2.2 call and will then be checked.

We also compare the total and configured cpu numbers against the smp reported numbers.

---
 s390x/stsi.c        | 62 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  1 +
 2 files changed, 63 insertions(+)
s390x/stsi.c +62 -0
index e9206bca137d2edb..10e588a78cc05186 100644
@@ -14,7 +14,28 @@
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <smp.h>
 
+struct stsi_322 {
+    uint8_t  reserved[31];
+    uint8_t  count;
+    struct {
+        uint8_t  reserved2[4];
+        uint16_t total_cpus;
+        uint16_t conf_cpus;
+        uint16_t standby_cpus;
+        uint16_t reserved_cpus;
+        uint8_t  name[8];
+        uint32_t caf;
+        uint8_t  cpi[16];
+        uint8_t reserved5[3];
+        uint8_t ext_name_encoding;
+        uint32_t reserved3;
+        uint8_t uuid[16];
+    } vm[8];
+    uint8_t reserved4[1504];
+    uint8_t ext_names[8][256];
+};
 static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
 
 static void test_specs(void)
@@ -76,11 +97,52 @@ static void test_fc(void)
 	report(stsi_get_fc(pagebuf) >= 2, "query fc >= 2");
 }
 
+static void test_3_2_2(void)
+{
+	int rc;
+	/* EBCDIC for "kvm-unit" */
+	uint8_t vm_name[] = { 0x92, 0xa5, 0x94, 0x60, 0xa4, 0x95, 0x89, 0xa3 };
+	uint8_t uuid[] = { 0x0f, 0xb8, 0x4a, 0x86, 0x72, 0x7c,
+			   0x11, 0xea, 0xbc, 0x55, 0x02, 0x42, 0xac, 0x13,
+			   0x00, 0x03 };
+	/* EBCDIC for "KVM/" */
+	uint8_t cpi_kvm[] = { 0xd2, 0xe5, 0xd4, 0x61 };
+	const char *vm_name_ext = "kvm-unit-test";
+	struct stsi_322 *data = (void *)pagebuf;
+
+	/* Is the function code available at all? */
+	if (stsi_get_fc(pagebuf) < 3)
+		return;
+
+	report_prefix_push("3.2.2");
+	rc = stsi(pagebuf, 3, 2, 2);
+	report(!rc, "call");
+
+	/* For now we concentrate on KVM/QEMU */
+	if (memcmp(&data->vm[0].cpi, cpi_kvm, sizeof(cpi_kvm)))
+		goto out;
+
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");
+	report(!memcmp(data->vm[0].name, vm_name, sizeof(data->vm[0].name)),
+	       "VM name == kvm-unit-test");
+	report(data->vm[0].ext_name_encoding == 2, "ext name encoding UTF-8");
+	report(!memcmp(data->ext_names[0], vm_name_ext, sizeof(vm_name_ext)),
+		       "ext VM name == kvm-unit-test");
+	report(!memcmp(data->vm[0].uuid, uuid, sizeof(uuid)), "uuid");
+
+out:
+	report_prefix_pop();
+}
+
 int main(void)
 {
 	report_prefix_push("stsi");
 	test_priv();
 	test_specs();
 	test_fc();
+	test_3_2_2();
 	return report_summary();
 }
s390x/unittests.cfg +1 -0
index 12d46c5b402328bb..16e876344e1957ec 100644
@@ -71,6 +71,7 @@ extra_params=-device diag288,id=watchdog0 --watchdog-action inject-nmi
 
 [stsi]
 file = stsi.elf
+extra_params=-name kvm-unit-test --uuid 0fb84a86-727c-11ea-bc55-0242ac130003
 
 [smp]
 file = smp.elf
Signature · 1 line
2.25.1
#1 lore raw
Quoted 21 lines · Janosch Frank

Subcode 3.2.2 is handled by KVM/QEMU and should therefore be tested a bit more thorough.

In this test we set a custom name and uuid through the QEMU command line. Both parameters will be passed to the guest on a stsi subcode 3.2.2 call and will then be checked.

We also compare the total and configured cpu numbers against the smp reported numbers.

---
 s390x/stsi.c        | 62 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  1 +
 2 files changed, 63 insertions(+)
s390x/stsi.c +0 -0
index e9206bca137d2edb..10e588a78cc05186 100644

s390x/stsi.c line 23

Quoted 10 lines
s390x/stsi.c +6 -0
@@ -14,7 +14,28 @@
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <smp.h>
 
+struct stsi_322 {
+    uint8_t  reserved[31];
+    uint8_t  count;
+    struct {
+        uint8_t  reserved2[4];

I dislike aligning the members using double-spaces ...

s390x/stsi.c line 31

Quoted 8 lines
s390x/stsi.c +8 -0
+        uint16_t total_cpus;
+        uint16_t conf_cpus;
+        uint16_t standby_cpus;
+        uint16_t reserved_cpus;
+        uint8_t  name[8];
+        uint32_t caf;
+        uint8_t  cpi[16];
+        uint8_t reserved5[3];

... e.g., here it's not aligned anymore. Just use single spaces.

Quoted 14 lines
s390x/stsi.c +7 -0
+        uint8_t ext_name_encoding;
+        uint32_t reserved3;
+        uint8_t uuid[16];
+    } vm[8];
+    uint8_t reserved4[1504];
+    uint8_t ext_names[8][256];
+};
 static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
 
 static void test_specs(void)
@@ -76,11 +97,52 @@ static void test_fc(void)
 	report(stsi_get_fc(pagebuf) >= 2, "query fc >= 2");
 }
 

s390x/stsi.c static void test_fc(void) · line 109

Quoted 10 lines
s390x/stsi.c +10 -0
+static void test_3_2_2(void)
+{
+	int rc;
+	/* EBCDIC for "kvm-unit" */
+	uint8_t vm_name[] = { 0x92, 0xa5, 0x94, 0x60, 0xa4, 0x95, 0x89, 0xa3 };
+	uint8_t uuid[] = { 0x0f, 0xb8, 0x4a, 0x86, 0x72, 0x7c,
+			   0x11, 0xea, 0xbc, 0x55, 0x02, 0x42, 0xac, 0x13,
+			   0x00, 0x03 };
+	/* EBCDIC for "KVM/" */
+	uint8_t cpi_kvm[] = { 0xd2, 0xe5, 0xd4, 0x61 };

All of these can be const.

s390x/stsi.c static void test_fc(void) · line 114

Quoted 5 lines
s390x/stsi.c +5 -0
+	const char *vm_name_ext = "kvm-unit-test";
+	struct stsi_322 *data = (void *)pagebuf;
+
+	/* Is the function code available at all? */
+	if (stsi_get_fc(pagebuf) < 3)

Maybe report_skip() ?

s390x/stsi.c static void test_fc(void) · line 122

Quoted 8 lines
s390x/stsi.c +8 -0
+		return;
+
+	report_prefix_push("3.2.2");
+	rc = stsi(pagebuf, 3, 2, 2);
+	report(!rc, "call");
+
+	/* For now we concentrate on KVM/QEMU */
+	if (memcmp(&data->vm[0].cpi, cpi_kvm, sizeof(cpi_kvm)))

Maybe report_skip() ?

s390x/stsi.c static void test_fc(void) · line 128

Quoted 6 lines
s390x/stsi.c +6 -0
+		goto out;
+
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");

IIRC, using -smp 1,maxcpus=X, you could also test the reported reserved CPUs.

Also passes under TCG, nice :)

Signature · 3 lines
Thanks,

David / dhildenb
#2 lore raw
Quoted 27 lines · David Hildenbrand
Quoted 26 lines · Janosch Frank

Subcode 3.2.2 is handled by KVM/QEMU and should therefore be tested a bit more thorough.

In this test we set a custom name and uuid through the QEMU command line. Both parameters will be passed to the guest on a stsi subcode 3.2.2 call and will then be checked.

We also compare the total and configured cpu numbers against the smp reported numbers.

---
 s390x/stsi.c        | 62 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  1 +
 2 files changed, 63 insertions(+)
s390x/stsi.c +1 -0
index e9206bca137d2edb..10e588a78cc05186 100644
@@ -14,7 +14,28 @@
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <smp.h>
 
Quoted 7 lines

s390x/stsi.c line 23

Quoted 5 lines
s390x/stsi.c +5 -0
+struct stsi_322 {
+    uint8_t  reserved[31];
+    uint8_t  count;
+    struct {
+        uint8_t  reserved2[4];

I dislike aligning the members using double-spaces ...

Time to fix target/s390x/cpu.h then :)

Quoted 39 lines

s390x/stsi.c line 31

Quoted 9 lines
s390x/stsi.c +8 -0
+        uint16_t total_cpus;
+        uint16_t conf_cpus;
+        uint16_t standby_cpus;
+        uint16_t reserved_cpus;
+        uint8_t  name[8];
+        uint32_t caf;
+        uint8_t  cpi[16];
+        uint8_t reserved5[3];

... e.g., here it's not aligned anymore. Just use single spaces.

Quoted 14 lines
s390x/stsi.c +7 -0
+        uint8_t ext_name_encoding;
+        uint32_t reserved3;
+        uint8_t uuid[16];
+    } vm[8];
+    uint8_t reserved4[1504];
+    uint8_t ext_names[8][256];
+};
 static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
 
 static void test_specs(void)
@@ -76,11 +97,52 @@ static void test_fc(void)
 	report(stsi_get_fc(pagebuf) >= 2, "query fc >= 2");
 }
 

s390x/stsi.c static void test_fc(void) · line 109

Quoted 10 lines
s390x/stsi.c +10 -0
+static void test_3_2_2(void)
+{
+	int rc;
+	/* EBCDIC for "kvm-unit" */
+	uint8_t vm_name[] = { 0x92, 0xa5, 0x94, 0x60, 0xa4, 0x95, 0x89, 0xa3 };
+	uint8_t uuid[] = { 0x0f, 0xb8, 0x4a, 0x86, 0x72, 0x7c,
+			   0x11, 0xea, 0xbc, 0x55, 0x02, 0x42, 0xac, 0x13,
+			   0x00, 0x03 };
+	/* EBCDIC for "KVM/" */
+	uint8_t cpi_kvm[] = { 0xd2, 0xe5, 0xd4, 0x61 };

All of these can be const.

Quoted 7 lines

s390x/stsi.c static void test_fc(void) · line 114

Quoted 5 lines
s390x/stsi.c +5 -0
+	const char *vm_name_ext = "kvm-unit-test";
+	struct stsi_322 *data = (void *)pagebuf;
+
+	/* Is the function code available at all? */
+	if (stsi_get_fc(pagebuf) < 3)

Maybe report_skip() ?

Ack

Quoted 11 lines

s390x/stsi.c static void test_fc(void) · line 122

Quoted 9 lines
s390x/stsi.c +8 -0
+		return;
+
+	report_prefix_push("3.2.2");
+	rc = stsi(pagebuf, 3, 2, 2);
+	report(!rc, "call");
+
+	/* For now we concentrate on KVM/QEMU */
+	if (memcmp(&data->vm[0].cpi, cpi_kvm, sizeof(cpi_kvm)))

Maybe report_skip() ?

Ack

Quoted 10 lines

s390x/stsi.c static void test_fc(void) · line 128

Quoted 7 lines
s390x/stsi.c +6 -0
+		goto out;
+
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");

IIRC, using -smp 1,maxcpus=X, you could also test the reported reserved CPUs.

Will try that

Quoted 4 lines

Also passes under TCG, nice :)

#3 lore raw
Quoted 11 lines · Janosch Frank
Quoted 8 lines · David Hildenbrand

s390x/stsi.c static void test_fc(void) · line 128

Quoted 4 lines · Janosch Frank
s390x/stsi.c +4 -0
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");

IIRC, using -smp 1,maxcpus=X, you could also test the reported reserved CPUs.

Will try that

Just like I thought, QEMU does not manipulate cpu counts and KVM pre-sets standby and reserved to 0. So we have absolutely no change when adding the smp parameter.

Quoted 7 lines
Quoted 5 lines

Also passes under TCG, nice :)

#4 lore raw
Quoted 11 lines · Janosch Frank
Quoted 10 lines · Janosch Frank
Quoted 8 lines · David Hildenbrand

s390x/stsi.c static void test_fc(void) · line 128

Quoted 4 lines · Janosch Frank
s390x/stsi.c +4 -0
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");

IIRC, using -smp 1,maxcpus=X, you could also test the reported reserved CPUs.

Quoted 5 lines
Quoted 1 line

Will try that

Just like I thought, QEMU does not manipulate cpu counts and KVM pre-sets standby and reserved to 0. So we have absolutely no change when adding the smp parameter.

Well, for TCG it is properly implemented. Is this a BUG in KVM's STSI code?

Signature · 3 lines
Thanks,

David / dhildenb
#5 lore raw
Quoted 12 lines · David Hildenbrand
Quoted 11 lines · Janosch Frank
Quoted 10 lines · Janosch Frank
Quoted 8 lines · David Hildenbrand

s390x/stsi.c static void test_fc(void) · line 128

Quoted 4 lines · Janosch Frank
s390x/stsi.c +4 -0
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");

IIRC, using -smp 1,maxcpus=X, you could also test the reported reserved CPUs.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Will try that

Just like I thought, QEMU does not manipulate cpu counts and KVM pre-sets standby and reserved to 0. So we have absolutely no change when adding the smp parameter.

Well, for TCG it is properly implemented. Is this a BUG in KVM's STSI code?

KVM tracks online cpus and created cpus, but only reports the online ones in stsi.
Will QEMU register/create a reserved CPU with KVM?

To fix this we could also fix-up the cpu reporting in QEMU after KVM wrote its results.

@Christian: Guidance?

#6 lore raw
Quoted 22 lines · Janosch Frank
Quoted 12 lines · David Hildenbrand
Quoted 11 lines · Janosch Frank
Quoted 10 lines · Janosch Frank
Quoted 8 lines · David Hildenbrand

s390x/stsi.c static void test_fc(void) · line 128

Quoted 4 lines · Janosch Frank
s390x/stsi.c +4 -0
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");

IIRC, using -smp 1,maxcpus=X, you could also test the reported reserved CPUs.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Will try that

Just like I thought, QEMU does not manipulate cpu counts and KVM pre-sets standby and reserved to 0. So we have absolutely no change when adding the smp parameter.

Well, for TCG it is properly implemented. Is this a BUG in KVM's STSI code?

Quoted 6 lines

KVM tracks online cpus and created cpus, but only reports the online ones in stsi.
Will QEMU register/create a reserved CPU with KVM?

To fix this we could also fix-up the cpu reporting in QEMU after KVM wrote its results.

I think that would be preferred, and handling it similar to the TCG implementation

Quoted 3 lines

@Christian: Guidance?

Signature · 3 lines
Thanks,

David / dhildenb
#7 lore raw
In reply to Janosch Frank
Quoted 22 lines · Janosch Frank
Quoted 12 lines · David Hildenbrand
Quoted 11 lines · Janosch Frank
Quoted 10 lines · Janosch Frank
Quoted 8 lines · David Hildenbrand

s390x/stsi.c static void test_fc(void) · line 128

Quoted 4 lines · Janosch Frank
s390x/stsi.c +4 -0
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");

IIRC, using -smp 1,maxcpus=X, you could also test the reported reserved CPUs.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Will try that

Just like I thought, QEMU does not manipulate cpu counts and KVM pre-sets standby and reserved to 0. So we have absolutely no change when adding the smp parameter.

Well, for TCG it is properly implemented. Is this a BUG in KVM's STSI code?

Quoted 8 lines

KVM tracks online cpus and created cpus, but only reports the online ones in stsi.
Will QEMU register/create a reserved CPU with KVM?

To fix this we could also fix-up the cpu reporting in QEMU after KVM wrote its results.

@Christian: Guidance?

The standby only make sense if we implement the sclp cpu configure things, which we do not. So this can be considered reserved, while standby must be 0.

I think we could implement this in QEMUs insert_stsi_3_2_2 function in kvm.c

#8 lore raw
In reply to Janosch Frank
Quoted 75 lines · Janosch Frank

Subcode 3.2.2 is handled by KVM/QEMU and should therefore be tested a bit more thorough.

In this test we set a custom name and uuid through the QEMU command line. Both parameters will be passed to the guest on a stsi subcode 3.2.2 call and will then be checked.

We also compare the total and configured cpu numbers against the smp reported numbers.

---
 s390x/stsi.c        | 62 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  1 +
 2 files changed, 63 insertions(+)
s390x/stsi.c +43 -0
index e9206bca137d2edb..10e588a78cc05186 100644
@@ -14,7 +14,28 @@
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <smp.h>
 
+struct stsi_322 {
+    uint8_t  reserved[31];
+    uint8_t  count;
+    struct {
+        uint8_t  reserved2[4];
+        uint16_t total_cpus;
+        uint16_t conf_cpus;
+        uint16_t standby_cpus;
+        uint16_t reserved_cpus;
+        uint8_t  name[8];
+        uint32_t caf;
+        uint8_t  cpi[16];
+        uint8_t reserved5[3];
+        uint8_t ext_name_encoding;
+        uint32_t reserved3;
+        uint8_t uuid[16];
+    } vm[8];
+    uint8_t reserved4[1504];
+    uint8_t ext_names[8][256];
+};
 static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
 
 static void test_specs(void)
@@ -76,11 +97,52 @@ static void test_fc(void)
 	report(stsi_get_fc(pagebuf) >= 2, "query fc >= 2");
 }
 
+static void test_3_2_2(void)
+{
+	int rc;
+	/* EBCDIC for "kvm-unit" */
+	uint8_t vm_name[] = { 0x92, 0xa5, 0x94, 0x60, 0xa4, 0x95, 0x89, 0xa3 };
+	uint8_t uuid[] = { 0x0f, 0xb8, 0x4a, 0x86, 0x72, 0x7c,
+			   0x11, 0xea, 0xbc, 0x55, 0x02, 0x42, 0xac, 0x13,
+			   0x00, 0x03 };
+	/* EBCDIC for "KVM/" */
+	uint8_t cpi_kvm[] = { 0xd2, 0xe5, 0xd4, 0x61 };
+	const char *vm_name_ext = "kvm-unit-test";
+	struct stsi_322 *data = (void *)pagebuf;
+
+	/* Is the function code available at all? */
+	if (stsi_get_fc(pagebuf) < 3)
+		return;
+
+	report_prefix_push("3.2.2");
+	rc = stsi(pagebuf, 3, 2, 2);
+	report(!rc, "call");
+
+	/* For now we concentrate on KVM/QEMU */

s390x/stsi.c static void test_fc(void) · line 131

Quoted 10 lines
s390x/stsi.c +10 -0
+	if (memcmp(&data->vm[0].cpi, cpi_kvm, sizeof(cpi_kvm)))
+		goto out;
+
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");
+	report(!memcmp(data->vm[0].name, vm_name, sizeof(data->vm[0].name)),
+	       "VM name == kvm-unit-test");
+	report(data->vm[0].ext_name_encoding == 2, "ext name encoding UTF-8");

should you rather do

if (data->vm[0].ext_name_encoding == 2) {
	...
} else {
	report_skip(...);
}

to make this future-proof?

Signature · 3 lines
Thanks,

David / dhildenb
#9 lore raw
Quoted 89 lines · David Hildenbrand
Quoted 75 lines · Janosch Frank

Subcode 3.2.2 is handled by KVM/QEMU and should therefore be tested a bit more thorough.

In this test we set a custom name and uuid through the QEMU command line. Both parameters will be passed to the guest on a stsi subcode 3.2.2 call and will then be checked.

We also compare the total and configured cpu numbers against the smp reported numbers.

---
 s390x/stsi.c        | 62 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  1 +
 2 files changed, 63 insertions(+)
s390x/stsi.c +43 -0
index e9206bca137d2edb..10e588a78cc05186 100644
@@ -14,7 +14,28 @@
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <smp.h>
 
+struct stsi_322 {
+    uint8_t  reserved[31];
+    uint8_t  count;
+    struct {
+        uint8_t  reserved2[4];
+        uint16_t total_cpus;
+        uint16_t conf_cpus;
+        uint16_t standby_cpus;
+        uint16_t reserved_cpus;
+        uint8_t  name[8];
+        uint32_t caf;
+        uint8_t  cpi[16];
+        uint8_t reserved5[3];
+        uint8_t ext_name_encoding;
+        uint32_t reserved3;
+        uint8_t uuid[16];
+    } vm[8];
+    uint8_t reserved4[1504];
+    uint8_t ext_names[8][256];
+};
 static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
 
 static void test_specs(void)
@@ -76,11 +97,52 @@ static void test_fc(void)
 	report(stsi_get_fc(pagebuf) >= 2, "query fc >= 2");
 }
 
+static void test_3_2_2(void)
+{
+	int rc;
+	/* EBCDIC for "kvm-unit" */
+	uint8_t vm_name[] = { 0x92, 0xa5, 0x94, 0x60, 0xa4, 0x95, 0x89, 0xa3 };
+	uint8_t uuid[] = { 0x0f, 0xb8, 0x4a, 0x86, 0x72, 0x7c,
+			   0x11, 0xea, 0xbc, 0x55, 0x02, 0x42, 0xac, 0x13,
+			   0x00, 0x03 };
+	/* EBCDIC for "KVM/" */
+	uint8_t cpi_kvm[] = { 0xd2, 0xe5, 0xd4, 0x61 };
+	const char *vm_name_ext = "kvm-unit-test";
+	struct stsi_322 *data = (void *)pagebuf;
+
+	/* Is the function code available at all? */
+	if (stsi_get_fc(pagebuf) < 3)
+		return;
+
+	report_prefix_push("3.2.2");
+	rc = stsi(pagebuf, 3, 2, 2);
+	report(!rc, "call");
+
+	/* For now we concentrate on KVM/QEMU */

s390x/stsi.c static void test_fc(void) · line 131

Quoted 10 lines
s390x/stsi.c +10 -0
+	if (memcmp(&data->vm[0].cpi, cpi_kvm, sizeof(cpi_kvm)))
+		goto out;
+
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");
+	report(!memcmp(data->vm[0].name, vm_name, sizeof(data->vm[0].name)),
+	       "VM name == kvm-unit-test");
+	report(data->vm[0].ext_name_encoding == 2, "ext name encoding UTF-8");

should you rather do

Quoted 8 lines
if (data->vm[0].ext_name_encoding == 2) {
	...
} else {
	report_skip(...);
}

to make this future-proof?

Do you expect UTF-16 or EBCDIC in the future? :)

#10 lore raw
Quoted 96 lines · Janosch Frank
Quoted 95 lines · David Hildenbrand
Quoted 75 lines · Janosch Frank

Subcode 3.2.2 is handled by KVM/QEMU and should therefore be tested a bit more thorough.

In this test we set a custom name and uuid through the QEMU command line. Both parameters will be passed to the guest on a stsi subcode 3.2.2 call and will then be checked.

We also compare the total and configured cpu numbers against the smp reported numbers.

---
 s390x/stsi.c        | 62 +++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  1 +
 2 files changed, 63 insertions(+)
s390x/stsi.c +43 -0
index e9206bca137d2edb..10e588a78cc05186 100644
@@ -14,7 +14,28 @@
 #include <asm/page.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <smp.h>
 
+struct stsi_322 {
+    uint8_t  reserved[31];
+    uint8_t  count;
+    struct {
+        uint8_t  reserved2[4];
+        uint16_t total_cpus;
+        uint16_t conf_cpus;
+        uint16_t standby_cpus;
+        uint16_t reserved_cpus;
+        uint8_t  name[8];
+        uint32_t caf;
+        uint8_t  cpi[16];
+        uint8_t reserved5[3];
+        uint8_t ext_name_encoding;
+        uint32_t reserved3;
+        uint8_t uuid[16];
+    } vm[8];
+    uint8_t reserved4[1504];
+    uint8_t ext_names[8][256];
+};
 static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
 
 static void test_specs(void)
@@ -76,11 +97,52 @@ static void test_fc(void)
 	report(stsi_get_fc(pagebuf) >= 2, "query fc >= 2");
 }
 
+static void test_3_2_2(void)
+{
+	int rc;
+	/* EBCDIC for "kvm-unit" */
+	uint8_t vm_name[] = { 0x92, 0xa5, 0x94, 0x60, 0xa4, 0x95, 0x89, 0xa3 };
+	uint8_t uuid[] = { 0x0f, 0xb8, 0x4a, 0x86, 0x72, 0x7c,
+			   0x11, 0xea, 0xbc, 0x55, 0x02, 0x42, 0xac, 0x13,
+			   0x00, 0x03 };
+	/* EBCDIC for "KVM/" */
+	uint8_t cpi_kvm[] = { 0xd2, 0xe5, 0xd4, 0x61 };
+	const char *vm_name_ext = "kvm-unit-test";
+	struct stsi_322 *data = (void *)pagebuf;
+
+	/* Is the function code available at all? */
+	if (stsi_get_fc(pagebuf) < 3)
+		return;
+
+	report_prefix_push("3.2.2");
+	rc = stsi(pagebuf, 3, 2, 2);
+	report(!rc, "call");
+
+	/* For now we concentrate on KVM/QEMU */

s390x/stsi.c static void test_fc(void) · line 131

Quoted 10 lines
s390x/stsi.c +10 -0
+	if (memcmp(&data->vm[0].cpi, cpi_kvm, sizeof(cpi_kvm)))
+		goto out;
+
+	report(data->vm[0].total_cpus == smp_query_num_cpus(), "cpu # total");
+	report(data->vm[0].conf_cpus == smp_query_num_cpus(), "cpu # configured");
+	report(data->vm[0].standby_cpus == 0, "cpu # standby");
+	report(data->vm[0].reserved_cpus == 0, "cpu # reserved");
+	report(!memcmp(data->vm[0].name, vm_name, sizeof(data->vm[0].name)),
+	       "VM name == kvm-unit-test");
+	report(data->vm[0].ext_name_encoding == 2, "ext name encoding UTF-8");

should you rather do

if (data->vm[0].ext_name_encoding == 2) {
	...
} else {
	report_skip(...);
}
Quoted 3 lines
Quoted 2 lines

to make this future-proof?

Do you expect UTF-16 or EBCDIC in the future? :)

Well, you never know :) If there is an option for other encodings ...

Signature · 3 lines
Thanks,

David / dhildenb