Initial commit with version 1.2.0-24
[packages/centos6/qemu.git] / 0089-tcg-sparc-Mask-shift-immediates-to-avoid-illegal-ins.patch
1 From 12e60f780a097837840ab1e7bb7d54b8c15112e8 Mon Sep 17 00:00:00 2001
2 From: Richard Henderson <rth@twiddle.net>
3 Date: Sun, 25 Mar 2012 21:36:28 +0200
4 Subject: [PATCH] tcg-sparc: Mask shift immediates to avoid illegal insns.
5
6 The xtensa-test image generates a sra_i32 with count 0x40.
7 Whether this is accident of tcg constant propagation or
8 originating directly from the instruction stream is immaterial.
9
10 Signed-off-by: Richard Henderson <rth@twiddle.net>
11 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
12 ---
13  tcg/sparc/tcg-target.c | 18 ++++++++++++------
14  1 file changed, 12 insertions(+), 6 deletions(-)
15
16 diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c
17 index e625aa3..be5c170 100644
18 --- a/tcg/sparc/tcg-target.c
19 +++ b/tcg/sparc/tcg-target.c
20 @@ -1154,13 +1154,16 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
21          goto gen_arith;
22      case INDEX_op_shl_i32:
23          c = SHIFT_SLL;
24 -        goto gen_arith;
25 +    do_shift32:
26 +        /* Limit immediate shift count lest we create an illegal insn.  */
27 +        tcg_out_arithc(s, args[0], args[1], args[2] & 31, const_args[2], c);
28 +        break;
29      case INDEX_op_shr_i32:
30          c = SHIFT_SRL;
31 -        goto gen_arith;
32 +        goto do_shift32;
33      case INDEX_op_sar_i32:
34          c = SHIFT_SRA;
35 -        goto gen_arith;
36 +        goto do_shift32;
37      case INDEX_op_mul_i32:
38          c = ARITH_UMUL;
39          goto gen_arith;
40 @@ -1281,13 +1284,16 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
41          break;
42      case INDEX_op_shl_i64:
43          c = SHIFT_SLLX;
44 -        goto gen_arith;
45 +    do_shift64:
46 +        /* Limit immediate shift count lest we create an illegal insn.  */
47 +        tcg_out_arithc(s, args[0], args[1], args[2] & 63, const_args[2], c);
48 +        break;
49      case INDEX_op_shr_i64:
50          c = SHIFT_SRLX;
51 -        goto gen_arith;
52 +        goto do_shift64;
53      case INDEX_op_sar_i64:
54          c = SHIFT_SRAX;
55 -        goto gen_arith;
56 +        goto do_shift64;
57      case INDEX_op_mul_i64:
58          c = ARITH_MULX;
59          goto gen_arith;
60 -- 
61 1.7.12.1
62