s390x: Cleanup and maintenance 4
v2 cover s390x: Cleanup and maintenance 4
A few small cleanups and two patches that I forgot to upstream which have now been rebased onto the machine.h library functions.
v2:
* Added host_is_qemu() function
* Fixed qemu checks
Janosch Frank (9):
lib: s390x: hardware: Add host_is_qemu() function
s390x: css: Skip if we're not run by qemu
s390x: diag308: Only test subcode 2 under QEMU
s390x: pfmf: Initialize pfmf_r1 union on declaration
s390x: snippets: asm: Add license and copyright headers
s390x: pv-diags: Cleanup includes
s390x: css: Cleanup includes
s390x: iep: Cleanup includes
s390x: mvpg: Cleanup includes
lib/s390x/hardware.h | 5 +++ s390x/css.c | 18 ++++++---- s390x/diag308.c | 15 ++++++++- s390x/iep.c | 3 +- s390x/mvpg.c | 3 -- s390x/pfmf.c | 39 +++++++++++----------- s390x/pv-diags.c | 17 ++-------- s390x/snippets/asm/snippet-pv-diag-288.S | 9 +++++ s390x/snippets/asm/snippet-pv-diag-500.S | 9 +++++ s390x/snippets/asm/snippet-pv-diag-yield.S | 9 +++++ 10 files changed, 80 insertions(+), 47 deletions(-)
Signature · 1 line
2.32.0
PATCH v2 1/9 lib: s390x: hardware: Add host_is_qemu() function
In the future we'll likely need to check if we're hosted on QEMU so let's make this as easy as possible by providing a dedicated function.
--- lib/s390x/hardware.h | 5 +++++ 1 file changed, 5 insertions(+)
lib/s390x/hardware.h +5 -0
@@ -45,6 +45,11 @@ static inline bool host_is_lpar(void)return detect_host () ==HOST_IS_LPAR ; } +static inline bool host_is_qemu (void ) +{ +return host_is_tcg () ||host_is_kvm (); +} +static inline bool machine_is_z15 (void ) {uint16_t machine =get_machine_id ();
Signature · 1 line
2.32.0
Re: [kvm-unit-tests PATCH v2 1/9] lib: s390x: hardware: Add host_is_qemu() function
Quoted 4 lines · On Thu, 7 Apr 2022 08:44:13 +0000 Janosch Frank <[email protected]> wrote:
In the future we'll likely need to check if we're hosted on QEMU so let's make this as easy as possible by providing a dedicated function.
Signed-off-by Janosch Frank <[email protected]>
Quoted 20 lines
--- lib/s390x/hardware.h | 5 +++++ 1 file changed, 5 insertions(+)lib/s390x/hardware.h +5
-0@@ -45,6 +45,11 @@ static inline bool host_is_lpar(void)return detect_host () ==HOST_IS_LPAR ; } +static inline bool host_is_qemu (void ) +{ +return host_is_tcg () ||host_is_kvm (); +} +static inline bool machine_is_z15 (void ) {uint16_t machine =get_machine_id ();
Re: [kvm-unit-tests PATCH v2 1/9] lib: s390x: hardware: Add host_is_qemu() function
In reply to Janosch FrankQuoted 5 lines · Janosch Frank
In the future we'll likely need to check if we're hosted on QEMU so let's make this as easy as possible by providing a dedicated function.
Signed-off-by Janosch Frank <[email protected]>
We could also adjust the check we already have in s390x/epsw.c to use the new function, but also fine to leave as-is.
Re: [kvm-unit-tests PATCH v2 1/9] lib: s390x: hardware: Add host_is_qemu() function
Quoted 11 lines · Nico Boehr
Quoted 5 lines · Janosch Frank
In the future we'll likely need to check if we're hosted on QEMU so let's make this as easy as possible by providing a dedicated function.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Nico Boehr <[email protected]>We could also adjust the check we already have in
s390x/epsw.cto use the new function, but also fine to leave as-is.
I'd suggest to fix it: It has the same "goto done" + prefix_pop problem that we recently saw in another patch, too.
Thomas
PATCH v2 2/9 s390x: css: Skip if we're not run by qemu
In reply to Janosch FrankThere's no guarantee that we even find a device at the address we're testing for if we're not running under QEMU.
--- s390x/css.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
s390x/css.c +10 -1
@@ -15,6 +15,7 @@#include <interrupt.h> #include <asm/arch_def.h> #include <alloc_page.h> +#include <hardware.h> #include <malloc_io.h> #include <css.h>
@@ -642,13 +643,21 @@ int main(int argc, char *argv[])int i;report_prefix_push ("Channel Subsystem" ); + +/* There's no guarantee where our devices are without qemu */ +if (!host_is_qemu ()) { +report_skip ("Not running under QEMU" ); + goto done; + } +enable_io_isc (0x80 >>IO_SCH_ISC );for (i =0 ; tests[i].name; i++) {report_prefix_push (tests[i].name); tests[i].func ();report_prefix_pop (); } -report_prefix_pop (); +done: +report_prefix_pop ();return report_summary (); }
Signature · 1 line
2.32.0
Re: [kvm-unit-tests PATCH v2 2/9] s390x: css: Skip if we're not run by qemu
Quoted 4 lines · On Thu, 7 Apr 2022 08:44:14 +0000 Janosch Frank <[email protected]> wrote:
There's no guarantee that we even find a device at the address we're testing for if we're not running under QEMU.
Signed-off-by Janosch Frank <[email protected]>
Quoted 39 lines
--- s390x/css.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)s390x/css.c +10
-1@@ -15,6 +15,7 @@#include <interrupt.h> #include <asm/arch_def.h> #include <alloc_page.h> +#include <hardware.h> #include <malloc_io.h> #include <css.h> @@ -642,13 +643,21 @@ int main(int argc, char *argv[])int i;report_prefix_push ("Channel Subsystem" ); + +/* There's no guarantee where our devices are without qemu */ +if (!host_is_qemu ()) { +report_skip ("Not running under QEMU" ); + goto done; + } +enable_io_isc (0x80 >>IO_SCH_ISC );for (i =0 ; tests[i].name; i++) {report_prefix_push (tests[i].name); tests[i].func ();report_prefix_pop (); } -report_prefix_pop (); +done: +report_prefix_pop ();return report_summary (); }
Re: [kvm-unit-tests PATCH v2 2/9] s390x: css: Skip if we're not run by qemu
In reply to Janosch FrankQuoted 4 lines · Janosch Frank
There's no guarantee that we even find a device at the address we're testing for if we're not running under QEMU.
Signed-off-by Janosch Frank <[email protected]>
PATCH v2 3/9 s390x: diag308: Only test subcode 2 under QEMU
In reply to Janosch FrankOther hypervisors might implement it and therefore not send a specification exception.
--- s390x/diag308.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
s390x/diag308.c +14 -1
@@ -8,6 +8,7 @@#include <libcflat.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> +#include <hardware.h> /* The diagnose calls should be blocked in problem state */ static void test_priv (void )
@@ -75,7 +76,7 @@ static void test_subcode6(void)/* Unsupported subcodes should generate a specification exception */ static void test_unsupported_subcode (void ) { -int subcodes[] = {2 ,0x101 ,0xffff ,0x10001 ,-1 }; +int subcodes[] = {0x101 ,0xffff ,0x10001 ,-1 };int idx;for (idx =0 ; idx <ARRAY_SIZE (subcodes); idx++) {
@@ -85,6 +86,18 @@ static void test_unsupported_subcode(void)check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );report_prefix_pop (); } + +/* +* Subcode 2 is not available under QEMU but might be on other +* hypervisors. +*/ +if (host_is_qemu ()) { +report_prefix_pushf ("0x%04x" ,2 ); +expect_pgm_int (); + asmvolatile ("diag %0,%1,0x308" ::"d" (0 ),"d" (2 )); +check_pgm_int_code (PGM_INT_CODE_SPECIFICATION ); +report_prefix_pop (); + } } static struct {
Signature · 1 line
2.32.0
Re: [kvm-unit-tests PATCH v2 3/9] s390x: diag308: Only test subcode 2 under QEMU
Quoted 35 lines · On Thu, 7 Apr 2022 08:44:15 +0000 Janosch Frank <[email protected]> wrote:
Other hypervisors might implement it and therefore not send a specification exception.
Signed-off-by Janosch Frank <[email protected]>--- s390x/diag308.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)s390x/diag308.c +4
-1@@ -8,6 +8,7 @@#include <libcflat.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> +#include <hardware.h> /* The diagnose calls should be blocked in problem state */ static void test_priv (void )@@ -75,7 +76,7 @@ static void test_subcode6(void)/* Unsupported subcodes should generate a specification exception */ static void test_unsupported_subcode (void ) { -int subcodes[] = {2 ,0x101 ,0xffff ,0x10001 ,-1 }; +int subcodes[] = {0x101 ,0xffff ,0x10001 ,-1 };int idx;for (idx =0 ; idx <ARRAY_SIZE (subcodes); idx++) {@@ -85,6 +86,18 @@ static void test_unsupported_subcode(void)check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );report_prefix_pop (); } + +/*
s390x/diag308.c static void test_unsupported_subcode(void) · line 100
Quoted 10 lines
s390x/diag308.c +10
-0+* Subcode 2 is not available under QEMU but might be on other +* hypervisors. +*/ +if (host_is_qemu ()) { +report_prefix_pushf ("0x%04x" ,2 ); +expect_pgm_int (); + asmvolatile ("diag %0,%1,0x308" ::"d" (0 ),"d" (2 )); +check_pgm_int_code (PGM_INT_CODE_SPECIFICATION ); +report_prefix_pop (); + }
move the prefix push and pop outside of the if, then add
else {
report_skip(...);
}Quoted 3 lines
s390x/diag308.c +0
-0} static struct {
PATCH v3 1/1 s390x: diag308: Only test subcode 2 under QEMU
Other hypervisors might implement it and therefore not send a specification exception.
--- s390x/diag308.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
s390x/diag308.c +17 -1
@@ -8,6 +8,7 @@#include <libcflat.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> +#include <hardware.h> /* The diagnose calls should be blocked in problem state */ static void test_priv (void )
@@ -75,7 +76,7 @@ static void test_subcode6(void)/* Unsupported subcodes should generate a specification exception */ static void test_unsupported_subcode (void ) { -int subcodes[] = {2 ,0x101 ,0xffff ,0x10001 ,-1 }; +int subcodes[] = {0x101 ,0xffff ,0x10001 ,-1 };int idx;for (idx =0 ; idx <ARRAY_SIZE (subcodes); idx++) {
@@ -85,6 +86,21 @@ static void test_unsupported_subcode(void)check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );report_prefix_pop (); } + +/* +* Subcode 2 is not available under QEMU but might be on other +* hypervisors so we only check for the specification +* exception on QEMU. +*/ +report_prefix_pushf ("0x%04x" ,2 ); +if (host_is_qemu ()) { +expect_pgm_int (); + asmvolatile ("diag %0,%1,0x308" ::"d" (0 ),"d" (2 )); +check_pgm_int_code (PGM_INT_CODE_SPECIFICATION ); + }else { +report_skip ("subcode is supported" ); + } +report_prefix_pop (); } static struct {
Signature · 1 line
2.32.0
Re: [kvm-unit-tests PATCH v3] s390x: diag308: Only test subcode 2 under QEMU
Quoted 4 lines · On Thu, 7 Apr 2022 13:02:52 +0000 Janosch Frank <[email protected]> wrote:
Other hypervisors might implement it and therefore not send a specification exception.
Signed-off-by Janosch Frank <[email protected]>
Quoted 47 lines
--- s390x/diag308.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)s390x/diag308.c +17
-1@@ -8,6 +8,7 @@#include <libcflat.h> #include <asm/asm-offsets.h> #include <asm/interrupt.h> +#include <hardware.h> /* The diagnose calls should be blocked in problem state */ static void test_priv (void )@@ -75,7 +76,7 @@ static void test_subcode6(void)/* Unsupported subcodes should generate a specification exception */ static void test_unsupported_subcode (void ) { -int subcodes[] = {2 ,0x101 ,0xffff ,0x10001 ,-1 }; +int subcodes[] = {0x101 ,0xffff ,0x10001 ,-1 };int idx;for (idx =0 ; idx <ARRAY_SIZE (subcodes); idx++) {@@ -85,6 +86,21 @@ static void test_unsupported_subcode(void)check_pgm_int_code (PGM_INT_CODE_SPECIFICATION );report_prefix_pop (); } + +/* +* Subcode 2 is not available under QEMU but might be on other +* hypervisors so we only check for the specification +* exception on QEMU. +*/ +report_prefix_pushf ("0x%04x" ,2 ); +if (host_is_qemu ()) { +expect_pgm_int (); + asmvolatile ("diag %0,%1,0x308" ::"d" (0 ),"d" (2 )); +check_pgm_int_code (PGM_INT_CODE_SPECIFICATION ); + }else { +report_skip ("subcode is supported" ); + } +report_prefix_pop (); } static struct {
Re: [kvm-unit-tests PATCH v3] s390x: diag308: Only test subcode 2 under QEMU
In reply to Janosch FrankQuoted 4 lines · Janosch Frank
Other hypervisors might implement it and therefore not send a specification exception.
Signed-off-by Janosch Frank <[email protected]>
PATCH v2 4/9 s390x: pfmf: Initialize pfmf_r1 union on declaration
In reply to Janosch FrankLet's make this test look a bit nicer.
--- s390x/pfmf.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
s390x/pfmf.c +19 -20
@@ -28,7 +28,11 @@ static void test_priv(void)static void test_4k_key (void ) { -union pfmf_r1 r1; +union pfmf_r1 r1 = { + .reg.sk =1 , + .reg.fsc =PFMF_FSC_4K , + .reg.key =0x30 , + };union skey skey;report_prefix_push ("4K" );
@@ -36,10 +40,6 @@ static void test_4k_key(void)report_skip ("storage key removal facility is active" ); goto out; } - r1.val =0 ; - r1.reg.sk =1 ; - r1.reg.fsc =PFMF_FSC_4K ; - r1.reg.key =0x30 ;pfmf (r1.val, pagebuf); skey.val =get_storage_key (pagebuf); skey.val &=SKEY_ACC |SKEY_FP ;
@@ -52,18 +52,19 @@ static void test_1m_key(void) {int i;bool rp = true; -union pfmf_r1 r1;union skey skey; +union pfmf_r1 r1 = { + .reg.fsc =PFMF_FSC_1M , + .reg.key =0x30 , + .reg.sk =1 , + };report_prefix_push ("1M" );if (test_facility (169 )) {report_skip ("storage key removal facility is active" ); goto out; } - r1.val =0 ; - r1.reg.sk =1 ; - r1.reg.fsc =PFMF_FSC_1M ; - r1.reg.key =0x30 ; +pfmf (r1.val, pagebuf);for (i =0 ; i <256 ; i++) { skey.val =get_storage_key (pagebuf + i *PAGE_SIZE );
@@ -80,11 +81,10 @@ out:static void test_4k_clear (void ) { -union pfmf_r1 r1; - - r1.val =0 ; - r1.reg.cf =1 ; - r1.reg.fsc =PFMF_FSC_4K ; +union pfmf_r1 r1 = { + .reg.cf =1 , + .reg.fsc =PFMF_FSC_4K , + };report_prefix_push ("4K" );memset (pagebuf,42 ,PAGE_SIZE );
@@ -97,13 +97,12 @@ static void test_4k_clear(void)static void test_1m_clear (void ) {int i; -union pfmf_r1 r1; +union pfmf_r1 r1 = { + .reg.cf =1 , + .reg.fsc =PFMF_FSC_1M , + };unsigned long sum =0 ; - r1.val =0 ; - r1.reg.cf =1 ; - r1.reg.fsc =PFMF_FSC_1M ; -report_prefix_push ("1M" );memset (pagebuf,42 ,PAGE_SIZE *256 );pfmf (r1.val, pagebuf);
Signature · 1 line
2.32.0
PATCH v2 5/9 s390x: snippets: asm: Add license and copyright headers
In reply to Janosch FrankTime for some cleanup of the snippets to make them look like any other test file.
--- s390x/snippets/asm/snippet-pv-diag-288.S | 9 +++++++++ s390x/snippets/asm/snippet-pv-diag-500.S | 9 +++++++++ s390x/snippets/asm/snippet-pv-diag-yield.S | 9 +++++++++ 3 files changed, 27 insertions(+)
s390x/snippets/asm/snippet-pv-diag-288.S +9 -0
@@ -1,3 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Diagnose 0x288 snippet used for PV interception testing. + * + * Copyright (c) 2021 IBM Corp + * + * Authors: + * Janosch Frank <[email protected]> + */ #include <asm/asm-offsets.h> .section .text
s390x/snippets/asm/snippet-pv-diag-500.S +9 -0
@@ -1,3 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Diagnose 0x500 snippet used for PV interception tests + * + * Copyright (c) 2021 IBM Corp + * + * Authors: + * Janosch Frank <[email protected]> + */ #include <asm/asm-offsets.h> .section .text
s390x/snippets/asm/snippet-pv-diag-yield.S +9 -0
@@ -1,3 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Diagnose 0x44 and 0x9c snippet used for PV interception tests + * + * Copyright (c) 2021 IBM Corp + * + * Authors: + * Janosch Frank <[email protected]> + */ .section .text xgr %r0, %r0
Signature · 1 line
2.32.0
PATCH v2 6/9 s390x: pv-diags: Cleanup includes
In reply to Janosch FrankThis file has way too much includes. Time to remove some.
--- s390x/pv-diags.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
s390x/pv-diags.c +2 -15
@@ -8,23 +8,10 @@* Janosch Frank <[email protected]> */ #include <libcflat.h> -#include <asm/asm-offsets.h> -#include <asm-generic/barrier.h> -#include <asm/interrupt.h> -#include <asm/pgtable.h> -#include <mmu.h> -#include <asm/page.h> -#include <asm/facility.h> -#include <asm/mem.h> -#include <asm/sigp.h> -#include <smp.h> -#include <alloc_page.h> -#include <vmalloc.h> -#include <sclp.h> #include <snippet.h> #include <sie.h> -#include <uv.h> -#include <asm/uv.h> +#include <sclp.h> +#include <asm/facility.h> static struct vm vm;
Signature · 1 line
2.32.0
PATCH v2 7/9 s390x: css: Cleanup includes
In reply to Janosch FrankMost includes were related to allocation but that's done in the io allocation library so having them in the test doesn't make sense.
--- s390x/css.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
s390x/css.c +3 -6
@@ -9,17 +9,14 @@*/ #include <libcflat.h> -#include <alloc_phys.h> -#include <asm/page.h> -#include <string.h> #include <interrupt.h> -#include <asm/arch_def.h> -#include <alloc_page.h> #include <hardware.h> +#include <asm/arch_def.h> +#include <asm/page.h> +#include <malloc_io.h> #include <css.h> -#include <asm/barrier.h> #define DEFAULT_CU_TYPE 0x3832/* virtio-ccw */ static unsigned long cu_type =DEFAULT_CU_TYPE ;
Signature · 1 line
2.32.0
PATCH v2 8/9 s390x: iep: Cleanup includes
In reply to Janosch FrankWe don't use barriers so let's remove the include.
--- s390x/iep.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
s390x/iep.c +1 -2
@@ -9,11 +9,10 @@*/ #include <libcflat.h> #include <vmalloc.h> +#include <mmu.h> #include <asm/facility.h> #include <asm/interrupt.h> -#include <mmu.h> #include <asm/pgtable.h> -#include <asm-generic/barrier.h> static void test_iep (void ) {
Signature · 1 line
2.32.0
PATCH v2 9/9 s390x: mvpg: Cleanup includes
In reply to Janosch FrankTime to remove unneeded includes.
--- s390x/mvpg.c | 3 --- 1 file changed, 3 deletions(-)
s390x/mvpg.c +0 -3
@@ -9,15 +9,12 @@*/ #include <libcflat.h> #include <asm/asm-offsets.h> -#include <asm-generic/barrier.h> #include <asm/interrupt.h> #include <asm/pgtable.h> #include <mmu.h> #include <asm/page.h> #include <asm/facility.h> #include <asm/mem.h> -#include <asm/sigp.h> -#include <smp.h> #include <alloc_page.h> #include <bitops.h> #include <hardware.h>
Signature · 1 line
2.32.0