From 39f4107981c9c9a5c9af6067cfbb4272a8112923 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 24 May 2011 19:52:28 +0200 Subject: [PATCH 01/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. Signed-off-by: Alexander Graf --- pc-bios/s390-zipl.rom | Bin 3336 -> 3304 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/pc-bios/s390-zipl.rom b/pc-bios/s390-zipl.rom index f7af9b155dc27500d4619ea6c9eb530d27a79f5d..3115128efe465a024b2deb780573358ae1b829a4 100644 GIT binary patch literal 3304 zcmZuzdvH`&8UOC?hP%xJ4gtbake-C44GpDB0K-eVH#`h2rHiy0klJiXfJjJU*wBL2 zu98~fSXolRYISA>mgBTqR@7m3wA0&`I)nZJR#L3~;o=?oM|YfFXzU;XuD|ar0V>{^ z`#9hEp1<#LuDZ07)R6y-Vy9C#g~; zyiW#_?m-n26a}9nAQk{6b4=2>V>KlANSdN%kze)ESiF5IK@-#vl{v!wIqmBgG(I<; zszC{;8J?$xMOxbrnAZjk_ed-V3;$L_-iM}H_`TaqVYS8}c=HzSU*iryU&s+sP{4^w zqAE3m$cYFa?aMt+;anBfG)3%Dg&H!bB3ds3&B6|_MNk4%q3$HZk#>-Rp?R5xYhK7w zYsiR^3`T_wf*i&dZ zg!=^K4YiU)zfE^I615YyB5pbcEVRB2;N6JTVYYGYUyxV`+pF~6YPHVrYx+6J9ETP| z(;GqeY5JgEFJzyzkJUh<7MMu)IHd|l857{Za_s9d)8y{(|E(~MB$XHDP=v}=9aj>_ z$y_;2<2Y`{QW&Q>fSH==U%xj18M5#*7d)|?GgHl#3&vo1Ah`f(d>R}35 z%VMNPlh2wf$U3BJq!(*H`sZ~gk_}OKKedn(%?b)T`7AojNu$xiPAnTl-V^l7>(!?T zwd+$S=rAx9w9kpfkOOpcy%S4j;vbbrdL?*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z(eJ6xE4Jt5=?@H$APs6SQf8H^LFrN&bK2 zWDx=q=J_(_%pR|n_y2k$&LKp!9rZ1tCfD^s=3YDBAM{e{G*L57`wOGG_NRm7=s>j9 zPC3HC#5uDE=o{QbJG{7=6yK96%xGpASFN&g)vTN$PXN`c3Fx3UUcuY-oC9lOe{Oc` zFb#6K&m76U2l9OR4o;ern4O)zi!Y9T&R2U@`Q3}y)9qAB*yfc~pP)m~FL%whLhkW(!G4*bPtnz)=`j96x&fM&tE9b!2NWbtN zYOio_p3!+HT_%d_m~&9vU2Emu(Cq%8L#UnZ-1(s8-rdTxy8nGwz)Z(}!&b#ytLoEm z99XUZo`tT-@A`x0jXtI*-4I9be_O5tlctJZs}0zesp`Vw>134f7YU#KA-MriEK8FM z{42IFP4t}3Sqxo-}hL(GJ- zxQcH(RGhN=J>UH;$m}o`s3--Wepw93(Ju?c$^8PDpD_O9H?H2wt$lw))}(=+K+w3! z*n_jZps;A{IJ3B9ypbO=$|ggiep3x2e^R+x=8eH$DKB-tO_*p*5&qup@1%@(+0$Zu}Jbk-0VV=6`;{!rDcK@hqNmOw6I8e4^Wy3R zyNTkhJ7X>JCb2!XCBBI^$Kox`O`@eO))a5uB6c)y+1}jRnLjG;=xS|c`R;go3w-U2 zcXY@M`SW64L*%;fjO?0*)c57FxMS!wc rS4*cr#ExB~81iXl4iog)xwvPI*xb>!U2KhYG>NA8j&1*w6w>=Il#<+z From d4a3ef69703e289af7b08122d969e72af799d15f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 24 May 2011 19:42:51 +0200 Subject: [PATCH 02/13] target-s390x: Fix build for non-linux hosts 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. Cc: Alexander Graf Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/helper.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/target-s390x/helper.c b/target-s390x/helper.c index c79af46693..745d8c52bb 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -28,11 +28,6 @@ #include "qemu-common.h" #include "qemu-timer.h" -#if !defined(CONFIG_USER_ONLY) -#include -#include "kvm.h" -#endif - //#define DEBUG_S390 //#define DEBUG_S390_PTE //#define DEBUG_S390_STDOUT From be82ee2aca363753888fe777215849a86f4e737c Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:25 +0200 Subject: [PATCH 03/13] target-s390x: Fix wrong argument in call of tcg_gen_shl_i64() 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. Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 8e71df3d26..865a9dfa53 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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 From 640239b26d6120724f6c1ec99f64ddb1df9314c3 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:26 +0200 Subject: [PATCH 04/13] target-s390x: Fix duplicate call of tcg_temp_new_i64 tmp2 = tcg_temp_new_i64() is already executed unconditionally, so there is no need to call it a second time for 64 bit hosts. Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 865a9dfa53..141a72f0e8 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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]); From a825aefbc2ade367327785feb0e28bb2d8ca3988 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:27 +0200 Subject: [PATCH 05/13] target-s390x: Add missing tcg_temp_free_i64() in gen_jcc() Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 141a72f0e8..6ec77ec578 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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); From 21de37a778667ad551a6ce1cabd1867e715e53c4 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:28 +0200 Subject: [PATCH 06/13] target-s390x: Add missing tcg_temp_free_i64() in do_mh() Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 6ec77ec578..a11cb19b87 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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] */ From e32a18320a48c5379a27185ad66f71999c53b430 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:29 +0200 Subject: [PATCH 07/13] target-s390x: Add missing tcg_temp_free_i64() in disas_b2() Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index a11cb19b87..f3f42a9cdc 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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) */ From 225b6af7cd504bc8430aa8ef04782845a62ee7b1 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:30 +0200 Subject: [PATCH 08/13] target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x8e Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index f3f42a9cdc..c5a3930243 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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] */ From bbf9f3b4d4327421f8d415bed9c5f50ca28cab1f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:31 +0200 Subject: [PATCH 09/13] target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x90 Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index c5a3930243..81b8c5b998 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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); From 2497a67fed5d4844ec0ea053d27b538712245dc2 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 27 May 2011 19:03:36 +0200 Subject: [PATCH 10/13] target-s390x: Add missing tcg_temp_free_i32() Signed-off-by: Stefan Weil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 81b8c5b998..5828b5f410 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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: From 87b0b70513fb554ff20374707d7e90b0bc6ffb2d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sat, 28 May 2011 02:12:33 +0200 Subject: [PATCH 11/13] s390x: free tmp explicitly in every opcode for disas_a5() The 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. Signed-off-by: Alexander Graf --- target-s390x/translate.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 5828b5f410..afeb5e6fd7 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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) From 5b185639c5740998de403415c749ac98e13418fd Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 30 May 2011 10:49:45 +0200 Subject: [PATCH 12/13] s390x: fix cksm instruction The 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. Signed-off-by: Alexander Graf --- target-s390x/op_helper.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/target-s390x/op_helper.c b/target-s390x/op_helper.c index 49760a40a2..db03a7971f 100644 --- a/target-s390x/op_helper.c +++ b/target-s390x/op_helper.c @@ -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, From e1b45cca620bf33168914283f81f6f3d8847f76b Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 30 May 2011 12:09:12 +0200 Subject: [PATCH 13/13] s390x: implement lrvgr The LRVGR instruction was missing. Implement it, so everyone's happy. Reported-by: Balazs Kutil Signed-off-by: Alexander Graf --- target-s390x/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index afeb5e6fd7..eda4624d11 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -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);