target-mips queue
Hi,
This pull request contains MIPS bug fixes for 2.4-rc1.
Thanks,
Leon
The following changes since commit 661725da09f47eb92d356fac10a4cf3b7ad1f61d:
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150714' into staging (2015-07-14 18:50:17 +0100)
are available in the git repository at:
git://github.com/lalrae/qemu.git tags/mips-20150716
for you to fetch changes up to 908680c6441ac468f4871d513f42be396ea0d264:
target-mips: fix page fault address for LWL/LWR/LDL/LDR (2015-07-15 14:07:25 +0100)
----------------------------------------------------------------
MIPS patches 2015-07-16
Changes:
* bug fixes
----------------------------------------------------------------
Andrew Bennett (1):
linux-user: Fix MIPS N64 trap and break instruction bug
Aurelien Jarno (2):
target-mips: fix ASID synchronisation for MIPS MT
target-mips: fix page fault address for LWL/LWR/LDL/LDR
Leon Alrae (3):
target-mips: correct DERET instruction
target-mips: fix logically dead code reported by Coverity
target-mips: fix resource leak reported by Coverity
Yongbok Kim (3):
target-mips: fix MIPS64R6-generic configuration
target-mips: fix to clear MSACSR.Cause disas/mips: fix disassembling R6 instructions
disas/mips.c | 12 ++++++------ linux-user/main.c | 4 ++-- target-mips/mips-defs.h | 2 +- target-mips/mips-semi.c | 23 +++++++++++++++++++---- target-mips/msa_helper.c | 6 ++++++ target-mips/op_helper.c | 5 ++--- target-mips/translate.c | 15 +++++++++++++++ target-mips/translate_init.c | 18 +++++++++--------- 8 files changed, 60 insertions(+), 25 deletions(-)
[Qemu-devel] [PULL 1/9] target-mips: fix MIPS64R6-generic configuration
From: Yongbok Kim <[email protected]>
Fix core configuration for MIPS64R6-generic to make it as close as I6400.
I6400 core has 48-bit of Virtual Address available (SEGBITS). MIPS SIMD Architecture is available.
Rearrange order of bits to match the specification.
--- target-mips/mips-defs.h | 2 +- target-mips/translate_init.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-)
target-mips/mips-defs.h +1 -1
@@ -11,7 +11,7 @@#if defined(TARGET_MIPS64 )#define TARGET_LONG_BITS 64#define TARGET_PHYS_ADDR_SPACE_BITS 48 -#define TARGET_VIRT_ADDR_SPACE_BITS 42 +#define TARGET_VIRT_ADDR_SPACE_BITS 48#else #define TARGET_LONG_BITS 32#define TARGET_PHYS_ADDR_SPACE_BITS 40
target-mips/translate_init.c +9 -9
@@ -655,14 +655,14 @@ static const mips_def_t mips_defs[] = (2 <<CP0C1_DS ) | (4 <<CP0C1_DL ) | (3 <<CP0C1_DA ) | (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), .CP0_Config2 = MIPS_CONFIG2, - .CP0_Config3 =MIPS_CONFIG3 | (1 <<CP0C3_RXI ) | (1 <<CP0C3_BP ) | - (1 <<CP0C3_BI ) | (1 <<CP0C3_ULRI ) | (1 <<CP0C3_LPA ) | - (1U << CP0C3_M), - .CP0_Config4 =MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) | - (3 << CP0C4_IE) | (1 << CP0C4_M), + .CP0_Config3 =MIPS_CONFIG3 | (1U <<CP0C3_M ) | (1 <<CP0C3_MSAP ) | + (1 <<CP0C3_BP ) | (1 <<CP0C3_BI ) | (1 <<CP0C3_ULRI ) | + (1 << CP0C3_RXI) | (1 << CP0C3_LPA), + .CP0_Config4 =MIPS_CONFIG4 | (1U <<CP0C4_M ) | (3 <<CP0C4_IE ) | + (0xfc << CP0C4_KScrExist), .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_LLB), - .CP0_Config5_rw_bitmask = (1 <<CP0C5_SBRI ) | (1 <<CP0C5_FRE ) | - (1 << CP0C5_UFE), + .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 <<CP0C5_SBRI ) | + (1 << CP0C5_FRE) | (1 << CP0C5_UFE), .CP0_LLAddr_rw_bitmask = 0, .CP0_LLAddr_shift = 0, .SYNCI_Step = 32,
@@ -674,9 +674,9 @@ static const mips_def_t mips_defs[] = .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_F64) | (1 << FCR0_L) | (1 <<FCR0_W ) | (1 <<FCR0_D ) | (1 <<FCR0_S ) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), - .SEGBITS = 42, + .SEGBITS = 48, .PABITS = 48, - .insn_flags = CPU_MIPS64R6, + .insn_flags = CPU_MIPS64R6 | ASE_MSA, .mmu_type = MMU_TYPE_R4000, }, {
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 2/9] target-mips: fix to clear MSACSR.Cause
In reply to Leon AlraeFrom: Yongbok Kim <[email protected]>
MSACSR.Cause bits are needed to be cleared before a vector floating-point instructions.
FEXDO.df, FEXUPL.df and FEXUPR.df were missed out.
--- target-mips/msa_helper.c | 6 ++++++ 1 file changed, 6 insertions(+)
target-mips/msa_helper.c +6 -0
@@ -2642,6 +2642,8 @@ void helper_msa_fexdo_df(CPUMIPSState *env, uint32_t df, uint32_t wd,wr_t *pwt = &(env->active_fpu.fpr[wt].wr);uint32_t i; +clear_msacsr_cause (env); +switch (df) {case DF_WORD :for (i =0 ; i <DF_ELEMENTS (DF_WORD ); i++) {
@@ -3192,6 +3194,8 @@ void helper_msa_fexupl_df(CPUMIPSState *env, uint32_t df, uint32_t wd,wr_t *pws = &(env->active_fpu.fpr[ws].wr);uint32_t i; +clear_msacsr_cause (env); +switch (df) {case DF_WORD :for (i =0 ; i <DF_ELEMENTS (DF_WORD ); i++) {
@@ -3224,6 +3228,8 @@ void helper_msa_fexupr_df(CPUMIPSState *env, uint32_t df, uint32_t wd,wr_t *pws = &(env->active_fpu.fpr[ws].wr);uint32_t i; +clear_msacsr_cause (env); +switch (df) {case DF_WORD :for (i =0 ; i <DF_ELEMENTS (DF_WORD ); i++) {
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 3/9] disas/mips: fix disassembling R6 instructions
In reply to Leon AlraeFrom: Yongbok Kim <[email protected]>
In the Release 6 of the MIPS Architecture, LL, SC, LLD, SCD, PREF and CACHE instructions have 9 bits offsets.
--- disas/mips.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
disas/mips.c +6 -6
@@ -1296,12 +1296,12 @@ const struct mips_opcode mips_builtin_opcodes[] = {"dmod", "d,s,t", 0x000000de, 0xfc0007ff, WR_d|RD_s|RD_t, 0, I64R6}, {"ddivu", "d,s,t", 0x0000009f, 0xfc0007ff, WR_d|RD_s|RD_t, 0, I64R6}, {"dmodu", "d,s,t", 0x000000df, 0xfc0007ff, WR_d|RD_s|RD_t, 0, I64R6}, -{"ll", "t,o(b)", 0x7c000036, 0xfc00007f, LDD|RD_b|WR_t, 0, I32R6}, -{"sc", "t,o(b)", 0x7c000026, 0xfc00007f, LDD|RD_b|WR_t, 0, I32R6}, -{"lld", "t,o(b)", 0x7c000037, 0xfc00007f, LDD|RD_b|WR_t, 0, I64R6}, -{"scd", "t,o(b)", 0x7c000027, 0xfc00007f, LDD|RD_b|WR_t, 0, I64R6}, -{"pref", "h,o(b)", 0x7c000035, 0xfc00007f, RD_b, 0, I32R6}, -{"cache", "k,o(b)", 0x7c000025, 0xfc00007f, RD_b, 0, I32R6}, +{"ll", "t,+o(b)", 0x7c000036, 0xfc00007f, LDD|RD_b|WR_t, 0, I32R6}, +{"sc", "t,+o(b)", 0x7c000026, 0xfc00007f, LDD|RD_b|WR_t, 0, I32R6}, +{"lld", "t,+o(b)", 0x7c000037, 0xfc00007f, LDD|RD_b|WR_t, 0, I64R6}, +{"scd", "t,+o(b)", 0x7c000027, 0xfc00007f, LDD|RD_b|WR_t, 0, I64R6}, +{"pref", "h,+o(b)", 0x7c000035, 0xfc00007f, RD_b, 0, I32R6}, +{"cache", "k,+o(b)", 0x7c000025, 0xfc00007f, RD_b, 0, I32R6}, {"seleqz", "d,v,t", 0x00000035, 0xfc0007ff, WR_d|RD_s|RD_t, 0, I32R6}, {"selnez", "d,v,t", 0x00000037, 0xfc0007ff, WR_d|RD_s|RD_t, 0, I32R6}, {"maddf.s", "D,S,T", 0x46000018, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, 0, I32R6},
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 4/9] target-mips: fix ASID synchronisation for MIPS MT
In reply to Leon AlraeFrom: Aurelien Jarno <[email protected]>
When syncing the task ASID with EntryHi, correctly or the value instead of assigning it.
--- target-mips/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-mips/op_helper.c +1 -1
@@ -661,7 +661,7 @@ static void sync_c0_tcstatus(CPUMIPSState *cpu, int tc,/* Sync the TASID with EntryHi. */ cpu->CP0_EntryHi &= ~0xff ; - cpu->CP0_EntryHi = tasid; + cpu->CP0_EntryHi |= tasid;compute_hflags (cpu); }
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 5/9] target-mips: correct DERET instruction
In reply to Leon AlraeFix Debug Mode flag clearing, and when DERET is placed between LL and SC do not make SC fail.
--- target-mips/op_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target-mips/op_helper.c +1 -2
@@ -2154,10 +2154,9 @@ void helper_deret(CPUMIPSState *env)debug_pre_eret (env);set_pc (env, env->CP0_DEPC); - env->hflags &=MIPS_HFLAG_DM ; + env->hflags &= ~MIPS_HFLAG_DM ;compute_hflags (env); debug_post_eret(env); - env->lladdr = 1; }#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 6/9] target-mips: fix logically dead code reported by Coverity
In reply to Leon AlraeMake use of CMPOP in floating-point compare instructions.
--- target-mips/translate.c | 3 +++ 1 file changed, 3 insertions(+)
target-mips/translate.c +3 -0
@@ -9552,6 +9552,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,gen_cmp_s (ctx, func-48 , ft, fs, cc); opn = condnames[func-48 ]; } + optype =CMPOP ;break ;case OPC_ADD_D :check_cp1_registers (ctx, fs | ft | fd);
@@ -10036,6 +10037,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,gen_cmp_d (ctx, func-48 , ft, fs, cc); opn = condnames[func-48 ]; } + optype =CMPOP ;break ;case OPC_CVT_S_D :check_cp1_registers (ctx, fs);
@@ -10461,6 +10463,7 @@ static void gen_farith (DisasContext *ctx, enum fopcode op1,gen_cmp_ps (ctx, func-48 , ft, fs, cc); opn = condnames[func-48 ]; } + optype =CMPOP ;break ;default :MIPS_INVAL (opn);
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 7/9] target-mips: fix resource leak reported by Coverity
In reply to Leon AlraeUHI assert and link operations call lock_user_string() twice to obtain two strings pointed by gpr[4] and gpr[5]. If the second lock_user_string() fails, then the first one won't get freed. Fix this by introducing another macro responsible for obtaining two strings and handling allocation failure.
--- target-mips/mips-semi.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
target-mips/mips-semi.c +19 -4
@@ -220,6 +220,23 @@ static int copy_argn_to_target(CPUMIPSState *env, int arg_num, } \ } while (0) +#define GET_TARGET_STRINGS_2 (p, addr, p2, addr2) \ + do { \ + p = lock_user_string(addr); \ + if (!p) { \ + gpr[2] = -1; \ + gpr[3] = EFAULT; \ + goto uhi_done; \ + } \ + p2 = lock_user_string(addr2); \ + if (!p2) { \ + unlock_user(p, addr, 0); \ + gpr[2] = -1; \ + gpr[3] = EFAULT; \ + goto uhi_done; \ + } \ + } while (0) +#define FREE_TARGET_STRING (p, gpr) \ do { \ unlock_user(p, gpr, 0); \
@@ -322,8 +339,7 @@ void helper_do_semihosting(CPUMIPSState *env)FREE_TARGET_STRING (p, gpr[4 ]);break ;case UHI_assert: -GET_TARGET_STRING (p, gpr[4 ]); -GET_TARGET_STRING (p2, gpr[5 ]); +GET_TARGET_STRINGS_2 (p, gpr[4 ], p2, gpr[5 ]);printf ("assertion '" );printf ("\"%s\"" , p);printf ("': file \"%s\", line %d\n" , p2, (int )gpr[6 ]);
@@ -341,8 +357,7 @@ void helper_do_semihosting(CPUMIPSState *env)break ;#ifndef _WIN32case UHI_link: -GET_TARGET_STRING (p, gpr[4 ]); -GET_TARGET_STRING (p2, gpr[5 ]); +GET_TARGET_STRINGS_2 (p, gpr[4 ], p2, gpr[5 ]); gpr[2 ] =link (p, p2); gpr[3 ] =errno_mips (errno);FREE_TARGET_STRING (p2, gpr[5 ]);
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 8/9] linux-user: Fix MIPS N64 trap and break instruction bug
In reply to Leon AlraeFrom: Andrew Bennett <[email protected]>
For the MIPS N64 ABI when QEMU reads the break/trap instruction so that it can inspect the break/trap code it reads 8 rather than 4 bytes which means it finds the code field from the instruction after the break/trap instruction. This then causes the break/trap handling code to fail because it does not understand the code number.
The fix forces QEMU to always read 4 bytes of instruction data rather than deciding how much to read based on the ABI.
--- linux-user/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/main.c +2 -2
@@ -2577,7 +2577,7 @@ done_syscall: code = (trap_instr >>6 ) &0x3f ; } }else { - ret =get_user_ual (trap_instr, env->active_tc.PC); + ret =get_user_u32 (trap_instr, env->active_tc.PC);if (ret !=0 ) { goto error; }
@@ -2611,7 +2611,7 @@ done_syscall: trap_instr = (instr[0 ] <<16 ) | instr[1 ]; }else { - ret =get_user_ual (trap_instr, env->active_tc.PC); + ret =get_user_u32 (trap_instr, env->active_tc.PC); }if (ret !=0 ) {
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 9/9] target-mips: fix page fault address for LWL/LWR/LDL/LDR
In reply to Leon AlraeFrom: Aurelien Jarno <[email protected]>
When a LWL, LWR, LDL or LDR instruction triggers a page fault, QEMU currently reports the aligned address in CP0 BadVAddr, while the Windows NT kernel expects the unaligned address.
This patch adds a byte access with the unaligned address at the beginning of the LWL/LWR/LDL/LDR instructions to possibly trigger a page fault and fill the QEMU TLB.
--- target-mips/translate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
target-mips/translate.c +12 -0
@@ -2142,6 +2142,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,break ;case OPC_LDL : t1 =tcg_temp_new (); +/* Do a byte access to possibly trigger a page +fault with the unaligned address. */ +tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx,MO_UB );tcg_gen_andi_tl (t1, t0,7 );#ifndef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl (t1, t1,7 );
@@ -2163,6 +2166,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,break ;case OPC_LDR : t1 =tcg_temp_new (); +/* Do a byte access to possibly trigger a page +fault with the unaligned address. */ +tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx,MO_UB );tcg_gen_andi_tl (t1, t0,7 );#ifdef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl (t1, t1,7 );
@@ -2229,6 +2235,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,break ;case OPC_LWL : t1 =tcg_temp_new (); +/* Do a byte access to possibly trigger a page +fault with the unaligned address. */ +tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx,MO_UB );tcg_gen_andi_tl (t1, t0,3 );#ifndef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl (t1, t1,3 );
@@ -2251,6 +2260,9 @@ static void gen_ld(DisasContext *ctx, uint32_t opc,break ;case OPC_LWR : t1 =tcg_temp_new (); +/* Do a byte access to possibly trigger a page +fault with the unaligned address. */ +tcg_gen_qemu_ld_tl (t1, t0, ctx->mem_idx,MO_UB );tcg_gen_andi_tl (t1, t0,3 );#ifdef TARGET_WORDS_BIGENDIAN tcg_gen_xori_tl (t1, t1,3 );
Signature · 1 line
2.1.0
Peter Maydell
AppliedQuoted 20 lines · Leon Alrae
Hi,
This pull request contains MIPS bug fixes for 2.4-rc1.
Thanks,
LeonCc Peter Maydell <[email protected]>Cc Aurelien Jarno <[email protected]>The following changes since commit
661725da09f47eb92d356fac10a4cf3b7ad1f61d:Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150714' into staging (2015-07-14 18:50:17 +0100)
are available in the git repository at:
git://github.com/lalrae/qemu.gittags/mips-20150716for you to fetch changes up to
908680c6441ac468f4871d513f42be396ea0d264:
Quoted 7 lines
target-mips: fix page fault address for LWL/LWR/LDL/LDR (2015-07-15 14:07:25 +0100)
----------------------------------------------------------------
MIPS patches 2015-07-16Changes:
* bug fixes
Applied, thanks.
-- PMM