s390x update
Dear Paolo,
please pull the following changes or merge them on gitlab:
* Moved to SPDX license identifiers and cleaning up licenses
* Added test_bit(_inv)() & SCLP feature bit checking
* Added first SIE lib and test for nesting tests
* Added diag318 emulation test
* Small UV fix
Gitlab merge request:
https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/4
The following changes since commit 4a54e8a3a88be171814e31dd6ab9b7a766644e32:
lib/alloc_page: Properly handle requests for fresh blocks (2021-01-19 13:18:54 -0500)
are available in the Git repository at:
https://gitlab.com/frankja/kvm-unit-tests.git tags/s390x-2021-20-01
for you to fetch changes up to 88fb0e5d52be357d3aab854c5c16303fe1608335:
s390x: Fix uv_call() exception behavior (2021-01-20 04:15:21 -0500)
Janosch Frank (11):
s390x: Move to GPL 2 and SPDX license identifiers
s390x: lib: Move to GPL 2 and SPDX license identifiers
s390x: Add test_bit to library
s390x: Consolidate sclp read info
s390x: SCLP feature checking
s390x: Split assembly into multiple files
s390x: sie: Add SIE to lib
s390x: sie: Add first SIE test
s390x: Add diag318 intercept test
s390x: Fix sclp.h style issues
s390x: Fix uv_call() exception behavior
lib/s390x/asm-offsets.c | 15 ++- lib/s390x/asm/arch_def.h | 13 ++- lib/s390x/asm/asm-offsets.h | 4 +- lib/s390x/asm/barrier.h | 4 +- lib/s390x/asm/bitops.h | 26 +++++ lib/s390x/asm/cpacf.h | 1 + lib/s390x/asm/facility.h | 7 +- lib/s390x/asm/float.h | 4 +- lib/s390x/asm/interrupt.h | 4 +- lib/s390x/asm/io.h | 4 +- lib/s390x/asm/mem.h | 4 +- lib/s390x/asm/page.h | 4 +- lib/s390x/asm/pgtable.h | 4 +- lib/s390x/asm/sigp.h | 4 +- lib/s390x/asm/spinlock.h | 4 +- lib/s390x/asm/stack.h | 4 +- lib/s390x/asm/time.h | 4 +- lib/s390x/asm/uv.h | 24 +++-- lib/s390x/css.h | 4 +- lib/s390x/css_dump.c | 4 +- lib/s390x/css_lib.c | 4 +- lib/s390x/interrupt.c | 11 +- lib/s390x/io.c | 6 +- lib/s390x/mmu.c | 4 +- lib/s390x/mmu.h | 4 +- lib/s390x/sclp-console.c | 5 +- lib/s390x/sclp.c | 61 +++++++++-- lib/s390x/sclp.h | 183 ++++++++++++++++++--------------- lib/s390x/sie.h | 198 ++++++++++++++++++++++++++++++++++++ lib/s390x/smp.c | 31 +++--- lib/s390x/smp.h | 4 +- lib/s390x/stack.c | 4 +- lib/s390x/vm.c | 3 +- lib/s390x/vm.h | 3 +- s390x/Makefile | 7 +- s390x/cmm.c | 4 +- s390x/cpu.S | 121 ++++++++++++++++++++++ s390x/cpumodel.c | 4 +- s390x/css.c | 4 +- s390x/cstart64.S | 123 +--------------------- s390x/diag10.c | 4 +- s390x/diag288.c | 4 +- s390x/diag308.c | 5 +- s390x/emulator.c | 4 +- s390x/gs.c | 4 +- s390x/iep.c | 4 +- s390x/intercept.c | 23 ++++- s390x/macros.S | 77 ++++++++++++++ s390x/pfmf.c | 4 +- s390x/sclp.c | 4 +- s390x/selftest.c | 4 +- s390x/sie.c | 113 ++++++++++++++++++++ s390x/skey.c | 4 +- s390x/skrf.c | 4 +- s390x/smp.c | 4 +- s390x/sthyi.c | 4 +- s390x/sthyi.h | 4 +- s390x/stsi.c | 4 +- s390x/unittests.cfg | 3 + s390x/uv-guest.c | 16 ++- s390x/vector.c | 4 +- 61 files changed, 831 insertions(+), 392 deletions(-) create mode 100644 lib/s390x/sie.h create mode 100644 s390x/cpu.S create mode 100644 s390x/macros.S create mode 100644 s390x/sie.c
Signature · 1 line
2.25.1
[kvm-unit-tests GIT PULL 01/11] s390x: Move to GPL 2 and SPDX license identifiers
In the past we had some issues when developers wanted to use code snippets or constants from the kernel in a test or in the library. To remedy that the s390x maintainers decided to move all files to GPL 2 (if possible).
At the same time let's move to SPDX identifiers as they are much nicer to read.
--- s390x/cmm.c | 4 +--- s390x/cpumodel.c | 4 +--- s390x/css.c | 4 +--- s390x/cstart64.S | 4 +--- s390x/diag10.c | 4 +--- s390x/diag288.c | 4 +--- s390x/diag308.c | 5 +---- s390x/emulator.c | 4 +--- s390x/gs.c | 4 +--- s390x/iep.c | 4 +--- s390x/intercept.c | 4 +--- s390x/pfmf.c | 4 +--- s390x/sclp.c | 4 +--- s390x/selftest.c | 4 +--- s390x/skey.c | 4 +--- s390x/skrf.c | 4 +--- s390x/smp.c | 4 +--- s390x/sthyi.c | 4 +--- s390x/sthyi.h | 4 +--- s390x/stsi.c | 4 +--- s390x/uv-guest.c | 4 +--- s390x/vector.c | 4 +--- 22 files changed, 22 insertions(+), 67 deletions(-)
s390x/cmm.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * CMM tests (ESSA) *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h>
s390x/cpumodel.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Test the known dependencies for facilities *
@@ -5,9 +6,6 @@* * Authors: * Christian Borntraeger <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <asm/facility.h>
s390x/css.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Channel Subsystem tests *
@@ -5,9 +6,6 @@* * 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. */ #include <libcflat.h>
s390x/cstart64.S +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x startup code *
@@ -6,9 +7,6 @@ * Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License version 2. */ #include <asm/asm-offsets.h> #include <asm/sigp.h>
s390x/diag10.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Release pages hypercall tests (DIAG 10) *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h>
s390x/diag288.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Timer Event DIAG288 test *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h>
s390x/diag308.c +1 -4
@@ -1,11 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Diagnose 0x308 hypercall tests * * Copyright (c) 2019 Thomas Huth, Red Hat Inc. -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License version 2, or (at -* your option) any later version. */ #include <libcflat.h>
s390x/emulator.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Emulator tests - for s390x CPU instructions that are usually interpreted * by the hardware
@@ -6,9 +7,6 @@* * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/cpacf.h>
s390x/gs.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Tests guarded storage support. *
@@ -6,9 +7,6 @@* Authors: * Martin Schwidefsky <[email protected]> * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/page.h>
s390x/iep.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Instruction Execution Prevention (IEP) DAT test. *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <vmalloc.h>
s390x/intercept.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Interception tests - for s390x CPU instruction that cause a VM exit *
@@ -5,9 +6,6 @@* * Authors: * Thomas Huth <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/asm-offsets.h>
s390x/pfmf.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Perform Frame Management Function (pfmf) tests *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/asm-offsets.h>
s390x/sclp.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Service Call tests *
@@ -5,9 +6,6 @@* * Authors: * Claudio Imbrenda <[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. */ #include <libcflat.h>
s390x/selftest.c +1 -3
@@ -1,12 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <util.h>
s390x/skey.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Storage key tests *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/asm-offsets.h>
s390x/skrf.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Storage key removal facility tests *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[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. */ #include <libcflat.h> #include <asm/asm-offsets.h>
s390x/smp.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Tests sigp emulation *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[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. */ #include <libcflat.h> #include <asm/asm-offsets.h>
s390x/sthyi.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Tests exceptions and data validity for the emulated sthyi * instruction.
@@ -6,9 +7,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/asm-offsets.h>
s390x/sthyi.h +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * STHYI related flags and structure definitions. *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _STHYI_H_#define _STHYI_H_
s390x/stsi.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Store System Information tests *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h>
s390x/uv-guest.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Guest Ultravisor Call tests *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[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. */ #include <libcflat.h>
s390x/vector.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Tests vector instruction support *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/page.h>
Signature · 1 line
2.25.1
[kvm-unit-tests GIT PULL 04/11] 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 | 31 +++++++++++++++++++++++++------ lib/s390x/sclp.h | 3 +++ lib/s390x/smp.c | 27 +++++++++++---------------- 4 files changed, 40 insertions(+), 22 deletions(-)
lib/s390x/io.c +1 -0
@@ -34,6 +34,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 +25 -6
@@ -23,6 +23,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__(PAGE_SIZE))); +static ReadInfo *read_info; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));static volatile bool sclp_busy;
@@ -108,6 +110,24 @@ 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 ) +{ +assert (read_info); +return read_info->entries_cpu; +} + +CPUEntry *sclp_get_cpu_entries (void ) +{ +assert (read_info); +return (CPUEntry *)(_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) {
@@ -125,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
@@ -268,6 +268,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 -16
@@ -23,7 +23,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;
@@ -32,8 +31,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)
@@ -226,10 +224,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 );
@@ -243,22 +241,19 @@ 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
[kvm-unit-tests GIT PULL 05/11] 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 | 25 +++++++++++++++++++++++++ lib/s390x/sclp.h | 13 ++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-)
lib/s390x/io.c +1 -0
@@ -35,6 +35,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 +25 -0
@@ -25,6 +25,7 @@ static uint64_t max_ram_size;static uint64_t ram_size; char _read_info[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));static ReadInfo *read_info; +struct sclp_facilities sclp_facilities; char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));static volatile bool sclp_busy;
@@ -128,6 +129,30 @@ CPUEntry *sclp_get_cpu_entries(void)return (CPUEntry *)(_read_info + read_info->offset_cpu); } +void sclp_facilities_setup (void ) +{ +unsigned short cpu0_addr =stap (); +CPUEntry *cpu; +int i; + +assert (read_info); + + cpu =sclp_get_cpu_entries (); +for (i =0 ; i < read_info->entries_cpu; i++, cpu++) { +/* +* The logic for only reading the facilities from the +* boot cpu comes from the kernel. I haven't yet found +* documentation that explains why this is necessary +* but I figure there's a reason behind doing it this +* way. +*/ +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
@@ -92,12 +92,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;
@@ -271,6 +281,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
[kvm-unit-tests GIT PULL 06/11] s390x: Split assembly into multiple files
In reply to Janosch FrankI've added too much to cstart64.S which is not start related already. Now that I want to add even more code it's time to split cstart64.S. lib.S has functions that are used in tests. macros.S contains macros which are used in cstart64.S and lib.S
--- s390x/Makefile | 6 +-- s390x/cpu.S | 65 ++++++++++++++++++++++++++ s390x/cstart64.S | 119 ++--------------------------------------------- s390x/macros.S | 77 ++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 118 deletions(-) create mode 100644 s390x/cpu.S create mode 100644 s390x/macros.S
s390x/Makefile +3 -3
@@ -66,10 +66,10 @@ cflatobjs += lib/s390x/css_lib.o OBJDIRS += lib/s390x -cstart.o = $(TEST_DIR)/cstart64.o +asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o FLATLIBS = $(libcflat) -%.elf: %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(cstart.o) +%.elf: %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(asmlib) $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) \ $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\" $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
@@ -90,4 +90,4 @@ arch_clean: asm_offsets_clean $(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d generated-files = $(asm-offsets) -$(tests:.elf=.o) $(cstart.o) $(cflatobjs): $(generated-files) +$(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)
s390x/cpu.S new file +65 -0
65 lines not on this page · raw message
s390x/cstart64.S +4 -115
152 lines not on this page · raw message
s390x/macros.S new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.25.1
[kvm-unit-tests GIT PULL 02/11] s390x: lib: Move to GPL 2 and SPDX license identifiers
In reply to Janosch FrankIn the past we had some issues when developers wanted to use code snippets or constants from the kernel in a test or in the library. To remedy that the s390x maintainers decided to move all files to GPL 2 (if possible).
At the same time let's move to SPDX identifiers as they are much nicer to read.
--- lib/s390x/asm-offsets.c | 4 +--- lib/s390x/asm/arch_def.h | 4 +--- lib/s390x/asm/asm-offsets.h | 4 +--- lib/s390x/asm/barrier.h | 4 +--- lib/s390x/asm/cpacf.h | 1 + lib/s390x/asm/facility.h | 4 +--- lib/s390x/asm/float.h | 4 +--- lib/s390x/asm/interrupt.h | 4 +--- lib/s390x/asm/io.h | 4 +--- lib/s390x/asm/mem.h | 4 +--- lib/s390x/asm/page.h | 4 +--- lib/s390x/asm/pgtable.h | 4 +--- lib/s390x/asm/sigp.h | 4 +--- lib/s390x/asm/spinlock.h | 4 +--- lib/s390x/asm/stack.h | 4 +--- lib/s390x/asm/time.h | 4 +--- lib/s390x/css.h | 4 +--- lib/s390x/css_dump.c | 4 +--- lib/s390x/css_lib.c | 4 +--- lib/s390x/interrupt.c | 4 +--- lib/s390x/io.c | 4 +--- lib/s390x/mmu.c | 4 +--- lib/s390x/mmu.h | 4 +--- lib/s390x/sclp-console.c | 5 +---- lib/s390x/sclp.c | 4 +--- lib/s390x/sclp.h | 5 +---- lib/s390x/smp.c | 4 +--- lib/s390x/smp.h | 4 +--- lib/s390x/stack.c | 4 +--- lib/s390x/vm.c | 3 +-- lib/s390x/vm.h | 3 +-- 31 files changed, 31 insertions(+), 90 deletions(-)
lib/s390x/asm-offsets.c +1 -3
@@ -1,11 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <kbuild.h>
lib/s390x/asm/arch_def.h +1 -3
@@ -1,11 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASM_S390X_ARCH_DEF_H_#define _ASM_S390X_ARCH_DEF_H_
lib/s390x/asm/asm-offsets.h +1 -3
@@ -1,10 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <generated/asm-offsets.h>
lib/s390x/asm/barrier.h +1 -3
@@ -1,12 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASM_S390X_BARRIER_H_#define _ASM_S390X_BARRIER_H_
lib/s390x/asm/cpacf.h +1 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * CP Assist for Cryptographic Functions (CPACF) *
lib/s390x/asm/facility.h +1 -3
@@ -1,11 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASM_S390X_FACILITY_H_#define _ASM_S390X_FACILITY_H_
lib/s390x/asm/float.h +1 -3
@@ -1,11 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2018 Red Hat Inc * * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASM_S390X_FLOAT_H_#define _ASM_S390X_FLOAT_H_
lib/s390x/asm/interrupt.h +1 -3
@@ -1,11 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASMS390X_IRQ_H_#define _ASMS390X_IRQ_H_
lib/s390x/asm/io.h +1 -3
@@ -1,12 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASMS390X_IO_H_#define _ASMS390X_IO_H_
lib/s390x/asm/mem.h +1 -3
@@ -1,11 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Physical memory management related functions and definitions. * * Copyright IBM Corp. 2018 * Author(s): Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASM_S390_MEM_H#define _ASM_S390_MEM_H
lib/s390x/asm/page.h +1 -3
@@ -1,12 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASMS390X_PAGE_H_#define _ASMS390X_PAGE_H_
lib/s390x/asm/pgtable.h +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x page table definitions and functions *
@@ -5,9 +6,6 @@* * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASMS390X_PGTABLE_H_#define _ASMS390X_PGTABLE_H_
lib/s390x/asm/sigp.h +1 -3
@@ -1,10 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * SIGP related definitions. * * Copied from the Linux kernel file arch/s390/include/asm/sigp.h -* -* This work is licensed under the terms of the GNU GPL, version -* 2. */ #ifndef ASM_S390X_SIGP_H
lib/s390x/asm/spinlock.h +1 -3
@@ -1,12 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef __ASMS390X_SPINLOCK_H#define __ASMS390X_SPINLOCK_H
lib/s390x/asm/stack.h +1 -3
@@ -1,12 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017 Red Hat Inc * * Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASMS390X_STACK_H_#define _ASMS390X_STACK_H_
lib/s390x/asm/time.h +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Clock utilities for s390 *
@@ -6,9 +7,6 @@* * Copied from the s390/intercept test by: * 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. */ #ifndef ASM_S390X_TIME_H #define ASM_S390X_TIME_H
lib/s390x/css.h +1 -3
@@ -1,11 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * CSS definitions * * Copyright IBM, Corp. 2020 * Author: 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. */ #ifndef CSS_H
lib/s390x/css_dump.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Channel subsystem structures dumping *
@@ -6,9 +7,6 @@* 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. -* * Description: * Provides the dumping functions for various structures used by subchannels: * - ORB : Operation request block, describes the I/O operation and points to
lib/s390x/css_lib.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Channel Subsystem tests library *
@@ -5,9 +6,6 @@* * 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. */ #include <libcflat.h> #include <alloc_phys.h>
lib/s390x/interrupt.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x interrupt handling *
@@ -5,9 +6,6 @@* * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <asm/barrier.h>
lib/s390x/io.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x io implementation *
@@ -6,9 +7,6 @@* Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <argv.h>
lib/s390x/mmu.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x MMU *
@@ -5,9 +6,6 @@* * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h>
lib/s390x/mmu.h +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x mmu functions *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #ifndef _ASMS390X_MMU_H_#define _ASMS390X_MMU_H_
lib/s390x/sclp-console.c +1 -4
@@ -1,11 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * SCLP ASCII access driver * * Copyright (c) 2013 Alexander Graf <[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. */ #include <libcflat.h>
lib/s390x/sclp.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x SCLP driver *
@@ -5,9 +6,6 @@* * Authors: * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h>
lib/s390x/sclp.h +1 -4
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * SCLP definitions *
@@ -7,10 +8,6 @@* and based on the file include/hw/s390x/sclp.h from QEMU * Copyright IBM, Corp. 2012 * Author: Christian Borntraeger <[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 SCLP_H
lib/s390x/smp.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x smp * Based on Linux's arch/s390/kernel/smp.c and
@@ -7,9 +8,6 @@* * Authors: * Janosch Frank <[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. */ #include <libcflat.h> #include <asm/arch_def.h>
lib/s390x/smp.h +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x smp *
@@ -5,9 +6,6 @@* * Authors: * Janosch Frank <[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. */ #ifndef SMP_H #define SMP_H
lib/s390x/stack.c +1 -3
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * s390x stack implementation *
@@ -6,9 +7,6 @@* Authors: * Thomas Huth <[email protected]> * David Hildenbrand <[email protected]> -* -* This code is free software; you can redistribute it and/or modify it -* under the terms of the GNU Library General Public License version 2. */ #include <libcflat.h> #include <stack.h>
lib/s390x/vm.c +1 -2
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Functions to retrieve VM-specific information *
@@ -5,8 +6,6 @@* * Authors: * Thomas Huth <[email protected]> -* -* SPDX-License-Identifier: LGPL-2.1-or-later */ #include <libcflat.h>
lib/s390x/vm.h +1 -2
@@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Functions to retrieve VM-specific information * * Copyright (c) 2020 Red Hat Inc -* -* SPDX-License-Identifier: LGPL-2.1-or-later */ #ifndef S390X_VM_H
Signature · 1 line
2.25.1
[kvm-unit-tests GIT PULL 07/11] 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 | 11 +++ lib/s390x/asm/arch_def.h | 9 ++ lib/s390x/interrupt.c | 7 ++ lib/s390x/sie.h | 198 +++++++++++++++++++++++++++++++++++++++ s390x/cpu.S | 56 +++++++++++ 5 files changed, 281 insertions(+) create mode 100644 lib/s390x/sie.h
lib/s390x/asm-offsets.c +11 -0
@@ -8,6 +8,7 @@#include <libcflat.h> #include <kbuild.h> #include <asm/arch_def.h> +#include <sie.h> int main (void ) {
@@ -69,6 +70,16 @@ 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_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 +9 -0
@@ -8,6 +8,15 @@ #ifndef _ASM_S390X_ARCH_DEF_H_ #define _ASM_S390X_ARCH_DEF_H_ +/* + * We currently only specify the stack frame members needed for the + * SIE library code. + */ +struct stack_frame { + unsigned long back_chain; + unsigned long empty1[5]; +}; + struct psw { uint64_t mask; uint64_t addr;
lib/s390x/interrupt.c +7 -0
@@ -11,6 +11,7 @@#include <asm/barrier.h> #include <sclp.h> #include <interrupt.h> +#include <sie.h> static bool pgm_int_expected;static bool ext_int_expected;
@@ -57,6 +58,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_exit) { + 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 +198 -0
198 lines not on this page · raw message
s390x/cpu.S +56 -0
62 lines not on this page · raw message
Signature · 1 line
2.25.1
[kvm-unit-tests GIT PULL 08/11] 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 | 113 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 117 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 +113 -0
113 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
[kvm-unit-tests GIT PULL 09/11] s390x: Add diag318 intercept test
In reply to Janosch FrankNot much to test except for the privilege and specification exceptions.
--- lib/s390x/sclp.c | 1 + lib/s390x/sclp.h | 6 +++++- s390x/intercept.c | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-)
lib/s390x/sclp.c +1 -0
@@ -138,6 +138,7 @@ void sclp_facilities_setup(void)assert (read_info); cpu =sclp_get_cpu_entries (); + sclp_facilities.has_diag318 = read_info->byte_134_diag318;for (i =0 ; i < read_info->entries_cpu; i++, cpu++) {/* * The logic for only reading the facilities from the
lib/s390x/sclp.h +5 -1
@@ -105,7 +105,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 {
@@ -130,6 +131,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
@@ -8,6 +8,7 @@* Thomas Huth <[email protected]> */ #include <libcflat.h> +#include <sclp.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> #include <asm/page.h>
@@ -152,6 +153,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 );
@@ -162,6 +180,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
[kvm-unit-tests GIT PULL 10/11] 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
@@ -79,10 +79,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))
@@ -90,15 +90,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;
@@ -110,77 +110,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
@@ -195,13 +195,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
@@ -254,25 +254,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
[kvm-unit-tests GIT PULL 11/11] s390x: Fix uv_call() exception behavior
In reply to Janosch FrankOn a program exception we usually skip the instruction that caused the exception and continue. That won't work for UV calls since a "brc 3,0b" will retry the instruction if the CC is > 1. Let's forgo the brc when checking for privilege exceptions and use a uv_call_once().
--- lib/s390x/asm/uv.h | 24 ++++++++++++++++-------- s390x/uv-guest.c | 6 +++--- 2 files changed, 19 insertions(+), 11 deletions(-)
lib/s390x/asm/uv.h +16 -8
@@ -50,19 +50,12 @@ struct uv_cb_share {u64 reserved28; } __attribute__((packed)) __attribute__((aligned(8))); -static inline int uv_call (unsigned long r1,unsigned long r2) +static inline int uv_call_once (unsigned long r1,unsigned long r2) {int cc; -/* -* The brc instruction will take care of the cc 2/3 case where -* we need to continue the execution because we were -* interrupted. The inline assembly will only return on -* success/error i.e. cc 0/1. -*/ asmvolatile ("0: .insn rrf,0xB9A40000,%[r1],%[r2],0,0\n" -" brc 3,0b\n" " ipm %[cc]\n" " srl %[cc],28\n" : [cc] "=d" (cc)
@@ -71,4 +64,19 @@ static inline int uv_call(unsigned long r1, unsigned long r2) return cc; } +static inline int uv_call (unsigned long r1,unsigned long r2) +{ +int cc; + +/* +* CC 2 and 3 tell us to re-execute because the instruction +* hasn't yet finished. +*/ +do { + cc =uv_call_once (r1, r2); + }while (cc >1 ); + +return cc; +} +#endif
s390x/uv-guest.c +3 -3
@@ -29,7 +29,7 @@ static void test_priv(void) uvcb.len =sizeof (struct uv_cb_qui );expect_pgm_int ();enter_pstate (); -uv_call (0 , (u64)&uvcb); +uv_call_once (0 , (u64)&uvcb);check_pgm_int_code (PGM_INT_CODE_PRIVILEGED_OPERATION );report_prefix_pop ();
@@ -38,7 +38,7 @@ static void test_priv(void) uvcb.len =sizeof (struct uv_cb_share );expect_pgm_int ();enter_pstate (); -uv_call (0 , (u64)&uvcb); +uv_call_once (0 , (u64)&uvcb);check_pgm_int_code (PGM_INT_CODE_PRIVILEGED_OPERATION );report_prefix_pop ();
@@ -47,7 +47,7 @@ static void test_priv(void) uvcb.len =sizeof (struct uv_cb_share );expect_pgm_int ();enter_pstate (); -uv_call (0 , (u64)&uvcb); +uv_call_once (0 , (u64)&uvcb);check_pgm_int_code (PGM_INT_CODE_PRIVILEGED_OPERATION );report_prefix_pop ();
Signature · 1 line
2.25.1
[kvm-unit-tests GIT PULL 03/11] s390x: Add test_bit to library
In reply to Janosch FrankQuery/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 ++- s390x/uv-guest.c | 6 +++--- 3 files changed, 31 insertions(+), 4 deletions(-)
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
@@ -11,13 +11,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 )
s390x/uv-guest.c +3 -3
@@ -75,11 +75,11 @@ static void test_query(void)* Ultravisor version and are expected to always be available * because they are basic building blocks. */ -report (uvcb.inst_calls_list[0 ] & (1UL << (63 -BIT_UVC_CMD_QUI )), +report (test_bit_inv (BIT_UVC_CMD_QUI , &uvcb.inst_calls_list[0 ]),"query indicated" ); -report (uvcb.inst_calls_list[0 ] & (1UL << (63 -BIT_UVC_CMD_SET_SHARED_ACCESS )), +report (test_bit_inv (BIT_UVC_CMD_SET_SHARED_ACCESS , &uvcb.inst_calls_list[0 ]),"share indicated" ); -report (uvcb.inst_calls_list[0 ] & (1UL << (63 -BIT_UVC_CMD_REMOVE_SHARED_ACCESS )), +report (test_bit_inv (BIT_UVC_CMD_REMOVE_SHARED_ACCESS , &uvcb.inst_calls_list[0 ]),"unshare indicated" );report_prefix_pop (); }
Signature · 1 line
2.25.1
Paolo Bonzini
maintainerQuoted 1 line · Janosch Frank
https://gitlab.com/frankja/kvm-unit-tests.git tags/s390x-2021-20-01
Pulled, thanks.
Paolo