* [Qemu-devel] [PULL 0/9] target-mips queue
@ 2015-07-16 8:17 Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 1/9] target-mips: fix MIPS64R6-generic configuration Leon Alrae
` (9 more replies)
0 siblings, 10 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Aurelien Jarno
Hi,
This pull request contains MIPS bug fixes for 2.4-rc1.
Thanks,
Leon
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
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(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 1/9] target-mips: fix MIPS64R6-generic configuration
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 2/9] target-mips: fix to clear MSACSR.Cause Leon Alrae
` (8 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Yongbok Kim
From: Yongbok Kim <yongbok.kim@imgtec.com>
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.
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
target-mips/mips-defs.h | 2 +-
target-mips/translate_init.c | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/target-mips/mips-defs.h b/target-mips/mips-defs.h
index 20aa87c..53b185e 100644
--- a/target-mips/mips-defs.h
+++ b/target-mips/mips-defs.h
@@ -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
diff --git a/target-mips/translate_init.c b/target-mips/translate_init.c
index ddfaff8..9304e74 100644
--- a/target-mips/translate_init.c
+++ b/target-mips/translate_init.c
@@ -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,
},
{
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 2/9] target-mips: fix to clear MSACSR.Cause
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 1/9] target-mips: fix MIPS64R6-generic configuration Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 3/9] disas/mips: fix disassembling R6 instructions Leon Alrae
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Yongbok Kim
From: Yongbok Kim <yongbok.kim@imgtec.com>
MSACSR.Cause bits are needed to be cleared before a vector floating-point
instructions.
FEXDO.df, FEXUPL.df and FEXUPR.df were missed out.
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
target-mips/msa_helper.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/target-mips/msa_helper.c b/target-mips/msa_helper.c
index 26ffdc7..a1cb48f 100644
--- a/target-mips/msa_helper.c
+++ b/target-mips/msa_helper.c
@@ -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++) {
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 3/9] disas/mips: fix disassembling R6 instructions
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 1/9] target-mips: fix MIPS64R6-generic configuration Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 2/9] target-mips: fix to clear MSACSR.Cause Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 4/9] target-mips: fix ASID synchronisation for MIPS MT Leon Alrae
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Yongbok Kim
From: Yongbok Kim <yongbok.kim@imgtec.com>
In the Release 6 of the MIPS Architecture, LL, SC, LLD, SCD, PREF
and CACHE instructions have 9 bits offsets.
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
disas/mips.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/disas/mips.c b/disas/mips.c
index 32940fe..01336a8 100644
--- a/disas/mips.c
+++ b/disas/mips.c
@@ -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},
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 4/9] target-mips: fix ASID synchronisation for MIPS MT
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
` (2 preceding siblings ...)
2015-07-16 8:17 ` [Qemu-devel] [PULL 3/9] disas/mips: fix disassembling R6 instructions Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 5/9] target-mips: correct DERET instruction Leon Alrae
` (5 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Aurelien Jarno
From: Aurelien Jarno <aurelien@aurel32.net>
When syncing the task ASID with EntryHi, correctly or the value instead
of assigning it.
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
target-mips/op_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 2a9ddff..d457a29 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -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);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 5/9] target-mips: correct DERET instruction
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
` (3 preceding siblings ...)
2015-07-16 8:17 ` [Qemu-devel] [PULL 4/9] target-mips: fix ASID synchronisation for MIPS MT Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 6/9] target-mips: fix logically dead code reported by Coverity Leon Alrae
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel
Fix Debug Mode flag clearing, and when DERET is placed between LL and SC
do not make SC fail.
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-mips/op_helper.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index d457a29..9c28631 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -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 */
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 6/9] target-mips: fix logically dead code reported by Coverity
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
` (4 preceding siblings ...)
2015-07-16 8:17 ` [Qemu-devel] [PULL 5/9] target-mips: correct DERET instruction Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 7/9] target-mips: fix resource leak " Leon Alrae
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel
Make use of CMPOP in floating-point compare instructions.
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-mips/translate.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 7302857..4a1ffdb 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -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);
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 7/9] target-mips: fix resource leak reported by Coverity
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
` (5 preceding siblings ...)
2015-07-16 8:17 ` [Qemu-devel] [PULL 6/9] target-mips: fix logically dead code reported by Coverity Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 8/9] linux-user: Fix MIPS N64 trap and break instruction bug Leon Alrae
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel
UHI 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.
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-mips/mips-semi.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/target-mips/mips-semi.c b/target-mips/mips-semi.c
index 1162c76..5050940 100644
--- a/target-mips/mips-semi.c
+++ b/target-mips/mips-semi.c
@@ -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 _WIN32
case 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]);
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 8/9] linux-user: Fix MIPS N64 trap and break instruction bug
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
` (6 preceding siblings ...)
2015-07-16 8:17 ` [Qemu-devel] [PULL 7/9] target-mips: fix resource leak " Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 9/9] target-mips: fix page fault address for LWL/LWR/LDL/LDR Leon Alrae
2015-07-16 10:44 ` [Qemu-devel] [PULL 0/9] target-mips queue Peter Maydell
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Andrew Bennett
From: Andrew Bennett <andrew.bennett@imgtec.com>
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.
Signed-off-by: Andrew Bennett <andrew.bennett@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
linux-user/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 05914b1..fdee981 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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) {
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 9/9] target-mips: fix page fault address for LWL/LWR/LDL/LDR
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
` (7 preceding siblings ...)
2015-07-16 8:17 ` [Qemu-devel] [PULL 8/9] linux-user: Fix MIPS N64 trap and break instruction bug Leon Alrae
@ 2015-07-16 8:17 ` Leon Alrae
2015-07-16 10:44 ` [Qemu-devel] [PULL 0/9] target-mips queue Peter Maydell
9 siblings, 0 replies; 15+ messages in thread
From: Leon Alrae @ 2015-07-16 8:17 UTC (permalink / raw)
To: qemu-devel; +Cc: Aurelien Jarno
From: Aurelien Jarno <aurelien@aurel32.net>
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.
Cc: Leon Alrae <leon.alrae@imgtec.com>
Reported-by: Hervé Poussineau <hpoussin@reactos.org>
Tested-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
target-mips/translate.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 4a1ffdb..d1de35a 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -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);
--
2.1.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PULL 0/9] target-mips queue
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
` (8 preceding siblings ...)
2015-07-16 8:17 ` [Qemu-devel] [PULL 9/9] target-mips: fix page fault address for LWL/LWR/LDL/LDR Leon Alrae
@ 2015-07-16 10:44 ` Peter Maydell
9 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2015-07-16 10:44 UTC (permalink / raw)
To: Leon Alrae; +Cc: QEMU Developers, Aurelien Jarno
On 16 July 2015 at 09:17, Leon Alrae <leon.alrae@imgtec.com> wrote:
> Hi,
>
> This pull request contains MIPS bug fixes for 2.4-rc1.
>
> Thanks,
> Leon
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
>
> 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
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 0/9] target-mips queue
@ 2015-10-30 15:00 Leon Alrae
2015-10-30 17:36 ` Peter Maydell
0 siblings, 1 reply; 15+ messages in thread
From: Leon Alrae @ 2015-10-30 15:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Aurelien Jarno
Hi,
Here's my current target-mips queue, just fixes and relatively minor
improvements.
Thanks,
Leon
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
The following changes since commit 7bc8e0c967a4ef77657174d28af775691e18b4ce:
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2015-10-29 09:49:52 +0000)
are available in the git repository at:
git://github.com/lalrae/qemu.git tags/mips-20151030
for you to fetch changes up to 60270f85cc93d2d34e45b7679c374b1d771f0eeb:
target-mips: fix updating XContext on mmu exception (2015-10-30 14:36:19 +0000)
----------------------------------------------------------------
MIPS patches 2015-10-30
Changes:
* R6 CPU can be woken up by non-enabled interrupts
* PC fix in KVM
* CP0 XContext calculation fix
* various MIPS R6 updates
----------------------------------------------------------------
James Hogan (1):
hw/mips_malta: Fix KVM PC initialisation
Leon Alrae (3):
target-mips: move the test for enabled interrupts to a separate function
target-mips: implement the CPU wake-up on non-enabled interrupts in R6
target-mips: update writing to CP0.Status.KX/SX/UX in MIPS Release R6
Yongbok Kim (5):
target-mips: Add enum for BREAK32
target-mips: add PC, XNP reg numbers to RDHWR
target-mips: Set Config5.XNP for R6 cores
target-mips: add SIGRIE instruction
target-mips: fix updating XContext on mmu exception
hw/mips/mips_malta.c | 2 +-
target-mips/cpu.c | 9 ++++---
target-mips/cpu.h | 37 ++++++++++++++-----------
target-mips/helper.c | 10 ++++---
target-mips/helper.h | 2 ++
target-mips/op_helper.c | 64 ++++++++++++++++++++++++--------------------
target-mips/translate.c | 43 +++++++++++++++++++++++++----
target-mips/translate_init.c | 4 +--
8 files changed, 112 insertions(+), 59 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PULL 0/9] target-mips queue
2015-10-30 15:00 Leon Alrae
@ 2015-10-30 17:36 ` Peter Maydell
0 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2015-10-30 17:36 UTC (permalink / raw)
To: Leon Alrae; +Cc: QEMU Developers, Aurelien Jarno
On 30 October 2015 at 15:00, Leon Alrae <leon.alrae@imgtec.com> wrote:
> Hi,
>
> Here's my current target-mips queue, just fixes and relatively minor
> improvements.
>
> Thanks,
> Leon
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
>
> The following changes since commit 7bc8e0c967a4ef77657174d28af775691e18b4ce:
>
> Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2015-10-29 09:49:52 +0000)
>
> are available in the git repository at:
>
> git://github.com/lalrae/qemu.git tags/mips-20151030
>
> for you to fetch changes up to 60270f85cc93d2d34e45b7679c374b1d771f0eeb:
>
> target-mips: fix updating XContext on mmu exception (2015-10-30 14:36:19 +0000)
>
> ----------------------------------------------------------------
> MIPS patches 2015-10-30
>
> Changes:
> * R6 CPU can be woken up by non-enabled interrupts
> * PC fix in KVM
> * CP0 XContext calculation fix
> * various MIPS R6 updates
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Qemu-devel] [PULL 0/9] target-mips queue
@ 2016-09-23 7:20 Leon Alrae
2016-09-23 15:15 ` Peter Maydell
0 siblings, 1 reply; 15+ messages in thread
From: Leon Alrae @ 2016-09-23 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, aurelien
Hi,
Here's my queue with the MIPS patches I've accumulated so far.
Thanks,
Leon
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
The following changes since commit 430da7a81d356e368ccd88dcca60f38da9aa5b9a:
Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20160915' into staging (2016-09-22 15:39:54 +0100)
are available in the git repository at:
git://github.com/lalrae/qemu.git tags/mips-20160923
for you to fetch changes up to fea55615b2f924128e115ceb2265069561b03ef8:
linux-user: Add missing Mips syscalls items in strace.list (2016-09-23 07:07:36 +0100)
----------------------------------------------------------------
MIPS patches 2016-09-23
Changes:
* 24KEc CPU definition
* SYNC instructions make use of tcg memory barrier ops
* various MIPS linux-user bug fixes
----------------------------------------------------------------
Aleksandar Markovic (7):
linux-user: Fix TARGET_SIOCATMARK definition for Mips
linux-user: Fix TARGET_F_GETOWN definition for Mips
linux-user: Fix structure target_flock definition for Mips
linux-user: Fix structure target_semid64_ds definition for Mips
linux-user: Fix certain argument alignment cases for Mips64
linux-user: Add missing TARGET_EDQUOT error code for Mips
linux-user: Add missing Mips syscalls items in strace.list
André Draszik (1):
target-mips: add 24KEc CPU definition
Leon Alrae (1):
target-mips: generate fences
linux-user/mips/target_structs.h | 16 ++++++
linux-user/mips/target_syscall.h | 2 +
linux-user/mips64/target_syscall.h | 2 +
linux-user/strace.list | 114 +++++++++++++++++++++++++++++++++++++
linux-user/syscall.c | 3 +-
linux-user/syscall_defs.h | 12 +++-
target-mips/translate.c | 32 ++++++++++-
target-mips/translate_init.c | 22 +++++++
8 files changed, 199 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PULL 0/9] target-mips queue
2016-09-23 7:20 Leon Alrae
@ 2016-09-23 15:15 ` Peter Maydell
0 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2016-09-23 15:15 UTC (permalink / raw)
To: Leon Alrae; +Cc: QEMU Developers, Aurelien Jarno
On 23 September 2016 at 08:20, Leon Alrae <leon.alrae@imgtec.com> wrote:
> Hi,
>
> Here's my queue with the MIPS patches I've accumulated so far.
>
> Thanks,
> Leon
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
>
> The following changes since commit 430da7a81d356e368ccd88dcca60f38da9aa5b9a:
>
> Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20160915' into staging (2016-09-22 15:39:54 +0100)
>
> are available in the git repository at:
>
> git://github.com/lalrae/qemu.git tags/mips-20160923
>
> for you to fetch changes up to fea55615b2f924128e115ceb2265069561b03ef8:
>
> linux-user: Add missing Mips syscalls items in strace.list (2016-09-23 07:07:36 +0100)
>
> ----------------------------------------------------------------
> MIPS patches 2016-09-23
>
> Changes:
> * 24KEc CPU definition
> * SYNC instructions make use of tcg memory barrier ops
> * various MIPS linux-user bug fixes
>
> ----------------------------------------------------------------
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2016-09-23 15:15 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16 8:17 [Qemu-devel] [PULL 0/9] target-mips queue Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 1/9] target-mips: fix MIPS64R6-generic configuration Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 2/9] target-mips: fix to clear MSACSR.Cause Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 3/9] disas/mips: fix disassembling R6 instructions Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 4/9] target-mips: fix ASID synchronisation for MIPS MT Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 5/9] target-mips: correct DERET instruction Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 6/9] target-mips: fix logically dead code reported by Coverity Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 7/9] target-mips: fix resource leak " Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 8/9] linux-user: Fix MIPS N64 trap and break instruction bug Leon Alrae
2015-07-16 8:17 ` [Qemu-devel] [PULL 9/9] target-mips: fix page fault address for LWL/LWR/LDL/LDR Leon Alrae
2015-07-16 10:44 ` [Qemu-devel] [PULL 0/9] target-mips queue Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2015-10-30 15:00 Leon Alrae
2015-10-30 17:36 ` Peter Maydell
2016-09-23 7:20 Leon Alrae
2016-09-23 15:15 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).