lib: s390x: Refactor and rename vm.[ch]
cover lib: s390x: Refactor and rename vm.[ch]
Refactor and rename vm.[ch] to hardware.[ch]
* Remove some uneeded #includes for vm.h
* Rename vm.[ch] to hardware.[ch]
* Move host_is_zvm6 to the library (was in a testcase)
* Consolidate all detection functions into detect_host, which returns what host system the test is running on
* Rename vm_is_* functions to host_is_*, which are then just wrappers around detect_host
* Move machine type macros from arch_def.h to hardware.h, add machine types for all known machines
* Add machine_is_* functions
* Refactor and rename get_machine_id to be a simple wrapper for stidp
* Add back get_machine_id using the stidp wrapper
Claudio Imbrenda (4):
s390x: remove spurious includes
lib: s390: rename and refactor vm.[ch]
lib: s390x: functions for machine models
lib: s390x: stidp wrapper and move get_machine_id
s390x/Makefile | 2 +- lib/s390x/asm/arch_def.h | 7 +- lib/s390x/hardware.h | 134 +++++++++++++++++++++++++++++++++++++++ lib/s390x/vm.h | 15 ----- lib/s390x/hardware.c | 86 +++++++++++++++++++++++++ lib/s390x/vm.c | 92 --------------------------- s390x/cpumodel.c | 4 +- s390x/mvpg-sie.c | 1 - s390x/mvpg.c | 4 +- s390x/pv-diags.c | 1 - s390x/skey.c | 28 +------- s390x/spec_ex-sie.c | 1 - s390x/uv-host.c | 4 +- 13 files changed, 230 insertions(+), 149 deletions(-) create mode 100644 lib/s390x/hardware.h delete mode 100644 lib/s390x/vm.h create mode 100644 lib/s390x/hardware.c delete mode 100644 lib/s390x/vm.c
Signature · 1 line
2.34.1
PATCH 1/4 s390x: remove spurious includes
Remove unused includes of vm.h
--- s390x/mvpg-sie.c | 1 - s390x/pv-diags.c | 1 - s390x/spec_ex-sie.c | 1 - 3 files changed, 3 deletions(-)
s390x/mvpg-sie.c +0 -1
@@ -16,7 +16,6 @@#include <asm/facility.h> #include <asm/mem.h> #include <alloc_page.h> -#include <vm.h> #include <sclp.h> #include <sie.h> #include <snippet.h>
s390x/pv-diags.c +0 -1
@@ -19,7 +19,6 @@#include <asm/sigp.h> #include <smp.h> #include <alloc_page.h> -#include <vm.h> #include <vmalloc.h> #include <sclp.h> #include <snippet.h>
s390x/spec_ex-sie.c +0 -1
@@ -11,7 +11,6 @@#include <asm/page.h> #include <asm/arch_def.h> #include <alloc_page.h> -#include <vm.h> #include <sie.h> #include <snippet.h>
Signature · 1 line
2.34.1
Re: [kvm-unit-tests PATCH v1 1/4] s390x: remove spurious includes
Quoted 1 line · Claudio Imbrenda
Remove unused includes of
vm.h
Quoted 5 lines
Signed-off-by Claudio Imbrenda <[email protected]>--- s390x/mvpg-sie.c | 1 - s390x/pv-diags.c | 1 -
I think there are more unused includes in pv-diags.c. I need to take another look at that.
Quoted 39 lines
s390x/spec_ex-sie.c | 1 - 3 files changed, 3 deletions(-)s390x/mvpg-sie.c +0
-1@@ -16,7 +16,6 @@#include <asm/facility.h> #include <asm/mem.h> #include <alloc_page.h> -#include <vm.h> #include <sclp.h> #include <sie.h> #include <snippet.h> s390x/pv-diags.c +0
-1@@ -19,7 +19,6 @@#include <asm/sigp.h> #include <smp.h> #include <alloc_page.h> -#include <vm.h> #include <vmalloc.h> #include <sclp.h> #include <snippet.h> s390x/spec_ex-sie.c +0
-1@@ -11,7 +11,6 @@#include <asm/page.h> #include <asm/arch_def.h> #include <alloc_page.h> -#include <vm.h> #include <sie.h> #include <snippet.h>
PATCH 2/4 lib: s390: rename and refactor vm.[ch]
In reply to Claudio ImbrendaRefactor and rename vm.[ch] to hardware.[ch]
* Rename vm.[ch] to hardware.[ch]
* Consolidate all detection functions into detect_host, which returns what host system the test is running on
* Move host_is_zvm6 to the library (was in a testcase)
* Rename vm_is_* functions to host_is_*, which are then just wrappers around detect_host
--- s390x/Makefile | 2 +- lib/s390x/hardware.h | 47 ++++++++++++++++++++++ lib/s390x/vm.h | 15 -------- lib/s390x/hardware.c | 86 +++++++++++++++++++++++++++++++++++++++++ lib/s390x/vm.c | 92 -------------------------------------------- s390x/cpumodel.c | 4 +- s390x/mvpg.c | 4 +- s390x/skey.c | 28 +------------- 8 files changed, 140 insertions(+), 138 deletions(-) create mode 100644 lib/s390x/hardware.h delete mode 100644 lib/s390x/vm.h create mode 100644 lib/s390x/hardware.c delete mode 100644 lib/s390x/vm.c
s390x/Makefile +1 -1
@@ -78,7 +78,7 @@ cflatobjs += lib/s390x/sclp-console.o cflatobjs += lib/s390x/interrupt.o cflatobjs += lib/s390x/mmu.o cflatobjs += lib/s390x/smp.o -cflatobjs += lib/s390x/vm.o +cflatobjs += lib/s390x/hardware.o cflatobjs += lib/s390x/css_dump.o cflatobjs += lib/s390x/css_lib.o cflatobjs += lib/s390x/malloc_io.o
lib/s390x/hardware.h new file +47 -0
47 lines not on this page · raw message
lib/s390x/vm.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* Functions to retrieve VM-specific information -* -* Copyright (c) 2020 Red Hat Inc -*/ - -#ifndef _S390X_VM_H_ -#define _S390X_VM_H_ - -bool vm_is_tcg (void ); -bool vm_is_kvm (void ); -bool vm_is_lpar (void ); - -#endif /* _S390X_VM_H_ */
lib/s390x/hardware.c new file +86 -0
86 lines not on this page · raw message
lib/s390x/vm.c deleted +0 -92
92 lines not on this page · raw message
s390x/cpumodel.c +2 -2
@@ -10,7 +10,7 @@*/ #include <asm/facility.h> -#include <vm.h> +#include <hardware.h> #include <sclp.h> #include <uv.h> #include <asm/uv.h>
@@ -118,7 +118,7 @@ int main(void)for (i =0 ; i <ARRAY_SIZE (dep); i++) {report_prefix_pushf ("%d implies %d" , dep[i].facility, dep[i].implied);if (test_facility (dep[i].facility)) { -report_xfail (dep[i].expected_tcg_fail &&vm_is_tcg (), +report_xfail (dep[i].expected_tcg_fail &&host_is_tcg (),test_facility (dep[i].implied),"implication not correct" ); }else {
s390x/mvpg.c +2 -2
@@ -20,7 +20,7 @@#include <smp.h> #include <alloc_page.h> #include <bitops.h> -#include <vm.h> +#include <hardware.h> /* Used to build the appropriate test values for register 0 */ #define KFC (x) ((x) << 10)
@@ -251,7 +251,7 @@ static void test_mmu_prot(void) fresh +=PAGE_SIZE ;/* Known issue in TCG: CCO flag is not honoured */ -if (vm_is_tcg ()) { +if (host_is_tcg ()) {report_prefix_push ("TCG" );report_skip ("destination invalid" );report_skip ("source invalid" );
s390x/skey.c +2 -26
@@ -13,7 +13,7 @@#include <asm/page.h> #include <asm/facility.h> #include <asm/mem.h> - +#include <hardware.h> static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
@@ -65,33 +65,9 @@ static void test_set(void) "set key test"); } -/* Returns true if we are running under z/VM 6.x */ -static bool check_for_zvm6 (void ) -{ -int dcbt;/* Descriptor block count */ -int nr; -static const unsigned char zvm6[] = { -/* This is "z/VM 6" in EBCDIC */ -0xa9 ,0x61 ,0xe5 ,0xd4 ,0x40 ,0x40 ,0x40 ,0x40 ,0xf6 - }; - -if (stsi (pagebuf,3 ,2 ,2 )) -return false; - - dcbt = pagebuf[31 ] &0xf ; - -for (nr =0 ; nr < dcbt; nr++) { -if (!memcmp (&pagebuf[32 + nr *64 +24 ], zvm6,sizeof (zvm6))) -return true; - } - -return false; -} -static void test_priv (void ) {union skey skey; -bool is_zvm6 =check_for_zvm6 ();memset (pagebuf,0 ,PAGE_SIZE *2 );report_prefix_push ("privileged" );
@@ -106,7 +82,7 @@ static void test_priv(void)report (skey.str.acc !=3 ,"skey did not change on exception" );report_prefix_push ("iske" ); -if (is_zvm6) { +if (host_is_zvm6 ()) {/* There is a known bug with z/VM 6, so skip the test there */ report_skip ("not working on z/VM 6" ); }else {
Signature · 1 line
2.34.1
Re: [kvm-unit-tests PATCH v1 2/4] lib: s390: rename and refactor vm.[ch]
Quoted 6 lines · Claudio Imbrenda
Refactor and rename vm.[ch] to hardware.[ch]
* Rename vm.[ch] to hardware.[ch]
* Consolidate all detection functions intodetect_host, which returns what host system the test is running on
* Movehost_is_zvm6to the library (was in a testcase)
We can drop that function, we don't need to fence this anymore.
PATCH 3/4 lib: s390x: functions for machine models
In reply to Claudio Imbrenda* move existing macros for machine models to hardware.h
* add macros for all known machine models
* add machine_is_* functions
--- lib/s390x/asm/arch_def.h | 3 -- lib/s390x/hardware.h | 82 ++++++++++++++++++++++++++++++++++++++++ s390x/uv-host.c | 4 +- 3 files changed, 84 insertions(+), 5 deletions(-)
lib/s390x/asm/arch_def.h +0 -3
@@ -219,9 +219,6 @@ static inline unsigned short stap(void)return cpu_address; } -#define MACHINE_Z15A 0x8561 -#define MACHINE_Z15B 0x8562 -static inline uint16_t get_machine_id (void ) {uint64_t cpuid;
lib/s390x/hardware.h +82 -0
92 lines not on this page · raw message
s390x/uv-host.c +2 -2
@@ -9,6 +9,7 @@*/ #include <libcflat.h> +#include <hardware.h> #include <alloc.h> #include <vmalloc.h> #include <sclp.h>
@@ -111,7 +112,6 @@ static void test_config_destroy(void)static void test_cpu_destroy (void ) {int rc; -uint16_t machineid =get_machine_id ();struct uv_cb_nodata uvcb = { .header.len =sizeof (uvcb), .header.cmd =UVC_CMD_DESTROY_SEC_CPU ,
@@ -126,7 +126,7 @@ static void test_cpu_destroy(void) "hdr invalid length"); uvcb.header.len +=8 ; -if (machineid !=MACHINE_Z15A && machineid !=MACHINE_Z15B ) { +if (!machine_is_z15 ()) { uvcb.handle +=1 ; rc =uv_call (0 , (uint64_t )&uvcb);report (rc ==1 && uvcb.header.rc ==UVC_RC_INV_CHANDLE ,"invalid handle" );
Signature · 1 line
2.34.1
Re: [kvm-unit-tests PATCH v1 3/4] lib: s390x: functions for machine models
Quoted 3 lines · Claudio Imbrenda
* move existing macros for machine models to
hardware.h
* add macros for all known machine models
* add machine_is_* functions
While I appreciate the effort that you put into this I question the need to check for anything below z13 right now.
I'd suggest we cut down this patch to the move of the z15 defines and be done with it for now.
Quoted 147 lines
--- lib/s390x/asm/arch_def.h | 3 -- lib/s390x/hardware.h | 82 ++++++++++++++++++++++++++++++++++++++++ s390x/uv-host.c | 4 +- 3 files changed, 84 insertions(+), 5 deletions(-)lib/s390x/asm/arch_def.h +0
-3@@ -219,9 +219,6 @@ static inline unsigned short stap(void)return cpu_address; } -#define MACHINE_Z15A 0x8561 -#define MACHINE_Z15B 0x8562 -static inline uint16_t get_machine_id (void ) {uint64_t cpuid;lib/s390x/hardware.h +82
-0@@ -13,6 +13,25 @@#define _S390X_HARDWARE_H_#include <asm/arch_def.h> +#define MACHINE_Z900 0x2064 +#define MACHINE_Z800 0x2066 +#define MACHINE_Z990 0x2084 +#define MACHINE_Z890 0x2086 +#define MACHINE_Z9EC 0x2094 +#define MACHINE_Z9BC 0x2096 +#define MACHINE_Z10EC 0x2097 +#define MACHINE_Z10BC 0x2098 +#define MACHINE_Z196 0x2817 +#define MACHINE_Z114 0x2818 +#define MACHINE_ZEC12 0x2827 +#define MACHINE_ZBC12 0x2828 +#define MACHINE_Z13 0x2964 +#define MACHINE_Z13S 0x2965 +#define MACHINE_Z14 0x3906 +#define MACHINE_Z14ZR1 0x3907 +#define MACHINE_Z15 0x8561 +#define MACHINE_Z15T02 0x8562 +enum s390_host {HOST_IS_UNKNOWN ,HOST_IS_LPAR ,@@ -44,4 +63,67 @@ static inline bool host_is_zvm6(void)return detect_host () ==HOST_IS_ZVM6 ; } +static inline bool machine_is_z900 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z900 || machine ==MACHINE_Z800 ; +} + +static inline bool machine_is_z990 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z990 || machine ==MACHINE_Z890 ; +} + +static inline bool machine_is_z9 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z9EC || machine ==MACHINE_Z9BC ; +} + +static inline bool machine_is_z10 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z10EC || machine ==MACHINE_Z10BC ; +} + +static inline bool machine_is_z1xx (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z196 || machine ==MACHINE_Z114 ; +} + +static inline bool machine_is_z12 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_ZEC12 || machine ==MACHINE_ZBC12 ; +} + +static inline bool machine_is_z13 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z13 || machine ==MACHINE_Z13S ; +} + +static inline bool machine_is_z14 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z14 || machine ==MACHINE_Z14ZR1 ; +} + +static inline bool machine_is_z15 (void ) +{ +uint16_t machine =get_machine_id (); + +return machine ==MACHINE_Z15 || machine ==MACHINE_Z15T02 ; +} +#endif /* _S390X_HARDWARE_H_ */ s390x/uv-host.c +2
-2@@ -9,6 +9,7 @@*/ #include <libcflat.h> +#include <hardware.h> #include <alloc.h> #include <vmalloc.h> #include <sclp.h> @@ -111,7 +112,6 @@ static void test_config_destroy(void)static void test_cpu_destroy (void ) {int rc; -uint16_t machineid =get_machine_id ();struct uv_cb_nodata uvcb = { .header.len =sizeof (uvcb), .header.cmd =UVC_CMD_DESTROY_SEC_CPU ,@@ -126,7 +126,7 @@ static void test_cpu_destroy(void) "hdr invalid length"); uvcb.header.len +=8 ; -if (machineid !=MACHINE_Z15A && machineid !=MACHINE_Z15B ) { +if (!machine_is_z15 ()) { uvcb.handle +=1 ; rc =uv_call (0 , (uint64_t )&uvcb);report (rc ==1 && uvcb.header.rc ==UVC_RC_INV_CHANDLE ,"invalid handle" );
PATCH 4/4 lib: s390x: stidp wrapper and move get_machine_id
In reply to Claudio ImbrendaRefactor get_machine_id in arch_def.h into a simple wrapper around stidp, add back get_machine_id in hardware.h using the stidp wrapper.
--- lib/s390x/asm/arch_def.h | 4 +--- lib/s390x/hardware.h | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-)
lib/s390x/asm/arch_def.h +1 -3
@@ -219,13 +219,11 @@ static inline unsigned short stap(void)return cpu_address; } -static inline uint16_t get_machine_id (void ) +static inline uint64_t stidp (void ) {uint64_t cpuid; asmvolatile ("stidp %0" :"=Q" (cpuid)); - cpuid = cpuid >>16 ; - cpuid &=0xffff ;return cpuid; }
lib/s390x/hardware.h +5 -0
@@ -43,6 +43,11 @@ enum s390_host {enum s390_host detect_host (void ); +static inline uint16_t get_machine_id (void ) +{ +return stidp () >>16 ; +} +static inline bool host_is_tcg (void ) {return detect_host () ==HOST_IS_TCG ;
Signature · 1 line
2.34.1
Re: [kvm-unit-tests PATCH v1 4/4] lib: s390x: stidp wrapper and move get_machine_id
Quoted 4 lines · Claudio Imbrenda
Refactor
get_machine_idinarch_def.hinto a simple wrapper around stidp, add backget_machine_idinhardware.husing the stidp wrapper.Signed-off-by Claudio Imbrenda <[email protected]>
Quoted 40 lines
--- lib/s390x/asm/arch_def.h | 4 +--- lib/s390x/hardware.h | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-)lib/s390x/asm/arch_def.h +1
-3@@ -219,13 +219,11 @@ static inline unsigned short stap(void)return cpu_address; } -static inline uint16_t get_machine_id (void ) +static inline uint64_t stidp (void ) {uint64_t cpuid; asmvolatile ("stidp %0" :"=Q" (cpuid)); - cpuid = cpuid >>16 ; - cpuid &=0xffff ;return cpuid; }lib/s390x/hardware.h +5
-0@@ -43,6 +43,11 @@ enum s390_host {enum s390_host detect_host (void ); +static inline uint16_t get_machine_id (void ) +{ +return stidp () >>16 ; +} +static inline bool host_is_tcg (void ) {return detect_host () ==HOST_IS_TCG ;