Skip to contentSkip to conversation

Current MIPS fixes

Qemu-devel Daniel Jacobowitz 2 participants 3 messages Dec 4, 2005 – Dec 5, 2005

lore
Share & tools
lore
#0 lore raw

Fabrice, since the last combined patch I sent you, I've dropped the exec.c bits; added EXCP_HALTED; improved the unaligned access traps; and shaved two bits off the branch delay slot state. It's still pretty slow, but I'm confident it can go faster. Also has the command line passing bits merged.

Signature · 2 lines
Daniel Jacobowitz
CodeSourcery, LLC

Index: cpu-exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/cpu-exec.c,v
retrieving revision 1.69

cpu-exec.c +10 -1
diff -u -p -r1.69 cpu-exec.c
@@ -191,7 +191,7 @@ static inline TranslationBlock *tb_find_
     cs_base = 0;
     pc = env->nip;
 #elif defined(TARGET_MIPS)
-    flags = env->hflags & MIPS_HFLAGS_TMASK;
+    flags = env->hflags & (MIPS_HFLAGS_TMASK | MIPS_HFLAG_BMASK);
     cs_base = 0;
     pc = env->PC;
 #else
@@ -280,6 +280,15 @@ int cpu_exec(CPUState *env1)
            set.  */
         if (env1->interrupt_request
             & (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD)) {
+            env1->halted = 0;
+        } else {
+            return EXCP_HALTED;
+        }
+    }
+#elif defined(TARGET_MIPS)
+    if (env1->halted) {
+        if (env1->interrupt_request &
+            (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)) {
             env1->halted = 0;
         } else {
             return EXCP_HALTED;

Index: exec-all.h
===================================================================
RCS file: /cvsroot/qemu/qemu/exec-all.h,v
retrieving revision 1.43

exec-all.h +1 -0
diff -u -p -r1.43 exec-all.h
@@ -62,6 +62,7 @@ extern target_ulong gen_opc_npc[OPC_BUF_
 extern uint8_t gen_opc_cc_op[OPC_BUF_SIZE];
 extern uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
 extern target_ulong gen_opc_jump_pc[2];
+extern uint32_t gen_opc_hflags[OPC_BUF_SIZE];
 
 typedef void (GenOpFunc)(void);
 typedef void (GenOpFunc1)(long);

Index: gdbstub.c
===================================================================
RCS file: /cvsroot/qemu/qemu/gdbstub.c,v
retrieving revision 1.33

gdbstub.c +72 -4

88 lines not on this page · raw message

Index: softmmu_template.h
===================================================================
RCS file: /cvsroot/qemu/qemu/softmmu_template.h,v
retrieving revision 1.14

softmmu_template.h +27 -1
diff -u -p -r1.14 softmmu_template.h
@@ -97,15 +97,28 @@ DATA_TYPE REGPARM(1) glue(glue(__ld, SUF
             /* slow unaligned access (it spans two pages or IO) */
         do_unaligned_access:
             retaddr = GETPC();
+#ifdef ALIGNED_ONLY
+            do_unaligned_access(addr, READ_ACCESS_TYPE, is_user, retaddr);
+#endif
             res = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(addr, 
                                                          is_user, retaddr);
         } else {
-            /* unaligned access in the same page */
+            /* unaligned/aligned access in the same page */
+#ifdef ALIGNED_ONLY
+            if ((addr & (DATA_SIZE - 1)) != 0) {
+                retaddr = GETPC();
+                do_unaligned_access(addr, READ_ACCESS_TYPE, is_user, retaddr);
+            }
+#endif
             res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(long)physaddr);
         }
     } else {
         /* the page is not in the TLB : fill it */
         retaddr = GETPC();
+#ifdef ALIGNED_ONLY
+        if ((addr & (DATA_SIZE - 1)) != 0)
+            do_unaligned_access(addr, READ_ACCESS_TYPE, is_user, retaddr);
+#endif
         tlb_fill(addr, READ_ACCESS_TYPE, is_user, retaddr);
         goto redo;
     }
@@ -213,15 +226,28 @@ void REGPARM(2) glue(glue(__st, SUFFIX),
         } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) {
         do_unaligned_access:
             retaddr = GETPC();
+#ifdef ALIGNED_ONLY
+            do_unaligned_access(addr, 1, is_user, retaddr);
+#endif
             glue(glue(slow_st, SUFFIX), MMUSUFFIX)(addr, val, 
                                                    is_user, retaddr);
         } else {
             /* aligned/unaligned access in the same page */
+#ifdef ALIGNED_ONLY
+            if ((addr & (DATA_SIZE - 1)) != 0) {
+                retaddr = GETPC();
+                do_unaligned_access(addr, 1, is_user, retaddr);
+            }
+#endif
             glue(glue(st, SUFFIX), _raw)((uint8_t *)(long)physaddr, val);
         }
     } else {
         /* the page is not in the TLB : fill it */
         retaddr = GETPC();
+#ifdef ALIGNED_ONLY
+        if ((addr & (DATA_SIZE - 1)) != 0)
+            do_unaligned_access(addr, 1, is_user, retaddr);
+#endif
         tlb_fill(addr, 1, is_user, retaddr);
         goto redo;
     }

Index: translate-all.c
===================================================================
RCS file: /cvsroot/qemu/qemu/translate-all.c,v
retrieving revision 1.13

translate-all.c +4 -0
diff -u -p -r1.13 translate-all.c
@@ -53,6 +53,8 @@ uint8_t gen_opc_cc_op[OPC_BUF_SIZE];
 #elif defined(TARGET_SPARC)
 target_ulong gen_opc_npc[OPC_BUF_SIZE];
 target_ulong gen_opc_jump_pc[2];
+#elif defined(TARGET_MIPS)
+uint32_t gen_opc_hflags[OPC_BUF_SIZE];
 #endif
 
 int code_copy_enabled = 1;
@@ -302,6 +304,8 @@ int cpu_restore_state(TranslationBlock *
     }
 #elif defined(TARGET_MIPS)
     env->PC = gen_opc_pc[j];
+    env->hflags &= ~MIPS_HFLAG_BMASK;
+    env->hflags |= gen_opc_hflags[j];
 #endif
     return 0;
 }

Index: hw/mips_r4k.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/mips_r4k.c,v
retrieving revision 1.11

mips_r4k.c +19 -2
diff -u -p -r1.11 mips_r4k.c
@@ -53,7 +53,7 @@ static void cpu_mips_update_count (CPUSt
     next = now + muldiv64(compare - tmp, ticks_per_sec, 100 * 1000 * 1000);
     if (next == now)
 	next++;
-#if 1
+#if 0
     if (logfile) {
         fprintf(logfile, "%s: 0x%08llx %08x %08x => 0x%08llx\n",
                 __func__, now, count, compare, next - now);
@@ -84,7 +84,7 @@ static void mips_timer_cb (void *opaque)
     CPUState *env;
 
     env = opaque;
-#if 1
+#if 0
     if (logfile) {
         fprintf(logfile, "%s\n", __func__);
     }
@@ -103,23 +103,29 @@ void cpu_mips_clock_init (CPUState *env)
 
 static void io_writeb (void *opaque, target_phys_addr_t addr, uint32_t value)
 {
+#if 0
     if (logfile)
         fprintf(logfile, "%s: addr %08x val %08x\n", __func__, addr, value);
+#endif
     cpu_outb(NULL, addr & 0xffff, value);
 }
 
 static uint32_t io_readb (void *opaque, target_phys_addr_t addr)
 {
     uint32_t ret = cpu_inb(NULL, addr & 0xffff);
+#if 0
     if (logfile)
         fprintf(logfile, "%s: addr %08x val %08x\n", __func__, addr, ret);
+#endif
     return ret;
 }
 
 static void io_writew (void *opaque, target_phys_addr_t addr, uint32_t value)
 {
+#if 0
     if (logfile)
         fprintf(logfile, "%s: addr %08x val %08x\n", __func__, addr, value);
+#endif
 #ifdef TARGET_WORDS_BIGENDIAN
     value = bswap16(value);
 #endif
@@ -132,15 +138,19 @@ static uint32_t io_readw (void *opaque, 
 #ifdef TARGET_WORDS_BIGENDIAN
     ret = bswap16(ret);
 #endif
+#if 0
     if (logfile)
         fprintf(logfile, "%s: addr %08x val %08x\n", __func__, addr, ret);
+#endif
     return ret;
 }
 
 static void io_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
 {
+#if 0
     if (logfile)
         fprintf(logfile, "%s: addr %08x val %08x\n", __func__, addr, value);
+#endif
 #ifdef TARGET_WORDS_BIGENDIAN
     value = bswap32(value);
 #endif
@@ -154,8 +164,10 @@ static uint32_t io_readl (void *opaque, 
 #ifdef TARGET_WORDS_BIGENDIAN
     ret = bswap32(ret);
 #endif
+#if 0
     if (logfile)
         fprintf(logfile, "%s: addr %08x val %08x\n", __func__, addr, ret);
+#endif
     return ret;
 }
 
@@ -233,6 +245,11 @@ void mips_r4k_init (int ram_size, int vg
             initrd_size = 0;
         }
         env->PC = KERNEL_LOAD_ADDR;
+	/* Store command line.  */
+        strcpy (phys_ram_base + (16 << 20) - 256, kernel_cmdline);
+        /* FIXME: little endian support */
+        *(int *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678);
+        *(int *)(phys_ram_base + (16 << 20) - 264) = tswap32 (ram_size);
     } else {
         kernel_base = 0;
         kernel_size = 0;

Index: target-mips/cpu.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/cpu.h,v
retrieving revision 1.3

cpu.h +18 -13
diff -u -p -r1.3 cpu.h
@@ -1,6 +1,8 @@
 #if !defined (__MIPS_CPU_H__)
 #define __MIPS_CPU_H__
 
+#define TARGET_HAS_ICE 1
+
 #include "mips-defs.h"
 #include "cpu-defs.h"
 #include "config.h"
@@ -18,6 +20,7 @@ typedef struct tlb_t tlb_t;
 struct tlb_t {
     target_ulong VPN;
     target_ulong end;
+    target_ulong end2;
     uint8_t ASID;
     uint8_t G;
     uint8_t C[2];
@@ -151,18 +154,20 @@ struct CPUMIPSState {
 #define MIPS_HFLAG_DM     0x0008 /* Debug mode                         */
 #define MIPS_HFLAG_SM     0x0010 /* Supervisor mode                    */
 #define MIPS_HFLAG_RE     0x0040 /* Reversed endianness                */
-#define MIPS_HFLAG_DS     0x0080 /* In / out of delay slot             */
-    /* Those flags keep the branch state if the translation is interrupted
-     * between the branch instruction and the delay slot
-     */
-#define MIPS_HFLAG_BMASK  0x0F00
-#define MIPS_HFLAG_B      0x0100 /* Unconditional branch               */
-#define MIPS_HFLAG_BC     0x0200 /* Conditional branch                 */
-#define MIPS_HFLAG_BL     0x0400 /* Likely branch                      */
-#define MIPS_HFLAG_BR     0x0800 /* branch to register (can't link TB) */
+    /* If translation is interrupted between the branch instruction and
+     * the delay slot, record what type of branch it is so that we can
+     * resume translation properly.  It might be possible to reduce
+     * this from three bits to two.  */
+#define MIPS_HFLAG_BMASK  0x0380
+#define MIPS_HFLAG_B      0x0080 /* Unconditional branch               */
+#define MIPS_HFLAG_BC     0x0100 /* Conditional branch                 */
+#define MIPS_HFLAG_BL     0x0180 /* Likely branch                      */
+#define MIPS_HFLAG_BR     0x0200 /* branch to register (can't link TB) */
     target_ulong btarget;        /* Jump / branch target               */
     int bcond;                   /* Branch condition (if needed)       */
 
+    int halted; /* TRUE if the CPU is in suspend state */
+
     CPU_COMMON
 };
 
@@ -202,15 +207,15 @@ enum {
     EXCP_IBE,
     EXCP_DBp,
     EXCP_SYSCALL,
-    EXCP_BREAK,
-    EXCP_CpU, /* 16 */
+    EXCP_BREAK, /* 16 */
+    EXCP_CpU,
     EXCP_RI,
     EXCP_OVERFLOW,
     EXCP_TRAP,
     EXCP_DDBS,
     EXCP_DWATCH,
-    EXCP_LAE, /* 22 */
-    EXCP_SAE,
+    EXCP_LAE,
+    EXCP_SAE, /* 24 */
     EXCP_LTLBL,
     EXCP_TLBL,
     EXCP_TLBS,

Index: target-mips/exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/exec.h,v
retrieving revision 1.4

exec.h +13 -12
diff -u -p -r1.4 exec.h
@@ -65,19 +65,19 @@ void do_tlbwi (void);
 void do_tlbwr (void);
 void do_tlbp (void);
 void do_tlbr (void);
-void do_lwl_raw (void);
-void do_lwr_raw (void);
-void do_swl_raw (void);
-void do_swr_raw (void);
+void do_lwl_raw (uint32_t);
+void do_lwr_raw (uint32_t);
+uint32_t do_swl_raw (uint32_t);
+uint32_t do_swr_raw (uint32_t);
 #if !defined(CONFIG_USER_ONLY)
-void do_lwl_user (void);
-void do_lwl_kernel (void);
-void do_lwr_user (void);
-void do_lwr_kernel (void);
-void do_swl_user (void);
-void do_swl_kernel (void);
-void do_swr_user (void);
-void do_swr_kernel (void);
+void do_lwl_user (uint32_t);
+void do_lwl_kernel (uint32_t);
+void do_lwr_user (uint32_t);
+void do_lwr_kernel (uint32_t);
+uint32_t do_swl_user (uint32_t);
+uint32_t do_swl_kernel (uint32_t);
+uint32_t do_swr_user (uint32_t);
+uint32_t do_swr_kernel (uint32_t);
 #endif
 void do_pmon (int function);
 
@@ -88,6 +88,7 @@ void do_interrupt (CPUState *env);
 void cpu_loop_exit(void);
 void do_raise_exception_err (uint32_t exception, int error_code);
 void do_raise_exception (uint32_t exception);
+void do_raise_exception_direct (uint32_t exception);
 
 void cpu_dump_state(CPUState *env, FILE *f, 
                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),

Index: target-mips/helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/helper.c,v retrieving revision 1.7

helper.c +14 -7
diff -u -p -r1.7 helper.c
@@ -46,7 +46,7 @@ static int map_address (CPUState *env, t
         tlb = &env->tlb[i];
         /* Check ASID, virtual page number & size */
         if ((tlb->G == 1 || tlb->ASID == ASID) &&
-            tlb->VPN == tag && address < tlb->end) {
+            tlb->VPN == tag && address < tlb->end2) {
             /* TLB match */
             n = (address >> 12) & 1;
             /* Check access rights */
@@ -167,10 +167,15 @@ int cpu_mips_handle_mmu_fault (CPUState 
     int ret = 0;
 
     if (logfile) {
+#if 0
         cpu_dump_state(env, logfile, fprintf, 0);
+#endif
         fprintf(logfile, "%s pc %08x ad %08x rw %d is_user %d smmu %d\n",
                 __func__, env->PC, address, rw, is_user, is_softmmu);
     }
+
+    rw &= 1;
+
     /* data access */
     /* XXX: put correct access by using cpu_restore_state()
        correctly */
@@ -226,7 +231,7 @@ int cpu_mips_handle_mmu_fault (CPUState 
         /* Raise exception */
         env->CP0_BadVAddr = address;
         env->CP0_Context = (env->CP0_Context & 0xff800000) |
-	                   ((address >> 8) &   0x007ffff0);
+	                   ((address >> 9) &   0x007ffff0);
         env->CP0_EntryHi =
             (env->CP0_EntryHi & 0x000000FF) | (address & 0xFFFFF000);
         env->exception_index = exception;
@@ -276,11 +281,12 @@ void do_interrupt (CPUState *env)
         env->CP0_Debug |= 1 << CP0DB_DDBL;
         goto set_DEPC;
     set_DEPC:
-        if (env->hflags & MIPS_HFLAG_DS) {
+        if (env->hflags & MIPS_HFLAG_BMASK) {
             /* If the exception was raised from a delay slot,
              * come back to the jump
              */
             env->CP0_DEPC = env->PC - 4;
+            env->hflags &= ~MIPS_HFLAG_BMASK;
         } else {
             env->CP0_DEPC = env->PC;
         }
@@ -316,8 +322,7 @@ void do_interrupt (CPUState *env)
         env->CP0_Status = (1 << CP0St_CU0) | (1 << CP0St_BEV) |
             (1 << CP0St_NMI);
     set_error_EPC:
-        env->hflags = MIPS_HFLAG_ERL;
-        if (env->hflags & MIPS_HFLAG_DS) {
+        if (env->hflags & MIPS_HFLAG_BMASK) {
             /* If the exception was raised from a delay slot,
              * come back to the jump
              */
@@ -325,6 +330,7 @@ void do_interrupt (CPUState *env)
         } else {
             env->CP0_ErrorEPC = env->PC;
         }
+        env->hflags = MIPS_HFLAG_ERL;
         pc = 0xBFC00000;
         break;
     case EXCP_MCHECK:
@@ -366,7 +372,7 @@ void do_interrupt (CPUState *env)
         goto set_EPC;
     case EXCP_CpU:
         cause = 11;
-        /* XXX: fill in the faulty unit number */
+        env->CP0_Cause = (env->CP0_Cause & ~0x03000000) | (env->error_code << 28);
         goto set_EPC;
     case EXCP_OVERFLOW:
         cause = 12;
@@ -391,12 +397,13 @@ void do_interrupt (CPUState *env)
         env->hflags |= MIPS_HFLAG_EXL;
         pc += offset;
         env->CP0_Cause = (env->CP0_Cause & ~0x7C) | (cause << 2);
-        if (env->hflags & MIPS_HFLAG_DS) {
+        if (env->hflags & MIPS_HFLAG_BMASK) {
             /* If the exception was raised from a delay slot,
              * come back to the jump
              */
             env->CP0_EPC = env->PC - 4;
             env->CP0_Cause |= 0x80000000;
+            env->hflags &= ~MIPS_HFLAG_BMASK;
         } else {
             env->CP0_EPC = env->PC;
             env->CP0_Cause &= ~0x80000000;

Index: target-mips/op.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/op.c,v
retrieving revision 1.4

op.c +16 -6
diff -u -p -r1.4 op.c
@@ -207,7 +207,7 @@ void op_addo (void)
     tmp = T0;
     T0 += T1;
     if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) {
-        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
+        CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
     }
     RETURN();
 }
@@ -225,7 +225,7 @@ void op_subo (void)
     tmp = T0;
     T0 = (int32_t)T0 - (int32_t)T1;
     if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) {
-        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
+        CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
     }
     RETURN();
 }
@@ -364,7 +364,7 @@ static inline void set_HILO (uint64_t HI
 
 void op_mult (void)
 {
-    set_HILO((int64_t)T0 * (int64_t)T1);
+    set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
     RETURN();
 }
 
@@ -378,7 +378,7 @@ void op_madd (void)
 {
     int64_t tmp;
 
-    tmp = ((int64_t)T0 * (int64_t)T1);
+    tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
     set_HILO((int64_t)get_HILO() + tmp);
     RETURN();
 }
@@ -396,7 +396,7 @@ void op_msub (void)
 {
     int64_t tmp;
 
-    tmp = ((int64_t)T0 * (int64_t)T1);
+    tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
     set_HILO((int64_t)get_HILO() - tmp);
     RETURN();
 }
@@ -595,11 +595,16 @@ void op_pmon (void)
 void op_trap (void)
 {
     if (T0) {
-        CALL_FROM_TB1(do_raise_exception, EXCP_TRAP);
+        CALL_FROM_TB1(do_raise_exception_direct, EXCP_TRAP);
     }
     RETURN();
 }
 
+void op_debug (void)
+{
+  CALL_FROM_TB1(do_raise_exception_direct, EXCP_DEBUG);
+}
+
 void op_set_lladdr (void)
 {
     env->CP0_LLAddr = T2;
@@ -654,3 +659,8 @@ void op_exit_tb (void)
     EXIT_TB();
 }
 
+void op_wait (void)
+{
+    env->halted = 1;
+    CALL_FROM_TB1(do_raise_exception, EXCP_HLT);
+}

Index: target-mips/op_helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/op_helper.c,v retrieving revision 1.7

op_helper.c +54 -4

130 lines not on this page · raw message

Index: target-mips/op_helper_mem.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/op_helper_mem.c,v retrieving revision 1.1

op_helper_mem.c +6 -14
diff -u -p -r1.1 op_helper_mem.c
@@ -1,11 +1,9 @@
-void glue(do_lwl, MEMSUFFIX) (void)
+void glue(do_lwl, MEMSUFFIX) (uint32_t tmp)
 {
 #if defined (DEBUG_OP)
     target_ulong sav = T0;
 #endif
-    uint32_t tmp;
 
-    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
     /* XXX: this is valid only in big-endian mode
      *      should be reverted for little-endian...
      */
@@ -32,14 +30,12 @@ void glue(do_lwl, MEMSUFFIX) (void)
     RETURN();
 }
 
-void glue(do_lwr, MEMSUFFIX) (void)
+void glue(do_lwr, MEMSUFFIX) (uint32_t tmp)
 {
 #if defined (DEBUG_OP)
     target_ulong sav = T0;
 #endif
-    uint32_t tmp;
 
-    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
     /* XXX: this is valid only in big-endian mode
      *      should be reverted for little-endian...
      */
@@ -66,14 +62,12 @@ void glue(do_lwr, MEMSUFFIX) (void)
     RETURN();
 }
 
-void glue(do_swl, MEMSUFFIX) (void)
+uint32_t glue(do_swl, MEMSUFFIX) (uint32_t tmp)
 {
 #if defined (DEBUG_OP)
     target_ulong sav;
 #endif
-    uint32_t tmp;
 
-    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
 #if defined (DEBUG_OP)
     sav = tmp;
 #endif
@@ -94,7 +88,6 @@ void glue(do_swl, MEMSUFFIX) (void)
         tmp = (tmp & 0xFFFFFF00) | (T1 >> 24);
         break;
     }
-    glue(stl, MEMSUFFIX)(T0 & ~3, tmp);
 #if defined (DEBUG_OP)
     if (logfile) {
         fprintf(logfile, "%s: %08x - %08x %08x => %08x\n",
@@ -102,16 +95,15 @@ void glue(do_swl, MEMSUFFIX) (void)
     }
 #endif
     RETURN();
+    return tmp;
 }
 
-void glue(do_swr, MEMSUFFIX) (void)
+uint32_t glue(do_swr, MEMSUFFIX) (uint32_t tmp)
 {
 #if defined (DEBUG_OP)
     target_ulong sav;
 #endif
-    uint32_t tmp;
 
-    tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
 #if defined (DEBUG_OP)
     sav = tmp;
 #endif
@@ -132,7 +124,6 @@ void glue(do_swr, MEMSUFFIX) (void)
         tmp = T1;
         break;
     }
-    glue(stl, MEMSUFFIX)(T0 & ~3, tmp);
 #if defined (DEBUG_OP)
     if (logfile) {
         fprintf(logfile, "%s: %08x - %08x %08x => %08x\n",
@@ -140,4 +131,5 @@ void glue(do_swr, MEMSUFFIX) (void)
     }
 #endif
     RETURN();
+    return tmp;
 }

Index: target-mips/op_mem.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/op_mem.c,v retrieving revision 1.1

op_mem.c +12 -5
diff -u -p -r1.1 op_mem.c
@@ -67,28 +67,35 @@ void glue(op_sw, MEMSUFFIX) (void)
     RETURN();
 }
 
-/* "half" load and stores */
+/* "half" load and stores.  We must do the memory access inline,
+   or fault handling won't work.  */
 void glue(op_lwl, MEMSUFFIX) (void)
 {
-    CALL_FROM_TB0(glue(do_lwl, MEMSUFFIX));
+    uint32_t tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
+    CALL_FROM_TB1(glue(do_lwl, MEMSUFFIX), tmp);
     RETURN();
 }
 
 void glue(op_lwr, MEMSUFFIX) (void)
 {
-    CALL_FROM_TB0(glue(do_lwr, MEMSUFFIX));
+    uint32_t tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
+    CALL_FROM_TB1(glue(do_lwr, MEMSUFFIX), tmp);
     RETURN();
 }
 
 void glue(op_swl, MEMSUFFIX) (void)
 {
-    CALL_FROM_TB0(glue(do_swl, MEMSUFFIX));
+    uint32_t tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
+    tmp = CALL_FROM_TB1(glue(do_swl, MEMSUFFIX), tmp);
+    glue(stl, MEMSUFFIX)(T0 & ~3, tmp);
     RETURN();
 }
 
 void glue(op_swr, MEMSUFFIX) (void)
 {
-    CALL_FROM_TB0(glue(do_swr, MEMSUFFIX));
+    uint32_t tmp = glue(ldl, MEMSUFFIX)(T0 & ~3);
+    tmp = CALL_FROM_TB1(glue(do_swr, MEMSUFFIX), tmp);
+    glue(stl, MEMSUFFIX)(T0 & ~3, tmp);
     RETURN();
 }
 

Index: target-mips/translate.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-mips/translate.c,v retrieving revision 1.10

translate.c +98 -43

311 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Daniel Jacobowitz

Fabrice, since the last combined patch I sent you, I've dropped the exec.c bits; added EXCP_HALTED; improved the unaligned access traps; and shaved two bits off the branch delay slot state. It's still pretty slow, but I'm confident it can go faster. Also has the command line passing bits merged.

I am about to commit it !

About your command line patch : can you also add support for the "-inird" option ? It would be easier for me to test it and to distribute a sample version.

Fabrice.

#2 lore raw
Quoted 7 lines · Fabrice Bellard
Quoted 5 lines · Daniel Jacobowitz

Fabrice, since the last combined patch I sent you, I've dropped the exec.c bits; added EXCP_HALTED; improved the unaligned access traps; and shaved two
bits off the branch delay slot state. It's still pretty slow, but I'm confident it can go faster. Also has the command line passing bits merged.

Quoted 5 lines

I am about to commit it !

About your command line patch : can you also add support for the "-inird" option ? It would be easier for me to test it and to distribute a sample version.

I'll take a look at what this requires later in the week. Thanks!

Signature · 2 lines
Daniel Jacobowitz
CodeSourcery, LLC