s390x: Cleanup and maintenance 2
v3 cover s390x: Cleanup and maintenance 2
Here are a few more fixes and cleanups that improve readability and architectural compliance.
v3:
* Check CC == 1 for rc 0x100 query
* ifndef the UV debug switch
* Replaced tprot fix
* Added a simple fix to the snippet lib linking problem
Janis Schoetterl-Glausch (1):
lib: s390x: Add access key argument to tprot
Janosch Frank (8):
s390x: uv: Tolerate 0x100 query return code
s390x: uv-host: Fence a destroy cpu test on z15
lib: s390x: uv: Fix share return value and print
lib: s390x: uv: Add UVC_ERR_DEBUG switch
lib: s390x: Print PGM code as hex
s390x: Add sthyi cc==0 r2+1 verification
s390x: snippets: Set stackptr and stacktop in cstart.S
s390x: snippets: Define all things that are needed to link the lib
lib/s390x/asm/arch_def.h | 20 +++++++++++++++++--- lib/s390x/asm/uv.h | 21 +++++++++++++-------- lib/s390x/interrupt.c | 2 +- lib/s390x/sclp.c | 2 +- s390x/skrf.c | 3 +-- s390x/snippets/c/cstart.S | 16 +++++++++++++++- s390x/snippets/c/flat.lds | 2 ++ s390x/sthyi.c | 20 +++++++++++--------- s390x/uv-guest.c | 4 +++- s390x/uv-host.c | 19 ++++++++++++------- 10 files changed, 76 insertions(+), 33 deletions(-)
Signature · 1 line
2.30.2
PATCH v3 1/9 s390x: uv: Tolerate 0x100 query return code
RC 0x100 is not an error but a notice that we could have gotten more data from the Ultravisor if we had asked for it. So let's tolerate them in our tests.
--- s390x/uv-guest.c | 4 +++- s390x/uv-host.c | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
s390x/uv-guest.c +3 -1
@@ -71,7 +71,9 @@ static void test_query(void) uvcb.header.len =sizeof (uvcb); cc =uv_call (0 , (u64)&uvcb); -report (cc ==0 && uvcb.header.rc ==UVC_RC_EXECUTED ,"successful query" ); +report ((!cc && uvcb.header.rc ==UVC_RC_EXECUTED ) || + (cc ==1 && uvcb.header.rc ==0x100 ), +"successful query" );/* * These bits have been introduced with the very first
s390x/uv-host.c +5 -3
@@ -385,7 +385,7 @@ static void test_init(void)static void test_query (void ) { -int i =0 ; +int i =0 , cc; uvcb_qui.header.cmd =UVC_CMD_QUI ; uvcb_qui.header.len =sizeof (uvcb_qui);
@@ -400,8 +400,10 @@ static void test_query(void)report (uvcb_qui.header.rc ==0x100 ,"insf length" ); uvcb_qui.header.len =sizeof (uvcb_qui); -uv_call (0 , (uint64_t )&uvcb_qui); -report (uvcb_qui.header.rc ==UVC_RC_EXECUTED ,"successful query" ); + cc =uv_call (0 , (uint64_t )&uvcb_qui); +report ((!cc && uvcb_qui.header.rc ==UVC_RC_EXECUTED ) || + (cc ==1 && uvcb_qui.header.rc ==0x100 ), +"successful query" );for (i =0 ; cmds[i].name; i++)report (uv_query_test_call (cmds[i].call_bit),"%s" , cmds[i].name);
Signature · 1 line
2.30.2
Re: [kvm-unit-tests PATCH v3 1/9] s390x: uv: Tolerate 0x100 query return code
Quoted 42 lines · Janosch Frank
RC
0x100is not an error but a notice that we could have gotten more data from the Ultravisor if we had asked for it. So let's tolerate them in our tests.Signed-off-by Janosch Frank <[email protected]>--- s390x/uv-guest.c | 4 +++- s390x/uv-host.c | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-)s390x/uv-guest.c +3
-1@@ -71,7 +71,9 @@ static void test_query(void) uvcb.header.len =sizeof (uvcb); cc =uv_call (0 , (u64)&uvcb); -report (cc ==0 && uvcb.header.rc ==UVC_RC_EXECUTED ,"successful query" ); +report ((!cc && uvcb.header.rc ==UVC_RC_EXECUTED ) || + (cc ==1 && uvcb.header.rc ==0x100 ), +"successful query" );/* * These bits have been introduced with the very first s390x/uv-host.c +1
-1@@ -385,7 +385,7 @@ static void test_init(void)static void test_query (void ) { -int i =0 ; +int i =0 , cc; uvcb_qui.header.cmd =UVC_CMD_QUI ; uvcb_qui.header.len =sizeof (uvcb_qui);@@ -400,8 +400,10 @@ static void test_query(void)report (uvcb_qui.header.rc ==0x100 ,"insf length" );
s390x/uv-host.c static void test_query(void) · line 409
Quoted 10 lines
s390x/uv-host.c +4
-2uvcb_qui.header.len =sizeof (uvcb_qui); -uv_call (0 , (uint64_t )&uvcb_qui); -report (uvcb_qui.header.rc ==UVC_RC_EXECUTED ,"successful query" ); + cc =uv_call (0 , (uint64_t )&uvcb_qui); +report ((!cc && uvcb_qui.header.rc ==UVC_RC_EXECUTED ) || + (cc ==1 && uvcb_qui.header.rc ==0x100 ), +"successful query" );for (i =0 ; cmds[i].name; i++)report (uv_query_test_call (cmds[i].call_bit),"%s" , cmds[i].name);
PATCH v3 2/9 s390x: uv-host: Fence a destroy cpu test on z15
In reply to Janosch FrankFirmware will not give us the expected return code on z15 so let's fence it for the z15 machine generation.
--- lib/s390x/asm/arch_def.h | 14 ++++++++++++++ s390x/uv-host.c | 11 +++++++---- 2 files changed, 21 insertions(+), 4 deletions(-)
lib/s390x/asm/arch_def.h +14 -0
@@ -219,6 +219,20 @@ 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; + + asmvolatile ("stidp %0" :"=Q" (cpuid)); + cpuid = cpuid >>16 ; + cpuid &=0xffff ; + +return cpuid; +} +static inline int tprot (unsigned long addr) {int cc;
s390x/uv-host.c +7 -4
@@ -111,6 +111,7 @@ 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 ,
@@ -125,10 +126,12 @@ static void test_cpu_destroy(void) "hdr invalid length"); uvcb.header.len +=8 ; - uvcb.handle +=1 ; - rc =uv_call (0 , (uint64_t )&uvcb); -report (rc ==1 && uvcb.header.rc ==UVC_RC_INV_CHANDLE ,"invalid handle" ); - uvcb.handle -=1 ; +if (machineid !=MACHINE_Z15A && machineid !=MACHINE_Z15B ) { + uvcb.handle +=1 ; + rc =uv_call (0 , (uint64_t )&uvcb); +report (rc ==1 && uvcb.header.rc ==UVC_RC_INV_CHANDLE ,"invalid handle" ); + uvcb.handle -=1 ; + } rc =uv_call (0 , (uint64_t )&uvcb);report (rc ==0 && uvcb.header.rc ==UVC_RC_EXECUTED ,"success" );
Signature · 1 line
2.30.2
PATCH v3 3/9 lib: s390x: uv: Fix share return value and print
In reply to Janosch FrankLet's only return 0/1 for success/failure respectively. If needed we can later add rc/rrc pointers so we can check for the reasons of cc==1 cases like we do in the kernel.
As share() might also be used in snippets it's best not to use prints to avoid linking problems so lets remove the report_info().
--- lib/s390x/asm/uv.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
lib/s390x/asm/uv.h +1 -8
@@ -219,15 +219,8 @@ static inline int share(unsigned long addr, u16 cmd) .header.len = sizeof(uvcb), .paddr = addr }; -int cc; - cc =uv_call (0 , (u64)&uvcb); -if (!cc && uvcb.header.rc ==UVC_RC_EXECUTED ) -return 0 ; - -report_info ("uv_call: cmd %04x cc %d response code: %04x" , cc, cmd, - uvcb.header.rc); -return -1 ; +return uv_call (0 , (u64)&uvcb); }/*
Signature · 1 line
2.30.2
PATCH v3 4/9 lib: s390x: uv: Add UVC_ERR_DEBUG switch
In reply to Janosch FrankEvery time something goes wrong in a way we don't expect, we need to add debug prints to some UVC to get the unexpected return code.
Let's just put the printing behind a macro so we can enable it if needed via a simple switch.
--- lib/s390x/asm/uv.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
lib/s390x/asm/uv.h +12 -0
@@ -12,6 +12,11 @@#ifndef _ASMS390X_UV_H_#define _ASMS390X_UV_H_ +/* Enables printing of command code and return codes for failed UVCs */ +#ifndef UVC_ERR_DEBUG +#define UVC_ERR_DEBUG 0 +#endif +#define UVC_RC_EXECUTED 0x0001#define UVC_RC_INV_CMD 0x0002#define UVC_RC_INV_STATE 0x0003
@@ -194,6 +199,13 @@ static inline int uv_call_once(unsigned long r1, unsigned long r2) : [cc] "=d" (cc) : [r1] "a" (r1), [r2] "a" (r2) : "memory", "cc"); + + if (UVC_ERR_DEBUG && cc) +printf ("UV call error: call %x rc %x rrc %x\n" , + ((struct uv_cb_header *)r2)->cmd, + ((struct uv_cb_header *)r2)->rc, + ((struct uv_cb_header *)r2)->rrc); +return cc; }
Signature · 1 line
2.30.2
Re: [kvm-unit-tests PATCH v3 4/9] lib: s390x: uv: Add UVC_ERR_DEBUG switch
Quoted 33 lines · Janosch Frank
Every time something goes wrong in a way we don't expect, we need to add debug prints to some UVC to get the unexpected return code.
Let's just put the printing behind a macro so we can enable it if needed via a simple switch.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- lib/s390x/asm/uv.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)lib/s390x/asm/uv.h +5
-0@@ -12,6 +12,11 @@#ifndef _ASMS390X_UV_H_#define _ASMS390X_UV_H_ +/* Enables printing of command code and return codes for failed UVCs */ +#ifndef UVC_ERR_DEBUG +#define UVC_ERR_DEBUG 0 +#endif +#define UVC_RC_EXECUTED 0x0001#define UVC_RC_INV_CMD 0x0002#define UVC_RC_INV_STATE 0x0003@@ -194,6 +199,13 @@ static inline int uv_call_once(unsigned long r1, unsigned long r2) : [cc] "=d" (cc) : [r1] "a" (r1), [r2] "a" (r2) : "memory", "cc");
lib/s390x/asm/uv.h static inline int uv_call_once(unsigned long r1, unsigned long r2) · line 211
Quoted 10 lines
lib/s390x/asm/uv.h +7
-0+ +if (UVC_ERR_DEBUG && cc) +printf ("UV call error: call %x rc %x rrc %x\n" , + ((struct uv_cb_header *)r2)->cmd, + ((struct uv_cb_header *)r2)->rc, + ((struct uv_cb_header *)r2)->rrc); +return cc; }
Re: [kvm-unit-tests PATCH v3 4/9] lib: s390x: uv: Add UVC_ERR_DEBUG switch
In reply to Janosch FrankQuoted 29 lines · Janosch Frank
Every time something goes wrong in a way we don't expect, we need to add debug prints to some UVC to get the unexpected return code.
Let's just put the printing behind a macro so we can enable it if needed via a simple switch.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- lib/s390x/asm/uv.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)lib/s390x/asm/uv.h +5
-0@@ -12,6 +12,11 @@#ifndef _ASMS390X_UV_H_#define _ASMS390X_UV_H_ +/* Enables printing of command code and return codes for failed UVCs */ +#ifndef UVC_ERR_DEBUG +#define UVC_ERR_DEBUG 0 +#endif +#define UVC_RC_EXECUTED 0x0001#define UVC_RC_INV_CMD 0x0002#define UVC_RC_INV_STATE 0x0003
lib/s390x/asm/uv.h static inline int uv_call_once(unsigned long r1, unsigned long r2) · line 203
Quoted 5 lines
lib/s390x/asm/uv.h +2
-0@@ -194,6 +199,13 @@ static inline int uv_call_once(unsigned long r1, unsigned long r2) : [cc] "=d" (cc) : [r1] "a" (r1), [r2] "a" (r2) : "memory", "cc"); + + if (UVC_ERR_DEBUG && cc)
That needs to check cc == 1...
Quoted 9 lines
lib/s390x/asm/uv.h +5
-0+printf ("UV call error: call %x rc %x rrc %x\n" , + ((struct uv_cb_header *)r2)->cmd, + ((struct uv_cb_header *)r2)->rc, + ((struct uv_cb_header *)r2)->rrc); +return cc; }
PATCH v3 5/9 lib: s390x: Add access key argument to tprot
In reply to Janosch FrankFrom: Janis Schoetterl-Glausch <[email protected]>
Currently there is only one callee passing a non zero key, but having the argument will be useful in the future.
--- lib/s390x/asm/arch_def.h | 6 +++--- lib/s390x/sclp.c | 2 +- s390x/skrf.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)
lib/s390x/asm/arch_def.h +3 -3
@@ -233,15 +233,15 @@ static inline uint16_t get_machine_id(void)return cpuid; } -static inline int tprot (unsigned long addr) +static inline int tprot (unsigned long addr,char access_key) {int cc; asmvolatile ( -" tprot 0(%1),0\n" +" tprot 0(%1),0(%2)\n" " ipm %0\n" " srl %0,28\n" - :"=d" (cc) :"a" (addr) :"cc" ); + :"=d" (cc) :"a" (addr),"a" (access_key <<4 ) :"cc" );return cc; }
lib/s390x/sclp.c +1 -1
@@ -217,7 +217,7 @@ void sclp_memory_setup(void)/* probe for r/w memory up to max memory size */ while (ram_size < max_ram_size) {expect_pgm_int (); - cc =tprot (ram_size + storage_increment_size -1 ); + cc =tprot (ram_size + storage_increment_size -1 ,0 );/* stop once we receive an exception or have protected memory */ if (clear_pgm_int () || cc !=0 )break ;
s390x/skrf.c +1 -2
@@ -103,8 +103,7 @@ static void test_tprot(void) {report_prefix_push ("tprot" );expect_pgm_int (); - asmvolatile ("tprot %[addr],0xf0(0)\n" - : : [addr]"a" (pagebuf) : ); +tprot ((unsigned long )pagebuf,0xf );check_pgm_int_code (PGM_INT_CODE_SPECIAL_OPERATION );report_prefix_pop (); }
Signature · 1 line
2.30.2
Re: [kvm-unit-tests PATCH v3 5/9] lib: s390x: Add access key argument to tprot
Quoted 54 lines · Janosch Frank
From: Janis Schoetterl-Glausch <[email protected]>
Currently there is only one callee passing a non zero key, but having the argument will be useful in the future.
Signed-off-by Janis Schoetterl-Glausch <[email protected]>--- lib/s390x/asm/arch_def.h | 6 +++--- lib/s390x/sclp.c | 2 +- s390x/skrf.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-)lib/s390x/asm/arch_def.h +3
-3@@ -233,15 +233,15 @@ static inline uint16_t get_machine_id(void)return cpuid; } -static inline int tprot (unsigned long addr) +static inline int tprot (unsigned long addr,char access_key) {int cc; asmvolatile ( -" tprot 0(%1),0\n" +" tprot 0(%1),0(%2)\n" " ipm %0\n" " srl %0,28\n" - :"=d" (cc) :"a" (addr) :"cc" ); + :"=d" (cc) :"a" (addr),"a" (access_key <<4 ) :"cc" );return cc; }lib/s390x/sclp.c +1
-1@@ -217,7 +217,7 @@ void sclp_memory_setup(void)/* probe for r/w memory up to max memory size */ while (ram_size < max_ram_size) {expect_pgm_int (); - cc =tprot (ram_size + storage_increment_size -1 ); + cc =tprot (ram_size + storage_increment_size -1 ,0 );/* stop once we receive an exception or have protected memory */ if (clear_pgm_int () || cc !=0 )break ;s390x/skrf.c +0
-0
s390x/skrf.c static void test_tprot(void) · line 109
Quoted 9 lines
s390x/skrf.c +1
-2@@ -103,8 +103,7 @@ static void test_tprot(void) {report_prefix_push ("tprot" );expect_pgm_int (); - asmvolatile ("tprot %[addr],0xf0(0)\n" - : : [addr]"a" (pagebuf) : ); +tprot ((unsigned long )pagebuf,0xf );check_pgm_int_code (PGM_INT_CODE_SPECIAL_OPERATION );report_prefix_pop (); }
PATCH v3 6/9 lib: s390x: Print PGM code as hex
In reply to Janosch FrankWe have them defined as hex constants in lib/s390x/asm/arch_def.h so why not print them as hex values?
--- lib/s390x/interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/s390x/interrupt.c +1 -1
@@ -169,7 +169,7 @@ static void print_pgm_info(struct stack_frame_int *stack) lc->pgm_old_psw.addr <= (uintptr_t)sie_exit);printf ("\n" ); -printf ("Unexpected program interrupt %s: %d on cpu %d at %#lx, ilen %d\n" , +printf ("Unexpected program interrupt %s: %#x on cpu %d at %#lx, ilen %d\n" , in_sie ?"in SIE" :"" , lc->pgm_int_code,stap (), lc->pgm_old_psw.addr, lc->pgm_int_id);print_int_regs (stack);
Signature · 1 line
2.30.2
PATCH v3 7/9 s390x: Add sthyi cc==0 r2+1 verification
In reply to Janosch FrankOn success r2 + 1 should be 0, let's also check for that.
--- s390x/sthyi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
s390x/sthyi.c +11 -9
@@ -24,16 +24,16 @@ static inline int sthyi(uint64_t vaddr, uint64_t fcode, uint64_t *rc, { register uint64_t code asm("0") = fcode; register uint64_t addr asm("2") = vaddr; - register uint64_t rc3 asm("3") = 0; + register uint64_t rc3 asm("3") = 42;int cc =0 ; - asmvolatile (".insn rre,0xB2560000,%[r1],%[r2]\n" -"ipm %[cc]\n" -"srl %[cc],28\n" - : [cc]"=d" (cc) - : [code]"d" (code), [addr]"a" (addr), [r1]"i" (r1), - [r2]"i" (r2) - :"memory" ,"cc" ,"r3" ); + asmvolatile ( +".insn rre,0xB2560000,%[r1],%[r2]\n" +"ipm %[cc]\n" +"srl %[cc],28\n" + : [cc]"=d" (cc),"+d" (rc3) + : [code]"d" (code), [addr]"a" (addr), [r1]"i" (r1), [r2]"i" (r2) + :"memory" ,"cc" );if (rc) *rc = rc3;return cc;
@@ -139,16 +139,18 @@ static void test_fcode0(void)struct sthyi_hdr_sctn *hdr;struct sthyi_mach_sctn *mach;struct sthyi_par_sctn *par; +uint64_t rc =42 ;/* Zero destination memory. */ memset (pagebuf,0 ,PAGE_SIZE );report_prefix_push ("fcode 0" ); -sthyi ((uint64_t )pagebuf,0 ,NULL ,0 ,2 ); +sthyi ((uint64_t )pagebuf,0 , &rc,0 ,2 ); hdr = (void *)pagebuf; mach = (void *)pagebuf + hdr->INFMOFF; par = (void *)pagebuf + hdr->INFPOFF; +report (!rc,"r2 + 1 == 0" );test_fcode0_hdr (hdr);test_fcode0_mach (mach);test_fcode0_par (par);
Signature · 1 line
2.30.2
Re: [kvm-unit-tests PATCH v3 7/9] s390x: Add sthyi cc==0 r2+1 verification
Quoted 44 lines · Janosch Frank
On success r2 + 1 should be 0, let's also check for that.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- s390x/sthyi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)s390x/sthyi.c +9
-8@@ -24,16 +24,16 @@ static inline int sthyi(uint64_t vaddr, uint64_t fcode, uint64_t *rc, { register uint64_t code asm("0") = fcode; register uint64_t addr asm("2") = vaddr; - register uint64_t rc3 asm("3") = 0; + register uint64_t rc3 asm("3") = 42;int cc =0 ; - asmvolatile (".insn rre,0xB2560000,%[r1],%[r2]\n" -"ipm %[cc]\n" -"srl %[cc],28\n" - : [cc]"=d" (cc) - : [code]"d" (code), [addr]"a" (addr), [r1]"i" (r1), - [r2]"i" (r2) - :"memory" ,"cc" ,"r3" ); + asmvolatile ( +".insn rre,0xB2560000,%[r1],%[r2]\n" +"ipm %[cc]\n" +"srl %[cc],28\n" + : [cc]"=d" (cc),"+d" (rc3) + : [code]"d" (code), [addr]"a" (addr), [r1]"i" (r1), [r2]"i" (r2) + :"memory" ,"cc" );if (rc) *rc = rc3;return cc;@@ -139,16 +139,18 @@ static void test_fcode0(void)struct sthyi_hdr_sctn *hdr;struct sthyi_mach_sctn *mach;struct sthyi_par_sctn *par; +uint64_t rc =42 ;/* Zero destination memory. */
s390x/sthyi.c static void test_fcode0(void) · line 153
Quoted 10 lines
s390x/sthyi.c +2
-1memset (pagebuf,0 ,PAGE_SIZE );report_prefix_push ("fcode 0" ); -sthyi ((uint64_t )pagebuf,0 ,NULL ,0 ,2 ); +sthyi ((uint64_t )pagebuf,0 , &rc,0 ,2 ); hdr = (void *)pagebuf; mach = (void *)pagebuf + hdr->INFMOFF; par = (void *)pagebuf + hdr->INFPOFF; +report (!rc,"r2 + 1 == 0" );
Could you please check for "rc == CODE_SUCCES" (since we've got that for this purpose)?
With that change:
Re: [kvm-unit-tests PATCH v3 7/9] s390x: Add sthyi cc==0 r2+1 verification
Quoted 54 lines · Thomas Huth
Quoted 53 lines · Janosch Frank
On success r2 + 1 should be 0, let's also check for that.
Signed-off-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>--- s390x/sthyi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)s390x/sthyi.c +10
-9@@ -24,16 +24,16 @@ static inline int sthyi(uint64_t vaddr, uint64_t fcode, uint64_t *rc, { register uint64_t code asm("0") = fcode; register uint64_t addr asm("2") = vaddr; - register uint64_t rc3 asm("3") = 0; + register uint64_t rc3 asm("3") = 42;int cc =0 ; - asmvolatile (".insn rre,0xB2560000,%[r1],%[r2]\n" -"ipm %[cc]\n" -"srl %[cc],28\n" - : [cc]"=d" (cc) - : [code]"d" (code), [addr]"a" (addr), [r1]"i" (r1), - [r2]"i" (r2) - :"memory" ,"cc" ,"r3" ); + asmvolatile ( +".insn rre,0xB2560000,%[r1],%[r2]\n" +"ipm %[cc]\n" +"srl %[cc],28\n" + : [cc]"=d" (cc),"+d" (rc3) + : [code]"d" (code), [addr]"a" (addr), [r1]"i" (r1), [r2]"i" (r2) + :"memory" ,"cc" );if (rc) *rc = rc3;return cc;@@ -139,16 +139,18 @@ static void test_fcode0(void)struct sthyi_hdr_sctn *hdr;struct sthyi_mach_sctn *mach;struct sthyi_par_sctn *par; +uint64_t rc =42 ;/* Zero destination memory. */ memset (pagebuf,0 ,PAGE_SIZE );report_prefix_push ("fcode 0" ); -sthyi ((uint64_t )pagebuf,0 ,NULL ,0 ,2 ); +sthyi ((uint64_t )pagebuf,0 , &rc,0 ,2 ); hdr = (void *)pagebuf; mach = (void *)pagebuf + hdr->INFMOFF; par = (void *)pagebuf + hdr->INFPOFF;
Quoted 4 lines
s390x/sthyi.c static void test_fcode0(void) · line 153
Quoted 1 line
s390x/sthyi.c +1
-0+report (!rc,"r2 + 1 == 0" );Could you please check for "rc ==
CODE_SUCCES" (since we've got that for this purpose)?
I'll do one better and also check for !cc
Quoted 4 lines
With that change:
Reviewed-by Thomas Huth <[email protected]>
Thanks!
PATCH v3 8/9 s390x: snippets: Set stackptr and stacktop in cstart.S
In reply to Janosch FrankWe have a stack, so why not define it and be a step closer to include the lib into the snippets.
--- s390x/snippets/c/cstart.S | 2 +- s390x/snippets/c/flat.lds | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
s390x/snippets/c/cstart.S +1 -1
@@ -17,7 +17,7 @@ start: xgr \i,\i .endr /* 0x3000 is the stack page for now */ - lghi %r15, 0x4000 - 160 + lghi %r15, stackptr sam64 brasl %r14, main /* For now let's only use cpu 0 in snippets so this will always work. */
s390x/snippets/c/flat.lds +2 -0
@@ -15,6 +15,8 @@ SECTIONS QUAD(0x0000000000004000) } . = 0x4000; + stackptr = . - 160; + stacktop = .; .text : { *(.init) *(.text)
Signature · 1 line
2.30.2
Re: [kvm-unit-tests PATCH v3 8/9] s390x: snippets: Set stackptr and stacktop in cstart.S
Quoted 14 lines · Janosch Frank
We have a stack, so why not define it and be a step closer to include the lib into the snippets.
Signed-off-by Janosch Frank <[email protected]>--- s390x/snippets/c/cstart.S | 2 +- s390x/snippets/c/flat.lds | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)s390x/snippets/c/cstart.S +0
-0
s390x/snippets/c/cstart.S start: · line 20
Quoted 5 lines
s390x/snippets/c/cstart.S +1
-1@@ -17,7 +17,7 @@ start: xgr \i,\i .endr /* 0x3000 is the stack page for now */ - lghi %r15, 0x4000 - 160 + lghi %r15, stackptr
I already wanted to ask you to replace the magic value 0x4000 here ... great to see that you already did it :-)
Re: [kvm-unit-tests PATCH v3 8/9] s390x: snippets: Set stackptr and stacktop in cstart.S
Quoted 10 lines · Thomas Huth
Quoted 9 lines · Janosch Frank
We have a stack, so why not define it and be a step closer to include the lib into the snippets.
Signed-off-by Janosch Frank <[email protected]>--- s390x/snippets/c/cstart.S | 2 +- s390x/snippets/c/flat.lds | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Quoted 13 lines
s390x/snippets/c/cstart.S start: · line 20
Quoted 10 lines
s390x/snippets/c/cstart.S +1
-1@@ -17,7 +17,7 @@ start: xgr \i,\i .endr /* 0x3000 is the stack page for now */ - lghi %r15, 0x4000 - 160 + lghi %r15, stackptrI already wanted to ask you to replace the magic value
0x4000here ... great to see that you already did it :-)
Magic mind reading :-)
Quoted 2 lines
Reviewed-by Thomas Huth <[email protected]>
Thanks!
PATCH v3 9/9 s390x: snippets: Define all things that are needed to link the lib
In reply to Janosch FrankLet's just define all of the needed things so we can link libcflat.
A significant portion of the lib won't work, like printing and allocation but we can still use things like memset() which already improves our lives significantly.
--- s390x/snippets/c/cstart.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
s390x/snippets/c/cstart.S +14 -0
@@ -20,6 +20,20 @@ start: lghi %r15, stackptr sam64 brasl %r14, main +/* + * Defining things that the linker needs to link in libcflat and make + * them result in sigp stop if called. + */ +.globl sie_exit +.globl sie_entry +.globl smp_cpu_setup_state +.globl ipl_args +.globl auxinfo +sie_exit: +sie_entry: +smp_cpu_setup_state: +ipl_args: +auxinfo: /* For now let's only use cpu 0 in snippets so this will always work. */ xgr %r0, %r0 sigp %r2, %r0, SIGP_STOP
Signature · 1 line
2.30.2
Re: [kvm-unit-tests PATCH v3 9/9] s390x: snippets: Define all things that are needed to link the lib
Quoted 23 lines · Janosch Frank
Let's just define all of the needed things so we can link libcflat.
A significant portion of the lib won't work, like printing and allocation but we can still use things like
memset()which already improves our lives significantly.Signed-off-by Janosch Frank <[email protected]>--- s390x/snippets/c/cstart.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)s390x/snippets/c/cstart.S +4
-0@@ -20,6 +20,20 @@ start: lghi %r15, stackptr sam64 brasl %r14, main +/* + * Defining things that the linker needs to link in libcflat and make + * them result in sigp stop if called. + */
s390x/snippets/c/cstart.S start: · line 36
Quoted 10 lines
s390x/snippets/c/cstart.S +10
-0+.globl sie_exit +.globl sie_entry +.globl smp_cpu_setup_state +.globl ipl_args +.globl auxinfo +sie_exit: +sie_entry: +smp_cpu_setup_state: +ipl_args: +auxinfo:
I think this likely could be done in a somewhat nicer way, e.g. by moving mem_init() and sclp_memory_setup() into a separate .c file in the lib, and by moving expect_pgm_int(), fixup_pgm_int() and friends into another separate .c file, too, so that we e.g. do not need to link against the code that uses sie_entry and sie_exit ... but that's a major rework on its own, so for the time being:
Re: [kvm-unit-tests PATCH v3 9/9] s390x: snippets: Define all things that are needed to link the lib
Quoted 28 lines · Thomas Huth
Quoted 27 lines · Janosch Frank
Let's just define all of the needed things so we can link libcflat.
A significant portion of the lib won't work, like printing and allocation but we can still use things like
memset()which already improves our lives significantly.Signed-off-by Janosch Frank <[email protected]>--- s390x/snippets/c/cstart.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)s390x/snippets/c/cstart.S +8
-0@@ -20,6 +20,20 @@ start: lghi %r15, stackptr sam64 brasl %r14, main +/* + * Defining things that the linker needs to link in libcflat and make + * them result in sigp stop if called. + */ +.globl sie_exit +.globl sie_entry +.globl smp_cpu_setup_state +.globl ipl_args
Quoted 8 lines
s390x/snippets/c/cstart.S start: · line 36
Quoted 6 lines
s390x/snippets/c/cstart.S +6
-0+.globl auxinfo +sie_exit: +sie_entry: +smp_cpu_setup_state: +ipl_args: +auxinfo:I think this likely could be done in a somewhat nicer way, e.g. by moving
Definitely, as I said, it's a simple fix
Quoted 8 lines
mem_init()andsclp_memory_setup()into a separate .c file in the lib, and by movingexpect_pgm_int(),fixup_pgm_int()and friends into another separate .c file, too, so that we e.g. do not need to link against the code that usessie_entryandsie_exit... but that's a major rework on its own, so for the time being:Acked-by Thomas Huth <[email protected]>
Thanks
Re: [kvm-unit-tests PATCH v3 9/9] s390x: snippets: Define all things that are needed to link the lib
Quoted 38 lines · Janosch Frank
Quoted 28 lines · Thomas Huth
Quoted 27 lines · Janosch Frank
Let's just define all of the needed things so we can link libcflat.
A significant portion of the lib won't work, like printing and allocation but we can still use things like
memset()which already improves our lives significantly.Signed-off-by Janosch Frank <[email protected]>---
s390x/snippets/c/cstart.S| 14 ++++++++++++++1 file changed, 14 insertions(+)s390x/snippets/c/cstart.S +0
-0@@ -20,6 +20,20 @@ start:lghi %r15, stackptr
sam64
brasl %r14, main
+/*
+ * Defining things that the linker needs to link in libcflat and make
+ * them result in sigp stop if called.
+ */
+.globlsie_exit
+.globlsie_entry
+.globlsmp_cpu_setup_state
+.globlipl_argsQuoted 8 lines
s390x/snippets/c/cstart.S
Quoted 6 lines
+.globl auxinfo
s390x/snippets/c/cstart.S +5
-0+sie_exit: +sie_entry: +smp_cpu_setup_state: +ipl_args: +auxinfo:I think this likely could be done in a somewhat nicer way, e.g. by moving
Quoted 1 line
Definitely, as I said, it's a simple fix
Alternatively, something like this might work, too:
s390x/Makefile +1 -1
@@ -80,7 +80,7 @@ asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o FLATLIBS = $(libcflat) SNIPPET_DIR = $(TEST_DIR)/snippets -snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o +snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o lib/auxinfo.o # perquisites (=guests) for the snippet hosts. # $(TEST_DIR)/<snippet-host>.elf: snippets = $(SNIPPET_DIR)/<c/asm>/<snippet>.gbin
s390x/snippets/c/cstart.S +4 -0
@@ -21,5 +21,9 @@ start: sam64 brasl %r14, main /* For now let's only use cpu 0 in snippets so this will always work. */ +.global puts +.global exit +puts: +exit: xgr %r0, %r0 sigp %r2, %r0, SIGP_STOP
I think that's more clear this way, since we're fencing the functions that caused the dependencies to the other functions from your patch. What do you think?
Thomas
Re: [kvm-unit-tests PATCH v3 9/9] s390x: snippets: Define all things that are needed to link the lib
Quoted 39 lines · Thomas Huth
Quoted 38 lines · Janosch Frank
Quoted 36 lines · Thomas Huth
Quoted 23 lines · Janosch Frank
Let's just define all of the needed things so we can link libcflat.
A significant portion of the lib won't work, like printing and allocation but we can still use things like
memset()which already improves our lives significantly.Signed-off-by Janosch Frank <[email protected]>--- s390x/snippets/c/cstart.S | 14 ++++++++++++++ 1 file changed, 14 insertions(+)s390x/snippets/c/cstart.S +4
-0@@ -20,6 +20,20 @@ start: lghi %r15, stackptr sam64 brasl %r14, main +/* + * Defining things that the linker needs to link in libcflat and make + * them result in sigp stop if called. + */s390x/snippets/c/cstart.S start: · line 36
Quoted 10 lines
s390x/snippets/c/cstart.S +10
-0+.globl sie_exit +.globl sie_entry +.globl smp_cpu_setup_state +.globl ipl_args +.globl auxinfo +sie_exit: +sie_entry: +smp_cpu_setup_state: +ipl_args: +auxinfo:I think this likely could be done in a somewhat nicer way, e.g. by moving
Quoted 3 lines
Quoted 1 line
Definitely, as I said, it's a simple fix
Alternatively, something like this might work, too:
Seems like it works for the two tests that I checked. Would you mind sending a proper patch?
I'd like to send out a pull today or on Monday.
Quoted 33 lines
s390x/Makefile +1
-1@@ -80,7 +80,7 @@ asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o FLATLIBS = $(libcflat) SNIPPET_DIR = $(TEST_DIR)/snippets -snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o +snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o lib/auxinfo.o # perquisites (=guests) for the snippet hosts. # $(TEST_DIR)/<snippet-host>.elf: snippets = $(SNIPPET_DIR)/<c/asm>/<snippet>.gbins390x/snippets/c/cstart.S +4
-0@@ -21,5 +21,9 @@ start: sam64 brasl %r14, main /* For now let's only use cpu 0 in snippets so this will always work. */ +.global puts +.global exit +puts: +exit: xgr %r0, %r0 sigp %r2, %r0, SIGP_STOPI think that's more clear this way, since we're fencing the functions that caused the dependencies to the other functions from your patch. What do you think?
Thomas