s390x patch queue June 03 2011
Hi,
This is my current patch queue for s390x related work. It contains:
* compile fixes
* add temp_frees where missing
* fix LMH, CKSM instructions
* update bootloader for increased bootup speed
* implement LRVGR instruction
With these patches, networking finally works for emulated s390x guests.
Please pull.
Alex
The following changes since commit 578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e:
Juha Riihim?ki (1):
audio: fix integer overflow expression
are available in the git repository at:
git://repo.or.cz/qemu/agraf.git s390-next
Alexander Graf (4):
s390x: update zipl rom
s390x: free tmp explicitly in every opcode for disas_a5()
s390x: fix cksm instruction
s390x: implement lrvgr
Stefan Weil (9):
target-s390x: Fix build for non-linux hosts
target-s390x: Fix wrong argument in call of tcg_gen_shl_i64()
target-s390x: Fix duplicate call of tcg_temp_new_i64
target-s390x: Add missing tcg_temp_free_i64() in gen_jcc()
target-s390x: Add missing tcg_temp_free_i64() in do_mh()
target-s390x: Add missing tcg_temp_free_i64() in disas_b2()
target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(),
opc == 0x8e
target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(),
opc == 0x90 target-s390x: Add missing tcg_temp_free_i32()
pc-bios/s390-zipl.rom | Bin 3336 -> 3304 bytes target-s390x/helper.c | 5 ----- target-s390x/op_helper.c | 28 ++++++++-------------------- target-s390x/translate.c | 31 +++++++++++++++++++++++++++---- 4 files changed, 35 insertions(+), 29 deletions(-)
PATCH 1/13 s390x: update zipl rom
The zipl bootloader rom we have has seen some dramatic speedups upstream, so let's update it to improve the experience when booting a guest image.
This binary is based on commit id 9a0842dd9823d529f721b418d554f17c72e009e3.
--- pc-bios/s390-zipl.rom | Bin 3336 -> 3304 bytes 1 files changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-zipl.rom binary +0 -0
Signature · 1 line
1.6.0.2
PATCH 2/13 target-s390x: Fix build for non-linux hosts
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
linux/kvm.h is not always available for compilation.
Neither linux/kvm.h nor kvm.h are needed, so remove both which also fixes the build problem for non-linux hosts.
--- target-s390x/helper.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
target-s390x/helper.c +0 -5
@@ -28,11 +28,6 @@#include "qemu-common.h" #include "qemu-timer.h" -#if !defined(CONFIG_USER_ONLY ) -#include <linux/kvm.h> -#include "kvm.h" -#endif -//#define DEBUG_S390 //#define DEBUG_S390_PTE //#define DEBUG_S390_STDOUT
Signature · 1 line
1.6.0.2
PATCH 3/13 target-s390x: Fix wrong argument in call of tcg_gen_shl_i64()
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
tcg_gen_shl_i64 needs a 3rd argument of type TCGv_i64. Set tmp4 so it can be used here.
v2:
Don't call tcg_const_i64() inside of the loop because it creates additional code.
--- target-s390x/translate.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
target-s390x/translate.c +2 -2
@@ -2056,7 +2056,7 @@ do_mh:even for very long ones... */ tmp =get_address (s,0 , b2, d2); tmp3 =tcg_const_i64 (stm_len); - tmp4 =tcg_const_i64 (32 ); + tmp4 =tcg_const_i64 (op ==0x26 ?32 :4 );for (i = r1;; i = (i +1 ) %16 ) {switch (op) {case 0x4 :
@@ -2070,7 +2070,7 @@ do_mh:#else tmp2 =tcg_temp_new_i64 ();tcg_gen_qemu_ld32u (tmp2, tmp,get_mem_index (s)); -tcg_gen_shl_i64 (tmp2, tmp2,4 ); +tcg_gen_shl_i64 (tmp2, tmp2, tmp4);tcg_gen_ext32u_i64 (regs[i], regs[i]);tcg_gen_or_i64 (regs[i], regs[i], tmp2);#endif
Signature · 1 line
1.6.0.2
PATCH 4/13 target-s390x: Fix duplicate call of tcg_temp_new_i64
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
tmp2 = tcg_temp_new_i64() is already executed unconditionally, so there is no need to call it a second time for 64 bit hosts.
--- target-s390x/translate.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
target-s390x/translate.c +0 -1
@@ -2068,7 +2068,6 @@ do_mh:tcg_gen_qemu_ld32u (tmp2, tmp,get_mem_index (s));tcg_gen_trunc_i64_i32 (TCGV_HIGH (regs[i]), tmp2);#else - tmp2 =tcg_temp_new_i64 ();tcg_gen_qemu_ld32u (tmp2, tmp,get_mem_index (s));tcg_gen_shl_i64 (tmp2, tmp2, tmp4);tcg_gen_ext32u_i64 (regs[i], regs[i]);
Signature · 1 line
1.6.0.2
PATCH 5/13 target-s390x: Add missing tcg_temp_free_i64() in gen_jcc()
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
--- target-s390x/translate.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
target-s390x/translate.c +1 -0
@@ -1095,6 +1095,7 @@ static void gen_jcc(DisasContext *s, uint32_t mask, int skip)tcg_gen_brcondi_i64 (TCG_COND_EQ , tmp64,0 , skip);break ;default : +tcg_temp_free_i64 (tmp64); goto do_dynamic; }tcg_temp_free_i64 (tmp64);
Signature · 1 line
1.6.0.2
PATCH 6/13 target-s390x: Add missing tcg_temp_free_i64() in do_mh()
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
--- target-s390x/translate.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
target-s390x/translate.c +1 -0
@@ -2094,6 +2094,7 @@ do_mh:tcg_gen_add_i64 (tmp, tmp, tmp3); }tcg_temp_free_i64 (tmp); +tcg_temp_free_i64 (tmp3);tcg_temp_free_i64 (tmp4);break ;case 0x2c :/* STCMH R1,M3,D2(B2) [RSY] */
Signature · 1 line
1.6.0.2
PATCH 7/13 target-s390x: Add missing tcg_temp_free_i64() in disas_b2()
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
--- target-s390x/translate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
target-s390x/translate.c +2 -0
@@ -2964,6 +2964,8 @@ static void disas_b2(DisasContext *s, int op, uint32_t insn)/* we need to keep cc_op intact */ s->is_jmp =DISAS_JUMP ;tcg_temp_free_i64 (tmp); +tcg_temp_free_i64 (tmp2); +tcg_temp_free_i64 (tmp3);break ;case 0x20 :/* SERVC R1,R2 [RRE] */ /* SCLP Service call (PV hypercall) */
Signature · 1 line
1.6.0.2
PATCH 8/13 target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x8e
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
--- target-s390x/translate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
target-s390x/translate.c +2 -0
@@ -4596,6 +4596,8 @@ static void disas_s390_insn(DisasContext *s)store_reg32 (r1, tmp32_1);tcg_gen_trunc_i64_i32 (tmp32_2, tmp2);store_reg32 (r1 +1 , tmp32_2); +tcg_temp_free_i64 (tmp); +tcg_temp_free_i64 (tmp2);break ;case 0x98 :/* LM R1,R3,D2(B2) [RS] */ case 0x90 :/* STM R1,R3,D2(B2) [RS] */
Signature · 1 line
1.6.0.2
PATCH 9/13 target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x90
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
--- target-s390x/translate.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
target-s390x/translate.c +1 -0
@@ -4621,6 +4621,7 @@ static void disas_s390_insn(DisasContext *s) }tcg_gen_add_i64 (tmp, tmp, tmp3); } +tcg_temp_free_i64 (tmp);tcg_temp_free_i64 (tmp2);tcg_temp_free_i64 (tmp3);tcg_temp_free_i64 (tmp4);
Signature · 1 line
1.6.0.2
PATCH 10/13 target-s390x: Add missing tcg_temp_free_i32()
In reply to Alexander GrafFrom: Stefan Weil <[email protected]>
--- target-s390x/translate.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
target-s390x/translate.c +3 -0
@@ -1078,9 +1078,12 @@ static void gen_jcc(DisasContext *s, uint32_t mask, int skip)tcg_gen_brcondi_i32 (TCG_COND_EQ , tmp,0 , skip);break ;default : +tcg_temp_free_i32 (tmp); +tcg_temp_free_i32 (tmp2); goto do_dynamic; }tcg_temp_free_i32 (tmp); +tcg_temp_free_i32 (tmp2);account_inline_branch (s);break ;case CC_OP_TM_64 :
Signature · 1 line
1.6.0.2
PATCH 11/13 s390x: free tmp explicitly in every opcode for disas_a5()
In reply to Alexander GrafThe disas_a5() function provided a TCG tmp variable which was populated by the respective opcode implementations, but freed at the end of the function in generic code.
That makes it really hard for code review, so let's move the freeing to the same scope as the actual allocation.
--- target-s390x/translate.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
target-s390x/translate.c +12 -1
@@ -2334,18 +2334,22 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2)case 0x0 :/* IIHH R1,I2 [RI] */ tmp =tcg_const_i64 (i2);tcg_gen_deposit_i64 (regs[r1], regs[r1], tmp,48 ,16 ); +tcg_temp_free_i64 (tmp);break ;case 0x1 :/* IIHL R1,I2 [RI] */ tmp =tcg_const_i64 (i2);tcg_gen_deposit_i64 (regs[r1], regs[r1], tmp,32 ,16 ); +tcg_temp_free_i64 (tmp);break ;case 0x2 :/* IILH R1,I2 [RI] */ tmp =tcg_const_i64 (i2);tcg_gen_deposit_i64 (regs[r1], regs[r1], tmp,16 ,16 ); +tcg_temp_free_i64 (tmp);break ;case 0x3 :/* IILL R1,I2 [RI] */ tmp =tcg_const_i64 (i2);tcg_gen_deposit_i64 (regs[r1], regs[r1], tmp,0 ,16 ); +tcg_temp_free_i64 (tmp);break ;case 0x4 :/* NIHH R1,I2 [RI] */ case 0x8 :/* OIHH R1,I2 [RI] */
@@ -2370,6 +2374,7 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2)set_cc_nz_u32 (s, tmp32);tcg_temp_free_i64 (tmp2);tcg_temp_free_i32 (tmp32); +tcg_temp_free_i64 (tmp);break ;case 0x5 :/* NIHL R1,I2 [RI] */ case 0x9 :/* OIHL R1,I2 [RI] */
@@ -2395,6 +2400,7 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2)set_cc_nz_u32 (s, tmp32);tcg_temp_free_i64 (tmp2);tcg_temp_free_i32 (tmp32); +tcg_temp_free_i64 (tmp);break ;case 0x6 :/* NILH R1,I2 [RI] */ case 0xa :/* OILH R1,I2 [RI] */
@@ -2420,6 +2426,7 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2)set_cc_nz_u32 (s, tmp32);tcg_temp_free_i64 (tmp2);tcg_temp_free_i32 (tmp32); +tcg_temp_free_i64 (tmp);break ;case 0x7 :/* NILL R1,I2 [RI] */ case 0xb :/* OILL R1,I2 [RI] */
@@ -2443,29 +2450,33 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2)set_cc_nz_u32 (s, tmp32);/* signedness should not matter here */ tcg_temp_free_i64 (tmp2);tcg_temp_free_i32 (tmp32); +tcg_temp_free_i64 (tmp);break ;case 0xc :/* LLIHH R1,I2 [RI] */ tmp =tcg_const_i64 ( ((uint64_t )i2) <<48 );store_reg (r1, tmp); +tcg_temp_free_i64 (tmp);break ;case 0xd :/* LLIHL R1,I2 [RI] */ tmp =tcg_const_i64 ( ((uint64_t )i2) <<32 );store_reg (r1, tmp); +tcg_temp_free_i64 (tmp);break ;case 0xe :/* LLILH R1,I2 [RI] */ tmp =tcg_const_i64 ( ((uint64_t )i2) <<16 );store_reg (r1, tmp); +tcg_temp_free_i64 (tmp);break ;case 0xf :/* LLILL R1,I2 [RI] */ tmp =tcg_const_i64 (i2);store_reg (r1, tmp); +tcg_temp_free_i64 (tmp);break ;default :LOG_DISAS ("illegal a5 operation 0x%x\n" , op);gen_illegal_opcode (s,2 );return ; } -tcg_temp_free_i64 (tmp); }static void disas_a7 (DisasContext *s,int op,int r1,int i2)
Signature · 1 line
1.6.0.2
PATCH 12/13 s390x: fix cksm instruction
In reply to Alexander GrafThe cksm instruction was implemented incorrectly, rendering UDP and TCP checksum calculation wrong, making an emulated s390x Linux guest break in most networking operations.
This patch fixes odd end checksum calculation, takes the input register as input for the checksum and optimizes the overflow pieces by a bit.
--- target-s390x/op_helper.c | 28 ++++++++-------------------- 1 files changed, 8 insertions(+), 20 deletions(-)
target-s390x/op_helper.c +8 -20
@@ -1731,25 +1731,15 @@ void HELPER(sqdbr)(uint32_t f1, uint32_t f2) env->fregs[f1].d =float64_sqrt (env->fregs[f2].d, &env->fpu_status); } -static inline uint64_t cksm_overflow (uint64_t cksm) -{ -if (cksm >0xffffffffULL ) { - cksm &=0xffffffffULL ; - cksm++; - } -return cksm; -} -/* checksum */ void HELPER (cksm )(uint32_t r1,uint32_t r2) {uint64_t src =get_address_31fix (r2);uint64_t src_len = env->regs[(r2 +1 ) &15 ]; -uint64_t cksm =0 ; +uint64_t cksm = (uint32_t )env->regs[r1];while (src_len >=4 ) { cksm +=ldl (src); - cksm =cksm_overflow (cksm);/* move to next word */ src_len -=4 ;
@@ -1760,26 +1750,24 @@ void HELPER(cksm)(uint32_t r1, uint32_t r2)case 0 :break ;case 1 : - cksm +=ldub (src); - cksm =cksm_overflow (cksm); + cksm +=ldub (src) <<24 ;break ;case 2 : - cksm +=lduw (src); - cksm =cksm_overflow (cksm); + cksm +=lduw (src) <<16 ;break ;case 3 : -/* XXX check if this really is correct */ - cksm +=lduw (src) <<8 ; - cksm +=ldub (src +2 ); - cksm =cksm_overflow (cksm); + cksm +=lduw (src) <<16 ; + cksm +=ldub (src +2 ) <<8 ;break ; }/* indicate we've processed everything */ + env->regs[r2] = src + src_len; env->regs[(r2 +1 ) &15 ] =0 ;/* store result */ - env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) | (uint32_t )cksm; + env->regs[r1] = (env->regs[r1] &0xffffffff00000000ULL ) | + ((uint32_t )cksm + (cksm >>32 )); } static inline uint32_t cc_calc_ltgt_32(CPUState *env, int32_t src,
Signature · 1 line
1.6.0.2
PATCH 13/13 s390x: implement lrvgr
In reply to Alexander GrafThe LRVGR instruction was missing. Implement it, so everyone's happy.
--- target-s390x/translate.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
target-s390x/translate.c +3 -0
@@ -3473,6 +3473,9 @@ static void disas_b9(DisasContext *s, int op, int r1, int r2)tcg_temp_free_i64 (tmp2);tcg_temp_free_i64 (tmp3);break ; +case 0x0f :/* LRVGR R1,R2 [RRE] */ +tcg_gen_bswap64_i64 (regs[r1], regs[r2]); +break ;case 0x1f :/* LRVR R1,R2 [RRE] */ tmp32_1 =load_reg32 (r2);tcg_gen_bswap32_i32 (tmp32_1, tmp32_1);
Signature · 1 line
1.6.0.2
Quoted 10 lines · Alexander Graf
Hi,
This is my current patch queue for s390x related work. It contains:
* compile fixes
* addtemp_freeswhere missing
* fix LMH, CKSM instructions
* update bootloader for increased bootup speed
* implement LRVGR instruction
Quoted 5 lines
With these patches, networking finally works for emulated s390x guests.
Please pull.
Alex
Thanks, pulled.
Quoted 34 lines
The following changes since commit
578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e:
Juha Riihim?ki (1):
audio: fix integer overflow expressionare available in the git repository at:
git://repo.or.cz/qemu/agraf.gits390-nextAlexander Graf (4):
s390x: update zipl rom
s390x: free tmp explicitly in every opcode fordisas_a5()
s390x: fix cksm instruction
s390x: implement lrvgrStefan Weil (9):
target-s390x: Fix build for non-linux hosts
target-s390x: Fix wrong argument in call oftcg_gen_shl_i64()
target-s390x: Fix duplicate call oftcg_temp_new_i64
target-s390x: Add missingtcg_temp_free_i64()ingen_jcc()
target-s390x: Add missingtcg_temp_free_i64()indo_mh()
target-s390x: Add missingtcg_temp_free_i64()indisas_b2()
target-s390x: Add missingtcg_temp_free_i64()indisas_s390_insn(),opc == 0x8e target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x90target-s390x: Add missing
tcg_temp_free_i32()pc-bios/s390-zipl.rom | Bin 3336 -> 3304 bytes target-s390x/helper.c | 5 ----- target-s390x/op_helper.c | 28 ++++++++-------------------- target-s390x/translate.c | 31 +++++++++++++++++++++++++++---- 4 files changed, 35 insertions(+), 29 deletions(-)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net