s390x update 2021-05-05
Dear Paolo,
please merge or pull the following changes:
* IO extensions (Pierre)
* New reviewer (Claudio)
* Minor changes
MERGE:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/7
PIPELINE:
https://gitlab.com/frankja/kvm-unit-tests/-/pipelines/297509337
PULL:
The following changes since commit abe823807d13e451ca5c37f1b5ada5847e08084f:
nSVM: Test addresses of MSR and IO permissions maps (2021-04-22 11:59:25 -0400)
are available in the Git repository at:
https://gitlab.com/frankja/kvm-unit-tests.git s390x-pull-2021-05-05
for you to fetch changes up to 7231778d3773f70582e705cf910976c79138d0c9:
s390x: Fix vector stfle checks (2021-05-05 08:01:45 +0000)
Claudio Imbrenda (2):
s390x: mvpg: add checks for op_acc_id
MAINTAINERS: s390x: add myself as reviewer
Janosch Frank (1):
s390x: Fix vector stfle checks
Pierre Morel (6):
s390x: css: Store CSS Characteristics
s390x: css: simplifications of the tests
s390x: css: extending the subchannel modifying functions
s390x: css: implementing Set CHannel Monitor
s390x: css: testing measurement block format 0
s390x: css: testing measurement block format 1
MAINTAINERS | 1 + lib/s390x/css.h | 115 ++++++++++++++++++++- lib/s390x/css_lib.c | 236 ++++++++++++++++++++++++++++++++++++++++---- s390x/css.c | 216 ++++++++++++++++++++++++++++++++++++++-- s390x/mvpg.c | 28 +++++- s390x/vector.c | 4 +- 6 files changed, 568 insertions(+), 32 deletions(-)
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 2/9] s390x: css: Store CSS Characteristics
From: Pierre Morel <[email protected]>
CSS characteristics exposes the features of the Channel SubSystem. Let's use Store Channel Subsystem Characteristics to retrieve the features of the CSS.
--- lib/s390x/css.h | 66 ++++++++++++++++++++++++++++++++ lib/s390x/css_lib.c | 93 ++++++++++++++++++++++++++++++++++++++++++++- s390x/css.c | 8 ++++ 3 files changed, 166 insertions(+), 1 deletion(-)
lib/s390x/css.h +66 -0
@@ -288,4 +288,70 @@ int css_residual_count(unsigned int schid);void enable_io_isc (uint8_t isc);int wait_and_check_io_completion (int schid); +/* +* CHSC definitions +*/ +struct chsc_header { +uint16_t len; +uint16_t code; +}; + +/* Store Channel Subsystem Characteristics */ +struct chsc_scsc { +struct chsc_header req; +uint16_t req_fmt; +uint8_t cssid; +uint8_t reserved[9 ]; +struct chsc_header res; +uint32_t res_fmt; +uint64_t general_char[255 ]; +uint64_t chsc_char[254 ]; +}; + +extern struct chsc_scsc *chsc_scsc; +#define CHSC_SCSC 0x0010 +#define CHSC_SCSC_LEN 0x0010 + +bool get_chsc_scsc (void ); + +#define CSS_GENERAL_FEAT_BITLEN (255 * 64) +#define CSS_CHSC_FEAT_BITLEN (254 * 64) + +#define CHSC_SCSC 0x0010 +#define CHSC_SCSC_LEN 0x0010 + +#define CHSC_ERROR 0x0000 +#define CHSC_RSP_OK 0x0001 +#define CHSC_RSP_INVAL 0x0002 +#define CHSC_RSP_REQERR 0x0003 +#define CHSC_RSP_ENOCMD 0x0004 +#define CHSC_RSP_NODATA 0x0005 +#define CHSC_RSP_SUP31B 0x0006 +#define CHSC_RSP_EFRMT 0x0007 +#define CHSC_RSP_ECSSID 0x0008 +#define CHSC_RSP_ERFRMT 0x0009 +#define CHSC_RSP_ESSID 0x000A +#define CHSC_RSP_EBUSY 0x000B +#define CHSC_RSP_MAX 0x000B + +static inline int _chsc (void *p) +{ +int cc; + + asmvolatile (" .insn rre,0xb25f0000,%2,0\n" +" ipm %0\n" +" srl %0,28\n" + :"=d" (cc),"=m" (p) + :"d" (p),"m" (p) + :"cc" ); + +return cc; +} + +bool chsc (void *p,uint16_t code,uint16_t len); + +#include <bitops.h> +#define css_test_general_feature (bit) test_bit_inv(bit, chsc_scsc->general_char) +#define css_test_chsc_feature (bit) test_bit_inv(bit, chsc_scsc->chsc_char) +#endif
lib/s390x/css_lib.c +92 -1
103 lines not on this page · raw message
s390x/css.c +8 -0
@@ -14,6 +14,7 @@#include <string.h> #include <interrupt.h> #include <asm/arch_def.h> +#include <alloc_page.h> #include <malloc_io.h> #include <css.h>
@@ -140,10 +141,17 @@ error_senseid:unregister_io_int_func (css_irq_io); } +static void css_init (void ) +{ +report (get_chsc_scsc (),"Store Channel Characteristics" ); +} +static struct {const char *name;void (*func)(void ); } tests[] = { +/* The css_init test is needed to initialize the CSS Characteristics */ + {"initialize CSS (chsc)" , css_init }, {"enumerate (stsch)" , test_enumerate }, {"enable (msch)" , test_enable }, {"sense (ssch/tsch)" , test_sense },
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 1/9] s390x: mvpg: add checks for op_acc_id
In reply to Janosch FrankFrom: Claudio Imbrenda <[email protected]>
Check the operand access identification when MVPG causes a page fault.
--- s390x/mvpg.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
s390x/mvpg.c +26 -2
@@ -36,6 +36,7 @@ static uint8_t source[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); static uint8_t buffer[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); +static struct lowcore *const lc;/* Keep track of fresh memory */ static uint8_t *fresh;
@@ -77,6 +78,21 @@ static int page_ok(const uint8_t *p)return 1 ; } +/* +* Check that the Operand Access Identification matches with the values of +* the r1 and r2 fields in the instruction format. The r1 and r2 fields are +* in the last byte of the instruction, and the Program Old PSW will point +* to the beginning of the instruction after the one that caused the fault +* (the fixup code in the interrupt handler takes care of that for +* nullifying instructions). Therefore it is enough to compare the byte +* before the one contained in the Program Old PSW with the value of the +* Operand Access Identification. +*/ +static inline bool check_oai (void ) +{ +return *(uint8_t *)(lc->pgm_old_psw.addr -1 ) == lc->op_acc_id; +} +static void test_exceptions (void ) {int i, expected;
@@ -201,17 +217,25 @@ static void test_mmu_prot(void)report (clear_pgm_int () ==PGM_INT_CODE_PROTECTION ,"destination read only" ); fresh +=PAGE_SIZE ; +report_prefix_push ("source invalid" );protect_page (source,PAGE_ENTRY_I ); + lc->op_acc_id =0 ;expect_pgm_int ();mvpg (0 , fresh, source); -report (clear_pgm_int () ==PGM_INT_CODE_PAGE_TRANSLATION ,"source invalid" ); +report (clear_pgm_int () ==PGM_INT_CODE_PAGE_TRANSLATION ,"exception" );unprotect_page (source,PAGE_ENTRY_I ); +report (check_oai (),"operand access ident" ); +report_prefix_pop (); fresh +=PAGE_SIZE ; +report_prefix_push ("destination invalid" );protect_page (fresh,PAGE_ENTRY_I ); + lc->op_acc_id =0 ;expect_pgm_int ();mvpg (0 , fresh, source); -report (clear_pgm_int () ==PGM_INT_CODE_PAGE_TRANSLATION ,"destination invalid" ); +report (clear_pgm_int () ==PGM_INT_CODE_PAGE_TRANSLATION ,"exception" ); +report (check_oai (),"operand access ident" ); +report_prefix_pop (); fresh +=PAGE_SIZE ;report_prefix_pop ();
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 3/9] s390x: css: simplifications of the tests
In reply to Janosch FrankFrom: Pierre Morel <[email protected]>
In order to ease the writing of tests based on:
- interrupt
- enabling a subchannel
- using multiple I/O on a channel without disabling it
We do the following simplifications:
- the I/O interrupt handler is registered on CSS initialization
- We do not enable again a subchannel in senseid if it is already enabled
- we add a css_enabled() function to test if a subchannel is enabled
--- lib/s390x/css.h | 1 + lib/s390x/css_lib.c | 41 ++++++++++++++++++++++++++--------------- s390x/css.c | 15 +++++---------- 3 files changed, 32 insertions(+), 25 deletions(-)
lib/s390x/css.h +1 -0
@@ -278,6 +278,7 @@ int css_enumerate(void);#define IO_SCH_ISC 3int css_enable (int schid,int isc); +bool css_enabled (int schid);/* Library functions */ int start_ccw1_chain (unsigned int sid,struct ccw1 *ccw);
lib/s390x/css_lib.c +26 -15
60 lines not on this page · raw message
s390x/css.c +5 -10
@@ -25,6 +25,7 @@ static unsigned long cu_type = DEFAULT_CU_TYPE;static int test_device_sid;static struct senseid *senseid; +struct ccw1 *ccw;static void test_enumerate (void ) {
@@ -58,7 +59,6 @@ static void test_enable(void)*/ static void test_sense (void ) { -struct ccw1 *ccw;int ret;int len;
@@ -74,18 +74,12 @@ static void test_sense(void)return ; } - ret =register_io_int_func (css_irq_io); -if (ret) { -report (0 ,"Could not register IRQ handler" ); -return ; - } - lowcore_ptr->io_int_param =0 ; senseid =alloc_io_mem (sizeof (*senseid),0 );if (!senseid) {report (0 ,"Allocation of senseid" ); - goto error_senseid; +return ; } ccw =ccw_alloc (CCW_CMD_SENSE_ID , senseid,sizeof (*senseid),CCW_F_SLI );
@@ -137,12 +131,13 @@ error:free_io_mem (ccw,sizeof (*ccw)); error_ccw:free_io_mem (senseid,sizeof (*senseid)); -error_senseid: -unregister_io_int_func (css_irq_io); }static void css_init (void ) { +assert (register_io_int_func (css_irq_io) ==0 ); + lowcore_ptr->io_int_param =0 ; +report (get_chsc_scsc (),"Store Channel Characteristics" ); }
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 4/9] s390x: css: extending the subchannel modifying functions
In reply to Janosch FrankFrom: Pierre Morel <[email protected]>
To enable or disable measurement we will need specific modifications on the subchannel.
--- lib/s390x/css.h | 9 +++- lib/s390x/css_lib.c | 100 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-)
lib/s390x/css.h +8 -1
@@ -82,6 +82,8 @@ struct pmcw {uint32_t intparm;#define PMCW_DNV 0x0001#define PMCW_ENABLE 0x0080 +#define PMCW_MBUE 0x0010 +#define PMCW_DCTME 0x0008#define PMCW_ISC_MASK 0x3800#define PMCW_ISC_SHIFT 11uint16_t flags;
@@ -94,6 +96,7 @@ struct pmcw {uint8_t pom;uint8_t pam;uint8_t chpid[8 ]; +#define PMCW_MBF1 0x0004uint32_t flags2; };#define PMCW_CHANNEL_TYPE (pmcw) (pmcw->flags2 >> 21)
@@ -101,7 +104,8 @@ struct pmcw {struct schib {struct pmcw pmcw;struct scsw scsw; -uint8_t md[12 ]; +uint64_t mbo; +uint8_t md[4 ]; } __attribute__ ((aligned (4 )));struct irb {
@@ -355,4 +359,7 @@ bool chsc(void *p, uint16_t code, uint16_t len);#define css_test_general_feature (bit) test_bit_inv(bit, chsc_scsc->general_char)#define css_test_chsc_feature (bit) test_bit_inv(bit, chsc_scsc->chsc_char) +bool css_enable_mb (int sid,uint64_t mb,uint16_t mbi,uint16_t flg,bool fmt1); +bool css_disable_mb (int schid); +#endif
lib/s390x/css_lib.c +100 -0
106 lines not on this page · raw message
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 5/9] s390x: css: implementing Set CHannel Monitor
In reply to Janosch FrankFrom: Pierre Morel <[email protected]>
We implement the call of the Set CHannel Monitor instruction, starting the monitoring of the all Channel Sub System, and initializing channel subsystem monitoring.
Initial tests report the presence of the extended measurement block feature, and verify the error reporting of the hypervisor for SCHM.
--- lib/s390x/css.h | 12 ++++++++++++ s390x/css.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
lib/s390x/css.h +12 -0
@@ -309,6 +309,7 @@ struct chsc_scsc {uint8_t reserved[9 ];struct chsc_header res;uint32_t res_fmt; +#define CSSC_EXTENDED_MEASUREMENT_BLOCK 48uint64_t general_char[255 ];uint64_t chsc_char[254 ]; };
@@ -359,6 +360,17 @@ bool chsc(void *p, uint16_t code, uint16_t len);#define css_test_general_feature (bit) test_bit_inv(bit, chsc_scsc->general_char)#define css_test_chsc_feature (bit) test_bit_inv(bit, chsc_scsc->chsc_char) +#define SCHM_DCTM 1/* activate Device Connection TiMe */ +#define SCHM_MBU 2/* activate Measurement Block Update */ + +static inline void schm (void *mbo,unsigned int flags) +{ + register void *__gpr2 asm("2") = mbo; + register long __gpr1 asm("1") = flags; + + asm("schm" : :"d" (__gpr2),"d" (__gpr1)); +} +bool css_enable_mb (int sid,uint64_t mb,uint16_t mbi,uint16_t flg,bool fmt1);bool css_disable_mb (int schid);
s390x/css.c +35 -0
@@ -141,6 +141,40 @@ static void css_init(void)report (get_chsc_scsc (),"Store Channel Characteristics" ); } +static void test_schm (void ) +{ +if (css_test_general_feature (CSSC_EXTENDED_MEASUREMENT_BLOCK )) +report_info ("Extended measurement block available" ); + +/* bits 59-63 of MB address must be 0 if MBU is defined */ +report_prefix_push ("Unaligned operand" ); +expect_pgm_int (); +schm ((void *)0x01 ,SCHM_MBU ); +check_pgm_int_code (PGM_INT_CODE_OPERAND ); +report_prefix_pop (); + +/* bits 36-61 of register 1 (flags) must be 0 */ +report_prefix_push ("Bad flags" ); +expect_pgm_int (); +schm (NULL ,0xfffffffc ); +check_pgm_int_code (PGM_INT_CODE_OPERAND ); +report_prefix_pop (); + +/* SCHM is a privilege operation */ +report_prefix_push ("Privilege" ); +enter_pstate (); +expect_pgm_int (); +schm (NULL ,SCHM_MBU ); +check_pgm_int_code (PGM_INT_CODE_PRIVILEGED_OPERATION ); +report_prefix_pop (); + +/* Normal operation */ +report_prefix_push ("Normal operation" ); +schm (NULL ,SCHM_MBU ); +report (1 ,"SCHM call without address" ); +report_prefix_pop (); +} + static struct { const char *name; void (*func)(void);
@@ -150,6 +184,7 @@ static struct { { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, + { "measurement block (schm)", test_schm }, { NULL, NULL } };
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 7/9] s390x: css: testing measurement block format 1
In reply to Janosch FrankFrom: Pierre Morel <[email protected]>
Measurement block format 1 is made available by the extended measurement block facility and is indicated in the SCHIB by the bit in the PMCW.
The MBO is specified in the SCHIB of each channel and the MBO defined by the SCHM instruction is ignored.
The test of the MB format 1 is just skipped if the feature is not available.
--- lib/s390x/css.h | 15 +++++++++ lib/s390x/css_lib.c | 2 +- s390x/css.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-)
lib/s390x/css.h +15 -0
@@ -107,6 +107,7 @@ struct schib {uint64_t mbo;uint8_t md[4 ]; } __attribute__ ((aligned(4))); +extern struct schib schib;struct irb {struct scsw scsw;
@@ -386,4 +387,18 @@ struct measurement_block_format0 { uint32_t initial_cmd_resp_time; }; +struct measurement_block_format1 { +uint32_t ssch_rsch_count; +uint32_t sample_count; +uint32_t device_connect_time; +uint32_t function_pending_time; +uint32_t device_disconnect_time; +uint32_t cu_queuing_time; +uint32_t device_active_only_time; +uint32_t device_busy_time; +uint32_t initial_cmd_resp_time; +uint32_t irq_delay_time; +uint32_t irq_prio_delay_time; +}; +#endif
lib/s390x/css_lib.c +1 -1
@@ -19,7 +19,7 @@#include <malloc_io.h> #include <css.h> -static struct schib schib; +struct schib schib;struct chsc_scsc *chsc_scsc;static const char *const chsc_rsp_description[] = {
s390x/css.c +75 -0
87 lines not on this page · raw message
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 8/9] MAINTAINERS: s390x: add myself as reviewer
In reply to Janosch FrankFrom: Claudio Imbrenda <[email protected]>
Message-Id: <[email protected]>
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -85,6 +85,7 @@ M: Thomas Huth <[email protected]> M: David Hildenbrand <[email protected]> M: Janosch Frank <[email protected]> R: Cornelia Huck <[email protected]> +R: Claudio Imbrenda <[email protected]> L: [email protected] L: [email protected] F: s390x/*
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 9/9] s390x: Fix vector stfle checks
In reply to Janosch Frank134 is for bcd
135 is for the vector enhancements
Not the other way around...
--- s390x/vector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
s390x/vector.c +2 -2
@@ -53,7 +53,7 @@ static void test_add(void)/* z14 vector extension test */ static void test_ext1_nand (void ) { -bool has_vext =test_facility (134 ); +bool has_vext =test_facility (135 );static struct prm {__uint128_t a,b,c; } prm __attribute__((aligned(16)));
@@ -79,7 +79,7 @@ static void test_ext1_nand(void)/* z14 bcd extension test */ static void test_bcd_add (void ) { -bool has_bcd =test_facility (135 ); +bool has_bcd =test_facility (134 );static struct prm {__uint128_t a,b,c; } prm __attribute__((aligned(16)));
Signature · 1 line
2.30.2
[kvm-unit-tests GIT PULL 6/9] s390x: css: testing measurement block format 0
In reply to Janosch FrankFrom: Pierre Morel <[email protected]>
We test the update of the measurement block format 0, the measurement block origin is calculated from the mbo argument used by the SCHM instruction and the offset calculated using the measurement block index of the SCHIB.
--- lib/s390x/css.h | 12 +++++++ s390x/css.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+)
lib/s390x/css.h +12 -0
@@ -374,4 +374,16 @@ static inline void schm(void *mbo, unsigned int flags)bool css_enable_mb (int sid,uint64_t mb,uint16_t mbi,uint16_t flg,bool fmt1);bool css_disable_mb (int schid); +struct measurement_block_format0 { +uint16_t ssch_rsch_count; +uint16_t sample_count; +uint32_t device_connect_time; +uint32_t function_pending_time; +uint32_t device_disconnect_time; +uint32_t cu_queuing_time; +uint32_t device_active_only_time; +uint32_t device_busy_time; +uint32_t initial_cmd_resp_time; +}; +#endif
s390x/css.c +83 -0
101 lines not on this page · raw message
Signature · 1 line
2.30.2
Paolo Bonzini
maintainerQuoted 42 lines · Janosch Frank
Dear Paolo,
please merge or pull the following changes:
* IO extensions (Pierre)
* New reviewer (Claudio)
* Minor changesMERGE:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/7PIPELINE:
https://gitlab.com/frankja/kvm-unit-tests/-/pipelines/297509337PULL:
The following changes since commitabe823807d13e451ca5c37f1b5ada5847e08084f:nSVM: Test addresses of MSR and IO permissions maps (2021-04-22 11:59:25 -0400)
are available in the Git repository at:
https://gitlab.com/frankja/kvm-unit-tests.git s390x-pull-2021-05-05for you to fetch changes up to
7231778d3773f70582e705cf910976c79138d0c9:s390x: Fix vector stfle checks (2021-05-05 08:01:45 +0000)Claudio Imbrenda (2):
s390x: mvpg: add checks forop_acc_id
MAINTAINERS: s390x: add myself as reviewerJanosch Frank (1):
s390x: Fix vector stfle checksPierre Morel (6):
s390x: css: Store CSS Characteristics
s390x: css: simplifications of the tests
s390x: css: extending the subchannel modifying functions
s390x: css: implementing Set CHannel Monitor
s390x: css: testing measurement block format 0
s390x: css: testing measurement block format 1
Quoted 8 lines
MAINTAINERS | 1 + lib/s390x/css.h | 115 ++++++++++++++++++++- lib/s390x/css_lib.c | 236 ++++++++++++++++++++++++++++++++++++++++---- s390x/css.c | 216 ++++++++++++++++++++++++++++++++++++++-- s390x/mvpg.c | 28 +++++- s390x/vector.c | 4 +- 6 files changed, 568 insertions(+), 32 deletions(-)
Pulled, thanks.
Paolo