Skip to contentSkip to conversation

s390x: cpumodel: Add sclp checks

PATCH Superseded Janosch Frank 4 participants 16 messages May 10, 2021 – May 11, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover s390x: cpumodel: Add sclp checks

SCLP facilities have been a bit overlooked in cpumodel tests and have recently caused some headaches. So lets extend the tests and the library with a bit of sclp feature checking.

Based on the uv_host branch / patches.

Janosch Frank (4):
s390x: sclp: Only fetch read info byte 134 if cpu entries are above it
lib: s390x: sclp: Extend feature probing
s390x: cpumodel: FMT4 SCLP test
s390x: cpumodel: FMT2 SCLP implies test

 lib/s390x/sclp.c | 23 +++++++++++++++-
 lib/s390x/sclp.h | 38 ++++++++++++++++++++++++--
 s390x/cpumodel.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 127 insertions(+), 5 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/4 s390x: sclp: Only fetch read info byte 134 if cpu entries are above it

The cpu offset tells us where the cpu entries are in the sclp read info structure.

---
 lib/s390x/sclp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/s390x/sclp.c +2 -1
index 7a9b2c52..f11c2035 100644
@@ -138,7 +138,8 @@ void sclp_facilities_setup(void)
 	assert(read_info);
 
 	cpu = sclp_get_cpu_entries();
-	sclp_facilities.has_diag318 = read_info->byte_134_diag318;
+	if (read_info->offset_cpu > 134)
+		sclp_facilities.has_diag318 = read_info->byte_134_diag318;
 	for (i = 0; i < read_info->entries_cpu; i++, cpu++) {
 		/*
 		 * The logic for only reading the facilities from the
Signature · 1 line
2.30.2
Reviewed-by on v1 1/4
#2 lore raw

Re: [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it

Quoted 15 lines · Janosch Frank

The cpu offset tells us where the cpu entries are in the sclp read info structure.

---
  lib/s390x/sclp.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
lib/s390x/sclp.c +0 -0
index 7a9b2c52..f11c2035 100644

lib/s390x/sclp.c void sclp_facilities_setup(void) · line 145

Quoted 9 lines
lib/s390x/sclp.c +2 -1
@@ -138,7 +138,8 @@ void sclp_facilities_setup(void)
  	assert(read_info);
 
  	cpu = sclp_get_cpu_entries();
-	sclp_facilities.has_diag318 = read_info->byte_134_diag318;
+	if (read_info->offset_cpu > 134)
+		sclp_facilities.has_diag318 = read_info->byte_134_diag318;
  	for (i = 0; i < read_info->entries_cpu; i++, cpu++) {
  		/*
  		 * The logic for only reading the facilities from the
Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v1 1/4
#3 lore raw

Re: [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it

In reply to Janosch Frank
Quoted 8 lines · On Mon, 10 May 2021 15:00:12 +0000 Janosch Frank <[email protected]> wrote:

The cpu offset tells us where the cpu entries are in the sclp read info structure.

---
 lib/s390x/sclp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#4 lore raw

PATCH 2/4 lib: s390x: sclp: Extend feature probing

In reply to Janosch Frank

Lets grab more of the feature bits from SCLP read info so we can use them in the cpumodel tests.

---
 lib/s390x/sclp.c | 20 ++++++++++++++++++++
 lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
 2 files changed, 55 insertions(+), 3 deletions(-)
lib/s390x/sclp.c +20 -0
index f11c2035..f25cfdb2 100644
@@ -129,6 +129,13 @@ CPUEntry *sclp_get_cpu_entries(void)
 	return (CPUEntry *)(_read_info + read_info->offset_cpu);
 }
 
+static bool sclp_feat_check(int byte, int mask)
+{
+	uint8_t *rib = (uint8_t *)read_info;
+
+	return !!(rib[byte] & mask);
+}
+
 void sclp_facilities_setup(void)
 {
 	unsigned short cpu0_addr = stap();
@@ -140,6 +147,14 @@ void sclp_facilities_setup(void)
 	cpu = sclp_get_cpu_entries();
 	if (read_info->offset_cpu > 134)
 		sclp_facilities.has_diag318 = read_info->byte_134_diag318;
+	sclp_facilities.has_gsls = sclp_feat_check(85, SCLP_FEAT_85_MASK_GSLS);
+	sclp_facilities.has_kss = sclp_feat_check(98, SCLP_FEAT_98_MASK_KSS);
+	sclp_facilities.has_cmma = sclp_feat_check(116, SCLP_FEAT_116_MASK_CMMA);
+	sclp_facilities.has_64bscao = sclp_feat_check(116, SCLP_FEAT_116_MASK_64BSCAO);
+	sclp_facilities.has_esca = sclp_feat_check(116, SCLP_FEAT_116_MASK_ESCA);
+	sclp_facilities.has_ibs = sclp_feat_check(117, SCLP_FEAT_117_MASK_IBS);
+	sclp_facilities.has_pfmfi = sclp_feat_check(117, SCLP_FEAT_117_MASK_PFMFI);
+
 	for (i = 0; i < read_info->entries_cpu; i++, cpu++) {
 		/*
 		 * The logic for only reading the facilities from the
@@ -150,6 +165,11 @@ void sclp_facilities_setup(void)
 		 */
 		if (cpu->address == cpu0_addr) {
 			sclp_facilities.has_sief2 = cpu->feat_sief2;
+			sclp_facilities.has_skeyi = cpu->feat_skeyi;
+			sclp_facilities.has_siif = cpu->feat_siif;
+			sclp_facilities.has_sigpif = cpu->feat_sigpif;
+			sclp_facilities.has_ib = cpu->feat_ib;
+			sclp_facilities.has_cei = cpu->feat_cei;
 			break;
 		}
 	}
lib/s390x/sclp.h +35 -3
index 85231333..48df1260 100644
@@ -94,9 +94,19 @@ typedef struct CPUEntry {
 	uint8_t reserved0;
 	uint8_t : 4;
 	uint8_t feat_sief2 : 1;
+	uint8_t feat_skeyi : 1;
+	uint8_t : 2;
+	uint8_t : 2;
+	uint8_t feat_gpere : 1;
+	uint8_t feat_siif : 1;
+	uint8_t feat_sigpif : 1;
 	uint8_t : 3;
-	uint8_t features_res2 [SCCB_CPU_FEATURE_LEN - 1];
-	uint8_t reserved2[6];
+	uint8_t reserved2[3];
+	uint8_t : 2;
+	uint8_t feat_ib : 1;
+	uint8_t feat_cei : 1;
+	uint8_t : 4;
+	uint8_t reserved3[6];
 	uint8_t type;
 	uint8_t reserved1;
 } __attribute__((packed)) CPUEntry;
@@ -105,10 +115,32 @@ extern struct sclp_facilities sclp_facilities;
 
 struct sclp_facilities {
 	uint64_t has_sief2 : 1;
+	uint64_t has_skeyi : 1;
+	uint64_t has_gpere : 1;
+	uint64_t has_siif : 1;
+	uint64_t has_sigpif : 1;
+	uint64_t has_ib : 1;
+	uint64_t has_cei : 1;
+
 	uint64_t has_diag318 : 1;
-	uint64_t : 62;
+	uint64_t has_gsls : 1;
+	uint64_t has_cmma : 1;
+	uint64_t has_64bscao : 1;
+	uint64_t has_esca : 1;
+	uint64_t has_kss : 1;
+	uint64_t has_pfmfi : 1;
+	uint64_t has_ibs : 1;
+	uint64_t : 64 - 15;
 };
 
+#define SCLP_FEAT_85_MASK_GSLS		(1 << 7)
+#define SCLP_FEAT_98_MASK_KSS		(1 << 0)
+#define SCLP_FEAT_116_MASK_64BSCAO	(1 << 7)
+#define SCLP_FEAT_116_MASK_CMMA		(1 << 6)
+#define SCLP_FEAT_116_MASK_ESCA		(1 << 3)
+#define SCLP_FEAT_117_MASK_PFMFI	(1 << 6)
+#define SCLP_FEAT_117_MASK_IBS		(1 << 5)
+
 typedef struct ReadInfo {
 	SCCBHeader h;
 	uint16_t rnmax;
Signature · 1 line
2.30.2
#5 lore raw

Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing

Quoted 15 lines · Janosch Frank

Lets grab more of the feature bits from SCLP read info so we can use them in the cpumodel tests.

---
  lib/s390x/sclp.c | 20 ++++++++++++++++++++
  lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
  2 files changed, 55 insertions(+), 3 deletions(-)
lib/s390x/sclp.c +0 -0
index f11c2035..f25cfdb2 100644

lib/s390x/sclp.c CPUEntry *sclp_get_cpu_entries(void) · line 137

Quoted 9 lines
lib/s390x/sclp.c +6 -0
@@ -129,6 +129,13 @@ CPUEntry *sclp_get_cpu_entries(void)
  	return (CPUEntry *)(_read_info + read_info->offset_cpu);
  }
 
+static bool sclp_feat_check(int byte, int mask)
+{
+	uint8_t *rib = (uint8_t *)read_info;
+
+	return !!(rib[byte] & mask);
+}

Instead of a mask, I'd just check for bit (offset) numbers within the byte.

static bool sclp_feat_check(int byte, int bit)

{
	uint8_t *rib = (uint8_t *)read_info;

	return !!(rib[byte] & (0x80 >> bit));
}
Signature · 3 lines
Thanks,

David / dhildenb
#6 lore raw

Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing

Quoted 29 lines · On Tue, 11 May 2021 13:43:36 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 15 lines · Janosch Frank

Lets grab more of the feature bits from SCLP read info so we can use them in the cpumodel tests.

---
  lib/s390x/sclp.c | 20 ++++++++++++++++++++
  lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
  2 files changed, 55 insertions(+), 3 deletions(-)
lib/s390x/sclp.c +0 -0
index f11c2035..f25cfdb2 100644

lib/s390x/sclp.c CPUEntry *sclp_get_cpu_entries(void) · line 137

Quoted 9 lines
lib/s390x/sclp.c +6 -0
@@ -129,6 +129,13 @@ CPUEntry *sclp_get_cpu_entries(void)
  	return (CPUEntry *)(_read_info + read_info->offset_cpu);
  }
 
+static bool sclp_feat_check(int byte, int mask)
+{
+	uint8_t *rib = (uint8_t *)read_info;
+
+	return !!(rib[byte] & mask);
+}  

Instead of a mask, I'd just check for bit (offset) numbers within the byte.

Quoted 6 lines

static bool sclp_feat_check(int byte, int bit)

{
	uint8_t *rib = (uint8_t *)read_info;

	return !!(rib[byte] & (0x80 >> bit));
}

using a mask might be useful to check multiple facilities at the same time, but in that case the check should be

return (rib[byte] & mask) == mask

I have no strong opinions either way

#7 lore raw

Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing

Quoted 36 lines · Claudio Imbrenda
Quoted 33 lines · On Tue, 11 May 2021 13:43:36 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 15 lines · Janosch Frank

Lets grab more of the feature bits from SCLP read info so we can use them in the cpumodel tests.

---
   lib/s390x/sclp.c | 20 ++++++++++++++++++++
   lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
   2 files changed, 55 insertions(+), 3 deletions(-)
lib/s390x/sclp.c +0 -0
index f11c2035..f25cfdb2 100644

lib/s390x/sclp.c CPUEntry *sclp_get_cpu_entries(void) · line 137

Quoted 9 lines
lib/s390x/sclp.c +6 -0
@@ -129,6 +129,13 @@ CPUEntry *sclp_get_cpu_entries(void)
   	return (CPUEntry *)(_read_info + read_info->offset_cpu);
   }
 
+static bool sclp_feat_check(int byte, int mask)
+{
+	uint8_t *rib = (uint8_t *)read_info;
+
+	return !!(rib[byte] & mask);
+}

Instead of a mask, I'd just check for bit (offset) numbers within the byte.

static bool sclp_feat_check(int byte, int bit)

{
	uint8_t *rib = (uint8_t *)read_info;
Quoted 5 lines
Quoted 2 lines
	return !!(rib[byte] & (0x80 >> bit));
}

using a mask might be useful to check multiple facilities at the same time, but in that case the check should be

IMHO checking with a mask here multiple facilities will be very error prone either way ... and we only have a single byte to check for.

Signature · 3 lines
Thanks,

David / dhildenb
#8 lore raw

Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing

Quoted 37 lines · On Tue, 11 May 2021 17:38:04 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 36 lines · Claudio Imbrenda
Quoted 33 lines · On Tue, 11 May 2021 13:43:36 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 15 lines · Janosch Frank

Lets grab more of the feature bits from SCLP read info so we can use them in the cpumodel tests.

---
   lib/s390x/sclp.c | 20 ++++++++++++++++++++
   lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
   2 files changed, 55 insertions(+), 3 deletions(-)
lib/s390x/sclp.c +0 -0
index f11c2035..f25cfdb2 100644

lib/s390x/sclp.c CPUEntry *sclp_get_cpu_entries(void) · line 137

Quoted 9 lines
lib/s390x/sclp.c +6 -0
@@ -129,6 +129,13 @@ CPUEntry *sclp_get_cpu_entries(void)
   	return (CPUEntry *)(_read_info +
 read_info->offset_cpu); }
 
+static bool sclp_feat_check(int byte, int mask)
+{
+	uint8_t *rib = (uint8_t *)read_info;
+
+	return !!(rib[byte] & mask);
+}  

Instead of a mask, I'd just check for bit (offset) numbers within the byte.

static bool sclp_feat_check(int byte, int bit)

{
	uint8_t *rib = (uint8_t *)read_info;
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
	return !!(rib[byte] & (0x80 >> bit));
}  

using a mask might be useful to check multiple facilities at the same time, but in that case the check should be

IMHO checking with a mask here multiple facilities will be very error prone either way ... and we only have a single byte to check for.

as I said, I do not have a strong opinion either way :)

#9 lore raw

Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing

Quoted 43 lines · On Tue, 11 May 2021 17:46:45 +0200 Claudio Imbrenda <[email protected]>…
Quoted 40 lines · On Tue, 11 May 2021 17:38:04 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 39 lines · Claudio Imbrenda
Quoted 35 lines · On Tue, 11 May 2021 13:43:36 +0200 David Hildenbrand <[email protected]> wrote:
Quoted 15 lines · Janosch Frank

Lets grab more of the feature bits from SCLP read info so we can use them in the cpumodel tests.

---
   lib/s390x/sclp.c | 20 ++++++++++++++++++++
   lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
   2 files changed, 55 insertions(+), 3 deletions(-)
lib/s390x/sclp.c +0 -0
index f11c2035..f25cfdb2 100644

lib/s390x/sclp.c CPUEntry *sclp_get_cpu_entries(void) · line 137

Quoted 9 lines
lib/s390x/sclp.c +6 -0
@@ -129,6 +129,13 @@ CPUEntry *sclp_get_cpu_entries(void)
   	return (CPUEntry *)(_read_info +
 read_info->offset_cpu); }
 
+static bool sclp_feat_check(int byte, int mask)
+{
+	uint8_t *rib = (uint8_t *)read_info;
+
+	return !!(rib[byte] & mask);
+}    

Instead of a mask, I'd just check for bit (offset) numbers within the byte.

static bool sclp_feat_check(int byte, int bit)

{
	uint8_t *rib = (uint8_t *)read_info;

	return !!(rib[byte] & (0x80 >> bit));
}    
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

using a mask might be useful to check multiple facilities at the same time, but in that case the check should be

IMHO checking with a mask here multiple facilities will be very error prone either way ... and we only have a single byte to check for.

as I said, I do not have a strong opinion either way :)

If you need a tie breaker, I'd vote for bit over mask :)

#10 lore raw

PATCH 3/4 s390x: cpumodel: FMT4 SCLP test

In reply to Janosch Frank

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.

---
 s390x/cpumodel.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)
s390x/cpumodel.c +58 -1
index 4dd8b96f..619c3dc7 100644
@@ -2,14 +2,69 @@
 /*
  * Test the known dependencies for facilities
  *
- * Copyright 2019 IBM Corp.
+ * Copyright 2019, 2021 IBM Corp.
  *
  * Authors:
  *    Christian Borntraeger <[email protected]>
+ *    Janosch Frank <[email protected]>
  */
 
 #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(void)
+{
+	report_prefix_push("sclp");
+
+	if (uv_os_is_guest())
+		test_sclp_features_fmt4();
+
+	report_prefix_pop();
+}
 
 static struct {
 	int facility;
@@ -60,6 +115,8 @@ int main(void)
 	}
 	report_prefix_pop();
 
+	test_sclp_features();
+
 	report_prefix_pop();
 	return report_summary();
 }
Signature · 1 line
2.30.2
Acked-by on v1 3/4
#11 lore raw

Re: [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test

Quoted 85 lines · Janosch Frank

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.

---
  s390x/cpumodel.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 58 insertions(+), 1 deletion(-)
s390x/cpumodel.c +56 -1
index 4dd8b96f..619c3dc7 100644
@@ -2,14 +2,69 @@
  /*
   * Test the known dependencies for facilities
   *
- * Copyright 2019 IBM Corp.
+ * Copyright 2019, 2021 IBM Corp.
   *
   * Authors:
   *    Christian Borntraeger <[email protected]>
+ *    Janosch Frank <[email protected]>
   */
 
  #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(void)
+{
+	report_prefix_push("sclp");
+
+	if (uv_os_is_guest())
+		test_sclp_features_fmt4();
+
+	report_prefix_pop();
+}
 
  static struct {
  	int facility;

s390x/cpumodel.c int main(void) · line 122

Quoted 8 lines
s390x/cpumodel.c +2 -0
@@ -60,6 +115,8 @@ int main(void)
  	}
  	report_prefix_pop();
 
+	test_sclp_features();
+
  	report_prefix_pop();
  	return report_summary();
  }
Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v1 3/4
#12 lore raw

Re: [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test

In reply to Janosch Frank
Quoted 4 lines · On Mon, 10 May 2021 15:00:14 +0000 Janosch Frank <[email protected]> wrote:

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.

Quoted 90 lines
---
 s390x/cpumodel.c | 59

+++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-)

s390x/cpumodel.c +18 -1
index 4dd8b96f..619c3dc7 100644
@@ -2,14 +2,69 @@
 /*
  * Test the known dependencies for facilities
  *
- * Copyright 2019 IBM Corp.
+ * Copyright 2019, 2021 IBM Corp.
  *
  * Authors:
  *    Christian Borntraeger <[email protected]>
+ *    Janosch Frank <[email protected]>
  */
 
 #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 */

s390x/cpumodel.c +40 -0
+	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(void)
+{
+	report_prefix_push("sclp");
+
+	if (uv_os_is_guest())
+		test_sclp_features_fmt4();
+
+	report_prefix_pop();
+}
 
 static struct {
 	int facility;
@@ -60,6 +115,8 @@ int main(void)
 	}
 	report_prefix_pop();
 
+	test_sclp_features();
+
 	report_prefix_pop();
 	return report_summary();
 }
#13 lore raw

PATCH 4/4 s390x: cpumodel: FMT2 SCLP implies test

In reply to Janosch Frank

The sie facilities require sief2 to also be enabled, so lets check if that's the case.

---
 s390x/cpumodel.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
s390x/cpumodel.c +12 -0
index 619c3dc7..67bb6543 100644
@@ -56,12 +56,24 @@ static void test_sclp_features_fmt4(void)
 	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();
 }
Signature · 1 line
2.30.2
Acked-by on v1 4/4
#14 lore raw

Re: [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test

Quoted 28 lines · Janosch Frank

The sie facilities require sief2 to also be enabled, so lets check if that's the case.

---
  s390x/cpumodel.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
s390x/cpumodel.c +10 -0
index 619c3dc7..67bb6543 100644
@@ -56,12 +56,24 @@ static void test_sclp_features_fmt4(void)
  	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)

s390x/cpumodel.c static void test_sclp_features_fmt4(void) · line 79

Quoted 10 lines
s390x/cpumodel.c +2 -0
  {
  	report_prefix_push("sclp");
 
  	if (uv_os_is_guest())
  		test_sclp_features_fmt4();
+	else
+		test_sclp_features_fmt2();
 
  	report_prefix_pop();
  }

I'd fold that into the previous patch

Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v1 4/4
#15 lore raw

Re: [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test

In reply to Janosch Frank
Quoted 4 lines · On Mon, 10 May 2021 15:00:15 +0000 Janosch Frank <[email protected]> wrote:

The sie facilities require sief2 to also be enabled, so lets check if that's the case.

I agree with David, you can fold this in the previous patch

Quoted 33 lines
---
 s390x/cpumodel.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
s390x/cpumodel.c +12 -0
index 619c3dc7..67bb6543 100644
@@ -56,12 +56,24 @@ static void test_sclp_features_fmt4(void)
 	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();
 }