s390x: Add SIE library and simple test
v2 cover s390x: Add SIE library and simple test
This is the absolute minimum needed to run VMs inside the KVM Unit Tests. It's more of a base for other tests that I can't (yet) publish than an addition of tests that check KVM functionality. However, I wanted to decrease the number of WIP patches in my private branch. Once the library is available maybe others will come and extend the SIE test itself.
Yes, I have added VM management functionality like VM create/destroy, etc but as it is not needed right now, I'd like to exclude it from this patch set for now.
Gitlab:
https://gitlab.com/frankja/kvm-unit-tests/-/tree/sie
CI:
https://gitlab.com/frankja/kvm-unit-tests/-/pipelines/222217716
v2:
* Added license and source identifiers to test_bit patch
* Changed the way I test for sclp feature bits
* Removed the cpu info page itself and all references
* Added the diag318 and a sclp.h style fix patch
Janosch Frank (7):
s390x: Add test_bit to library
s390x: Consolidate sclp read info
s390x: SCLP feature checking
s390x: sie: Add SIE to lib
s390x: sie: Add first SIE test
s390x: Add diag318 intercept test
s390x: Fix sclp.h style issues
lib/s390x/asm-offsets.c | 13 +++ lib/s390x/asm/arch_def.h | 7 ++ lib/s390x/asm/bitops.h | 26 ++++++ lib/s390x/asm/facility.h | 3 +- lib/s390x/interrupt.c | 7 ++ lib/s390x/io.c | 2 + lib/s390x/sclp.c | 50 ++++++++-- lib/s390x/sclp.h | 178 +++++++++++++++++++---------------- lib/s390x/sie.h | 197 +++++++++++++++++++++++++++++++++++++++ lib/s390x/smp.c | 28 +++--- s390x/Makefile | 1 + s390x/cstart64.S | 56 +++++++++++ s390x/intercept.c | 19 ++++ s390x/sie.c | 125 +++++++++++++++++++++++++ s390x/unittests.cfg | 3 + 15 files changed, 611 insertions(+), 104 deletions(-) create mode 100644 lib/s390x/sie.h create mode 100644 s390x/sie.c
Signature · 1 line
2.25.1
PATCH v2 1/7 s390x: Add test_bit to library
Query/feature bits are commonly tested via MSB bit numbers on s390. Let's add test bit functions, so we don't need to copy code to test query bits.
The test_bit code has been taken from the kernel since most s390x KVM unit test developers are used to them.
--- lib/s390x/asm/bitops.h | 26 ++++++++++++++++++++++++++ lib/s390x/asm/facility.h | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-)
lib/s390x/asm/bitops.h +26 -0
@@ -1,3 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Bitops taken from the kernel as most developers are already used +* to them. +* +* Copyright IBM Corp. 1999,2013 +* +* Author(s): Martin Schwidefsky <[email protected]>, +* +*/ #ifndef _ASMS390X_BITOPS_H_#define _ASMS390X_BITOPS_H_
@@ -7,4 +17,20 @@#define BITS_PER_LONG 64 +static inline bool test_bit (unsigned long nr, +const volatile unsigned long *ptr) +{ +const volatile unsigned char *addr; + + addr = ((const volatile unsigned char *)ptr); + addr += (nr ^ (BITS_PER_LONG -8 )) >>3 ; +return (*addr >> (nr &7 )) &1 ; +} + +static inline bool test_bit_inv (unsigned long nr, +const volatile unsigned long *ptr) +{ +return test_bit (nr ^ (BITS_PER_LONG -1 ), ptr); +} +#endif
lib/s390x/asm/facility.h +2 -1
@@ -13,13 +13,14 @@#include <libcflat.h> #include <asm/facility.h> #include <asm/arch_def.h> +#include <bitops.h> #define NB_STFL_DOUBLEWORDS 32extern uint64_t stfl_doublewords[];static inline bool test_facility (int nr) { -return stfl_doublewords[nr /64 ] & (0x8000000000000000UL >> (nr %64 )); +return test_bit_inv (nr, stfl_doublewords); }static inline void stfl (void )
Signature · 1 line
2.25.1
PATCH v2 2/7 s390x: Consolidate sclp read info
In reply to Janosch FrankLet's only read the information once and pass a pointer to it instead of calling sclp multiple times.
--- lib/s390x/io.c | 1 + lib/s390x/sclp.c | 29 +++++++++++++++++++++++------ lib/s390x/sclp.h | 3 +++ lib/s390x/smp.c | 28 +++++++++++----------------- 4 files changed, 38 insertions(+), 23 deletions(-)
lib/s390x/io.c +1 -0
@@ -36,6 +36,7 @@ void setup(void) {setup_args_progname (ipl_args);setup_facilities (); +sclp_read_info ();sclp_console_setup ();sclp_memory_setup ();smp_setup ();
lib/s390x/sclp.c +23 -6
@@ -25,6 +25,8 @@ extern unsigned long stacktop;static uint64_t storage_increment_size;static uint64_t max_ram_size;static uint64_t ram_size; +char _read_info[PAGE_SIZE] __attribute__((__aligned__(4096))); +static ReadInfo *read_info; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));static volatile bool sclp_busy;
@@ -110,6 +112,22 @@ static void sclp_read_scp_info(ReadInfo *ri, int length)report_abort ("READ_SCP_INFO failed" ); } +void sclp_read_info (void ) +{ +sclp_read_scp_info ((void *)_read_info,SCCB_SIZE ); + read_info = (ReadInfo *)_read_info; +} + +int sclp_get_cpu_num (void ) +{ +return read_info->entries_cpu; +} + +CPUEntry *sclp_get_cpu_entries (void ) +{ +return (void *)read_info + read_info->offset_cpu; +} +/* Perform service call. Return 0 on success, non-zero otherwise. */ int sclp_service_call (unsigned int command,void *sccb) {
@@ -127,23 +145,22 @@ int sclp_service_call(unsigned int command, void *sccb)void sclp_memory_setup (void ) { -ReadInfo *ri = (void *)_sccb;uint64_t rnmax, rnsize;int cc; -sclp_read_scp_info (ri,SCCB_SIZE ); +assert (read_info);/* calculate the storage increment size */ - rnsize = ri->rnsize; + rnsize = read_info->rnsize;if (!rnsize) { - rnsize = ri->rnsize2; + rnsize = read_info->rnsize2; } storage_increment_size = rnsize <<20 ;/* calculate the maximum memory size */ - rnmax = ri->rnmax; + rnmax = read_info->rnmax;if (!rnmax) { - rnmax = ri->rnmax2; + rnmax = read_info->rnmax2; } max_ram_size = rnmax * storage_increment_size;
lib/s390x/sclp.h +3 -0
@@ -271,6 +271,9 @@ void sclp_wait_busy(void);void sclp_mark_busy (void );void sclp_console_setup (void );void sclp_print (const char *str); +void sclp_read_info (void ); +int sclp_get_cpu_num (void ); +CPUEntry *sclp_get_cpu_entries (void );int sclp_service_call (unsigned int command,void *sccb);void sclp_memory_setup (void );uint64_t get_ram_size (void );
lib/s390x/smp.c +11 -17
@@ -25,7 +25,6 @@#include "smp.h" #include "sclp.h" -static char cpu_info_buffer[PAGE_SIZE] __attribute__((__aligned__(4096)));static struct cpu *cpus;static struct cpu *cpu0;static struct spinlock lock;
@@ -34,8 +33,7 @@ extern void smp_cpu_setup_state(void);int smp_query_num_cpus (void ) { -struct ReadCpuInfo *info = (void *)cpu_info_buffer; -return info->nr_configured; +return sclp_get_cpu_num (); }struct cpu *smp_cpu_from_addr (uint16_t addr)
@@ -228,10 +226,10 @@ void smp_teardown(void) {int i =0 ;uint16_t this_cpu =stap (); -struct ReadCpuInfo *info = (void *)cpu_info_buffer; +int num =smp_query_num_cpus ();spin_lock (&lock); -for (; i < info->nr_configured; i++) { +for (; i < num; i++) {if (cpus[i].active && cpus[i].addr != this_cpu) {sigp_retry (cpus[i].addr,SIGP_STOP ,0 ,NULL );
@@ -245,22 +243,18 @@ extern uint64_t *stackptr;void smp_setup (void ) {int i =0 ; +int num =smp_query_num_cpus ();unsigned short cpu0_addr =stap (); -struct ReadCpuInfo *info = (void *)cpu_info_buffer; +struct CPUEntry *entry =sclp_get_cpu_entries (); -spin_lock (&lock); -sclp_mark_busy (); - info->h.length =PAGE_SIZE ; -sclp_service_call (SCLP_READ_CPU_INFO , cpu_info_buffer); +if (num >1 ) +printf ("SMP: Initializing, found %d cpus\n" , num); -if (smp_query_num_cpus () >1 ) -printf ("SMP: Initializing, found %d cpus\n" , info->nr_configured); - - cpus =calloc (info->nr_configured,sizeof (cpus)); -for (i =0 ; i < info->nr_configured; i++) { - cpus[i].addr = info->entries[i].address; + cpus =calloc (num,sizeof (cpus)); +for (i =0 ; i < num; i++) { + cpus[i].addr = entry[i].address; cpus[i].active = false; -if (info->entries[i].address == cpu0_addr) { +if (entry[i].address == cpu0_addr) { cpu0 = &cpus[i]; cpu0->stack = stackptr; cpu0->lowcore = (void *)0 ;
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v2 2/7] s390x: Consolidate sclp read info
Quoted 139 lines · Janosch Frank
Let's only read the information once and pass a pointer to it instead of calling sclp multiple times.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Cornelia Huck <[email protected]>--- lib/s390x/io.c | 1 + lib/s390x/sclp.c | 29 +++++++++++++++++++++++------ lib/s390x/sclp.h | 3 +++ lib/s390x/smp.c | 28 +++++++++++----------------- 4 files changed, 38 insertions(+), 23 deletions(-)lib/s390x/io.c +1
-0@@ -36,6 +36,7 @@ void setup(void) {setup_args_progname (ipl_args);setup_facilities (); +sclp_read_info ();sclp_console_setup ();sclp_memory_setup ();smp_setup ();lib/s390x/sclp.c +23
-6@@ -25,6 +25,8 @@ extern unsigned long stacktop;static uint64_t storage_increment_size;static uint64_t max_ram_size;static uint64_t ram_size; +char _read_info[PAGE_SIZE] __attribute__((__aligned__(4096))); +static ReadInfo *read_info; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));static volatile bool sclp_busy;@@ -110,6 +112,22 @@ static void sclp_read_scp_info(ReadInfo *ri, int length)report_abort ("READ_SCP_INFO failed" ); } +void sclp_read_info (void ) +{ +sclp_read_scp_info ((void *)_read_info,SCCB_SIZE ); + read_info = (ReadInfo *)_read_info; +} + +int sclp_get_cpu_num (void ) +{ +return read_info->entries_cpu; +} + +CPUEntry *sclp_get_cpu_entries (void ) +{ +return (void *)read_info + read_info->offset_cpu; +} +/* Perform service call. Return 0 on success, non-zero otherwise. */ int sclp_service_call (unsigned int command,void *sccb) {@@ -127,23 +145,22 @@ int sclp_service_call(unsigned int command, void *sccb)void sclp_memory_setup (void ) { -ReadInfo *ri = (void *)_sccb;uint64_t rnmax, rnsize;int cc; -sclp_read_scp_info (ri,SCCB_SIZE ); +assert (read_info);/* calculate the storage increment size */ - rnsize = ri->rnsize; + rnsize = read_info->rnsize;if (!rnsize) { - rnsize = ri->rnsize2; + rnsize = read_info->rnsize2; } storage_increment_size = rnsize <<20 ;/* calculate the maximum memory size */ - rnmax = ri->rnmax; + rnmax = read_info->rnmax;if (!rnmax) { - rnmax = ri->rnmax2; + rnmax = read_info->rnmax2; } max_ram_size = rnmax * storage_increment_size;lib/s390x/sclp.h +3
-0@@ -271,6 +271,9 @@ void sclp_wait_busy(void);void sclp_mark_busy (void );void sclp_console_setup (void );void sclp_print (const char *str); +void sclp_read_info (void ); +int sclp_get_cpu_num (void ); +CPUEntry *sclp_get_cpu_entries (void );int sclp_service_call (unsigned int command,void *sccb);void sclp_memory_setup (void );uint64_t get_ram_size (void );lib/s390x/smp.c +3
-5@@ -25,7 +25,6 @@#include "smp.h" #include "sclp.h" -static char cpu_info_buffer[PAGE_SIZE] __attribute__((__aligned__(4096)));static struct cpu *cpus;static struct cpu *cpu0;static struct spinlock lock;@@ -34,8 +33,7 @@ extern void smp_cpu_setup_state(void);int smp_query_num_cpus (void ) { -struct ReadCpuInfo *info = (void *)cpu_info_buffer; -return info->nr_configured; +return sclp_get_cpu_num (); }struct cpu *smp_cpu_from_addr (uint16_t addr)@@ -228,10 +226,10 @@ void smp_teardown(void) {int i =0 ;uint16_t this_cpu =stap (); -struct ReadCpuInfo *info = (void *)cpu_info_buffer; +int num =smp_query_num_cpus ();spin_lock (&lock); -for (; i < info->nr_configured; i++) { +for (; i < num; i++) {if (cpus[i].active && cpus[i].addr != this_cpu) {sigp_retry (cpus[i].addr,SIGP_STOP ,0 ,NULL );
lib/s390x/smp.c extern uint64_t *stackptr; · line 251
Quoted 9 lines
lib/s390x/smp.c +2
-2@@ -245,22 +243,18 @@ extern uint64_t *stackptr;void smp_setup (void ) {int i =0 ; +int num =smp_query_num_cpus ();unsigned short cpu0_addr =stap (); -struct ReadCpuInfo *info = (void *)cpu_info_buffer; +struct CPUEntry *entry =sclp_get_cpu_entries (); -spin_lock (&lock);
You've removed the spin_lock(), but not the spin_unlock() at the end of the function ... looks wrong to me? I guess you rather should keep the spin_lock() call here?
Quoted 12 lines
lib/s390x/smp.c +2
-8-sclp_mark_busy (); - info->h.length =PAGE_SIZE ; -sclp_service_call (SCLP_READ_CPU_INFO , cpu_info_buffer); +if (num >1 ) +printf ("SMP: Initializing, found %d cpus\n" , num); -if (smp_query_num_cpus () >1 ) -printf ("SMP: Initializing, found %d cpus\n" , info->nr_configured); - - cpus =calloc (info->nr_configured,sizeof (cpus)); -for (i =0 ; i < info->nr_configured; i++) {
lib/s390x/smp.c extern uint64_t *stackptr; · line 260
Quoted 10 lines
lib/s390x/smp.c +4
-2- cpus[i].addr = info->entries[i].address; + cpus =calloc (num,sizeof (cpus)); +for (i =0 ; i < num; i++) { + cpus[i].addr = entry[i].address; cpus[i].active = false; -if (info->entries[i].address == cpu0_addr) { +if (entry[i].address == cpu0_addr) { cpu0 = &cpus[i]; cpu0->stack = stackptr; cpu0->lowcore = (void *)0 ;
Apart from the spin_lock() problem, patch looks fine to me now.
Thomas
Re: [kvm-unit-tests PATCH v2 2/7] s390x: Consolidate sclp read info
In reply to Janosch FrankQuoted 11 lines · Janosch Frank
Let's only read the information once and pass a pointer to it instead of calling sclp multiple times.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Cornelia Huck <[email protected]>--- lib/s390x/io.c | 1 + lib/s390x/sclp.c | 29 +++++++++++++++++++++++------ lib/s390x/sclp.h | 3 +++ lib/s390x/smp.c | 28 +++++++++++----------------- 4 files changed, 38 insertions(+), 23 deletions(-)
...
Quoted 15 lines
lib/s390x/sclp.c +2
-0@@ -25,6 +25,8 @@ extern unsigned long stacktop;static uint64_t storage_increment_size;static uint64_t max_ram_size;static uint64_t ram_size; +char _read_info[PAGE_SIZE] __attribute__((__aligned__(4096))); +static ReadInfo *read_info; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));static volatile bool sclp_busy;@@ -110,6 +112,22 @@ static void sclp_read_scp_info(ReadInfo *ri, int length)report_abort ("READ_SCP_INFO failed" );
lib/s390x/sclp.c static void sclp_read_scp_info(ReadInfo *ri, int length) · line 122
Quoted 10 lines
lib/s390x/sclp.c +8
-0} +void sclp_read_info (void ) +{ +sclp_read_scp_info ((void *)_read_info,SCCB_SIZE ); + read_info = (ReadInfo *)_read_info; +} + +int sclp_get_cpu_num (void ) +{
I forgot to say: Maybe add a
assert(read_info);
here, just in case? (since we can dereference the NULL pointer in the k-u-t)
lib/s390x/sclp.c static void sclp_read_scp_info(ReadInfo *ri, int length) · line 127
Quoted 5 lines
lib/s390x/sclp.c +5
-0+return read_info->entries_cpu; +} + +CPUEntry *sclp_get_cpu_entries (void ) +{
dito.
lib/s390x/sclp.c static void sclp_read_scp_info(ReadInfo *ri, int length) · line 129
Quoted 2 lines
lib/s390x/sclp.c +2
-0+return (void *)read_info + read_info->offset_cpu; +}
Thomas
PATCH v2 3/7 s390x: SCLP feature checking
In reply to Janosch FrankAvailability of SIE is announced via a feature bit in a SCLP info CPU entry. Let's add a framework that allows us to easily check for such facilities.
--- lib/s390x/io.c | 1 + lib/s390x/sclp.c | 19 +++++++++++++++++++ lib/s390x/sclp.h | 13 ++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-)
lib/s390x/io.c +1 -0
@@ -37,6 +37,7 @@ void setup(void)setup_args_progname (ipl_args);setup_facilities ();sclp_read_info (); +sclp_facilities_setup ();sclp_console_setup ();sclp_memory_setup ();smp_setup ();
lib/s390x/sclp.c +19 -0
@@ -11,6 +11,7 @@*/ #include <libcflat.h> +#include <bitops.h> #include <asm/page.h> #include <asm/arch_def.h> #include <asm/interrupt.h>
@@ -27,6 +28,7 @@ static uint64_t max_ram_size;static uint64_t ram_size; char _read_info[PAGE_SIZE] __attribute__((__aligned__(4096)));static ReadInfo *read_info; +struct sclp_facilities sclp_facilities; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));static volatile bool sclp_busy;
@@ -128,6 +130,23 @@ CPUEntry *sclp_get_cpu_entries(void)return (void *)read_info + read_info->offset_cpu; } +void sclp_facilities_setup (void ) +{ +unsigned short cpu0_addr =stap (); +CPUEntry *cpu; +int i; + +assert (read_info); + + cpu = (void *)read_info + read_info->offset_cpu; +for (i =0 ; i < read_info->entries_cpu; i++, cpu++) { +if (cpu->address == cpu0_addr) { + sclp_facilities.has_sief2 = cpu->feat_sief2; +break ; + } + } +} +/* Perform service call. Return 0 on success, non-zero otherwise. */ int sclp_service_call (unsigned int command,void *sccb) {
lib/s390x/sclp.h +12 -1
@@ -95,12 +95,22 @@ typedef struct SCCBHeader {typedef struct CPUEntry {uint8_t address;uint8_t reserved0; -uint8_t features[SCCB_CPU_FEATURE_LEN ]; + uint8_t : 4; +uint8_t feat_sief2 :1 ; + uint8_t : 3; +uint8_t features_res2 [SCCB_CPU_FEATURE_LEN -1 ];uint8_t reserved2[6 ];uint8_t type;uint8_t reserved1; } __attribute__((packed))CPUEntry ; +extern struct sclp_facilities sclp_facilities; + +struct sclp_facilities { +uint64_t has_sief2 :1 ; + uint64_t : 63; +}; + typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax;
@@ -274,6 +284,7 @@ void sclp_print(const char *str);void sclp_read_info (void );int sclp_get_cpu_num (void );CPUEntry *sclp_get_cpu_entries (void ); +void sclp_facilities_setup (void );int sclp_service_call (unsigned int command,void *sccb);void sclp_memory_setup (void );uint64_t get_ram_size (void );
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v2 3/7] s390x: SCLP feature checking
Quoted 97 lines · Janosch Frank
Availability of SIE is announced via a feature bit in a SCLP info CPU entry. Let's add a framework that allows us to easily check for such facilities.
Signed-off-by Janosch Frank <[email protected]>--- lib/s390x/io.c | 1 + lib/s390x/sclp.c | 19 +++++++++++++++++++ lib/s390x/sclp.h | 13 ++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-)lib/s390x/io.c +1
-0@@ -37,6 +37,7 @@ void setup(void)setup_args_progname (ipl_args);setup_facilities ();sclp_read_info (); +sclp_facilities_setup ();sclp_console_setup ();sclp_memory_setup ();smp_setup ();lib/s390x/sclp.c +19
-0@@ -11,6 +11,7 @@*/ #include <libcflat.h> +#include <bitops.h> #include <asm/page.h> #include <asm/arch_def.h> #include <asm/interrupt.h> @@ -27,6 +28,7 @@ static uint64_t max_ram_size;static uint64_t ram_size; char _read_info[PAGE_SIZE] __attribute__((__aligned__(4096)));static ReadInfo *read_info; +struct sclp_facilities sclp_facilities; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));static volatile bool sclp_busy;@@ -128,6 +130,23 @@ CPUEntry *sclp_get_cpu_entries(void)return (void *)read_info + read_info->offset_cpu; } +void sclp_facilities_setup (void ) +{ +unsigned short cpu0_addr =stap (); +CPUEntry *cpu; +int i; + +assert (read_info); + + cpu = (void *)read_info + read_info->offset_cpu; +for (i =0 ; i < read_info->entries_cpu; i++, cpu++) { +if (cpu->address == cpu0_addr) { + sclp_facilities.has_sief2 = cpu->feat_sief2; +break ; + } + } +} +/* Perform service call. Return 0 on success, non-zero otherwise. */ int sclp_service_call (unsigned int command,void *sccb) {lib/s390x/sclp.h +11
-1@@ -95,12 +95,22 @@ typedef struct SCCBHeader {typedef struct CPUEntry {uint8_t address;uint8_t reserved0; -uint8_t features[SCCB_CPU_FEATURE_LEN ]; + uint8_t : 4; +uint8_t feat_sief2 :1 ; + uint8_t : 3; +uint8_t features_res2 [SCCB_CPU_FEATURE_LEN -1 ];uint8_t reserved2[6 ];uint8_t type;uint8_t reserved1; } __attribute__((packed))CPUEntry ; +extern struct sclp_facilities sclp_facilities; + +struct sclp_facilities { +uint64_t has_sief2 :1 ; + uint64_t : 63; +}; + typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax;
lib/s390x/sclp.h void sclp_print(const char *str); · line 290
Quoted 7 lines
lib/s390x/sclp.h +1
-0@@ -274,6 +284,7 @@ void sclp_print(const char *str);void sclp_read_info (void );int sclp_get_cpu_num (void );CPUEntry *sclp_get_cpu_entries (void ); +void sclp_facilities_setup (void );int sclp_service_call (unsigned int command,void *sccb);void sclp_memory_setup (void );uint64_t get_ram_size (void );
Re: [kvm-unit-tests PATCH v2 3/7] s390x: SCLP feature checking
In reply to Janosch FrankQuoted 10 lines · On Fri, 27 Nov 2020 08:06:25 -0500 Janosch Frank <[email protected]> wrote:
Availability of SIE is announced via a feature bit in a SCLP info CPU entry. Let's add a framework that allows us to easily check for such facilities.
Signed-off-by Janosch Frank <[email protected]>--- lib/s390x/io.c | 1 + lib/s390x/sclp.c | 19 +++++++++++++++++++ lib/s390x/sclp.h | 13 ++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-)
PATCH v2 4/7 s390x: sie: Add SIE to lib
In reply to Janosch FrankThis commit adds the definition of the SIE control block struct and the assembly to execute SIE and save/restore guest registers.
--- lib/s390x/asm-offsets.c | 13 +++ lib/s390x/asm/arch_def.h | 7 ++ lib/s390x/interrupt.c | 7 ++ lib/s390x/sie.h | 197 +++++++++++++++++++++++++++++++++++++++ s390x/cstart64.S | 56 +++++++++++ 5 files changed, 280 insertions(+) create mode 100644 lib/s390x/sie.h
lib/s390x/asm-offsets.c +13 -0
@@ -10,6 +10,7 @@#include <libcflat.h> #include <kbuild.h> #include <asm/arch_def.h> +#include <sie.h> int main (void ) {
@@ -71,6 +72,18 @@ int main(void)OFFSET (GEN_LC_ARS_SA , lowcore, ars_sa);OFFSET (GEN_LC_CRS_SA , lowcore, crs_sa);OFFSET (GEN_LC_PGM_INT_TDB , lowcore, pgm_int_tdb); +OFFSET (__SF_GPRS, stack_frame, gprs); +OFFSET (__SF_SIE_CONTROL, stack_frame, empty1[0 ]); +OFFSET (__SF_SIE_SAVEAREA, stack_frame, empty1[1 ]); +OFFSET (__SF_SIE_REASON, stack_frame, empty1[2 ]); +OFFSET (__SF_SIE_FLAGS, stack_frame, empty1[3 ]); +OFFSET (SIE_SAVEAREA_HOST_GRS , vm_save_area, host.grs[0 ]); +OFFSET (SIE_SAVEAREA_HOST_FPRS , vm_save_area, host.fprs[0 ]); +OFFSET (SIE_SAVEAREA_HOST_FPC , vm_save_area, host.fpc); +OFFSET (SIE_SAVEAREA_GUEST_GRS , vm_save_area, guest.grs[0 ]); +OFFSET (SIE_SAVEAREA_GUEST_FPRS , vm_save_area, guest.fprs[0 ]); +OFFSET (SIE_SAVEAREA_GUEST_FPC , vm_save_area, guest.fpc); +return 0 ; }
lib/s390x/asm/arch_def.h +7 -0
@@ -10,6 +10,13 @@ #ifndef _ASM_S390X_ARCH_DEF_H_ #define _ASM_S390X_ARCH_DEF_H_ +struct stack_frame { + unsigned long back_chain; + unsigned long empty1[5]; + unsigned long gprs[10]; + unsigned int empty2[8]; +}; + struct psw { uint64_t mask; uint64_t addr;
lib/s390x/interrupt.c +7 -0
@@ -13,6 +13,7 @@#include <asm/barrier.h> #include <sclp.h> #include <interrupt.h> +#include <sie.h> static bool pgm_int_expected;static bool ext_int_expected;
@@ -59,6 +60,12 @@ void register_pgm_cleanup_func(void (*f)(void))static void fixup_pgm_int (void ) { +/* If we have an error on SIE we directly move to sie_exit */ +if (lc->pgm_old_psw.addr >= (uint64_t )&sie_entry && + lc->pgm_old_psw.addr <= (uint64_t )&sie_entry +10 ) { + lc->pgm_old_psw.addr = (uint64_t )&sie_exit; + } +switch (lc->pgm_int_code) {case PGM_INT_CODE_PRIVILEGED_OPERATION :/* Normal operation is in supervisor state, so this exception
lib/s390x/sie.h new file +197 -0
197 lines not on this page · raw message
s390x/cstart64.S +56 -0
62 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 5/7 s390x: sie: Add first SIE test
In reply to Janosch FrankLet's check if we get the correct interception data on a few diags. This commit is more of an addition of boilerplate code than a real test.
--- s390x/Makefile | 1 + s390x/sie.c | 125 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 129 insertions(+) create mode 100644 s390x/sie.c
s390x/Makefile +1 -0
@@ -19,6 +19,7 @@ tests += $(TEST_DIR)/smp.elf tests += $(TEST_DIR)/sclp.elf tests += $(TEST_DIR)/css.elf tests += $(TEST_DIR)/uv-guest.elf +tests += $(TEST_DIR)/sie.elf tests_binary = $(patsubst %.elf,%.bin,$(tests)) ifneq ($(HOST_KEY_DOCUMENT),)
s390x/sie.c new file +125 -0
125 lines not on this page · raw message
s390x/unittests.cfg +3 -0
@@ -96,3 +96,6 @@ smp = 2 [uv-guest] file = uv-guest.elf + +[sie] +file = sie.elf
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v2 5/7] s390x: sie: Add first SIE test
Quoted 47 lines · Janosch Frank
Let's check if we get the correct interception data on a few diags. This commit is more of an addition of boilerplate code than a real test.
Signed-off-by Janosch Frank <[email protected]>--- s390x/Makefile | 1 + s390x/sie.c | 125 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 129 insertions(+) create mode 100644 s390x/sie.cs390x/Makefile +1
-0@@ -19,6 +19,7 @@ tests += $(TEST_DIR)/smp.elf tests += $(TEST_DIR)/sclp.elf tests += $(TEST_DIR)/css.elf tests += $(TEST_DIR)/uv-guest.elf +tests += $(TEST_DIR)/sie.elf tests_binary = $(patsubst %.elf,%.bin,$(tests)) ifneq ($(HOST_KEY_DOCUMENT),)s390x/sie.c new file +17
-0@@ -0,0 +1,125 @@ +#include <libcflat.h> +#include <asm/asm-offsets.h> +#include <asm/arch_def.h> +#include <asm/interrupt.h> +#include <asm/page.h> +#include <alloc_page.h> +#include <vmalloc.h> +#include <asm/facility.h> +#include <mmu.h> +#include <sclp.h> +#include <sie.h> + +static u8 *guest; +static u8 *guest_instr; +static struct vm vm; + +static void handle_validity (struct vm *vm)
s390x/sie.c line 27
Quoted 10 lines
s390x/sie.c new file +10
-0+{ +report (0 ,"VALIDITY: %x" , vm->sblk->ipb >>16 ); +} + +static void sie (struct vm *vm) +{ +while (vm->sblk->icptcode ==0 ) { +sie64a (vm->sblk, &vm->save_area); +if (vm->sblk->icptcode ==32 ) +handle_validity (vm);
Indent with TABs, not spaces, please.
Quoted 44 lines
s390x/sie.c new file +44
-0+ } + vm->save_area.guest.grs[14 ] = vm->sblk->gg14; + vm->save_area.guest.grs[15 ] = vm->sblk->gg15; +} + +static void sblk_cleanup (struct vm *vm) +{ + vm->sblk->icptcode =0 ; +} + +static void intercept_diag_10 (void ) +{ +u32 instr =0x83020010 ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); +report (vm.sblk->icptcode ==4 && vm.sblk->ipa ==0x8302 && vm.sblk->ipb ==0x100000 , +"Diag 10 intercept" ); +sblk_cleanup (&vm); +} + +static void intercept_diag_44 (void ) +{ +u32 instr =0x83020044 ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); +report (vm.sblk->icptcode ==4 && vm.sblk->ipa ==0x8302 && vm.sblk->ipb ==0x440000 , +"Diag 44 intercept" ); +sblk_cleanup (&vm); +} + +static void intercept_diag_9c (void ) +{ +u32 instr =0x8302009c ; +
s390x/sie.c line 81
Quoted 10 lines
s390x/sie.c new file +10
-0+ vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); +report (vm.sblk->icptcode ==4 && vm.sblk->ipa ==0x8302 && vm.sblk->ipb ==0x9c0000 , +"Diag 9c intercept" ); +sblk_cleanup (&vm); +}
All three functions are pretty much the same code, except for the diag number. I think you could use a unified function for this and then just call it three times with the wanted diagnose code? Or do you plan to extend these functions later in different ways?
Thomas
Re: [kvm-unit-tests PATCH v2 5/7] s390x: sie: Add first SIE test
In reply to Janosch FrankQuoted 12 lines · On Fri, 27 Nov 2020 08:06:27 -0500 Janosch Frank <[email protected]> wrote:
Let's check if we get the correct interception data on a few diags. This commit is more of an addition of boilerplate code than a real test.
Signed-off-by Janosch Frank <[email protected]>--- s390x/Makefile | 1 + s390x/sie.c | 125 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 129 insertions(+) create mode 100644 s390x/sie.c
(...)
s390x/sie.c line 26
Quoted 5 lines
s390x/sie.c new file +5
-0+static void sie (struct vm *vm) +{ +while (vm->sblk->icptcode ==0 ) { +sie64a (vm->sblk, &vm->save_area); +if (vm->sblk->icptcode ==32 )
Can you maybe add #defines for the intercept codes you're checking for?
Quoted 12 lines
s390x/sie.c new file +12
-0+handle_validity (vm); + } + vm->save_area.guest.grs[14 ] = vm->sblk->gg14; + vm->save_area.guest.grs[15 ] = vm->sblk->gg15; +} + +static void sblk_cleanup (struct vm *vm) +{ + vm->sblk->icptcode =0 ; +} + +static void intercept_diag_10 (void )
s390x/sie.c line 48
Quoted 10 lines
s390x/sie.c new file +10
-0+{ +u32 instr =0x83020010 ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); + report(vm.sblk->icptcode == 4 && vm.sblk->ipa == 0x8302 && vm.sblk->ipb == 0x100000,
Again, some #defines might help here, making clear that 0x8302 means diag. (The ipb value is clear enough :) Maybe you can also assemble instr out of pre-made pieces? Or factor out some code to a common function?
Quoted 33 lines
s390x/sie.c new file +33
-0+ "Diag 10 intercept"); +sblk_cleanup (&vm); +} + +static void intercept_diag_44 (void ) +{ +u32 instr =0x83020044 ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); +report (vm.sblk->icptcode ==4 && vm.sblk->ipa ==0x8302 && vm.sblk->ipb ==0x440000 , +"Diag 44 intercept" ); +sblk_cleanup (&vm); +} + +static void intercept_diag_9c (void ) +{ +u32 instr =0x8302009c ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); +report (vm.sblk->icptcode ==4 && vm.sblk->ipa ==0x8302 && vm.sblk->ipb ==0x9c0000 , +"Diag 9c intercept" ); +sblk_cleanup (&vm); +}
(...)
Re: [kvm-unit-tests PATCH v2 5/7] s390x: sie: Add first SIE test
Quoted 18 lines · Cornelia Huck
Quoted 12 lines · On Fri, 27 Nov 2020 08:06:27 -0500 Janosch Frank <[email protected]> wrote:
Let's check if we get the correct interception data on a few diags. This commit is more of an addition of boilerplate code than a real test.
Signed-off-by Janosch Frank <[email protected]>--- s390x/Makefile | 1 + s390x/sie.c | 125 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 129 insertions(+) create mode 100644 s390x/sie.c(...)
Quoted 7 lines
s390x/sie.c line 26
Quoted 5 lines
s390x/sie.c new file +5
-0+static void sie (struct vm *vm) +{ +while (vm->sblk->icptcode ==0 ) { +sie64a (vm->sblk, &vm->save_area); +if (vm->sblk->icptcode ==32 )Can you maybe add #defines for the intercept codes you're checking for?
Sure ICTP_VALIDITY and ICPT_INSTRUCTION would make sense.
Quoted 20 lines
Quoted 20 lines
s390x/sie.c new file +19
-0+handle_validity (vm); + } + vm->save_area.guest.grs[14 ] = vm->sblk->gg14; + vm->save_area.guest.grs[15 ] = vm->sblk->gg15; +} + +static void sblk_cleanup (struct vm *vm) +{ + vm->sblk->icptcode =0 ; +} + +static void intercept_diag_10 (void ) +{ +u32 instr =0x83020010 ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE );
Quoted 8 lines
s390x/sie.c line 48
Quoted 3 lines
s390x/sie.c new file +3
-0+memcpy (guest_instr, &instr,4 ); +sie (&vm); + report(vm.sblk->icptcode == 4 && vm.sblk->ipa == 0x8302 && vm.sblk->ipb == 0x100000,Again, some #defines might help here, making clear that
0x8302means diag. (The ipb value is clear enough :) Maybe you can also assemble instr out of pre-made pieces? Or factor out some code to a common function?
Yes, a diag test function that has the code as a parameter would make this look nicer and I could also test ipa against the first 16bits of instr.
Quoted 37 lines
Quoted 34 lines
s390x/sie.c new file +33
-0+ "Diag 10 intercept"); +sblk_cleanup (&vm); +} + +static void intercept_diag_44 (void ) +{ +u32 instr =0x83020044 ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); +report (vm.sblk->icptcode ==4 && vm.sblk->ipa ==0x8302 && vm.sblk->ipb ==0x440000 , +"Diag 44 intercept" ); +sblk_cleanup (&vm); +} + +static void intercept_diag_9c (void ) +{ +u32 instr =0x8302009c ; + + vm.sblk->gpsw.addr =PAGE_SIZE *2 ; + vm.sblk->gpsw.mask =0x0000000180000000ULL ; + +memset (guest_instr,0 ,PAGE_SIZE ); +memcpy (guest_instr, &instr,4 ); +sie (&vm); +report (vm.sblk->icptcode ==4 && vm.sblk->ipa ==0x8302 && vm.sblk->ipb ==0x9c0000 , +"Diag 9c intercept" ); +sblk_cleanup (&vm); +}(...)
PATCH v2 6/7 s390x: Add diag318 intercept test
In reply to Janosch FrankNot much to test except for the privilege and specification exceptions.
--- lib/s390x/sclp.c | 2 ++ lib/s390x/sclp.h | 6 +++++- s390x/intercept.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-)
lib/s390x/sclp.c +2 -0
@@ -138,6 +138,8 @@ void sclp_facilities_setup(void)assert (read_info); + sclp_facilities.has_diag318 = read_info->byte_134_diag318; + cpu = (void *)read_info + read_info->offset_cpu;for (i =0 ; i < read_info->entries_cpu; i++, cpu++) {if (cpu->address == cpu0_addr) {
lib/s390x/sclp.h +5 -1
@@ -108,7 +108,8 @@ extern struct sclp_facilities sclp_facilities;struct sclp_facilities {uint64_t has_sief2 :1 ; - uint64_t : 63; +uint64_t has_diag318 :1 ; + uint64_t : 62; }; typedef struct ReadInfo {
@@ -133,6 +134,9 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t reserved7[134 -128 ]; + uint8_t byte_134_diag318 : 1; + uint8_t : 7;struct CPUEntry entries[0 ]; } __attribute__((packed)) ReadInfo;
s390x/intercept.c +19 -0
@@ -10,6 +10,7 @@* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> +#include <sclp.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> #include <asm/page.h>
@@ -154,6 +155,23 @@ static void test_testblock(void)check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); } +static void test_diag318 (void ) +{ +expect_pgm_int (); +enter_pstate (); + asmvolatile ("diag %0,0,0x318\n" : :"d" (0x42 )); +check_pgm_int_code (PGM_INT_CODE_PRIVILEGED_OPERATION ); + +if (!sclp_facilities.has_diag318) +expect_pgm_int (); + + asmvolatile ("diag %0,0,0x318\n" : :"d" (0x42 )); + +if (!sclp_facilities.has_diag318) +check_pgm_int_code (PGM_INT_CODE_SPECIFICATION ); + +} +struct {const char *name;void (*func)(void );
@@ -164,6 +182,7 @@ struct { { "stap", test_stap, false }, { "stidp", test_stidp, false }, { "testblock", test_testblock, false }, + { "diag318", test_diag318, false }, { NULL, NULL, false } };
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v2 6/7] s390x: Add diag318 intercept test
Quoted 68 lines · Janosch Frank
Not much to test except for the privilege and specification exceptions.
Signed-off-by Janosch Frank <[email protected]>--- lib/s390x/sclp.c | 2 ++ lib/s390x/sclp.h | 6 +++++- s390x/intercept.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-)lib/s390x/sclp.c +2
-0@@ -138,6 +138,8 @@ void sclp_facilities_setup(void)assert (read_info); + sclp_facilities.has_diag318 = read_info->byte_134_diag318; + cpu = (void *)read_info + read_info->offset_cpu;for (i =0 ; i < read_info->entries_cpu; i++, cpu++) {if (cpu->address == cpu0_addr) {lib/s390x/sclp.h +5
-1@@ -108,7 +108,8 @@ extern struct sclp_facilities sclp_facilities;struct sclp_facilities {uint64_t has_sief2 :1 ; - uint64_t : 63; +uint64_t has_diag318 :1 ; + uint64_t : 62; }; typedef struct ReadInfo {@@ -133,6 +134,9 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t reserved7[134 -128 ]; + uint8_t byte_134_diag318 : 1; + uint8_t : 7;struct CPUEntry entries[0 ]; } __attribute__((packed)) ReadInfo;s390x/intercept.c +6
-0@@ -10,6 +10,7 @@* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> +#include <sclp.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> #include <asm/page.h> @@ -154,6 +155,23 @@ static void test_testblock(void)check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); } +static void test_diag318 (void ) +{ +expect_pgm_int (); +enter_pstate (); + asmvolatile ("diag %0,0,0x318\n" : :"d" (0x42 ));
s390x/intercept.c static void test_testblock(void) · line 172
Quoted 10 lines
s390x/intercept.c +10
-0+check_pgm_int_code (PGM_INT_CODE_PRIVILEGED_OPERATION ); + +if (!sclp_facilities.has_diag318) +expect_pgm_int (); + + asmvolatile ("diag %0,0,0x318\n" : :"d" (0x42 )); + +if (!sclp_facilities.has_diag318) +check_pgm_int_code (PGM_INT_CODE_SPECIFICATION ); +
Maybe remove the empty line above.
Quoted 7 lines
s390x/intercept.c +2
-0+} +struct {const char *name;void (*func)(void );
s390x/intercept.c struct { · line 188
Quoted 7 lines
s390x/intercept.c +1
-0@@ -164,6 +182,7 @@ struct { { "stap", test_stap, false }, { "stidp", test_stidp, false }, { "testblock", test_testblock, false }, + { "diag318", test_diag318, false }, { NULL, NULL, false } };
Re: [kvm-unit-tests PATCH v2 6/7] s390x: Add diag318 intercept test
Quoted 73 lines · Thomas Huth
Quoted 72 lines · Janosch Frank
Not much to test except for the privilege and specification exceptions.
Signed-off-by Janosch Frank <[email protected]>--- lib/s390x/sclp.c | 2 ++ lib/s390x/sclp.h | 6 +++++- s390x/intercept.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-)lib/s390x/sclp.c +2
-0@@ -138,6 +138,8 @@ void sclp_facilities_setup(void)assert (read_info); + sclp_facilities.has_diag318 = read_info->byte_134_diag318; + cpu = (void *)read_info + read_info->offset_cpu;for (i =0 ; i < read_info->entries_cpu; i++, cpu++) {if (cpu->address == cpu0_addr) {lib/s390x/sclp.h +5
-1@@ -108,7 +108,8 @@ extern struct sclp_facilities sclp_facilities;struct sclp_facilities {uint64_t has_sief2 :1 ; - uint64_t : 63; +uint64_t has_diag318 :1 ; + uint64_t : 62; }; typedef struct ReadInfo {@@ -133,6 +134,9 @@ typedef struct ReadInfo {uint16_t highest_cpu;uint8_t _reserved5[124 -122 ];/* 122-123 */ uint32_t hmfai; +uint8_t reserved7[134 -128 ]; + uint8_t byte_134_diag318 : 1; + uint8_t : 7;struct CPUEntry entries[0 ]; } __attribute__((packed)) ReadInfo;s390x/intercept.c +10
-0@@ -10,6 +10,7 @@* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> +#include <sclp.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> #include <asm/page.h> @@ -154,6 +155,23 @@ static void test_testblock(void)check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); } +static void test_diag318 (void ) +{ +expect_pgm_int (); +enter_pstate (); + asmvolatile ("diag %0,0,0x318\n" : :"d" (0x42 )); +check_pgm_int_code (PGM_INT_CODE_PRIVILEGED_OPERATION ); + +if (!sclp_facilities.has_diag318) +expect_pgm_int ();
Quoted 8 lines
s390x/intercept.c static void test_testblock(void) · line 172
Quoted 6 lines
s390x/intercept.c +6
-0+ + asmvolatile ("diag %0,0,0x318\n" : :"d" (0x42 )); + +if (!sclp_facilities.has_diag318) +check_pgm_int_code (PGM_INT_CODE_SPECIFICATION ); +Maybe remove the empty line above.
Sure
Quoted 17 lines
Quoted 8 lines
s390x/intercept.c +2
-0+} +struct {const char *name;void (*func)(void );s390x/intercept.c struct { · line 188
Quoted 7 lines
s390x/intercept.c +1
-0@@ -164,6 +182,7 @@ struct { { "stap", test_stap, false }, { "stidp", test_stidp, false }, { "testblock", test_testblock, false }, + { "diag318", test_diag318, false }, { NULL, NULL, false } };Reviewed-by Thomas Huth <[email protected]>
Thanks!
Quoted 1 line
Re: [kvm-unit-tests PATCH v2 6/7] s390x: Add diag318 intercept test
In reply to Janosch FrankQuoted 10 lines · On Fri, 27 Nov 2020 08:06:28 -0500 Janosch Frank <[email protected]> wrote:
Not much to test except for the privilege and specification exceptions.
Signed-off-by Janosch Frank <[email protected]>--- lib/s390x/sclp.c | 2 ++ lib/s390x/sclp.h | 6 +++++- s390x/intercept.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-)
PATCH v2 7/7 s390x: Fix sclp.h style issues
In reply to Janosch FrankFix indentation
--- lib/s390x/sclp.h | 172 +++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 86 deletions(-)
lib/s390x/sclp.h +86 -86
@@ -82,10 +82,10 @@#define SCCB_SIZE 4096typedef struct SCCBHeader { -uint16_t length; -uint8_t function_code; -uint8_t control_mask[3 ]; -uint16_t response_code; +uint16_t length; +uint8_t function_code; +uint8_t control_mask[3 ]; +uint16_t response_code; } __attribute__((packed))SCCBHeader ;#define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader))
@@ -93,15 +93,15 @@ typedef struct SCCBHeader {/* CPU information */ typedef struct CPUEntry { -uint8_t address; -uint8_t reserved0; - uint8_t : 4; -uint8_t feat_sief2 :1 ; - uint8_t : 3; -uint8_t features_res2 [SCCB_CPU_FEATURE_LEN -1 ]; -uint8_t reserved2[6 ]; -uint8_t type; -uint8_t reserved1; +uint8_t address; +uint8_t reserved0; + uint8_t : 4; +uint8_t feat_sief2 :1 ; + uint8_t : 3; +uint8_t features_res2 [SCCB_CPU_FEATURE_LEN -1 ]; +uint8_t reserved2[6 ]; +uint8_t type; +uint8_t reserved1; } __attribute__((packed))CPUEntry ;extern struct sclp_facilities sclp_facilities;
@@ -113,77 +113,77 @@ struct sclp_facilities { };typedef struct ReadInfo { -SCCBHeader h; -uint16_t rnmax; -uint8_t rnsize; -uint8_t _reserved1[16 -11 ];/* 11-15 */ -uint16_t entries_cpu;/* 16-17 */ -uint16_t offset_cpu;/* 18-19 */ -uint8_t _reserved2[24 -20 ];/* 20-23 */ -uint8_t loadparm[8 ];/* 24-31 */ -uint8_t _reserved3[48 -32 ];/* 32-47 */ -uint64_t facilities;/* 48-55 */ -uint8_t _reserved0[76 -56 ];/* 56-75 */ -uint32_t ibc_val; -uint8_t conf_char[99 -80 ];/* 80-98 */ -uint8_t mha_pow; -uint32_t rnsize2; -uint64_t rnmax2; -uint8_t _reserved6[116 -112 ];/* 112-115 */ -uint8_t conf_char_ext[120 -116 ];/* 116-119 */ -uint16_t highest_cpu; -uint8_t _reserved5[124 -122 ];/* 122-123 */ -uint32_t hmfai; -uint8_t reserved7[134 -128 ]; -uint8_t byte_134_diag318 :1 ; - uint8_t : 7; -struct CPUEntry entries[0 ]; +SCCBHeader h; +uint16_t rnmax; +uint8_t rnsize; +uint8_t _reserved1[16 -11 ];/* 11-15 */ +uint16_t entries_cpu;/* 16-17 */ +uint16_t offset_cpu;/* 18-19 */ +uint8_t _reserved2[24 -20 ];/* 20-23 */ +uint8_t loadparm[8 ];/* 24-31 */ +uint8_t _reserved3[48 -32 ];/* 32-47 */ +uint64_t facilities;/* 48-55 */ +uint8_t _reserved0[76 -56 ];/* 56-75 */ +uint32_t ibc_val; +uint8_t conf_char[99 -80 ];/* 80-98 */ +uint8_t mha_pow; +uint32_t rnsize2; +uint64_t rnmax2; +uint8_t _reserved6[116 -112 ];/* 112-115 */ +uint8_t conf_char_ext[120 -116 ];/* 116-119 */ +uint16_t highest_cpu; +uint8_t _reserved5[124 -122 ];/* 122-123 */ +uint32_t hmfai; +uint8_t reserved7[134 -128 ]; +uint8_t byte_134_diag318 :1 ; + uint8_t : 7; +struct CPUEntry entries[0 ]; } __attribute__((packed))ReadInfo ;typedef struct ReadCpuInfo { -SCCBHeader h; -uint16_t nr_configured;/* 8-9 */ -uint16_t offset_configured;/* 10-11 */ -uint16_t nr_standby;/* 12-13 */ -uint16_t offset_standby;/* 14-15 */ -uint8_t reserved0[24 -16 ];/* 16-23 */ -struct CPUEntry entries[0 ]; +SCCBHeader h; +uint16_t nr_configured;/* 8-9 */ +uint16_t offset_configured;/* 10-11 */ +uint16_t nr_standby;/* 12-13 */ +uint16_t offset_standby;/* 14-15 */ +uint8_t reserved0[24 -16 ];/* 16-23 */ +struct CPUEntry entries[0 ]; } __attribute__((packed))ReadCpuInfo ;typedef struct ReadStorageElementInfo { -SCCBHeader h; -uint16_t max_id; -uint16_t assigned; -uint16_t standby; -uint8_t _reserved0[16 -14 ];/* 14-15 */ -uint32_t entries[0 ]; +SCCBHeader h; +uint16_t max_id; +uint16_t assigned; +uint16_t standby; +uint8_t _reserved0[16 -14 ];/* 14-15 */ +uint32_t entries[0 ]; } __attribute__((packed))ReadStorageElementInfo ;typedef struct AttachStorageElement { -SCCBHeader h; -uint8_t _reserved0[10 -8 ];/* 8-9 */ -uint16_t assigned; -uint8_t _reserved1[16 -12 ];/* 12-15 */ -uint32_t entries[0 ]; +SCCBHeader h; +uint8_t _reserved0[10 -8 ];/* 8-9 */ +uint16_t assigned; +uint8_t _reserved1[16 -12 ];/* 12-15 */ +uint32_t entries[0 ]; } __attribute__((packed))AttachStorageElement ;typedef struct AssignStorage { -SCCBHeader h; -uint16_t rn; +SCCBHeader h; +uint16_t rn; } __attribute__((packed))AssignStorage ;typedef struct IoaCfgSccb { -SCCBHeader header; -uint8_t atype; -uint8_t reserved1; -uint16_t reserved2; -uint32_t aid; +SCCBHeader header; +uint8_t atype; +uint8_t reserved1; +uint16_t reserved2; +uint32_t aid; } __attribute__((packed))IoaCfgSccb ;typedef struct SCCB { -SCCBHeader h; -char data[SCCB_DATA_LEN ]; - } __attribute__((packed))SCCB ; +SCCBHeader h; +char data[SCCB_DATA_LEN ]; +} __attribute__((packed))SCCB ;/* SCLP event types */ #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a
@@ -198,13 +198,13 @@ typedef struct SCCB {#define SCLP_SELECTIVE_READ 0x01typedef struct WriteEventMask { -SCCBHeader h; -uint16_t _reserved; -uint16_t mask_length; -uint32_t cp_receive_mask; -uint32_t cp_send_mask; -uint32_t send_mask; -uint32_t receive_mask; +SCCBHeader h; +uint16_t _reserved; +uint16_t mask_length; +uint32_t cp_receive_mask; +uint32_t cp_send_mask; +uint32_t send_mask; +uint32_t receive_mask; } __attribute__((packed))WriteEventMask ;#define MDBTYP_GO 0x0001
@@ -257,25 +257,25 @@ struct mdb { } __attribute__((packed));typedef struct EventBufferHeader { -uint16_t length; -uint8_t type; -uint8_t flags; -uint16_t _reserved; +uint16_t length; +uint8_t type; +uint8_t flags; +uint16_t _reserved; } __attribute__((packed))EventBufferHeader ;typedef struct WriteEventData { -SCCBHeader h; -EventBufferHeader ebh; -union { -char data[0 ]; -struct mdb mdb; - } msg; +SCCBHeader h; +EventBufferHeader ebh; +union { +char data[0 ]; +struct mdb mdb; + } msg; } __attribute__((packed))WriteEventData ;typedef struct ReadEventData { -SCCBHeader h; -EventBufferHeader ebh; -uint32_t mask; +SCCBHeader h; +EventBufferHeader ebh; +uint32_t mask; } __attribute__((packed))ReadEventData ;extern char _sccb[];
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH v2 7/7] s390x: Fix sclp.h style issues
Quoted 6 lines · Janosch Frank
Fix indentation
Signed-off-by Janosch Frank <[email protected]>--- lib/s390x/sclp.h | 172 +++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 86 deletions(-)
Re: [kvm-unit-tests PATCH v2 7/7] s390x: Fix sclp.h style issues
In reply to Janosch FrankQuoted 6 lines · On Fri, 27 Nov 2020 08:06:29 -0500 Janosch Frank <[email protected]> wrote:
Fix indentation
Signed-off-by Janosch Frank <[email protected]>--- lib/s390x/sclp.h | 172 +++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 86 deletions(-)