* [PATCH v2 0/4] target/mips: misc microMIPS fixes
@ 2023-02-16 5:17 Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 1/4] target/mips: fix JALS32/J32 instruction handling for microMIPS Marcin Nowakowski
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Marcin Nowakowski @ 2023-02-16 5:17 UTC (permalink / raw)
To: qemu-devel
Cc: marcin.nowakowski, Philippe Mathieu-Daudé, Aurelien Jarno,
Jiaxun Yang, Aleksandar Rikalo
v2:
- add reviewed-by to patch 1 & 2
- add CP0.Config7.WII for P5600
- new patch: add CP0.Config[4,5] for M14K(c)
Marcin Nowakowski (4):
target/mips: fix JALS32/J32 instruction handling for microMIPS
target/mips: fix SWM32 handling for micromips
target/mips: implement CP0.Config7.WII bit support
target/mips: set correct CP0.Config[4,5] values for M14K(c)
target/mips/cpu-defs.c.inc | 13 +++++++++++--
target/mips/cpu.c | 6 ++++--
target/mips/cpu.h | 1 +
target/mips/tcg/ldst_helper.c | 4 ++--
target/mips/tcg/translate.c | 7 +++++++
5 files changed, 25 insertions(+), 6 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/4] target/mips: fix JALS32/J32 instruction handling for microMIPS
2023-02-16 5:17 [PATCH v2 0/4] target/mips: misc microMIPS fixes Marcin Nowakowski
@ 2023-02-16 5:17 ` Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 2/4] target/mips: fix SWM32 handling for micromips Marcin Nowakowski
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Marcin Nowakowski @ 2023-02-16 5:17 UTC (permalink / raw)
To: qemu-devel
Cc: marcin.nowakowski, Philippe Mathieu-Daudé, Aurelien Jarno,
Jiaxun Yang, Aleksandar Rikalo, Richard Henderson
microMIPS J & JAL instructions perform a jump in a 128MB region and 5
top bits of the address need to be preserved. This is different behavior
compared to standard mips systems, where the jump is executed within a
256MB region.
Note that microMIPS32 instruction set documentation appears to have
inconsistent information regarding JALX32 instruction - it is written in
the doc that:
"To execute a procedure call within the current 256 MB-aligned region
(...)
The low 26 bits of the target address is the target field shifted left
2 bits."
But the target address is already 26 bits. Moreover, the operation
description indicates that 28 bits are copied, so the statement about
use of 26 bits is _most likely_ incorrect and the corresponding code
remains the same as for standard mips instruction set.
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@fungible.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/mips/tcg/translate.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index 624e6b7786..567ca11ccf 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -4917,6 +4917,13 @@ static void gen_compute_branch(DisasContext *ctx, uint32_t opc,
break;
case OPC_J:
case OPC_JAL:
+ {
+ /* Jump to immediate */
+ int jal_mask = ctx->hflags & MIPS_HFLAG_M16 ? 0xF8000000 : 0xF0000000;
+ btgt = ((ctx->base.pc_next + insn_bytes) & jal_mask) |
+ (uint32_t)offset;
+ break;
+ }
case OPC_JALX:
/* Jump to immediate */
btgt = ((ctx->base.pc_next + insn_bytes) & (int32_t)0xF0000000) |
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/4] target/mips: fix SWM32 handling for micromips
2023-02-16 5:17 [PATCH v2 0/4] target/mips: misc microMIPS fixes Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 1/4] target/mips: fix JALS32/J32 instruction handling for microMIPS Marcin Nowakowski
@ 2023-02-16 5:17 ` Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 3/4] target/mips: implement CP0.Config7.WII bit support Marcin Nowakowski
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Marcin Nowakowski @ 2023-02-16 5:17 UTC (permalink / raw)
To: qemu-devel
Cc: marcin.nowakowski, Philippe Mathieu-Daudé, Aurelien Jarno,
Jiaxun Yang, Aleksandar Rikalo
SWM32 should store a sequence of 32-bit words from the GPRs, but it was
incorrectly coded to store 16-bit words only. As a result, an LWM32 that
usually follows would restore invalid register values.
Fixes: 7dd547e5ab ("target/mips: Use cpu_*_mmuidx_ra instead of
MMU_MODE*_SUFFIX")
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@fungible.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/mips/tcg/ldst_helper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/mips/tcg/ldst_helper.c b/target/mips/tcg/ldst_helper.c
index d0bd0267b2..c1a8380e34 100644
--- a/target/mips/tcg/ldst_helper.c
+++ b/target/mips/tcg/ldst_helper.c
@@ -248,14 +248,14 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
target_ulong i;
for (i = 0; i < base_reglist; i++) {
- cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
+ cpu_stl_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
mem_idx, GETPC());
addr += 4;
}
}
if (do_r31) {
- cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
+ cpu_stl_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/4] target/mips: implement CP0.Config7.WII bit support
2023-02-16 5:17 [PATCH v2 0/4] target/mips: misc microMIPS fixes Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 1/4] target/mips: fix JALS32/J32 instruction handling for microMIPS Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 2/4] target/mips: fix SWM32 handling for micromips Marcin Nowakowski
@ 2023-02-16 5:17 ` Marcin Nowakowski
2023-02-16 8:08 ` Philippe Mathieu-Daudé
2023-02-16 5:17 ` [PATCH v2 4/4] target/mips: set correct CP0.Config[4, 5] values for M14K(c) Marcin Nowakowski
2023-03-09 13:36 ` [PATCH v2 0/4] target/mips: misc microMIPS fixes Philippe Mathieu-Daudé
4 siblings, 1 reply; 8+ messages in thread
From: Marcin Nowakowski @ 2023-02-16 5:17 UTC (permalink / raw)
To: qemu-devel
Cc: marcin.nowakowski, Philippe Mathieu-Daudé, Aurelien Jarno,
Jiaxun Yang, Aleksandar Rikalo
Some pre-release 6 cores use CP0.Config7.WII bit to indicate that a
disabled interrupt should wake up a sleeping CPU.
Enable this bit by default for M14K(c) and P5600. There are potentially
other cores that support this feature, but I do not have a complete
list.
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@fungible.com>
---
target/mips/cpu-defs.c.inc | 3 +++
target/mips/cpu.c | 6 ++++--
target/mips/cpu.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc
index 480e60aeec..fdde04dfb9 100644
--- a/target/mips/cpu-defs.c.inc
+++ b/target/mips/cpu-defs.c.inc
@@ -333,6 +333,7 @@ const mips_def_t mips_defs[] =
.CP0_Config1 = MIPS_CONFIG1,
.CP0_Config2 = MIPS_CONFIG2,
.CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (1 << CP0C3_VInt),
+ .CP0_Config7 = 1 << CP0C7_WII,
.CP0_LLAddr_rw_bitmask = 0,
.CP0_LLAddr_shift = 4,
.SYNCI_Step = 32,
@@ -354,6 +355,7 @@ const mips_def_t mips_defs[] =
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA),
.CP0_Config2 = MIPS_CONFIG2,
.CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (0 << CP0C3_VInt),
+ .CP0_Config7 = 1 << CP0C7_WII,
.CP0_LLAddr_rw_bitmask = 0,
.CP0_LLAddr_shift = 4,
.SYNCI_Step = 32,
@@ -392,6 +394,7 @@ const mips_def_t mips_defs[] =
.CP0_Config5_rw_bitmask = (1 << CP0C5_K) | (1 << CP0C5_CV) |
(1 << CP0C5_MSAEn) | (1 << CP0C5_UFE) |
(1 << CP0C5_FRE) | (1 << CP0C5_UFR),
+ .CP0_Config7 = 1 << CP0C7_WII,
.CP0_LLAddr_rw_bitmask = 0,
.CP0_LLAddr_shift = 0,
.SYNCI_Step = 32,
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index 7a565466cb..7ba359696f 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -144,12 +144,14 @@ static bool mips_cpu_has_work(CPUState *cs)
/*
* Prior to MIPS Release 6 it is implementation dependent if non-enabled
* interrupts wake-up the CPU, however most of the implementations only
- * check for interrupts that can be taken.
+ * check for interrupts that can be taken. For pre-release 6 CPUs,
+ * check for CP0 Config7 'Wait IE ignore' bit.
*/
if ((cs->interrupt_request & CPU_INTERRUPT_HARD) &&
cpu_mips_hw_interrupts_pending(env)) {
if (cpu_mips_hw_interrupts_enabled(env) ||
- (env->insn_flags & ISA_MIPS_R6)) {
+ (env->insn_flags & ISA_MIPS_R6) ||
+ (env->CP0_Config7 & (1 << CP0C7_WII))) {
has_work = true;
}
}
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 0a085643a3..abee7a99d7 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -980,6 +980,7 @@ typedef struct CPUArchState {
#define CP0C6_DATAPREF 0
int32_t CP0_Config7;
int64_t CP0_Config7_rw_bitmask;
+#define CP0C7_WII 31
#define CP0C7_NAPCGEN 2
#define CP0C7_UNIMUEN 1
#define CP0C7_VFPUCGEN 0
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/4] target/mips: set correct CP0.Config[4, 5] values for M14K(c)
2023-02-16 5:17 [PATCH v2 0/4] target/mips: misc microMIPS fixes Marcin Nowakowski
` (2 preceding siblings ...)
2023-02-16 5:17 ` [PATCH v2 3/4] target/mips: implement CP0.Config7.WII bit support Marcin Nowakowski
@ 2023-02-16 5:17 ` Marcin Nowakowski
2023-02-16 8:02 ` [PATCH v2 4/4] target/mips: set correct CP0.Config[4,5] " Philippe Mathieu-Daudé
2023-03-09 13:36 ` [PATCH v2 0/4] target/mips: misc microMIPS fixes Philippe Mathieu-Daudé
4 siblings, 1 reply; 8+ messages in thread
From: Marcin Nowakowski @ 2023-02-16 5:17 UTC (permalink / raw)
To: qemu-devel
Cc: marcin.nowakowski, Philippe Mathieu-Daudé, Aurelien Jarno,
Jiaxun Yang, Aleksandar Rikalo
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@fungible.com>
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/mips/cpu-defs.c.inc | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc
index fdde04dfb9..d45f245a67 100644
--- a/target/mips/cpu-defs.c.inc
+++ b/target/mips/cpu-defs.c.inc
@@ -332,7 +332,10 @@ const mips_def_t mips_defs[] =
(0x1 << CP0C0_AR) | (MMU_TYPE_FMT << CP0C0_MT),
.CP0_Config1 = MIPS_CONFIG1,
.CP0_Config2 = MIPS_CONFIG2,
- .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (1 << CP0C3_VInt),
+ .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (1 << CP0C3_VInt) |
+ (1 << CP0C3_M),
+ .CP0_Config4 = MIPS_CONFIG4 | (1 << CP0C4_M),
+ .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_NFExists),
.CP0_Config7 = 1 << CP0C7_WII,
.CP0_LLAddr_rw_bitmask = 0,
.CP0_LLAddr_shift = 4,
@@ -354,7 +357,10 @@ const mips_def_t mips_defs[] =
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA),
.CP0_Config2 = MIPS_CONFIG2,
- .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (0 << CP0C3_VInt),
+ .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (0 << CP0C3_VInt) |
+ (1 << CP0C3_M),
+ .CP0_Config4 = MIPS_CONFIG4 | (1 << CP0C4_M),
+ .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_NFExists),
.CP0_Config7 = 1 << CP0C7_WII,
.CP0_LLAddr_rw_bitmask = 0,
.CP0_LLAddr_shift = 4,
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 4/4] target/mips: set correct CP0.Config[4,5] values for M14K(c)
2023-02-16 5:17 ` [PATCH v2 4/4] target/mips: set correct CP0.Config[4, 5] values for M14K(c) Marcin Nowakowski
@ 2023-02-16 8:02 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-16 8:02 UTC (permalink / raw)
To: Marcin Nowakowski, qemu-devel
Cc: Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo
On 16/2/23 06:17, Marcin Nowakowski wrote:
> Signed-off-by: Marcin Nowakowski <marcin.nowakowski@fungible.com>
> Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/mips/cpu-defs.c.inc | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/4] target/mips: implement CP0.Config7.WII bit support
2023-02-16 5:17 ` [PATCH v2 3/4] target/mips: implement CP0.Config7.WII bit support Marcin Nowakowski
@ 2023-02-16 8:08 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-16 8:08 UTC (permalink / raw)
To: Marcin Nowakowski, qemu-devel
Cc: Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo
On 16/2/23 06:17, Marcin Nowakowski wrote:
> Some pre-release 6 cores use CP0.Config7.WII bit to indicate that a
> disabled interrupt should wake up a sleeping CPU.
> Enable this bit by default for M14K(c) and P5600. There are potentially
> other cores that support this feature, but I do not have a complete
> list.
>
> Signed-off-by: Marcin Nowakowski <marcin.nowakowski@fungible.com>
> ---
> target/mips/cpu-defs.c.inc | 3 +++
> target/mips/cpu.c | 6 ++++--
> target/mips/cpu.h | 1 +
> 3 files changed, 8 insertions(+), 2 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/4] target/mips: misc microMIPS fixes
2023-02-16 5:17 [PATCH v2 0/4] target/mips: misc microMIPS fixes Marcin Nowakowski
` (3 preceding siblings ...)
2023-02-16 5:17 ` [PATCH v2 4/4] target/mips: set correct CP0.Config[4, 5] values for M14K(c) Marcin Nowakowski
@ 2023-03-09 13:36 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-03-09 13:36 UTC (permalink / raw)
To: Marcin Nowakowski, qemu-devel
Cc: Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo
> Marcin Nowakowski (4):
> target/mips: fix JALS32/J32 instruction handling for microMIPS
> target/mips: fix SWM32 handling for micromips
> target/mips: implement CP0.Config7.WII bit support
> target/mips: set correct CP0.Config[4,5] values for M14K(c)
Merged as commits 9055ffd76e..dcebb36eb0.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-09 13:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16 5:17 [PATCH v2 0/4] target/mips: misc microMIPS fixes Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 1/4] target/mips: fix JALS32/J32 instruction handling for microMIPS Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 2/4] target/mips: fix SWM32 handling for micromips Marcin Nowakowski
2023-02-16 5:17 ` [PATCH v2 3/4] target/mips: implement CP0.Config7.WII bit support Marcin Nowakowski
2023-02-16 8:08 ` Philippe Mathieu-Daudé
2023-02-16 5:17 ` [PATCH v2 4/4] target/mips: set correct CP0.Config[4, 5] values for M14K(c) Marcin Nowakowski
2023-02-16 8:02 ` [PATCH v2 4/4] target/mips: set correct CP0.Config[4,5] " Philippe Mathieu-Daudé
2023-03-09 13:36 ` [PATCH v2 0/4] target/mips: misc microMIPS fixes Philippe Mathieu-Daudé
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).