Skip to contentSkip to conversation

Add support for CPU_LOG_INT (MIPS targets)

PATCH In review Stefan Weil 2 participants 4 messages Oct 2, 2008 – Oct 14, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for CPU_LOG_INT (MIPS targets)

This patch adds some interrupt logging for MIPS targets.

Please apply it to Qemu trunk.

Regards
Stefan

Add interrupt logging for MIPS targets.

mips_int.c +21 -2
Index: hw/mips_int.c
===================================================================
@@ -1,6 +1,7 @@
 #include "hw.h"
 #include "mips.h"
 #include "cpu.h"
+#include "qemu-log.h"
 
 /* Raise IRQ to CPU if necessary. It must be called every time the active
    IRQ may change */
@@ -12,10 +13,28 @@
         !(env->hflags & MIPS_HFLAG_DM)) {
         if ((env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) &&
             !(env->interrupt_request & CPU_INTERRUPT_HARD)) {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: cpu_interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }
             cpu_interrupt(env, CPU_INTERRUPT_HARD);
-	}
-    } else
+        } else {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: no interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }
+        }
+    } else {
+        if (loglevel & CPU_LOG_INT) {
+            fprintf(logfile, "%s: cpu_reset_interrupt\n", __func__);
+            cpu_dump_state(env, logfile, fprintf, 0);
+        }
         cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+    }
 }
 
 static void cpu_mips_irq_request(void *opaque, int irq, int level)
#1 lore raw
Quoted 35 lines · Stefan Weil

This patch adds some interrupt logging for MIPS targets.

Please apply it to Qemu trunk.

Regards
Stefan

Add interrupt logging for MIPS targets.

Index: hw/mips_int.c
===================================================================

mips_int.c +7 -0
@@ -1,6 +1,7 @@
 #include "hw.h"
 #include "mips.h"
 #include "cpu.h"
+#include "qemu-log.h"
 
 /* Raise IRQ to CPU if necessary. It must be called every time the active
    IRQ may change */
@@ -12,10 +13,28 @@
         !(env->hflags & MIPS_HFLAG_DM)) {
         if ((env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) &&
             !(env->interrupt_request & CPU_INTERRUPT_HARD)) {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: cpu_interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }

mips_int.c line 29

Quoted 10 lines
mips_int.c +7 -2
             cpu_interrupt(env, CPU_INTERRUPT_HARD);
-	}
-    } else
+        } else {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: no interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }

I am not sure we really want to log this case, as no interrupt are actually triggered (disabled interrupt, already processing an interrupt, etc.)

mips_int.c line 40

Quoted 11 lines
mips_int.c +7 -0
+        }
+    } else {
+        if (loglevel & CPU_LOG_INT) {
+            fprintf(logfile, "%s: cpu_reset_interrupt\n", __func__);
+            cpu_dump_state(env, logfile, fprintf, 0);
+        }
         cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+    }
 }
 
 static void cpu_mips_irq_request(void *opaque, int irq, int level)

Otherwise looks ok.

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#2 lore raw
Quoted 36 lines · Aurelien Jarno

On Thu, Oct 02, 2008 at 10:04:26PM +0200, Stefan Weil wrote:

...

Quoted 33 lines

Add interrupt logging for MIPS targets.

Index: hw/mips_int.c
===================================================================

mips_int.c +11 -2
@@ -1,6 +1,7 @@
 #include "hw.h"
 #include "mips.h"
 #include "cpu.h"
+#include "qemu-log.h"
 
 /* Raise IRQ to CPU if necessary. It must be called every time the active
    IRQ may change */
@@ -12,10 +13,28 @@
         !(env->hflags & MIPS_HFLAG_DM)) {
         if ((env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) &&
             !(env->interrupt_request & CPU_INTERRUPT_HARD)) {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: cpu_interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }
             cpu_interrupt(env, CPU_INTERRUPT_HARD);
-	}
-    } else
+        } else {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: no interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
Quoted 9 lines

mips_int.c line 39

Quoted 4 lines
mips_int.c +3 -0
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }
 

I am not sure we really want to log this case, as no interrupt are actually triggered (disabled interrupt, already processing an interrupt, etc.)

Well, I added this code to debug a real problem, not just for fun. It helps to see who triggers this code, even when interrupts are disabled at that moment.

Quoted 10 lines
Quoted 10 lines
mips_int.c +7 -0
+        }
+    } else {
+        if (loglevel & CPU_LOG_INT) {
+            fprintf(logfile, "%s: cpu_reset_interrupt\n", __func__);
+            cpu_dump_state(env, logfile, fprintf, 0);
+        }
         cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+    }
 }
 
Quoted 6 lines
Quoted 2 lines

static void cpu_mips_irq_request(void *opaque, int irq, int level)

Otherwise looks ok.

Thanks,
Stefan

#3 lore raw
Quoted 46 lines · Stefan Weil
Quoted 36 lines · Aurelien Jarno

On Thu, Oct 02, 2008 at 10:04:26PM +0200, Stefan Weil wrote:

...

Quoted 33 lines

Add interrupt logging for MIPS targets.

Index: hw/mips_int.c
===================================================================

mips_int.c +11 -2
@@ -1,6 +1,7 @@
 #include "hw.h"
 #include "mips.h"
 #include "cpu.h"
+#include "qemu-log.h"
 
 /* Raise IRQ to CPU if necessary. It must be called every time the active
    IRQ may change */
@@ -12,10 +13,28 @@
         !(env->hflags & MIPS_HFLAG_DM)) {
         if ((env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) &&
             !(env->interrupt_request & CPU_INTERRUPT_HARD)) {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: cpu_interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }
             cpu_interrupt(env, CPU_INTERRUPT_HARD);
-	}
-    } else
+        } else {
+            if (loglevel & CPU_LOG_INT) {
+                fprintf(logfile, "%s: no interrupt (0x%08x,0x%08x)\n", __func__,
+                  env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask,
Quoted 9 lines

mips_int.c line 39

Quoted 4 lines
mips_int.c +3 -0
+                  env->interrupt_request);
+                cpu_dump_state(env, logfile, fprintf, 0);
+            }
 

I am not sure we really want to log this case, as no interrupt are actually triggered (disabled interrupt, already processing an interrupt, etc.)

Quoted 4 lines

Well, I added this code to debug a real problem, not just for fun. It helps to see who triggers this code, even when interrupts are disabled at that moment.

Then if you want to see the interrupts in all cases, what about adding it directly to cpu_mips_irq_request()? The resulting code would be cleaner.

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net