kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH 0/4] s390x: cpumodel: Add sclp checks
@ 2021-05-10 15:00 Janosch Frank
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it Janosch Frank
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Janosch Frank @ 2021-05-10 15:00 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, cohuck, linux-s390, imbrenda, thuth

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(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it
  2021-05-10 15:00 [kvm-unit-tests PATCH 0/4] s390x: cpumodel: Add sclp checks Janosch Frank
@ 2021-05-10 15:00 ` Janosch Frank
  2021-05-11 11:39   ` David Hildenbrand
  2021-05-11 16:32   ` Cornelia Huck
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing Janosch Frank
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 16+ messages in thread
From: Janosch Frank @ 2021-05-10 15:00 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, cohuck, linux-s390, imbrenda, thuth

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

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 lib/s390x/sclp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
index 7a9b2c52..f11c2035 100644
--- a/lib/s390x/sclp.c
+++ b/lib/s390x/sclp.c
@@ -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
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing
  2021-05-10 15:00 [kvm-unit-tests PATCH 0/4] s390x: cpumodel: Add sclp checks Janosch Frank
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it Janosch Frank
@ 2021-05-10 15:00 ` Janosch Frank
  2021-05-11 11:43   ` David Hildenbrand
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test Janosch Frank
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test Janosch Frank
  3 siblings, 1 reply; 16+ messages in thread
From: Janosch Frank @ 2021-05-10 15:00 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, cohuck, linux-s390, imbrenda, thuth

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

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 lib/s390x/sclp.c | 20 ++++++++++++++++++++
 lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
index f11c2035..f25cfdb2 100644
--- a/lib/s390x/sclp.c
+++ b/lib/s390x/sclp.c
@@ -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;
 		}
 	}
diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h
index 85231333..48df1260 100644
--- a/lib/s390x/sclp.h
+++ b/lib/s390x/sclp.h
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test
  2021-05-10 15:00 [kvm-unit-tests PATCH 0/4] s390x: cpumodel: Add sclp checks Janosch Frank
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it Janosch Frank
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing Janosch Frank
@ 2021-05-10 15:00 ` Janosch Frank
  2021-05-11 11:45   ` David Hildenbrand
  2021-05-11 14:42   ` Claudio Imbrenda
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test Janosch Frank
  3 siblings, 2 replies; 16+ messages in thread
From: Janosch Frank @ 2021-05-10 15:00 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, cohuck, linux-s390, imbrenda, thuth

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>
---
 s390x/cpumodel.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c
index 4dd8b96f..619c3dc7 100644
--- a/s390x/cpumodel.c
+++ b/s390x/cpumodel.c
@@ -2,14 +2,69 @@
 /*
  * 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(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();
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test
  2021-05-10 15:00 [kvm-unit-tests PATCH 0/4] s390x: cpumodel: Add sclp checks Janosch Frank
                   ` (2 preceding siblings ...)
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test Janosch Frank
@ 2021-05-10 15:00 ` Janosch Frank
  2021-05-11 11:46   ` David Hildenbrand
  2021-05-11 14:36   ` Claudio Imbrenda
  3 siblings, 2 replies; 16+ messages in thread
From: Janosch Frank @ 2021-05-10 15:00 UTC (permalink / raw)
  To: kvm; +Cc: frankja, david, cohuck, linux-s390, imbrenda, thuth

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

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/cpumodel.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c
index 619c3dc7..67bb6543 100644
--- a/s390x/cpumodel.c
+++ b/s390x/cpumodel.c
@@ -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();
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it Janosch Frank
@ 2021-05-11 11:39   ` David Hildenbrand
  2021-05-11 16:32   ` Cornelia Huck
  1 sibling, 0 replies; 16+ messages in thread
From: David Hildenbrand @ 2021-05-11 11:39 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: cohuck, linux-s390, imbrenda, thuth

On 10.05.21 17:00, Janosch Frank wrote:
> The cpu offset tells us where the cpu entries are in the sclp read
> info structure.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
>   lib/s390x/sclp.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
> index 7a9b2c52..f11c2035 100644
> --- a/lib/s390x/sclp.c
> +++ b/lib/s390x/sclp.c
> @@ -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
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing Janosch Frank
@ 2021-05-11 11:43   ` David Hildenbrand
  2021-05-11 14:41     ` Claudio Imbrenda
  0 siblings, 1 reply; 16+ messages in thread
From: David Hildenbrand @ 2021-05-11 11:43 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: cohuck, linux-s390, imbrenda, thuth

On 10.05.21 17:00, Janosch Frank wrote:
> Lets grab more of the feature bits from SCLP read info so we can use
> them in the cpumodel tests.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
>   lib/s390x/sclp.c | 20 ++++++++++++++++++++
>   lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
>   2 files changed, 55 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
> index f11c2035..f25cfdb2 100644
> --- a/lib/s390x/sclp.c
> +++ b/lib/s390x/sclp.c
> @@ -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));
}

-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test Janosch Frank
@ 2021-05-11 11:45   ` David Hildenbrand
  2021-05-11 14:42   ` Claudio Imbrenda
  1 sibling, 0 replies; 16+ messages in thread
From: David Hildenbrand @ 2021-05-11 11:45 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: cohuck, linux-s390, imbrenda, thuth

On 10.05.21 17:00, Janosch Frank 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.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>   s390x/cpumodel.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 58 insertions(+), 1 deletion(-)
> 
> diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c
> index 4dd8b96f..619c3dc7 100644
> --- a/s390x/cpumodel.c
> +++ b/s390x/cpumodel.c
> @@ -2,14 +2,69 @@
>   /*
>    * 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(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();
>   }
> 

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test Janosch Frank
@ 2021-05-11 11:46   ` David Hildenbrand
  2021-05-11 14:36   ` Claudio Imbrenda
  1 sibling, 0 replies; 16+ messages in thread
From: David Hildenbrand @ 2021-05-11 11:46 UTC (permalink / raw)
  To: Janosch Frank, kvm; +Cc: cohuck, linux-s390, imbrenda, thuth

On 10.05.21 17:00, Janosch Frank wrote:
> The sie facilities require sief2 to also be enabled, so lets check if
> that's the case.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>   s390x/cpumodel.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c
> index 619c3dc7..67bb6543 100644
> --- a/s390x/cpumodel.c
> +++ b/s390x/cpumodel.c
> @@ -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();
>   }
> 

I'd fold that into the previous patch

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test Janosch Frank
  2021-05-11 11:46   ` David Hildenbrand
@ 2021-05-11 14:36   ` Claudio Imbrenda
  1 sibling, 0 replies; 16+ messages in thread
From: Claudio Imbrenda @ 2021-05-11 14:36 UTC (permalink / raw)
  To: Janosch Frank; +Cc: kvm, david, cohuck, linux-s390, thuth

On Mon, 10 May 2021 15:00:15 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> The sie facilities require sief2 to also be enabled, so lets check if
> that's the case.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

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

> ---
>  s390x/cpumodel.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c
> index 619c3dc7..67bb6543 100644
> --- a/s390x/cpumodel.c
> +++ b/s390x/cpumodel.c
> @@ -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();
>  }


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing
  2021-05-11 11:43   ` David Hildenbrand
@ 2021-05-11 14:41     ` Claudio Imbrenda
  2021-05-11 15:38       ` David Hildenbrand
  0 siblings, 1 reply; 16+ messages in thread
From: Claudio Imbrenda @ 2021-05-11 14:41 UTC (permalink / raw)
  To: David Hildenbrand; +Cc: Janosch Frank, kvm, cohuck, linux-s390, thuth

On Tue, 11 May 2021 13:43:36 +0200
David Hildenbrand <david@redhat.com> wrote:

> On 10.05.21 17:00, Janosch Frank wrote:
> > Lets grab more of the feature bits from SCLP read info so we can use
> > them in the cpumodel tests.
> > 
> > Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> > Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > ---
> >   lib/s390x/sclp.c | 20 ++++++++++++++++++++
> >   lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
> >   2 files changed, 55 insertions(+), 3 deletions(-)
> > 
> > diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
> > index f11c2035..f25cfdb2 100644
> > --- a/lib/s390x/sclp.c
> > +++ b/lib/s390x/sclp.c
> > @@ -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));
> }

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



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test Janosch Frank
  2021-05-11 11:45   ` David Hildenbrand
@ 2021-05-11 14:42   ` Claudio Imbrenda
  1 sibling, 0 replies; 16+ messages in thread
From: Claudio Imbrenda @ 2021-05-11 14:42 UTC (permalink / raw)
  To: Janosch Frank; +Cc: kvm, david, cohuck, linux-s390, thuth

On Mon, 10 May 2021 15:00:14 +0000
Janosch Frank <frankja@linux.ibm.com> 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.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  s390x/cpumodel.c | 59
> +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58
> insertions(+), 1 deletion(-)
> 
> diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c
> index 4dd8b96f..619c3dc7 100644
> --- a/s390x/cpumodel.c
> +++ b/s390x/cpumodel.c
> @@ -2,14 +2,69 @@
>  /*
>   * 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(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();
>  }


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing
  2021-05-11 14:41     ` Claudio Imbrenda
@ 2021-05-11 15:38       ` David Hildenbrand
  2021-05-11 15:46         ` Claudio Imbrenda
  0 siblings, 1 reply; 16+ messages in thread
From: David Hildenbrand @ 2021-05-11 15:38 UTC (permalink / raw)
  To: Claudio Imbrenda; +Cc: Janosch Frank, kvm, cohuck, linux-s390, thuth

On 11.05.21 16:41, Claudio Imbrenda wrote:
> On Tue, 11 May 2021 13:43:36 +0200
> David Hildenbrand <david@redhat.com> wrote:
> 
>> On 10.05.21 17:00, Janosch Frank wrote:
>>> Lets grab more of the feature bits from SCLP read info so we can use
>>> them in the cpumodel tests.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
>>> ---
>>>    lib/s390x/sclp.c | 20 ++++++++++++++++++++
>>>    lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
>>>    2 files changed, 55 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
>>> index f11c2035..f25cfdb2 100644
>>> --- a/lib/s390x/sclp.c
>>> +++ b/lib/s390x/sclp.c
>>> @@ -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));
>> }
> 
> 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.


-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing
  2021-05-11 15:38       ` David Hildenbrand
@ 2021-05-11 15:46         ` Claudio Imbrenda
  2021-05-11 16:36           ` Cornelia Huck
  0 siblings, 1 reply; 16+ messages in thread
From: Claudio Imbrenda @ 2021-05-11 15:46 UTC (permalink / raw)
  To: David Hildenbrand; +Cc: Janosch Frank, kvm, cohuck, linux-s390, thuth

On Tue, 11 May 2021 17:38:04 +0200
David Hildenbrand <david@redhat.com> wrote:

> On 11.05.21 16:41, Claudio Imbrenda wrote:
> > On Tue, 11 May 2021 13:43:36 +0200
> > David Hildenbrand <david@redhat.com> wrote:
> >   
> >> On 10.05.21 17:00, Janosch Frank wrote:  
> >>> Lets grab more of the feature bits from SCLP read info so we can
> >>> use them in the cpumodel tests.
> >>>
> >>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> >>> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> >>> ---
> >>>    lib/s390x/sclp.c | 20 ++++++++++++++++++++
> >>>    lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
> >>>    2 files changed, 55 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
> >>> index f11c2035..f25cfdb2 100644
> >>> --- a/lib/s390x/sclp.c
> >>> +++ b/lib/s390x/sclp.c
> >>> @@ -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));
> >> }  
> > 
> > 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 :)



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it
  2021-05-10 15:00 ` [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it Janosch Frank
  2021-05-11 11:39   ` David Hildenbrand
@ 2021-05-11 16:32   ` Cornelia Huck
  1 sibling, 0 replies; 16+ messages in thread
From: Cornelia Huck @ 2021-05-11 16:32 UTC (permalink / raw)
  To: Janosch Frank; +Cc: kvm, david, linux-s390, imbrenda, thuth

On Mon, 10 May 2021 15:00:12 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> The cpu offset tells us where the cpu entries are in the sclp read
> info structure.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
>  lib/s390x/sclp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing
  2021-05-11 15:46         ` Claudio Imbrenda
@ 2021-05-11 16:36           ` Cornelia Huck
  0 siblings, 0 replies; 16+ messages in thread
From: Cornelia Huck @ 2021-05-11 16:36 UTC (permalink / raw)
  To: Claudio Imbrenda; +Cc: David Hildenbrand, Janosch Frank, kvm, linux-s390, thuth

On Tue, 11 May 2021 17:46:45 +0200
Claudio Imbrenda <imbrenda@linux.ibm.com> wrote:

> On Tue, 11 May 2021 17:38:04 +0200
> David Hildenbrand <david@redhat.com> wrote:
> 
> > On 11.05.21 16:41, Claudio Imbrenda wrote:  
> > > On Tue, 11 May 2021 13:43:36 +0200
> > > David Hildenbrand <david@redhat.com> wrote:
> > >     
> > >> On 10.05.21 17:00, Janosch Frank wrote:    
> > >>> Lets grab more of the feature bits from SCLP read info so we can
> > >>> use them in the cpumodel tests.
> > >>>
> > >>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> > >>> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > >>> ---
> > >>>    lib/s390x/sclp.c | 20 ++++++++++++++++++++
> > >>>    lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++---
> > >>>    2 files changed, 55 insertions(+), 3 deletions(-)
> > >>>
> > >>> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
> > >>> index f11c2035..f25cfdb2 100644
> > >>> --- a/lib/s390x/sclp.c
> > >>> +++ b/lib/s390x/sclp.c
> > >>> @@ -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));
> > >> }    
> > > 
> > > 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 :)


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-05-11 16:36 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 15:00 [kvm-unit-tests PATCH 0/4] s390x: cpumodel: Add sclp checks Janosch Frank
2021-05-10 15:00 ` [kvm-unit-tests PATCH 1/4] s390x: sclp: Only fetch read info byte 134 if cpu entries are above it Janosch Frank
2021-05-11 11:39   ` David Hildenbrand
2021-05-11 16:32   ` Cornelia Huck
2021-05-10 15:00 ` [kvm-unit-tests PATCH 2/4] lib: s390x: sclp: Extend feature probing Janosch Frank
2021-05-11 11:43   ` David Hildenbrand
2021-05-11 14:41     ` Claudio Imbrenda
2021-05-11 15:38       ` David Hildenbrand
2021-05-11 15:46         ` Claudio Imbrenda
2021-05-11 16:36           ` Cornelia Huck
2021-05-10 15:00 ` [kvm-unit-tests PATCH 3/4] s390x: cpumodel: FMT4 SCLP test Janosch Frank
2021-05-11 11:45   ` David Hildenbrand
2021-05-11 14:42   ` Claudio Imbrenda
2021-05-10 15:00 ` [kvm-unit-tests PATCH 4/4] s390x: cpumodel: FMT2 SCLP implies test Janosch Frank
2021-05-11 11:46   ` David Hildenbrand
2021-05-11 14:36   ` Claudio Imbrenda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).