summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-05-18 01:13:09 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-05-18 01:13:09 +0000
commit34ae7b51f54a5d58d30e31a92f8ece02973de50b (patch)
treef425df361d7f8992723368ba914408e7209c5285
parentf96f4c9d720bced5ee0f57c9dc36cf17347155b9 (diff)
downloadfocaccia-qemu-34ae7b51f54a5d58d30e31a92f8ece02973de50b.tar.gz
focaccia-qemu-34ae7b51f54a5d58d30e31a92f8ece02973de50b.zip
Work around the lack of proper handling for self-modifying code.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2827 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--target-mips/op.c10
-rw-r--r--target-mips/translate.c22
2 files changed, 30 insertions, 2 deletions
diff --git a/target-mips/op.c b/target-mips/op.c
index 1188e82846..e119765b3c 100644
--- a/target-mips/op.c
+++ b/target-mips/op.c
@@ -1001,6 +1001,16 @@ void op_jnz_T2 (void)
     RETURN();
 }
 
+void op_flush_icache_range(void) {
+    CALL_FROM_TB2(tlb_flush_page, env, T0 + T1);
+    RETURN();
+}
+
+void op_flush_icache_all(void) {
+    CALL_FROM_TB1(tb_flush, env);
+    RETURN();
+}
+
 /* CP0 functions */
 void op_mfc0_index (void)
 {
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 410560c286..66e9def854 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -5648,8 +5648,26 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
          gen_ldst(ctx, op, rt, rs, imm);
          break;
     case OPC_CACHE:
-         /* Treat as a noop */
-         break;
+        /* FIXME: This works around self-modifying code, but only
+           if the guest OS handles it properly, and if there's no
+           such code executed in uncached space. */
+        if (!(rt & 0x3))
+            switch ((rt >> 2) & 0x7) {
+            case 4:
+                GEN_LOAD_REG_TN(T0, rs);
+                GEN_LOAD_IMM_TN(T1, imm);
+                gen_op_flush_icache_range();
+                break;
+            case 2:
+            case 1:
+            case 0:
+                /* Can be very inefficient. */
+                gen_op_flush_icache_all();
+                break;
+            default:
+                break;
+            }
+        break;
     case OPC_PREF:
         /* Treat as a noop */
         break;