s390x: cpumodel: Add sclp checks
v2 cover s390x: cpumodel: Add sclp checks
SCLP facilities have been a bit overlooked in cpumodel tests and have recently caused some headaches. So let's extend the tests and the library with a bit of sclp feature checking.
Based on the uv_host branch / patches.
v2:
* Check bit instead of mask
* Squashed fmt 2 and 4 patches into one
Janosch Frank (3):
s390x: sclp: Only fetch read info byte 134 if cpu entries are above it
lib: s390x: sclp: Extend feature probing
s390x: cpumodel: FMT2 and FMT4 SCLP 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
PATCH v2 1/3 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
@@ -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
PATCH v2 2/3 lib: s390x: sclp: Extend feature probing
In reply to Janosch FrankLets 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
@@ -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 bit) +{ +uint8_t *rib = (uint8_t *)read_info; + +return !!(rib[byte] & (0x80 >> bit)); +} +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_BIT_GSLS ); + sclp_facilities.has_kss =sclp_feat_check (98 ,SCLP_FEAT_98_BIT_KSS ); + sclp_facilities.has_cmma =sclp_feat_check (116 ,SCLP_FEAT_116_BIT_CMMA ); + sclp_facilities.has_64bscao =sclp_feat_check (116 ,SCLP_FEAT_116_BIT_64BSCAO ); + sclp_facilities.has_esca =sclp_feat_check (116 ,SCLP_FEAT_116_BIT_ESCA ); + sclp_facilities.has_ibs =sclp_feat_check (117 ,SCLP_FEAT_117_BIT_IBS ); + sclp_facilities.has_pfmfi =sclp_feat_check (117 ,SCLP_FEAT_117_BIT_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
@@ -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_BIT_GSLS 7 +#define SCLP_FEAT_98_BIT_KSS 0 +#define SCLP_FEAT_116_BIT_64BSCAO 7 +#define SCLP_FEAT_116_BIT_CMMA 6 +#define SCLP_FEAT_116_BIT_ESCA 3 +#define SCLP_FEAT_117_BIT_PFMFI 6 +#define SCLP_FEAT_117_BIT_IBS 5 + typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax;
Signature · 1 line
2.30.2
PATCH v2 3/3 s390x: cpumodel: FMT2 and FMT4 SCLP test
In reply to Janosch FrankSCLP 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 | 71 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-)
s390x/cpumodel.c +70 -1
@@ -2,14 +2,81 @@/* * 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_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 (); }
Signature · 1 line
2.30.2
Re: [kvm-unit-tests PATCH v2 2/3] lib: s390x: sclp: Extend feature probing
In reply to Janosch FrankQuoted 106 lines · Janosch Frank
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 <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- lib/s390x/sclp.c | 20 ++++++++++++++++++++ lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-)lib/s390x/sclp.c +20
-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 bit) +{ +uint8_t *rib = (uint8_t *)read_info; + +return !!(rib[byte] & (0x80 >> bit)); +} +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_BIT_GSLS ); + sclp_facilities.has_kss =sclp_feat_check (98 ,SCLP_FEAT_98_BIT_KSS ); + sclp_facilities.has_cmma =sclp_feat_check (116 ,SCLP_FEAT_116_BIT_CMMA ); + sclp_facilities.has_64bscao =sclp_feat_check (116 ,SCLP_FEAT_116_BIT_64BSCAO ); + sclp_facilities.has_esca =sclp_feat_check (116 ,SCLP_FEAT_116_BIT_ESCA ); + sclp_facilities.has_ibs =sclp_feat_check (117 ,SCLP_FEAT_117_BIT_IBS ); + sclp_facilities.has_pfmfi =sclp_feat_check (117 ,SCLP_FEAT_117_BIT_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 +28
-3@@ -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_BIT_GSLS 7
lib/s390x/sclp.h extern struct sclp_facilities sclp_facilities; · line 146
Quoted 10 lines
lib/s390x/sclp.h +7
-0+#define SCLP_FEAT_98_BIT_KSS 0 +#define SCLP_FEAT_116_BIT_64BSCAO 7 +#define SCLP_FEAT_116_BIT_CMMA 6 +#define SCLP_FEAT_116_BIT_ESCA 3 +#define SCLP_FEAT_117_BIT_PFMFI 6 +#define SCLP_FEAT_117_BIT_IBS 5 + typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax;
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v2 2/3] lib: s390x: sclp: Extend feature probing
In reply to Janosch FrankQuoted 1 line · On Wed, 19 May 2021 08:26:47 +0000 Janosch Frank <[email protected]> wrote:
Lets grab more of the feature bits from SCLP read info so we can use
s/Lets/Let's/ :)
Quoted 8 lines
them in the cpumodel tests.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- lib/s390x/sclp.c | 20 ++++++++++++++++++++ lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-)
(...)
Maybe add
/* bit number within a certain byte */
lib/s390x/sclp.h extern struct sclp_facilities sclp_facilities; · line 146
Quoted 11 lines
lib/s390x/sclp.h +8
-0+#define SCLP_FEAT_85_BIT_GSLS 7 +#define SCLP_FEAT_98_BIT_KSS 0 +#define SCLP_FEAT_116_BIT_64BSCAO 7 +#define SCLP_FEAT_116_BIT_CMMA 6 +#define SCLP_FEAT_116_BIT_ESCA 3 +#define SCLP_FEAT_117_BIT_PFMFI 6 +#define SCLP_FEAT_117_BIT_IBS 5 + typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax;
Re: [kvm-unit-tests PATCH v2 3/3] s390x: cpumodel: FMT2 and FMT4 SCLP test
In reply to Janosch FrankQuoted 9 lines · On Wed, 19 May 2021 08:26:48 +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.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- s390x/cpumodel.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-)
Re: [kvm-unit-tests PATCH v2 2/3] lib: s390x: sclp: Extend feature probing
In reply to Cornelia HuckQuoted 6 lines · Cornelia Huck
Quoted 1 line · On Wed, 19 May 2021 08:26:47 +0000 Janosch Frank <[email protected]> wrote:
Lets grab more of the feature bits from SCLP read info so we can use
s/Lets/Let's/ :)
Sigh
Quoted 10 lines
Quoted 9 lines
them in the cpumodel tests.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- lib/s390x/sclp.c | 20 ++++++++++++++++++++ lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-)
Quoted 5 lines
(...)
Maybe add
/* bit number within a certain byte */
Sure
Quoted 15 lines
lib/s390x/sclp.h extern struct sclp_facilities sclp_facilities; · line 146
Quoted 12 lines
lib/s390x/sclp.h +8
-0+#define SCLP_FEAT_85_BIT_GSLS 7 +#define SCLP_FEAT_98_BIT_KSS 0 +#define SCLP_FEAT_116_BIT_64BSCAO 7 +#define SCLP_FEAT_116_BIT_CMMA 6 +#define SCLP_FEAT_116_BIT_ESCA 3 +#define SCLP_FEAT_117_BIT_PFMFI 6 +#define SCLP_FEAT_117_BIT_IBS 5 + typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax;Acked-by Cornelia Huck <[email protected]>
Thanks!