s390x: Testing the Channel Subsystem I/O
v6 cover s390x: Testing the Channel Subsystem I/O
Goal of the series is to have a framwork to test Channel-Subsystem I/O with QEMU/KVM.
To be able to support interrupt for CSS I/O and for SCLP we need to modify the interrupt framework to allow re-entrant interruptions.
We add a registration for IRQ callbacks to the test programm to define its own interrupt handler. We need to do special work under interrupt like acknoledging the interrupt.
Being working on PSW bits to allow I/O interrupt, we define new PSW bits in arch_def.h and use __ASSEMBLER__ define to be able to include this header in an assembler source file.
This series presents four major tests:
- Enumeration:
The CSS is enumerated using the STSCH instruction recursively on all potentially existing channels.
Keeping the first channel found as a reference for future use. Checks STSCH
- Enable:
If the enumeration succeeded the tests enables the reference channel with MSCH and verifies with STSCH that the channel is effectively enabled
Checks MSCH
- Sense:
If the channel is enabled this test sends a SENSE_ID command to the reference channel, analysing the answer and expecting the Control unit type being 0xc0ca
Checks SSCH(READ) and IO-IRQ
- ping-pong:
If the reference channel leads to the PONG device (0xc0ca), the test exchanges a string containing a 9 digit number with the PONG device and expecting this number to be incremented by the PONG device.
Checks SSCH(WRITE)
Note:
- The following patches may be pulled first:
s390x: saving regs for interrupts
s390x: Use PSW bits definitions in cstart
s390x: Move control register bit definitions and add AFP to them
- I think this one if it receives reviewed-by can also be pulled now:
s390x: define wfi: wait for interrupt
- this patch has a comment from Janosch who asks change so... need opinion:
but since I need reviews for the next patches I let it here unchanged.
s390x: interrupt registration
- These 5 patches are really I/O oriented and need reviewed-by:
s390x: Library resources for CSS tests
s390x: css: stsch, enumeration test
s390x: css: msch, enable test
s390x: css: ssch/tsch with sense and interrupt
s390x: css: ping pong
Pierre Morel (10):
s390x: saving regs for interrupts
s390x: Use PSW bits definitions in cstart
s390x: Move control register bit definitions and add AFP to them
s390x: interrupt registration
s390x: Library resources for CSS tests
s390x: css: stsch, enumeration test
s390x: css: msch, enable test
s390x: define wfi: wait for interrupt
s390x: css: ssch/tsch with sense and interrupt
s390x: css: ping pong
lib/s390x/asm/arch_def.h | 31 +++- lib/s390x/css.h | 277 +++++++++++++++++++++++++++++++ lib/s390x/css_dump.c | 157 ++++++++++++++++++ lib/s390x/css_lib.c | 55 +++++++ lib/s390x/interrupt.c | 23 ++- lib/s390x/interrupt.h | 8 + s390x/Makefile | 3 + s390x/css.c | 343 +++++++++++++++++++++++++++++++++++++++ s390x/cstart64.S | 51 ++++-- s390x/unittests.cfg | 4 + 10 files changed, 936 insertions(+), 16 deletions(-) create mode 100644 lib/s390x/css.h create mode 100644 lib/s390x/css_dump.c create mode 100644 lib/s390x/css_lib.c create mode 100644 lib/s390x/interrupt.h create mode 100644 s390x/css.c
Signature · 90 lines
2.25.1 Changelog: from v5 to v6 - Added comments for IRQ handling in s390x: saving regs for interrupts (Janosch) - fixed BUG on reset_psw, added PSW_MASK_PSW_SHORT and PSW_RESET_MASK - fixed several lines over 80 chars - fixed licenses, use GPL V2 (no more LGPL) - replacing delay() with wfi() (Wait For Interrupt) during the css tests (suggested by Connie's comments) - suppressing delay() induces suppressing the patch "s390x: export the clock get_clock_ms() utility" which is already reviewed but can be picked from the v5 series. - changed the logic of the tests, the 4 css tests are always run one after the other so no need to re-run enumeration and enabling at the begining of each tests, it has alredy been done. This makes code simpler. from v4 to v5 - add a patch to explicitely define the initial_cr0 value (Janosch) - add RB from Janosh on interrupt registration - several formating, typo correction and removing unnecessary initialization in "linrary resources..." (Janosch) - several formating and typo corrections on "stsch enumeration test" (Connie) - reworking the msch test (Connie) - reworking of ssch test, pack the sense-id structure (Connie) from v3 to v4 - add RB from David and Thomas for patchs (3) irq registration and (4) clock export - rework the PSW bit definitions (Thomas) - Suppress undef DEBUG from css_dump (Thomas) - rework report() functions using new scheme (Thomas) - suppress un-necessary report_info() - more spelling corrections - add a loop around enable bit testing (Connie) - rework IRQ testing (Connie) - Test data addresses to be under 2G (Connie) from v2 to v3: - Rework spelling (Connie) - More descriptions (Connie) - use __ASSEMBLER__ preprocessing to keep bits definitions and C structures in the same file (David) - rename the new file clock.h as time.h (Janosch, David?) - use registration for the IO interruption (David, Thomas) - test the SCHIB to verify it has really be modified (Connie) - Lot of simplifications in the tests (Connie) from v1 to v2: - saving floating point registers (David, Janosh) - suppress unused PSW bits defintions (Janosh) - added Thomas reviewed-by - style and comments modifications (Connie, Janosh) - moved get_clock_ms() into headers and use it (Thomas) - separate header and library utility from tests - Suppress traces, separate tests, make better usage of reports
PATCH v6 1/10 s390x: saving regs for interrupts
If we use multiple source of interrupts, for example, using SCLP console to print information while using I/O interrupts, we need to have a re-entrant register saving interruption handling.
Instead of saving at a static memory address, let's save the base registers and the floating point registers on the stack.
Note that we keep the static register saving to recover from the RESET tests.
--- s390x/cstart64.S | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
s390x/cstart64.S +32 -2
@@ -118,6 +118,36 @@ memsetxc: lmg %r0, %r15, GEN_LC_SW_INT_GRS .endm +/* Save registers on the stack (r15), so we can have stacked interrupts. */ + .macro SAVE_IRQ_REGS + /* Allocate a stack frame for 15 integer registers */ + slgfi %r15, 15 * 8 + /* Store all registers from r0 to r14 on the stack */ + stmg %r0, %r14, 0(%r15) + /* Allocate a stack frame for 16 floating point registers */ + /* The size of a FP register is the size of an integer */ + slgfi %r15, 16 * 8 + /* Save fp register on stack: offset to SP is multiple of reg number */ + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + std \i, \i * 8(%r15) + .endr + .endm + +/* Restore the register in reverse order */ + .macro RESTORE_IRQ_REGS + /* Restore fp register from stack: SP still where it was left */ + /* and offset to SP is a multile of reg number */ + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + ld \i, \i * 8(%r15) + .endr + /* Now it is done, rewind the stack pointer by 16 integers */ + algfi %r15, 16 * 8 + /* Load the registers from stack */ + lmg %r0, %r14, 0(%r15) + /* Rewind the stack by 15 integers */ + algfi %r15, 15 * 8 + .endm + .section .text /* * load_reset calling convention:
@@ -182,9 +212,9 @@ mcck_int: lpswe GEN_LC_MCCK_OLD_PSW io_int: - SAVE_REGS + SAVE_IRQ_REGS brasl %r14, handle_io_int - RESTORE_REGS + RESTORE_IRQ_REGS lpswe GEN_LC_IO_OLD_PSW svc_int:
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 01/10] s390x: saving regs for interrupts
Quoted 3 lines · Pierre Morel
If we use multiple source of interrupts, for example, using SCLP console to print information while using I/O interrupts, we need to have a re-entrant register saving interruption handling.
So the primary reason is to print during I/O interrupts (which we already do, but usually never trigger - handle_io_int())
Quoted 3 lines
Instead of saving at a static memory address, let's save the base registers and the floating point registers on the stack.
".. in case of I/O interrupts".
Quoted 3 lines
Note that we keep the static register saving to recover from the RESET tests.
and for all other types of interrupts.
Quoted 11 lines
Signed-off-by Pierre Morel <[email protected]>--- s390x/cstart64.S | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)s390x/cstart64.S +0
-0
s390x/cstart64.S memsetxc: · line 122
Quoted 5 lines
s390x/cstart64.S +2
-0@@ -118,6 +118,36 @@ memsetxc: lmg %r0, %r15, GEN_LC_SW_INT_GRS .endm +/* Save registers on the stack (r15), so we can have stacked interrupts. */ + .macro SAVE_IRQ_REGS
s/SAVE_IRQ_REGS/SAVE_REGS_STACK/ ?
Same for the other macro.
s390x/cstart64.S memsetxc: · line 123
Quoted 1 line
s390x/cstart64.S +1
-0+ /* Allocate a stack frame for 15 integer registers */
not integers. sizeof(int) == 4.
"doublewords" should be the right s390x speak.
s390x/cstart64.S memsetxc: · line 134
Quoted 11 lines
s390x/cstart64.S +11
-0+ slgfi %r15, 15 * 8 + /* Store all registers from r0 to r14 on the stack */ + stmg %r0, %r14, 0(%r15) + /* Allocate a stack frame for 16 floating point registers */ + /* The size of a FP register is the size of an integer */ + slgfi %r15, 16 * 8 + /* Save fp register on stack: offset to SP is multiple of reg number */ + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + std \i, \i * 8(%r15) + .endr + .endm
What about the FPC?
Quoted 5 lines
s390x/cstart64.S +5
-0+ +/* Restore the register in reverse order */ + .macro RESTORE_IRQ_REGS + /* Restore fp register from stack: SP still where it was left */ + /* and offset to SP is a multile of reg number */
s390x/cstart64.S memsetxc: · line 149
Quoted 10 lines
s390x/cstart64.S +10
-0+ .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + ld \i, \i * 8(%r15) + .endr + /* Now it is done, rewind the stack pointer by 16 integers */ + algfi %r15, 16 * 8 + /* Load the registers from stack */ + lmg %r0, %r14, 0(%r15) + /* Rewind the stack by 15 integers */ + algfi %r15, 15 * 8 + .endm
Dito, FPC?
Quoted 17 lines
s390x/cstart64.S +3
-2+ .section .text /* * load_reset calling convention:@@ -182,9 +212,9 @@ mcck_int: lpswe GEN_LC_MCCK_OLD_PSW io_int: - SAVE_REGS + SAVE_IRQ_REGS brasl %r14, handle_io_int - RESTORE_REGS + RESTORE_IRQ_REGS lpswe GEN_LC_IO_OLD_PSW svc_int:
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v6 01/10] s390x: saving regs for interrupts
Quoted 5 lines · David Hildenbrand
Quoted 3 lines · Pierre Morel
If we use multiple source of interrupts, for example, using SCLP console to print information while using I/O interrupts, we need to have a re-entrant register saving interruption handling.
Quoted 8 lines
So the primary reason is to print during I/O interrupts (which we already do, but usually never trigger -
handle_io_int())Quoted 3 lines
Instead of saving at a static memory address, let's save the base registers and the floating point registers on the stack.
".. in case of I/O interrupts".
OK
Quoted 6 lines
Quoted 4 lines
Note that we keep the static register saving to recover from the RESET tests.
and for all other types of interrupts.
OK
Quoted 15 lines
Quoted 15 lines
Signed-off-by Pierre Morel <[email protected]>--- s390x/cstart64.S | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)s390x/cstart64.S +0
-0@@ -118,6 +118,36 @@ memsetxc: lmg %r0, %r15, GEN_LC_SW_INT_GRS .endm
Quoted 6 lines
s390x/cstart64.S memsetxc: · line 122
Quoted 2 lines
s390x/cstart64.S +2
-0+/* Save registers on the stack (r15), so we can have stacked interrupts. */ + .macro SAVE_IRQ_REGSs/SAVE_IRQ_REGS/SAVE_REGS_STACK/ ?
Same for the other macro.
OK
Quoted 4 lines
s390x/cstart64.S memsetxc: · line 123
Quoted 2 lines
s390x/cstart64.S +1
-0+ /* Allocate a stack frame for 15 integer registers */not integers. sizeof(int) == 4.
hum, yes, I just do not know from where I took the word "integer" here!.
Quoted 2 lines
"doublewords" should be the right s390x speak.
in fact they are named general registers in the POP. (which indeed are doublewords :) )
Quoted 14 lines
s390x/cstart64.S memsetxc: · line 134
Quoted 12 lines
s390x/cstart64.S +11
-0+ slgfi %r15, 15 * 8 + /* Store all registers from r0 to r14 on the stack */ + stmg %r0, %r14, 0(%r15) + /* Allocate a stack frame for 16 floating point registers */ + /* The size of a FP register is the size of an integer */ + slgfi %r15, 16 * 8 + /* Save fp register on stack: offset to SP is multiple of reg number */ + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + std \i, \i * 8(%r15) + .endr + .endmWhat about the FPC?
Seems I forgot it.
I will update.
Thanks.
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
PATCH v6 2/10 s390x: Use PSW bits definitions in cstart
In reply to Pierre MorelThis patch defines the PSW bits EA/BA used to initialize the PSW masks for exceptions.
Since some PSW mask definitions exist already in arch_def.h we add these definitions there.
We move all PSW definitions together and protect assembler code against C syntax.
--- lib/s390x/asm/arch_def.h | 16 ++++++++++++---- s390x/cstart64.S | 15 ++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-)
lib/s390x/asm/arch_def.h +12 -4
@@ -10,15 +10,22 @@#ifndef _ASM_S390X_ARCH_DEF_H_#define _ASM_S390X_ARCH_DEF_H_ +#define PSW_MASK_EXT 0x0100000000000000UL +#define PSW_MASK_DAT 0x0400000000000000UL +#define PSW_MASK_SHORT_PSW 0x0008000000000000UL +#define PSW_MASK_PSTATE 0x0001000000000000UL +#define PSW_MASK_BA 0x0000000080000000UL +#define PSW_MASK_EA 0x0000000100000000UL + +#define PSW_EXCEPTION_MASK (PSW_MASK_EA | PSW_MASK_BA) +#define PSW_RESET_MASK (PSW_EXCEPTION_MASK | PSW_MASK_SHORT_PSW) + +#ifndef __ASSEMBLER__struct psw {uint64_t mask;uint64_t addr; }; -#define PSW_MASK_EXT 0x0100000000000000UL -#define PSW_MASK_DAT 0x0400000000000000UL -#define PSW_MASK_PSTATE 0x0001000000000000UL -#define CR0_EXTM_SCLP 0X0000000000000200UL#define CR0_EXTM_EXTC 0X0000000000002000UL#define CR0_EXTM_EMGC 0X0000000000004000UL
@@ -297,4 +304,5 @@ static inline uint32_t get_prefix(void)return current_prefix; } +#endif /* __ASSEMBLER */ #endif
s390x/cstart64.S +8 -7
@@ -12,6 +12,7 @@ */ #include <asm/asm-offsets.h> #include <asm/sigp.h> +#include <asm/arch_def.h> .section .init
@@ -225,19 +226,19 @@ svc_int: .align 8 reset_psw: - .quad 0x0008000180000000 + .quad PSW_RESET_MASK initial_psw: - .quad 0x0000000180000000, clear_bss_start + .quad PSW_EXCEPTION_MASK, clear_bss_start pgm_int_psw: - .quad 0x0000000180000000, pgm_int + .quad PSW_EXCEPTION_MASK, pgm_int ext_int_psw: - .quad 0x0000000180000000, ext_int + .quad PSW_EXCEPTION_MASK, ext_int mcck_int_psw: - .quad 0x0000000180000000, mcck_int + .quad PSW_EXCEPTION_MASK, mcck_int io_int_psw: - .quad 0x0000000180000000, io_int + .quad PSW_EXCEPTION_MASK, io_int svc_int_psw: - .quad 0x0000000180000000, svc_int + .quad PSW_EXCEPTION_MASK, svc_int initial_cr0: /* enable AFP-register control, so FP regs (+BFP instr) can be used */ .quad 0x0000000000040000
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 02/10] s390x: Use PSW bits definitions in cstart
Quoted 64 lines · Pierre Morel
This patch defines the PSW bits EA/BA used to initialize the PSW masks for exceptions.
Since some PSW mask definitions exist already in
arch_def.hwe add these definitions there.
We move all PSW definitions together and protect assembler code against C syntax.Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/asm/arch_def.h | 16 ++++++++++++---- s390x/cstart64.S | 15 ++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-)lib/s390x/asm/arch_def.h +12
-4@@ -10,15 +10,22 @@#ifndef _ASM_S390X_ARCH_DEF_H_#define _ASM_S390X_ARCH_DEF_H_ +#define PSW_MASK_EXT 0x0100000000000000UL +#define PSW_MASK_DAT 0x0400000000000000UL +#define PSW_MASK_SHORT_PSW 0x0008000000000000UL +#define PSW_MASK_PSTATE 0x0001000000000000UL +#define PSW_MASK_BA 0x0000000080000000UL +#define PSW_MASK_EA 0x0000000100000000UL + +#define PSW_EXCEPTION_MASK (PSW_MASK_EA | PSW_MASK_BA) +#define PSW_RESET_MASK (PSW_EXCEPTION_MASK | PSW_MASK_SHORT_PSW) + +#ifndef __ASSEMBLER__struct psw {uint64_t mask;uint64_t addr; }; -#define PSW_MASK_EXT 0x0100000000000000UL -#define PSW_MASK_DAT 0x0400000000000000UL -#define PSW_MASK_PSTATE 0x0001000000000000UL -#define CR0_EXTM_SCLP 0X0000000000000200UL#define CR0_EXTM_EXTC 0X0000000000002000UL#define CR0_EXTM_EMGC 0X0000000000004000UL@@ -297,4 +304,5 @@ static inline uint32_t get_prefix(void)return current_prefix; } +#endif /* __ASSEMBLER */ #endif s390x/cstart64.S +1
-0@@ -12,6 +12,7 @@ */ #include <asm/asm-offsets.h> #include <asm/sigp.h> +#include <asm/arch_def.h> .section .init
s390x/cstart64.S svc_int: · line 229
Quoted 5 lines
s390x/cstart64.S +1
-1@@ -225,19 +226,19 @@ svc_int: .align 8 reset_psw: - .quad 0x0008000180000000 + .quad PSW_RESET_MASK
I'd really prefer
.quad PSW_EXCEPTION_MASK | PSW_MASK_SHORT_PSW
here instead and drop PSW_RESET_MASK. Makes it clearer that we are talking about a special short psw here.
Apart from that, looks good to me.
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v6 02/10] s390x: Use PSW bits definitions in cstart
Quoted 73 lines · David Hildenbrand
Quoted 64 lines · Pierre Morel
This patch defines the PSW bits EA/BA used to initialize the PSW masks for exceptions.
Since some PSW mask definitions exist already in
arch_def.hwe add these definitions there.
We move all PSW definitions together and protect assembler code against C syntax.Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/asm/arch_def.h | 16 ++++++++++++---- s390x/cstart64.S | 15 ++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-)lib/s390x/asm/arch_def.h +12
-4@@ -10,15 +10,22 @@#ifndef _ASM_S390X_ARCH_DEF_H_#define _ASM_S390X_ARCH_DEF_H_ +#define PSW_MASK_EXT 0x0100000000000000UL +#define PSW_MASK_DAT 0x0400000000000000UL +#define PSW_MASK_SHORT_PSW 0x0008000000000000UL +#define PSW_MASK_PSTATE 0x0001000000000000UL +#define PSW_MASK_BA 0x0000000080000000UL +#define PSW_MASK_EA 0x0000000100000000UL + +#define PSW_EXCEPTION_MASK (PSW_MASK_EA | PSW_MASK_BA) +#define PSW_RESET_MASK (PSW_EXCEPTION_MASK | PSW_MASK_SHORT_PSW) + +#ifndef __ASSEMBLER__struct psw {uint64_t mask;uint64_t addr; }; -#define PSW_MASK_EXT 0x0100000000000000UL -#define PSW_MASK_DAT 0x0400000000000000UL -#define PSW_MASK_PSTATE 0x0001000000000000UL -#define CR0_EXTM_SCLP 0X0000000000000200UL#define CR0_EXTM_EXTC 0X0000000000002000UL#define CR0_EXTM_EMGC 0X0000000000004000UL@@ -297,4 +304,5 @@ static inline uint32_t get_prefix(void)return current_prefix; } +#endif /* __ASSEMBLER */ #endif s390x/cstart64.S +1
-0@@ -12,6 +12,7 @@ */ #include <asm/asm-offsets.h> #include <asm/sigp.h> +#include <asm/arch_def.h> .section .inits390x/cstart64.S svc_int: · line 229
Quoted 5 lines
s390x/cstart64.S +1
-1@@ -225,19 +226,19 @@ svc_int: .align 8 reset_psw: - .quad 0x0008000180000000 + .quad PSW_RESET_MASKI'd really prefer
Quoted 8 lines
.quad
PSW_EXCEPTION_MASK|PSW_MASK_SHORT_PSWhere instead and drop
PSW_RESET_MASK. Makes it clearer that we are talking about a special short psw here.Apart from that, looks good to me.
Thanks, I will do as you propose,
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
PATCH v6 3/10 s390x: Move control register bit definitions and add AFP to them
In reply to Pierre MorelWhile adding the definition for the AFP-Register control bit, move all existing definitions for CR0 out of the C zone to the assmbler zone to keep the definitions concerning CR0 together.
--- lib/s390x/asm/arch_def.h | 11 ++++++----- s390x/cstart64.S | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-)
lib/s390x/asm/arch_def.h +6 -5
@@ -20,17 +20,18 @@#define PSW_EXCEPTION_MASK (PSW_MASK_EA | PSW_MASK_BA)#define PSW_RESET_MASK (PSW_EXCEPTION_MASK | PSW_MASK_SHORT_PSW) +#define CR0_EXTM_SCLP 0X0000000000000200UL +#define CR0_EXTM_EXTC 0X0000000000002000UL +#define CR0_EXTM_EMGC 0X0000000000004000UL +#define CR0_EXTM_MASK 0X0000000000006200UL +#define CR0_AFP_REG_CRTL 0x0000000000040000UL + #ifndef __ASSEMBLER__ struct psw { uint64_t mask; uint64_t addr; }; -#define CR0_EXTM_SCLP 0X0000000000000200UL -#define CR0_EXTM_EXTC 0X0000000000002000UL -#define CR0_EXTM_EMGC 0X0000000000004000UL -#define CR0_EXTM_MASK 0X0000000000006200UL - struct lowcore { uint8_t pad_0x0000[0x0080 - 0x0000]; /* 0x0000 */ uint32_t ext_int_param; /* 0x0080 */
s390x/cstart64.S +1 -1
@@ -241,4 +241,4 @@ svc_int_psw: .quad PSW_EXCEPTION_MASK, svc_int initial_cr0: /* enable AFP-register control, so FP regs (+BFP instr) can be used */ - .quad 0x0000000000040000 + .quad CR0_AFP_REG_CRTL
Signature · 1 line
2.25.1
PATCH v6 4/10 s390x: interrupt registration
In reply to Pierre MorelLet's make it possible to add and remove a custom io interrupt handler, that can be used instead of the normal one.
--- lib/s390x/interrupt.c | 23 ++++++++++++++++++++++- lib/s390x/interrupt.h | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 lib/s390x/interrupt.h
lib/s390x/interrupt.c +22 -1
@@ -10,9 +10,9 @@* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> -#include <asm/interrupt.h> #include <asm/barrier.h> #include <sclp.h> +#include <interrupt.h> static bool pgm_int_expected;static bool ext_int_expected;
@@ -144,12 +144,33 @@ void handle_mcck_int(void) stap(), lc->mcck_old_psw.addr); } +static void (*io_int_func)(void ); +void handle_io_int (void ) { +if (io_int_func) +return io_int_func (); +report_abort ("Unexpected io interrupt: on cpu %d at %#lx" ,stap (), lc->io_old_psw.addr); } +int register_io_int_func (void (*f)(void )) +{ +if (io_int_func) +return -1 ; + io_int_func = f; +return 0 ; +} + +int unregister_io_int_func (void (*f)(void )) +{ +if (io_int_func != f) +return -1 ; + io_int_func =NULL ; +return 0 ; +} +void handle_svc_int (void ) { report_abort("Unexpected supervisor call interrupt: on cpu %d at %#lx",
lib/s390x/interrupt.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __INTERRUPT_H +#define __INTERRUPT_H +#include <asm/interrupt.h> + +int register_io_int_func (void (*f)(void )); +int unregister_io_int_func (void (*f)(void )); + +#endif /* __INTERRUPT_H */
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 04/10] s390x: interrupt registration
Quoted 7 lines · On Fri, 24 Apr 2020 12:45:46 +0200 Pierre Morel <[email protected]> wrote:
Let's make it possible to add and remove a custom io interrupt handler, that can be used instead of the normal one.
Signed-off-by Pierre Morel <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Reviewed-by Janosch Frank <[email protected]>
Quoted 5 lines
--- lib/s390x/interrupt.c | 23 ++++++++++++++++++++++- lib/s390x/interrupt.h | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 lib/s390x/interrupt.h
As the "normal one" means "no handler, just abort", is there any reason not simply to always provide one? What is the use case for multiple I/O interrupt handlers?
Re: [kvm-unit-tests PATCH v6 04/10] s390x: interrupt registration
Quoted 16 lines · Cornelia Huck
Quoted 7 lines · On Fri, 24 Apr 2020 12:45:46 +0200 Pierre Morel <[email protected]> wrote:
Let's make it possible to add and remove a custom io interrupt handler, that can be used instead of the normal one.
Signed-off-by Pierre Morel <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Reviewed-by Janosch Frank <[email protected]>Quoted 5 lines
--- lib/s390x/interrupt.c | 23 ++++++++++++++++++++++- lib/s390x/interrupt.h | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)create mode 100644
lib/s390x/interrupt.h
Quoted 4 lines
As the "normal one" means "no handler, just abort", is there any reason not simply to always provide one? What is the use case for multiple I/O interrupt handlers?
I can only agree, I proposed this initially.
David asked for a registration.
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Re: [kvm-unit-tests PATCH v6 04/10] s390x: interrupt registration
Quoted 19 lines · Pierre Morel
Quoted 16 lines · Cornelia Huck
Quoted 12 lines · On Fri, 24 Apr 2020 12:45:46 +0200 Pierre Morel <[email protected]> wrote:
Let's make it possible to add and remove a custom io interrupt handler, that can be used instead of the normal one.
Signed-off-by Pierre Morel <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by David Hildenbrand <[email protected]>Reviewed-by Janosch Frank <[email protected]>--- lib/s390x/interrupt.c | 23 ++++++++++++++++++++++- lib/s390x/interrupt.h | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-)create mode 100644
lib/s390x/interrupt.h
Quoted 8 lines
Quoted 4 lines
As the "normal one" means "no handler, just abort", is there any reason not simply to always provide one? What is the use case for multiple I/O interrupt handlers?
I can only agree, I proposed this initially.
David asked for a registration.
I don't understand "not simply to always provide one" or "multiple I/O interrupt handlers".
There is always exactly *one* handler
void handle_io_int(void)
{
...
}
All we do here, is to allow to register a callback from the handler, e.g., to verify in a test case that a specific I/O interrupt was received.
Signature · 3 lines
Thanks, David / dhildenb
PATCH v6 5/10 s390x: Library resources for CSS tests
In reply to Pierre MorelThese are the include and library utilities for the css tests patch series.
Debug function can be activated by defining DEBUG_CSS before the inclusion of the css.h header file.
--- lib/s390x/css.h | 256 +++++++++++++++++++++++++++++++++++++++++++ lib/s390x/css_dump.c | 157 ++++++++++++++++++++++++++ 2 files changed, 413 insertions(+) create mode 100644 lib/s390x/css.h create mode 100644 lib/s390x/css_dump.c
lib/s390x/css.h new file +256 -0
@@ -0,0 +1,256 @@ +/* +* CSS definitions +* +* Copyright IBM, Corp. 2020 +* Author: Pierre Morel <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ + +#ifndef CSS_H +#define CSS_H + +#define CCW_F_CD 0x80 +#define CCW_F_CC 0x40 +#define CCW_F_SLI 0x20 +#define CCW_F_SKP 0x10 +#define CCW_F_PCI 0x08 +#define CCW_F_IDA 0x04 +#define CCW_F_S 0x02 +#define CCW_F_MIDA 0x01 + +#define CCW_C_NOP 0x03 +#define CCW_C_TIC 0x08 + +struct ccw1 { +unsigned char code; +unsigned char flags; +unsigned short count; +uint32_t data_address; +} __attribute__ ((aligned (4 ))); + +#define ORB_M_KEY 0xf0000000 +#define ORB_F_SUSPEND 0x08000000 +#define ORB_F_STREAMING 0x04000000 +#define ORB_F_MODIFCTRL 0x02000000 +#define ORB_F_SYNC 0x01000000 +#define ORB_F_FORMAT 0x00800000 +#define ORB_F_PREFETCH 0x00400000 +#define ORB_F_INIT_IRQ 0x00200000 +#define ORB_F_ADDRLIMIT 0x00100000 +#define ORB_F_SUSP_IRQ 0x00080000 +#define ORB_F_TRANSPORT 0x00040000 +#define ORB_F_IDAW2 0x00020000 +#define ORB_F_IDAW_2K 0x00010000 +#define ORB_M_LPM 0x0000ff00 +#define ORB_F_LPM_DFLT 0x00008000 +#define ORB_F_ILSM 0x00000080 +#define ORB_F_CCW_IND 0x00000040 +#define ORB_F_ORB_EXT 0x00000001 + +struct orb { +uint32_t intparm; +uint32_t ctrl; +uint32_t cpa; +uint32_t prio; +uint32_t reserved[4 ]; +} __attribute__ ((aligned (4 ))); + +struct scsw { +uint32_t ctrl; +uint32_t ccw_addr; +uint8_t dev_stat; +uint8_t sch_stat; +uint16_t count; +}; + +struct pmcw { +uint32_t intparm; +#define PMCW_DNV 0x0001 +#define PMCW_ENABLE 0x0080 +uint16_t flags; +uint16_t devnum; +uint8_t lpm; +uint8_t pnom; +uint8_t lpum; +uint8_t pim; +uint16_t mbi; +uint8_t pom; +uint8_t pam; +uint8_t chpid[8 ]; +uint32_t flags2; +}; + +struct schib { +struct pmcw pmcw; +struct scsw scsw; +uint8_t md[12 ]; +} __attribute__ ((aligned (4 ))); + +struct irb { +struct scsw scsw; +uint32_t esw[5 ]; +uint32_t ecw[8 ]; +uint32_t emw[8 ]; +} __attribute__ ((aligned (4 ))); + +/* CSS low level access functions */ + +static inline int ssch (unsigned long schid,struct orb *addr) +{ + register long long reg1 asm("1") = schid; +int cc; + + asmvolatile ( +" ssch 0(%2)\n" +" ipm %0\n" +" srl %0,28\n" + :"=d" (cc) + :"d" (reg1),"a" (addr),"m" (*addr) + :"cc" ,"memory" ); +return cc; +} + +static inline int stsch (unsigned long schid,struct schib *addr) +{ + register unsigned long reg1 asm ("1") = schid; +int cc; + + asmvolatile ( +" stsch 0(%3)\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc),"=m" (*addr) + :"d" (reg1),"a" (addr) + :"cc" ); +return cc; +} + +static inline int msch (unsigned long schid,struct schib *addr) +{ + register unsigned long reg1 asm ("1") = schid; +int cc; + + asmvolatile ( +" msch 0(%3)\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc),"=m" (*addr) + :"d" (reg1),"a" (addr) + :"cc" ); +return cc; +} + +static inline int tsch (unsigned long schid,struct irb *addr) +{ + register unsigned long reg1 asm ("1") = schid; +int cc; + + asmvolatile ( +" tsch 0(%3)\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc),"=m" (*addr) + :"d" (reg1),"a" (addr) + :"cc" ); +return cc; +} + +static inline int hsch (unsigned long schid) +{ + register unsigned long reg1 asm("1") = schid; +int cc; + + asmvolatile ( +" hsch\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc) + :"d" (reg1) + :"cc" ); +return cc; +} + +static inline int xsch (unsigned long schid) +{ + register unsigned long reg1 asm("1") = schid; +int cc; + + asmvolatile ( +" xsch\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc) + :"d" (reg1) + :"cc" ); +return cc; +} + +static inline int csch (unsigned long schid) +{ + register unsigned long reg1 asm("1") = schid; +int cc; + + asmvolatile ( +" csch\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc) + :"d" (reg1) + :"cc" ); +return cc; +} + +static inline int rsch (unsigned long schid) +{ + register unsigned long reg1 asm("1") = schid; +int cc; + + asmvolatile ( +" rsch\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc) + :"d" (reg1) + :"cc" ); +return cc; +} + +static inline int rchp (unsigned long chpid) +{ + register unsigned long reg1 asm("1") = chpid; +int cc; + + asmvolatile ( +" rchp\n" +" ipm %0\n" +" srl %0,28" + :"=d" (cc) + :"d" (reg1) + :"cc" ); +return cc; +} + +/* Debug functions */ +char *dump_pmcw_flags (uint16_t f); +char *dump_scsw_flags (uint32_t f); + +#ifdef DEBUG_CSS +void dump_scsw (struct scsw *); +void dump_irb (struct irb *irbp); +void dump_schib (struct schib *sch); +struct ccw *dump_ccw (struct ccw *cp); +#else +static inline void dump_scsw (struct scsw *scsw) {} +static inline void dump_irb (struct irb *irbp) {} +static inline void dump_pmcw (struct pmcw *p) {} +static inline void dump_schib (struct schib *sch) {} +static inline void dump_orb (struct orb *op) {} +static inline struct ccw *dump_ccw (struct ccw *cp) +{ +return NULL ; +} +#endif /* DEBUG_CSS */ +#endif
lib/s390x/css_dump.c new file +157 -0
157 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 05/10] s390x: Library resources for CSS tests
Quoted 2 lines · On Fri, 24 Apr 2020 12:45:47 +0200 Pierre Morel <[email protected]> wrote:
These are the include and library utilities for the css tests patch series.
"Provide some definitions and library routines that can be used by tests targeting the channel subsystem."
?
Quoted 11 lines
Debug function can be activated by defining
DEBUG_CSSbefore the inclusion of thecss.hheader file.Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/css.h | 256 +++++++++++++++++++++++++++++++++++++++++++ lib/s390x/css_dump.c | 157 ++++++++++++++++++++++++++ 2 files changed, 413 insertions(+) create mode 100644 lib/s390x/css.h create mode 100644 lib/s390x/css_dump.c
(...)
Quoted 12 lines
lib/s390x/css_dump.c new file +6
-0@@ -0,0 +1,157 @@ +/* +* Channel subsystem structures dumping +* +* Copyright (c) 2020 IBM Corp. +* +* Authors:
lib/s390x/css_dump.c line 16
Quoted 10 lines
lib/s390x/css_dump.c new file +10
-0+* Pierre Morel <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2. +* +* Description: +* Provides the dumping functions for various structures used by subchannels: +* - ORB : Operation request block, describes the I/O operation and points to +* a CCW chain +* - CCW : Channel Command Word, describes the data and flow control
"describes the command, data, and flow control" ?
lib/s390x/css_dump.c line 17
Quoted 1 line
lib/s390x/css_dump.c new file +1
-0+* - IRB : Interuption response Block, describes the result of an operation
s/operation/operation;/
lib/s390x/css_dump.c line 23
Quoted 7 lines
lib/s390x/css_dump.c new file +6
-0+* holds a SCSW and model-dependent data. +* - SCHIB: SubCHannel Information Block composed of: +* - SCSW: SubChannel Status Word, status of the channel. +* - PMCW: Path Management Control Word +* You need the QEMU ccw-pong device in QEMU to answer the I/O transfers. +*/
(...)
Otherwise, looks good.
Re: [kvm-unit-tests PATCH v6 05/10] s390x: Library resources for CSS tests
Quoted 10 lines · Cornelia Huck
Quoted 2 lines · On Fri, 24 Apr 2020 12:45:47 +0200 Pierre Morel <[email protected]> wrote:
These are the include and library utilities for the css tests patch series.
"Provide some definitions and library routines that can be used by tests targeting the channel subsystem."
?
Definitively better. Thanks, I will update.
Quoted 31 lines
Quoted 12 lines
Debug function can be activated by defining
DEBUG_CSSbefore the inclusion of thecss.hheader file.Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/css.h | 256 +++++++++++++++++++++++++++++++++++++++++++ lib/s390x/css_dump.c | 157 ++++++++++++++++++++++++++ 2 files changed, 413 insertions(+)create mode 100644
lib/s390x/css.h
create mode 100644lib/s390x/css_dump.c(...)
Quoted 16 lines
lib/s390x/css_dump.c new file +10
-0@@ -0,0 +1,157 @@ +/* +* Channel subsystem structures dumping +* +* Copyright (c) 2020 IBM Corp. +* +* Authors: +* Pierre Morel <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2.
Quoted 8 lines
lib/s390x/css_dump.c line 16
Quoted 6 lines
lib/s390x/css_dump.c new file +6
-0+* +* Description: +* Provides the dumping functions for various structures used by subchannels: +* - ORB : Operation request block, describes the I/O operation and points to +* a CCW chain +* - CCW : Channel Command Word, describes the data and flow control "describes the command, data, and flow control" ?
OK, thanks
Quoted 4 lines
lib/s390x/css_dump.c line 17
Quoted 2 lines
lib/s390x/css_dump.c new file +1
-0+* - IRB : Interuption response Block, describes the result of an operation s/operation/operation;/
? I do not understand, do you want a ";" at the end of "operation" Isn't it a typo error?
Quoted 4 lines
Quoted 3 lines
lib/s390x/css_dump.c new file +2
-0+* holds a SCSW and model-dependent data. +* - SCHIB: SubCHannel Information Block composed of:
Quoted 9 lines
lib/s390x/css_dump.c line 23
Quoted 4 lines
lib/s390x/css_dump.c new file +4
-0+* - SCSW: SubChannel Status Word, status of the channel. +* - PMCW: Path Management Control Word +* You need the QEMU ccw-pong device in QEMU to answer the I/O transfers. +*/ (...)
Otherwise, looks good.
Thanks,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Re: [kvm-unit-tests PATCH v6 05/10] s390x: Library resources for CSS tests
Quoted 9 lines · On Fri, 15 May 2020 09:02:37 +0200 Pierre Morel <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck
Quoted 1 line · On Fri, 24 Apr 2020 12:45:47 +0200 Pierre Morel <[email protected]> wrote:
+ * - IRB : Interuption response Block, describes the result of an operation
s/operation/operation;/
? I do not understand, do you want a ";" at the end of "operation"
Yes, I think that makes the description read more like a proper sentence (describe what its purpose is; describe its contents).
Quoted 4 lines
Isn't it a typo error?
Quoted 2 lines
Quoted 2 lines
+ * holds a SCSW and model-dependent data.
Re: [kvm-unit-tests PATCH v6 05/10] s390x: Library resources for CSS tests
Quoted 7 lines · Cornelia Huck
Quoted 3 lines · On Fri, 15 May 2020 09:02:37 +0200 Pierre Morel <[email protected]> wrote:
Quoted 2 lines · Cornelia Huck
On Fri, 24 Apr 2020 12:45:47 +0200
Pierre Morel <[email protected]> wrote:
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+ * - IRB : Interuption response Block, describes the result of an operation
s/operation/operation;/
? I do not understand, do you want a ";" at the end of "operation"
Yes, I think that makes the description read more like a proper sentence (describe what its purpose is; describe its contents).
You are right, thanks.
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
PATCH v6 6/10 s390x: css: stsch, enumeration test
In reply to Pierre MorelFirst step for testing the channel subsystem is to enumerate the css and retrieve the css devices.
This tests the success of STSCH I/O instruction, we do not test the reaction of the VM for an instruction with wrong parameters.
--- lib/s390x/css.h | 1 + s390x/Makefile | 2 + s390x/css.c | 92 +++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 ++ 4 files changed, 99 insertions(+) create mode 100644 s390x/css.c
lib/s390x/css.h +1 -0
@@ -82,6 +82,7 @@ struct pmcw {uint8_t chpid[8 ];uint32_t flags2; }; +#define PMCW_CHANNEL_TYPE (pmcw) (pmcw->flags2 >> 21)struct schib {struct pmcw pmcw;
s390x/Makefile +2 -0
@@ -17,6 +17,7 @@ tests += $(TEST_DIR)/stsi.elf tests += $(TEST_DIR)/skrf.elf tests += $(TEST_DIR)/smp.elf tests += $(TEST_DIR)/sclp.elf +tests += $(TEST_DIR)/css.elf tests_binary = $(patsubst %.elf,%.bin,$(tests)) all: directories test_cases test_cases_binary
@@ -51,6 +52,7 @@ cflatobjs += lib/s390x/sclp-console.o cflatobjs += lib/s390x/interrupt.o cflatobjs += lib/s390x/mmu.o cflatobjs += lib/s390x/smp.o +cflatobjs += lib/s390x/css_dump.o OBJDIRS += lib/s390x
s390x/css.c new file +92 -0
92 lines not on this page · raw message
s390x/unittests.cfg +4 -0
@@ -83,3 +83,7 @@ extra_params = -m 1G [sclp-3g] file = sclp.elf extra_params = -m 3G + +[css] +file = css.elf +extra_params =-device ccw-pong
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 06/10] s390x: css: stsch, enumeration test
Quoted 20 lines · Pierre Morel
First step for testing the channel subsystem is to enumerate the css and retrieve the css devices.
This tests the success of STSCH I/O instruction, we do not test the reaction of the VM for an instruction with wrong parameters.
Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/css.h | 1 + s390x/Makefile | 2 + s390x/css.c | 92 +++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 ++ 4 files changed, 99 insertions(+) create mode 100644 s390x/css.clib/s390x/css.h +0
-0
lib/s390x/css.h struct pmcw { · line 85
Quoted 4 lines
lib/s390x/css.h +1
-0@@ -82,6 +82,7 @@ struct pmcw {uint8_t chpid[8 ];uint32_t flags2; }; +#define PMCW_CHANNEL_TYPE (pmcw) (pmcw->flags2 >> 21)
Why isn't this in the library patch?
Quoted 16 lines
lib/s390x/css.h +0
-0struct schib {struct pmcw pmcw;s390x/Makefile +1
-0@@ -17,6 +17,7 @@ tests += $(TEST_DIR)/stsi.elf tests += $(TEST_DIR)/skrf.elf tests += $(TEST_DIR)/smp.elf tests += $(TEST_DIR)/sclp.elf +tests += $(TEST_DIR)/css.elf tests_binary = $(patsubst %.elf,%.bin,$(tests)) all: directories test_cases test_cases_binary
s390x/Makefile cflatobjs += lib/s390x/sclp-console.o · line 55
Quoted 4 lines
s390x/Makefile +1
-0@@ -51,6 +52,7 @@ cflatobjs += lib/s390x/sclp-console.o cflatobjs += lib/s390x/interrupt.o cflatobjs += lib/s390x/mmu.o cflatobjs += lib/s390x/smp.o +cflatobjs += lib/s390x/css_dump.o
Why isn't this in the library patch?
Quoted 21 lines
s390x/Makefile +0
-0OBJDIRS += lib/s390xs390x/css.c new file +12
-0@@ -0,0 +1,92 @@ +/* +* Channel Subsystem tests +* +* Copyright (c) 2020 IBM Corp +* +* Authors: +* Pierre Morel <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2. +*/ +
s390x/css.c line 22
Quoted 10 lines
s390x/css.c new file +10
-0+#include <libcflat.h> +#include <alloc_phys.h> +#include <asm/page.h> +#include <string.h> +#include <interrupt.h> +#include <asm/arch_def.h> + +#include <css.h> + +#define SID_ONE 0x00010000
Why isn't this in the library patch?
Quoted 24 lines
s390x/css.c new file +24
-0+ +static struct schib schib; +static int test_device_sid; + +static void test_enumerate (void ) +{ +struct pmcw *pmcw = &schib.pmcw; +int cc; +int scn; +int scn_found =0 ; +int dev_found =0 ; + +for (scn =0 ; scn <0xffff ; scn++) { + cc =stsch (scn|SID_ONE , &schib); +switch (cc) { +case 0 :/* 0 means SCHIB stored */ +break ; +case 3 :/* 3 means no more channels */ + goto out; +default :/* 1 or 2 should never happened for STSCH */ +report (0 ,"Unexpected cc=%d on subchannel number 0x%x" , + cc, scn); +return ; + }
s390x/css.c line 56
Quoted 10 lines
s390x/css.c new file +10
-0+/* We currently only support type 0, a.k.a. I/O channels */ +if (PMCW_CHANNEL_TYPE (pmcw) !=0 ) +continue ; +/* We ignore I/O channels without valid devices */ + scn_found++; +if (!(pmcw->flags &PMCW_DNV )) +continue ; +/* We keep track of the first device as our test device */ +if (!test_device_sid) + test_device_sid = scn|SID_ONE ;
Give the pipe some space :)
s390x/css.c line 57
Quoted 1 line
s390x/css.c new file +1
-0+ dev_found++;
Newlines would make this more readable.
s390x/css.c line 59
Quoted 2 lines
s390x/css.c new file +2
-0+ } +out:
We can report dev_found instead of 0/1 and a if/else
report(dev_found,
"Tested subchannels: %d, I/O subchannels: %d, I/O devices: %d",
scn, scn_found, dev_found); Quoted 46 lines
s390x/css.c new file +33
-0+if (!dev_found) { +report (0 , +"Tested subchannels: %d, I/O subchannels: %d, I/O devices: %d" , + scn, scn_found, dev_found); +return ; + } +report (1 , +"Tested subchannels: %d, I/O subchannels: %d, I/O devices: %d" , + scn, scn_found, dev_found); +} + +static struct { +const char *name; +void (*func)(void ); +} tests[] = { + {"enumerate (stsch)" , test_enumerate }, + {NULL ,NULL } +}; + +int main (int argc,char *argv[]) +{ +int i; + +report_prefix_push ("Channel Subsystem" ); +for (i =0 ; tests[i].name; i++) { +report_prefix_push (tests[i].name); + tests[i].func (); +report_prefix_pop (); + } +report_prefix_pop (); + +return report_summary (); +}s390x/unittests.cfg +4
-0@@ -83,3 +83,7 @@ extra_params = -m 1G [sclp-3g] file = sclp.elf extra_params = -m 3G + +[css] +file = css.elf +extra_params =-device ccw-pong
Re: [kvm-unit-tests PATCH v6 06/10] s390x: css: stsch, enumeration test
Quoted 4 lines · Janosch Frank
Quoted 3 lines · Pierre Morel
First step for testing the channel subsystem is to enumerate the css and retrieve the css devices.
...snip...
Quoted 11 lines
lib/s390x/css.h struct pmcw { · line 85
Quoted 9 lines
lib/s390x/css.h +1
-0@@ -82,6 +82,7 @@ struct pmcw {uint8_t chpid[8 ];uint32_t flags2; }; +#define PMCW_CHANNEL_TYPE (pmcw) (pmcw->flags2 >> 21)Why isn't this in the library patch?
OK
Quoted 7 lines
lib/s390x/css.h cflatobjs += lib/s390x/sclp-console.o · line 55
Quoted 5 lines
lib/s390x/css.h +1
-0@@ -51,6 +52,7 @@ cflatobjs += lib/s390x/sclp-console.o cflatobjs += lib/s390x/interrupt.o cflatobjs += lib/s390x/mmu.o cflatobjs += lib/s390x/smp.o +cflatobjs += lib/s390x/css_dump.oWhy isn't this in the library patch?
OK
Quoted 1 line
...snip...
Quoted 3 lines
Quoted 1 line
+#define
SID_ONE0x00010000Why isn't this in the library patch?
OK
Quoted 1 line
...snip...
Quoted 8 lines
lib/s390x/css.h
Quoted 2 lines
lib/s390x/css.h +2
-0+if (!test_device_sid) + test_device_sid = scn|SID_ONE ;Give the pipe some space :)
lib/s390x/css.h
Quoted 1 line
lib/s390x/css.h +1
-0+ dev_found++;Newlines would make this more readable.
OK and yes.
Quoted 9 lines
lib/s390x/css.h
Quoted 3 lines
lib/s390x/css.h +2
-0+ } +out:We can report
dev_foundinstead of 0/1 and a if/elsereport(dev_found,
"Tested subchannels: %d, I/O subchannels: %d, I/O devices: %d", scn, scn_found, dev_found);
Yes, :)
Thanks,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Re: [kvm-unit-tests PATCH v6 06/10] s390x: css: stsch, enumeration test
In reply to Pierre MorelQuoted 4 lines · On Fri, 24 Apr 2020 12:45:48 +0200 Pierre Morel <[email protected]> wrote:
First step for testing the channel subsystem is to enumerate the css and retrieve the css devices.
This tests the success of STSCH I/O instruction, we do not test the
s/of/of the/
Quoted 11 lines
reaction of the VM for an instruction with wrong parameters.
Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/css.h | 1 + s390x/Makefile | 2 + s390x/css.c | 92 +++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 ++ 4 files changed, 99 insertions(+) create mode 100644 s390x/css.c
(...)
Quoted 6 lines
s390x/css.c new file +6
-0+static void test_enumerate (void ) +{ +struct pmcw *pmcw = &schib.pmcw; +int cc; +int scn; +int scn_found =0 ;
s390x/css.c line 42
Quoted 10 lines
s390x/css.c new file +10
-0+int dev_found =0 ; + +for (scn =0 ; scn <0xffff ; scn++) { + cc =stsch (scn|SID_ONE , &schib); +switch (cc) { +case 0 :/* 0 means SCHIB stored */ +break ; +case 3 :/* 3 means no more channels */ + goto out; +default :/* 1 or 2 should never happened for STSCH */
s/happened/happen/
Quoted 4 lines
s390x/css.c new file +4
-0+report (0 ,"Unexpected cc=%d on subchannel number 0x%x" , + cc, scn); +return ; + }
Re: [kvm-unit-tests PATCH v6 06/10] s390x: css: stsch, enumeration test
Quoted 9 lines · Cornelia Huck
Quoted 4 lines · On Fri, 24 Apr 2020 12:45:48 +0200 Pierre Morel <[email protected]> wrote:
First step for testing the channel subsystem is to enumerate the css and retrieve the css devices.
This tests the success of STSCH I/O instruction, we do not test the
s/of/of the/
Yes, zhanks.
Quoted 18 lines
Quoted 12 lines
reaction of the VM for an instruction with wrong parameters.
Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/css.h | 1 + s390x/Makefile | 2 + s390x/css.c | 92 +++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 ++ 4 files changed, 99 insertions(+)create mode 100644
s390x/css.c(...)
Quoted 3 lines
s390x/css.c new file +3
-0+static void test_enumerate (void ) +{ +struct pmcw *pmcw = &schib.pmcw;
...snip...
goto out;
Quoted 3 lines
s390x/css.c line 42
Quoted 1 line
s390x/css.c new file +1
-0+default :/* 1 or 2 should never happened for STSCH */ s/happened/happen/
Yes, thanks.
Quoted 6 lines
s390x/css.c line 46
Quoted 5 lines
s390x/css.c new file +4
-0+report (0 ,"Unexpected cc=%d on subchannel number 0x%x" , + cc, scn); +return ; + }
Thanks,
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
PATCH v6 7/10 s390x: css: msch, enable test
In reply to Pierre MorelA second step when testing the channel subsystem is to prepare a channel for use.
This includes:
- Get the current SubCHannel Information Block (SCHIB) using STSCH
- Update it in memory to set the ENABLE bit
- Tell the CSS that the SCHIB has been modified using MSCH
- Get the SCHIB from the CSS again to verify that the subchannel is enabled.
This tests the MSCH instruction to enable a channel succesfuly. This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
--- s390x/css.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
s390x/css.c +48 -0
@@ -68,11 +68,59 @@ out: scn, scn_found, dev_found); } +static void test_enable (void ) +{ +struct pmcw *pmcw = &schib.pmcw; +int cc; + +if (!test_device_sid) { +report_skip ("No device" ); +return ; + } +/* Read the SCHIB for this subchannel */ + cc =stsch (test_device_sid, &schib); +if (cc) { +report (0 ,"stsch cc=%d" , cc); +return ; + } + +/* Update the SCHIB to enable the channel */ + pmcw->flags |=PMCW_ENABLE ; + +/* Tell the CSS we want to modify the subchannel */ + cc =msch (test_device_sid, &schib); +if (cc) { +/* +* If the subchannel is status pending or +* if a function is in progress, +* we consider both cases as errors. +*/ +report (0 ,"msch cc=%d" , cc); +return ; + } + +/* +* Read the SCHIB again to verify the enablement +*/ + cc =stsch (test_device_sid, &schib); +if (cc) { +report (0 ,"stsch cc=%d" , cc); +return ; + } + +if (!(pmcw->flags &PMCW_ENABLE )) { +report (0 ,"Enable failed. pmcw: %x" , pmcw->flags); +return ; + } +report (1 ,"Tested" ); +} +static struct {const char *name;void (*func)(void ); } tests[] = { {"enumerate (stsch)" , test_enumerate }, + {"enable (msch)" , test_enable }, {NULL ,NULL } };
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 07/10] s390x: css: msch, enable test
Quoted 10 lines · Pierre Morel
A second step when testing the channel subsystem is to prepare a channel for use.
This includes:
- Get the current SubCHannel Information Block (SCHIB) using STSCH
- Update it in memory to set the ENABLE bit
- Tell the CSS that the SCHIB has been modified using MSCH
- Get the SCHIB from the CSS again to verify that the subchannel is enabled.This tests the MSCH instruction to enable a channel succesfuly.
successfully
Quoted 2 lines
This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
Would we expect needing retries for the pong device?
Quoted 13 lines
Signed-off-by Pierre Morel <[email protected]>--- s390x/css.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)s390x/css.c +0
-0@@ -68,11 +68,59 @@ out: scn, scn_found, dev_found); }
s390x/css.c out: · line 79
Quoted 10 lines
s390x/css.c +9
-0+static void test_enable (void ) +{ +struct pmcw *pmcw = &schib.pmcw; +int cc; + +if (!test_device_sid) { +report_skip ("No device" ); +return ; + }
If these tests are layered on top of each other and need a device to work, we should abort or skip and exit the test if the enumeration doesn't bring up devices
Quoted 26 lines
s390x/css.c +26
-0+/* Read the SCHIB for this subchannel */ + cc =stsch (test_device_sid, &schib); +if (cc) { +report (0 ,"stsch cc=%d" , cc); +return ; + } + +/* Update the SCHIB to enable the channel */ + pmcw->flags |=PMCW_ENABLE ; + +/* Tell the CSS we want to modify the subchannel */ + cc =msch (test_device_sid, &schib); +if (cc) { +/* +* If the subchannel is status pending or +* if a function is in progress, +* we consider both cases as errors. +*/ +report (0 ,"msch cc=%d" , cc); +return ; + } + +/* +* Read the SCHIB again to verify the enablement +*/ + cc =stsch (test_device_sid, &schib);
s390x/css.c out: · line 115
Quoted 10 lines
s390x/css.c +10
-0+if (cc) { +report (0 ,"stsch cc=%d" , cc); +return ; + } + +if (!(pmcw->flags &PMCW_ENABLE )) { +report (0 ,"Enable failed. pmcw: %x" , pmcw->flags); +return ; + } +report (1 ,"Tested" );
s/Tested/Enabled/
Quoted 12 lines
s390x/css.c +3
-0+} +static struct {const char *name;void (*func)(void ); } tests[] = { {"enumerate (stsch)" , test_enumerate }, + {"enable (msch)" , test_enable }, {NULL ,NULL } };
Re: [kvm-unit-tests PATCH v6 07/10] s390x: css: msch, enable test
Quoted 10 lines · Janosch Frank
Quoted 9 lines · Pierre Morel
A second step when testing the channel subsystem is to prepare a channel for use.
This includes:
- Get the current SubCHannel Information Block (SCHIB) using STSCH
- Update it in memory to set the ENABLE bit
- Tell the CSS that the SCHIB has been modified using MSCH
- Get the SCHIB from the CSS again to verify that the subchannel is enabled.
Quoted 3 lines
Quoted 1 line
This tests the MSCH instruction to enable a channel succesfuly.
successfully
Thx
Quoted 5 lines
Quoted 3 lines
This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
Would we expect needing retries for the pong device?
Yes it can be that we need to retry some instructions if we want them to succeed.
This is the case for example if we develop a driver for an operating system.
When working with firmware, sometime, things do not work at the first time. Mostly due to races in silicium, firmware or hypervisor or between them all.
Since our purpose is to detect such problems we do not retry instructions but report the error.
If we detect such problem we may in the future enhance the tests.
Quoted 4 lines
Quoted 2 lines
Quoted 9 lines
s390x/css.c out: · line 79
Quoted 5 lines
s390x/css.c +5
-0+ +if (!test_device_sid) { +report_skip ("No device" ); +return ; + }If these tests are layered on top of each other and need a device to work, we should abort or skip and exit the test if the enumeration doesn't bring up devices
OK, we can abort instead of skipping
Quoted 3 lines
s390x/css.c out: · line 115
Quoted 1 line
s390x/css.c +1
-0+report (1 ,"Tested" );s/Tested/Enabled/
OK
Thanks,
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Re: [kvm-unit-tests PATCH v6 07/10] s390x: css: msch, enable test
Quoted 15 lines · On Tue, 28 Apr 2020 10:27:36 +0200 Pierre Morel <[email protected]> wrote:
Quoted 6 lines · Janosch Frank
Quoted 2 lines · Pierre Morel
This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
Would we expect needing retries for the pong device?
Yes it can be that we need to retry some instructions if we want them to succeed.
This is the case for example if we develop a driver for an operating system. When working with firmware, sometime, things do not work at the first time. Mostly due to races in silicium, firmware or hypervisor or between them all.
Quoted 4 lines
Since our purpose is to detect such problems we do not retry instructions but report the error.
If we detect such problem we may in the future enhance the tests.
I think I've seen retries needed on z/VM in the past; do you know if that still happens?
Re: [kvm-unit-tests PATCH v6 07/10] s390x: css: msch, enable test
Quoted 18 lines · Cornelia Huck
Quoted 15 lines · On Tue, 28 Apr 2020 10:27:36 +0200 Pierre Morel <[email protected]> wrote:
Quoted 6 lines · Janosch Frank
Quoted 2 lines · Pierre Morel
This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
Would we expect needing retries for the pong device?
Yes it can be that we need to retry some instructions if we want them to succeed.
This is the case for example if we develop a driver for an operating system. When working with firmware, sometime, things do not work at the first time. Mostly due to races in silicium, firmware or hypervisor or between them all.
Quoted 8 lines
Quoted 4 lines
Since our purpose is to detect such problems we do not retry instructions but report the error.
If we detect such problem we may in the future enhance the tests.
I think I've seen retries needed on z/VM in the past; do you know if that still happens?
I did not try the tests under z/VM, nor direct on an LPAR, only under QEMU/KVM. Under QEMU/KVM, I did not encounter any need for retry, 100% of the enabled succeeded on first try.
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Re: [kvm-unit-tests PATCH v6 07/10] s390x: css: msch, enable test
Quoted 24 lines · On Fri, 15 May 2020 09:11:52 +0200 Pierre Morel <[email protected]> wrote:
Quoted 23 lines · Cornelia Huck
Quoted 19 lines · On Tue, 28 Apr 2020 10:27:36 +0200 Pierre Morel <[email protected]> wrote:
Quoted 6 lines · Janosch Frank
Quoted 2 lines · Pierre Morel
This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
Would we expect needing retries for the pong device?
Yes it can be that we need to retry some instructions if we want them to succeed.
This is the case for example if we develop a driver for an operating system. When working with firmware, sometime, things do not work at the first time. Mostly due to races in silicium, firmware or hypervisor or between them all.Since our purpose is to detect such problems we do not retry instructions but report the error.
If we detect such problem we may in the future enhance the tests.
Quoted 8 lines
Quoted 3 lines
I think I've seen retries needed on z/VM in the past; do you know if that still happens?
I did not try the tests under z/VM, nor direct on an LPAR, only under QEMU/KVM.
Under QEMU/KVM, I did not encounter any need for retry, 100% of the enabled succeeded on first try.
Yep, QEMU/KVM should be fine. Do you plan to run this on anything else?
Re: [kvm-unit-tests PATCH v6 07/10] s390x: css: msch, enable test
Quoted 31 lines · Cornelia Huck
Quoted 28 lines · On Fri, 15 May 2020 09:11:52 +0200 Pierre Morel <[email protected]> wrote:
Quoted 26 lines · Cornelia Huck
Quoted 15 lines · On Tue, 28 Apr 2020 10:27:36 +0200 Pierre Morel <[email protected]> wrote:
Quoted 6 lines · Janosch Frank
Quoted 2 lines · Pierre Morel
This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
Would we expect needing retries for the pong device?
Yes it can be that we need to retry some instructions if we want them to succeed.
This is the case for example if we develop a driver for an operating system. When working with firmware, sometime, things do not work at the first time. Mostly due to races in silicium, firmware or hypervisor or between them all.Quoted 4 lines
Since our purpose is to detect such problems we do not retry instructions but report the error.
If we detect such problem we may in the future enhance the tests.
I think I've seen retries needed on z/VM in the past; do you know if that still happens?
Quoted 7 lines
Quoted 4 lines
I did not try the tests under z/VM, nor direct on an LPAR, only under QEMU/KVM.
Under QEMU/KVM, I did not encounter any need for retry, 100% of the enabled succeeded on first try.Yep, QEMU/KVM should be fine. Do you plan to run this on anything else?
I'd like to have it compatible with z/VM / LPAR as well if it isn't too much work. You never know when you need it and having tests for all hypervisors has been quite a help in the past.
Re: [kvm-unit-tests PATCH v6 07/10] s390x: css: msch, enable test
Quoted 37 lines · Janosch Frank
Quoted 36 lines · Cornelia Huck
Quoted 32 lines · On Fri, 15 May 2020 09:11:52 +0200 Pierre Morel <[email protected]> wrote:
Quoted 18 lines · Cornelia Huck
Quoted 15 lines · On Tue, 28 Apr 2020 10:27:36 +0200 Pierre Morel <[email protected]> wrote:
Quoted 6 lines · Janosch Frank
Quoted 2 lines · Pierre Morel
This is NOT a routine to really enable the channel, no retry is done, in case of error, a report is made.
Would we expect needing retries for the pong device?
Yes it can be that we need to retry some instructions if we want them to succeed.
This is the case for example if we develop a driver for an operating system. When working with firmware, sometime, things do not work at the first time. Mostly due to races in silicium, firmware or hypervisor or between them all.Quoted 8 lines
Quoted 4 lines
Since our purpose is to detect such problems we do not retry instructions but report the error.
If we detect such problem we may in the future enhance the tests.
I think I've seen retries needed on z/VM in the past; do you know if that still happens?
I did not try the tests under z/VM, nor direct on an LPAR, only under QEMU/KVM.
Under QEMU/KVM, I did not encounter any need for retry, 100% of the enabled succeeded on first try.
Quoted 7 lines
Quoted 2 lines
Yep, QEMU/KVM should be fine. Do you plan to run this on anything else?
I'd like to have it compatible with z/VM / LPAR as well if it isn't too much work. You never know when you need it and having tests for all hypervisors has been quite a help in the past.
OK, then I can add some retries in prevision.
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
PATCH v6 8/10 s390x: define wfi: wait for interrupt
In reply to Pierre Morelwfi(irq_mask) allows the programm to wait for an interrupt. The interrupt handler is in charge to remove the WAIT bit when it finished handling interrupt.
--- lib/s390x/asm/arch_def.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
lib/s390x/asm/arch_def.h +11 -0
@@ -13,6 +13,7 @@#define PSW_MASK_EXT 0x0100000000000000UL#define PSW_MASK_DAT 0x0400000000000000UL#define PSW_MASK_SHORT_PSW 0x0008000000000000UL +#define PSW_MASK_WAIT 0x0002000000000000UL#define PSW_MASK_PSTATE 0x0001000000000000UL#define PSW_MASK_BA 0x0000000080000000UL#define PSW_MASK_EA 0x0000000100000000UL
@@ -254,6 +255,16 @@ static inline void load_psw_mask(uint64_t mask) : "+r" (tmp) : "a" (&psw) : "memory", "cc" ); } +static inline void wfi (uint64_t irq_mask) +{ +uint64_t psw_mask; + + psw_mask =extract_psw_mask (); +load_psw_mask (psw_mask | irq_mask |PSW_MASK_WAIT ); +load_psw_mask (psw_mask); +} + +static inline void enter_pstate (void ) {uint64_t mask;
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 08/10] s390x: define wfi: wait for interrupt
Quoted 1 line · Pierre Morel
wfi(irq_mask)allows the programm to wait for an interrupt.
s/programm/program/
Quoted 2 lines
The interrupt handler is in charge to remove the WAIT bit when it finished handling interrupt.
...finished handling the interrupt.
Quoted 19 lines
Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/asm/arch_def.h | 11 +++++++++++ 1 file changed, 11 insertions(+)lib/s390x/asm/arch_def.h +1
-0@@ -13,6 +13,7 @@#define PSW_MASK_EXT 0x0100000000000000UL#define PSW_MASK_DAT 0x0400000000000000UL#define PSW_MASK_SHORT_PSW 0x0008000000000000UL +#define PSW_MASK_WAIT 0x0002000000000000UL#define PSW_MASK_PSTATE 0x0001000000000000UL#define PSW_MASK_BA 0x0000000080000000UL#define PSW_MASK_EA 0x0000000100000000UL
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 258
Quoted 4 lines
lib/s390x/asm/arch_def.h +1
-0@@ -254,6 +255,16 @@ static inline void load_psw_mask(uint64_t mask) : "+r" (tmp) : "a" (&psw) : "memory", "cc" ); } +static inline void wfi (uint64_t irq_mask)
enabled_wait()
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 260
Quoted 2 lines
lib/s390x/asm/arch_def.h +2
-0+{ +uint64_t psw_mask;
You can directly initialize this variable.
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 263
Quoted 3 lines
lib/s390x/asm/arch_def.h +3
-0+ + psw_mask =extract_psw_mask (); +load_psw_mask (psw_mask | irq_mask |PSW_MASK_WAIT );
Maybe add a comment here:
/*
* After being woken and having processed the interrupt, let's restore
the PSW mask.
*/
Quoted 8 lines
lib/s390x/asm/arch_def.h +4
-0+load_psw_mask (psw_mask); +} + +static inline void enter_pstate (void ) {uint64_t mask;
Re: [kvm-unit-tests PATCH v6 08/10] s390x: define wfi: wait for interrupt
Quoted 4 lines · Janosch Frank
Quoted 1 line · Pierre Morel
wfi(irq_mask)allows the programm to wait for an interrupt.s/programm/program/
Thx,
Quoted 5 lines
Quoted 3 lines
The interrupt handler is in charge to remove the WAIT bit when it finished handling interrupt.
...finished handling the interrupt.
OK, thx
Quoted 7 lines
Quoted 5 lines
}+static inline void
wfi(uint64_t irq_mask)
enabled_wait()
I do not like enabled_wait(), we do not know what is enabled and we do not know what we are waiting for.
What about wait_for_interrupt()
Quoted 12 lines
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 260
Quoted 3 lines
lib/s390x/asm/arch_def.h +2
-0+{ +uint64_t psw_mask;You can directly initialize this variable.
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 263
Quoted 3 lines
lib/s390x/asm/arch_def.h +3
-0+ + psw_mask =extract_psw_mask (); +load_psw_mask (psw_mask | irq_mask |PSW_MASK_WAIT );Maybe add a comment here:
Quoted 8 lines
/*
* After being woken and having processed the interrupt, let's restore
the PSW mask.
*/lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 266
Quoted 3 lines
lib/s390x/asm/arch_def.h +3
-0+load_psw_mask (psw_mask); +} +
I can do this, but wasn't it obvious?
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Re: [kvm-unit-tests PATCH v6 08/10] s390x: define wfi: wait for interrupt
Quoted 24 lines · Pierre Morel
Quoted 4 lines · Janosch Frank
Quoted 1 line · Pierre Morel
wfi(irq_mask)allows the programm to wait for an interrupt.s/programm/program/
Thx,
Quoted 5 lines
Quoted 3 lines
The interrupt handler is in charge to remove the WAIT bit when it finished handling interrupt.
...finished handling the interrupt.
OK, thx
Quoted 6 lines
Quoted 5 lines
}+static inline void
wfi(uint64_t irq_mask)
Quoted 7 lines
Quoted 1 line
enabled_wait()I do not like
enabled_wait(), we do not know what is enabled and we do not know what we are waiting for.What about
wait_for_interrupt()
As long as it's not called wfi...
Quoted 18 lines
Quoted 18 lines
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 260
Quoted 4 lines
lib/s390x/asm/arch_def.h +2
-0+{ +uint64_t psw_mask;You can directly initialize this variable.
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 263
Quoted 3 lines
lib/s390x/asm/arch_def.h +3
-0+ + psw_mask =extract_psw_mask (); +load_psw_mask (psw_mask | irq_mask |PSW_MASK_WAIT );Maybe add a comment here:
/*
* After being woken and having processed the interrupt, let's restore
the PSW mask.
*/
Quoted 5 lines
Quoted 3 lines
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 266
Quoted 3 lines
lib/s390x/asm/arch_def.h +3
-0+load_psw_mask (psw_mask); +} +I can do this, but wasn't it obvious?
It took me a minute, so it will take even longer for developers that are not yet familiar with s390 kernel development.
Quoted 5 lines
Regards,
Pierre
Re: [kvm-unit-tests PATCH v6 08/10] s390x: define wfi: wait for interrupt
Quoted 53 lines · Janosch Frank
Quoted 24 lines · Pierre Morel
Quoted 4 lines · Janosch Frank
Quoted 1 line · Pierre Morel
wfi(irq_mask)allows the programm to wait for an interrupt.s/programm/program/
Thx,
Quoted 5 lines
Quoted 3 lines
The interrupt handler is in charge to remove the WAIT bit when it finished handling interrupt.
...finished handling the interrupt.
OK, thx
Quoted 6 lines
Quoted 5 lines
}+static inline void
wfi(uint64_t irq_mask)Quoted 7 lines
Quoted 1 line
enabled_wait()I do not like
enabled_wait(), we do not know what is enabled and we do not know what we are waiting for.What about
wait_for_interrupt()As long as it's not called wfi...
Quoted 18 lines
Quoted 18 lines
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 260
Quoted 4 lines
lib/s390x/asm/arch_def.h +2
-0+{ +uint64_t psw_mask;You can directly initialize this variable.
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 263
Quoted 3 lines
lib/s390x/asm/arch_def.h +3
-0+ + psw_mask =extract_psw_mask (); +load_psw_mask (psw_mask | irq_mask |PSW_MASK_WAIT );Maybe add a comment here:
/*
* After being woken and having processed the interrupt, let's restore
the PSW mask.
*/
Quoted 16 lines
Quoted 5 lines
Quoted 3 lines
lib/s390x/asm/arch_def.h static inline void load_psw_mask(uint64_t mask) · line 266
Quoted 3 lines
lib/s390x/asm/arch_def.h +3
-0+load_psw_mask (psw_mask); +} +I can do this, but wasn't it obvious?
It took me a minute, so it will take even longer for developers that are not yet familiar with s390 kernel development.
Quoted 5 lines
Regards,
Pierre
OK, will do
Thx
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
PATCH v6 9/10 s390x: css: ssch/tsch with sense and interrupt
In reply to Pierre MorelWe add a new css_lib file to contain the I/O function we may share with different tests.
First function is the subchannel_enable() function.
When a channel is enabled we can start a SENSE_ID command using the SSCH instruction to recognize the control unit and device.
This tests the success of SSCH, the I/O interruption and the TSCH instructions.
The test expects a device with a control unit type of 0xC0CA as the first subchannel of the CSS.
--- lib/s390x/asm/arch_def.h | 1 + lib/s390x/css.h | 20 ++++++ lib/s390x/css_lib.c | 55 +++++++++++++++ s390x/Makefile | 1 + s390x/css.c | 149 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 226 insertions(+) create mode 100644 lib/s390x/css_lib.c
lib/s390x/asm/arch_def.h +1 -0
@@ -10,6 +10,7 @@#ifndef _ASM_S390X_ARCH_DEF_H_#define _ASM_S390X_ARCH_DEF_H_ +#define PSW_MASK_IO 0x0200000000000000UL#define PSW_MASK_EXT 0x0100000000000000UL#define PSW_MASK_DAT 0x0400000000000000UL#define PSW_MASK_SHORT_PSW 0x0008000000000000UL
lib/s390x/css.h +20 -0
@@ -97,6 +97,19 @@ struct irb {uint32_t emw[8 ]; } __attribute__ ((aligned(4))); +#define CCW_CMD_SENSE_ID 0xe4 +#define PONG_CU 0xc0ca +struct senseid { +/* common part */ +uint8_t reserved;/* always 0x'FF' */ +uint16_t cu_type;/* control unit type */ +uint8_t cu_model;/* control unit model */ +uint16_t dev_type;/* device type */ +uint8_t dev_model;/* device model */ +uint8_t unused;/* padding byte */ +uint8_t padding[256 -10 ];/* Extra padding for CCW */ +} __attribute__ ((aligned(4))) __attribute__ ((packed)); +/* CSS low level access functions */ static inline int ssch (unsigned long schid,struct orb *addr)
@@ -254,4 +267,11 @@ static inline struct ccw *dump_ccw(struct ccw *cp)return NULL ; }#endif /* DEBUG_CSS */ + +#define SID_ONE 0x00010000 + +/* Library functions */ +int enable_subchannel (unsigned int sid); +int start_ccw1_chain (unsigned int sid,struct ccw1 *ccw); +#endif
lib/s390x/css_lib.c new file +55 -0
55 lines not on this page · raw message
s390x/Makefile +1 -0
@@ -53,6 +53,7 @@ cflatobjs += lib/s390x/interrupt.o cflatobjs += lib/s390x/mmu.o cflatobjs += lib/s390x/smp.o cflatobjs += lib/s390x/css_dump.o +cflatobjs += lib/s390x/css_lib.o OBJDIRS += lib/s390x
s390x/css.c +149 -0
176 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 09/10] s390x: css: ssch/tsch with sense and interrupt
Quoted 1 line · On Fri, 24 Apr 2020 12:45:51 +0200 Pierre Morel <[email protected]> wrote:
We add a new
css_libfile to contain the I/O function we may
s/function/functions/
Quoted 22 lines
share with different tests.
First function is thesubchannel_enable()function.When a channel is enabled we can start a
SENSE_IDcommand using the SSCH instruction to recognize the control unit and device.This tests the success of SSCH, the I/O interruption and the TSCH instructions.
The test expects a device with a control unit type of
0xC0CAas the first subchannel of the CSS.Signed-off-by Pierre Morel <[email protected]>--- lib/s390x/asm/arch_def.h | 1 + lib/s390x/css.h | 20 ++++++ lib/s390x/css_lib.c | 55 +++++++++++++++ s390x/Makefile | 1 + s390x/css.c | 149 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 226 insertions(+) create mode 100644 lib/s390x/css_lib.c
(...)
Quoted 15 lines
s390x/css.c +15
-0+static void irq_io (void ) +{ +int ret =0 ; +char *flags; +int sid; + +report_prefix_push ("Interrupt" ); +/* Lowlevel set the SID as interrupt parameter. */ +if (lowcore->io_int_param != test_device_sid) { +report (0 , +"Bad io_int_param: %x expected %x" , + lowcore->io_int_param, test_device_sid); + goto pop; + } +report_prefix_pop ();
s390x/css.c static void test_enable(void) · line 165
Quoted 10 lines
s390x/css.c +10
-0+ +report_prefix_push ("tsch" ); + sid = lowcore->subsys_id_word; + ret =tsch (sid, &irb); +switch (ret) { +case 1 : +dump_irb (&irb); + flags =dump_scsw_flags (irb.scsw.ctrl); +report (0 , +"I/O interrupt, but sch not status pending: %s" , flags);
"...but tsch reporting sch as not status pending" ?
A buggy implementation might give the wrong cc for tsch, but still indicate status pending in the control block.
s390x/css.c static void test_enable(void) · line 171
Quoted 6 lines
s390x/css.c +6
-0+break ; +case 2 : +report (0 ,"TSCH returns unexpected CC 2" ); +break ; +case 3 : +report (0 ,"Subchannel %08x not operational" , sid);
"tsch reporting subchannel %08x as not operational" ?
Quoted 9 lines
s390x/css.c +9
-0+break ; +case 0 : +/* Stay humble on success */ +break ; + } +pop: +report_prefix_pop (); + lowcore->io_old_psw.mask &= ~PSW_MASK_WAIT ; +}
(...)
Quoted 23 lines
s390x/css.c +23
-0+/* +* test_sense +* Pre-requisits: +* - We need the QEMU PONG device as the first recognized +* device by the enumeration. +* - ./s390x-run s390x/css.elf -device ccw-pong,cu_type=0xc0ca +*/ +static void test_sense (void ) +{ +int ret; + +if (!test_device_sid) { +report_skip ("No device" ); +return ; + } + + ret =enable_subchannel (test_device_sid); +if (ret <0 ) { +report (0 , +"Could not enable the subchannel: %08x" , + test_device_sid); +return ; + }
s390x/css.c static void test_enable(void) · line 235
Quoted 10 lines
s390x/css.c +10
-0+ + ret =register_io_int_func (irq_io); +if (ret) { +report (0 ,"Could not register IRQ handler" ); + goto unreg_cb; + } + + lowcore->io_int_param =0 ; + + ret =start_subchannel (CCW_CMD_SENSE_ID , &senseid,sizeof (senseid));
You're always send the full (extended) sense id block. What if the the machine you're running on doesn't support extended sense id? Would the SLI ccw flag help?
s390x/css.c static void test_enable(void) · line 237
Quoted 2 lines
s390x/css.c +2
-0+if (!ret) { +report (0 ,"start_senseid failed" );
"ssch failed for SENSE ID on sch <sch>" ?
s390x/css.c static void test_enable(void) · line 246
Quoted 9 lines
s390x/css.c +9
-0+ goto unreg_cb; + } + +wfi (PSW_MASK_IO ); + +if (lowcore->io_int_param != test_device_sid) { +report (0 , +"No interrupts. io_int_param: expect 0x%08x, got 0x%08x" , + test_device_sid, lowcore->io_int_param);
Doesn't irq_io() already moan here?
Quoted 18 lines
s390x/css.c +18
-0+ goto unreg_cb; + } + +report_info ("reserved %02x cu_type %04x cu_model %02x dev_type %04x dev_model %02x" , + senseid.reserved, senseid.cu_type, senseid.cu_model, + senseid.dev_type, senseid.dev_model); + +if (senseid.cu_type ==PONG_CU ) +report (1 ,"cu_type: expect 0x%04x got 0x%04x" , +PONG_CU_TYPE , senseid.cu_type); +else +report (0 ,"cu_type: expect 0x%04x got 0x%04x" , +PONG_CU_TYPE , senseid.cu_type); + +unreg_cb: +unregister_io_int_func (irq_io); +} +
Re: [kvm-unit-tests PATCH v6 09/10] s390x: css: ssch/tsch with sense and interrupt
Quoted 6 lines · Cornelia Huck
Quoted 1 line · On Fri, 24 Apr 2020 12:45:51 +0200 Pierre Morel <[email protected]> wrote:
We add a new
css_libfile to contain the I/O function we mays/function/functions/
Yes, thanks.
Quoted 11 lines
s390x/css.c static void test_enable(void) · line 165
Quoted 9 lines
s390x/css.c +9
-0+report_prefix_push ("tsch" ); + sid = lowcore->subsys_id_word; + ret =tsch (sid, &irb); +switch (ret) { +case 1 : +dump_irb (&irb); + flags =dump_scsw_flags (irb.scsw.ctrl); +report (0 , +"I/O interrupt, but sch not status pending: %s" , flags);"...but tsch reporting sch as not status pending" ?
Yes, better, Thx
Quoted 3 lines
A buggy implementation might give the wrong cc for tsch, but still indicate status pending in the control block.
OK, I will write the status for other error cases too.
Quoted 4 lines
s390x/css.c static void test_enable(void) · line 168
Quoted 4 lines
s390x/css.c +3
-0+break ; +case 2 : +report (0 ,"TSCH returns unexpected CC 2" );
will also s/TSCH/tsch/ here
Quoted 5 lines
s390x/css.c static void test_enable(void) · line 171
Quoted 3 lines
s390x/css.c +3
-0+break ; +case 3 : +report (0 ,"Subchannel %08x not operational" , sid);"tsch reporting subchannel %08x as not operational" ?
Yes, better.
and I will standardize these three reports.
Quoted 11 lines
Quoted 10 lines
s390x/css.c +9
-0+break ; +case 0 : +/* Stay humble on success */ +break ; + } +pop: +report_prefix_pop (); + lowcore->io_old_psw.mask &= ~PSW_MASK_WAIT ; +}
...snip...
Quoted 7 lines
s390x/css.c static void test_enable(void) · line 235
Quoted 3 lines
s390x/css.c +3
-0+ lowcore->io_int_param =0 ; + + ret =start_subchannel (CCW_CMD_SENSE_ID , &senseid,sizeof (senseid));You're always send the full (extended) sense id block. What if the the machine you're running on doesn't support extended sense id? Would the SLI ccw flag help?
Yes, you are right, since I only use senseid for recognition of the PONG subchannel, I can accept non extended senseid
Quoted 5 lines
s390x/css.c static void test_enable(void) · line 237
Quoted 3 lines
s390x/css.c +2
-0+if (!ret) { +report (0 ,"start_senseid failed" );"ssch failed for SENSE ID on sch <sch>" ?
Better. Thx
Quoted 12 lines
s390x/css.c static void test_enable(void) · line 246
Quoted 10 lines
s390x/css.c +9
-0+ goto unreg_cb; + } + +wfi (PSW_MASK_IO ); + +if (lowcore->io_int_param != test_device_sid) { +report (0 , +"No interrupts. io_int_param: expect 0x%08x, got 0x%08x" , + test_device_sid, lowcore->io_int_param);Doesn't
irq_io()already moan here?
Yes, right, I kept this from last version with delays. It has no sense here:
- We are the only user of the CSS
- If the interrupt did not fire we are stuck in wfi()
Thanks.
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
PATCH v6 10/10 s390x: css: ping pong
In reply to Pierre MorelTo test a write command with the SSCH instruction we need a QEMU device, with control unit type 0xC0CA. The PONG device is such a device.
This type of device responds to PONG_WRITE requests by incrementing an integer, stored as a string at offset 0 of the CCW data.
--- s390x/css.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
s390x/css.c +54 -0
@@ -23,6 +23,12 @@#define PSW_PRG_MASK (PSW_MASK_EA | PSW_MASK_BA)#define PONG_CU_TYPE 0xc0ca +/* Channel Commands for PONG device */ +#define PONG_WRITE 0x21/* Write */ +#define PONG_READ 0x22/* Read buffer */ + +#define BUFSZ 9 +static char buffer[BUFSZ ];struct lowcore *lowcore = (void *)0x0 ;
@@ -262,6 +268,53 @@ unreg_cb:unregister_io_int_func (irq_io); } +static void test_ping (void ) +{ +int success, result; +int cnt =0 , max =4 ; + +if (senseid.cu_type !=PONG_CU ) { +report_skip ("No PONG, no ping-pong" ); +return ; + } + + result =register_io_int_func (irq_io); +if (result) { +report (0 ,"Could not register IRQ handler" ); +return ; + } + +while (cnt++ < max) { +snprintf (buffer,BUFSZ ,"%08x\n" , cnt); + success =start_subchannel (PONG_WRITE , buffer,BUFSZ ); +if (!success) { +report (0 ,"start_subchannel failed" ); + goto unreg_cb; + } + +wfi (PSW_MASK_IO ); + + success =start_subchannel (PONG_READ , buffer,BUFSZ ); +if (!success) { +report (0 ,"start_subchannel failed" ); + goto unreg_cb; + } + +wfi (PSW_MASK_IO ); + + result =atol (buffer); +if (result != (cnt +1 )) { +report (0 ,"Bad answer from pong: %08x - %08x" , + cnt, result); + goto unreg_cb; + } + } +report (1 ,"ping-pong count 0x%08x" , cnt); + +unreg_cb: +unregister_io_int_func (irq_io); +} + static struct { const char *name; void (*func)(void);
@@ -269,6 +322,7 @@ static struct { { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, + { "ping-pong (ssch/tsch)", test_ping }, { NULL, NULL } };
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v6 10/10] s390x: css: ping pong
Quoted 29 lines · Pierre Morel
To test a write command with the SSCH instruction we need a QEMU device, with control unit type
0xC0CA. The PONG device is such a device.This type of device responds to
PONG_WRITErequests by incrementing an integer, stored as a string at offset 0 of the CCW data.Signed-off-by Pierre Morel <[email protected]>--- s390x/css.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)s390x/css.c +6
-0@@ -23,6 +23,12 @@#define PSW_PRG_MASK (PSW_MASK_EA | PSW_MASK_BA)#define PONG_CU_TYPE 0xc0ca +/* Channel Commands for PONG device */ +#define PONG_WRITE 0x21/* Write */ +#define PONG_READ 0x22/* Read buffer */ + +#define BUFSZ 9 +static char buffer[BUFSZ ];struct lowcore *lowcore = (void *)0x0 ;
s390x/css.c unreg_cb: · line 277
Quoted 10 lines
s390x/css.c +7
-0@@ -262,6 +268,53 @@ unreg_cb:unregister_io_int_func (irq_io); } +static void test_ping (void ) +{ +int success, result; +int cnt =0 , max =4 ; + +if (senseid.cu_type !=PONG_CU ) { +report_skip ("No PONG, no ping-pong" );
"Device is not a pong device."
s390x/css.c unreg_cb: · line 285
Quoted 8 lines
s390x/css.c +8
-0+return ; + } + + result =register_io_int_func (irq_io); +if (result) { +report (0 ,"Could not register IRQ handler" ); +return ; + }
I'm not sure if it's worth checking the return values or even having a check in register_io_int_func() in the first place.
Quoted 44 lines
s390x/css.c +33
-0+ +while (cnt++ < max) { +snprintf (buffer,BUFSZ ,"%08x\n" , cnt); + success =start_subchannel (PONG_WRITE , buffer,BUFSZ ); +if (!success) { +report (0 ,"start_subchannel failed" ); + goto unreg_cb; + } + +wfi (PSW_MASK_IO ); + + success =start_subchannel (PONG_READ , buffer,BUFSZ ); +if (!success) { +report (0 ,"start_subchannel failed" ); + goto unreg_cb; + } + +wfi (PSW_MASK_IO ); + + result =atol (buffer); +if (result != (cnt +1 )) { +report (0 ,"Bad answer from pong: %08x - %08x" , + cnt, result); + goto unreg_cb; + } + } +report (1 ,"ping-pong count 0x%08x" , cnt); + +unreg_cb: +unregister_io_int_func (irq_io); +} + static struct { const char *name; void (*func)(void);@@ -269,6 +322,7 @@ static struct { { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, + { "ping-pong (ssch/tsch)", test_ping }, { NULL, NULL } };
Re: [kvm-unit-tests PATCH v6 10/10] s390x: css: ping pong
Quoted 9 lines · Janosch Frank
Quoted 7 lines · Pierre Morel
To test a write command with the SSCH instruction we need a QEMU device, with control unit type
0xC0CA. The PONG device is such a device.This type of device responds to
PONG_WRITErequests by incrementing an integer, stored as a string at offset 0 of the CCW data.Signed-off-by Pierre Morel <[email protected]>
Quoted 9 lines
s390x/css.c unreg_cb: · line 277
Quoted 7 lines
s390x/css.c +7
-0+static void test_ping (void ) +{ +int success, result; +int cnt =0 , max =4 ; + +if (senseid.cu_type !=PONG_CU ) { +report_skip ("No PONG, no ping-pong" );"Device is not a pong device."
:( so far for poetry
Quoted 12 lines
s390x/css.c unreg_cb: · line 285
Quoted 9 lines
s390x/css.c +8
-0+return ; + } + + result =register_io_int_func (irq_io); +if (result) { +report (0 ,"Could not register IRQ handler" ); +return ; + }I'm not sure if it's worth checking the return values or even having a check in
register_io_int_func()in the first place.
I wait for reviewers/maintainers having already given their reviewed-by to the interrupt registration patch to give their opinion. Then I change it if needed.
Regards,
Pierre
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen