qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Patch] Add handling of edge triggered interrupts in fu


From: Erik de Castro Lopo
Subject: Re: [Qemu-devel] [Patch] Add handling of edge triggered interrupts in function pic_irq_request.
Date: Thu, 15 May 2008 21:27:15 +1000

Erik de Castro Lopo wrote:

> Sorry, this patch needs more testing.

Ah, I had one crash of the guest OS, but I now realize that was
due to another bug related to rebooting the guest OS. I plan on
tracking down this bug later.

For now, as long as I use the -no-reboot option I can install XP64
under qemu-system-x86_64.

I should probably explain a little about how I came up with this fix.

As had been noted on the qemu-user forum:

    http://qemu-forum.ipi.fi/viewtopic.php?f=9&t=4329

somewhere between version 0.9.0 and 0.9.1, support for running
XP64 as a guest OS was broken. For me, this meant that installing
XP64 under qemu would hang very early in the install process.

Over the last two nights, I did a binary search from SVN revision
3000 to 4000 and found that XP64 stopped working at SVN 3371.
Inspecting the differences between 3370 and 3371 I zeroed in on
this difference:

------- Following diff for illustration purposes only -------
--- hw/pc.c     (revision 3370)
+++ hw/pc.c     (revision 3371)
@@ -100,10 +103,8 @@
 static void pic_irq_request(void *opaque, int irq, int level)
 {
     CPUState *env = opaque;
-    if (level)
+    if (level && apic_accept_pic_intr(env))
         cpu_interrupt(env, CPU_INTERRUPT_HARD);
-    else
-        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
 }
 
 /* PC cmos mappings */

--------- Above diff for illustration purposes only ---------

and I noted that patch 3371 was removing call to cpu_reset_interrupt
for the case when the interrupt was not level triggered  (is that
right?). To me, removing this interrupt handling didn't seem right.
I therefore applied the following patch to 3371 to get the xp64
install process past the place where is was hanging before.

------- Following diff for illustration purposes only -------
--- hw/pc.c     2008-05-15 01:00:12 +0000
+++ hw/pc.c     2008-05-15 01:00:53 +0000
@@ -105,6 +105,8 @@
     CPUState *env = opaque;
     if (level && apic_accept_pic_intr(env))
         cpu_interrupt(env, CPU_INTERRUPT_HARD);
+    else
+        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
 }
 
 /* PC cmos mappings */

--------- Above diff for illustration purposes only ---------

Unfortunately, the codebase has moved on since 3371 and this patch did
not apply to current SVN head.

I then did another binary search to find where my patch could no
longer be applied. That was at SVN revision 4207. The diff between
my patched SVN revision 4206 and SVN revision 4207 is below.

------- Following diff for illustration purposes only -------
 static void pic_irq_request(void *opaque, int irq, int level)
 {
-    CPUState *env = opaque;
-    if (level && apic_accept_pic_intr(env))
-        cpu_interrupt(env, CPU_INTERRUPT_HARD);
-    else
-        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+    CPUState *env = first_cpu;
+
+    if (!level)
+        return;
+
+    while (env) {
+        if (apic_accept_pic_intr(env))
+            apic_local_deliver(env, APIC_LINT0);
+        env = env->next_cpu;
+    }
 }
--------- Above diff for illustration purposes only ---------

Comparing my patched 4206 with 4207 resulted in the following patch.

--------- This is the patch I'd like to see applied ---------
diff --git a/hw/pc.c b/hw/pc.c
index c92384c..65ea5c6 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -118,8 +118,10 @@ static void pic_irq_request(void *opaque, int irq, int 
level)
 {
     CPUState *env = first_cpu;
 
-    if (!level)
+    if (!level) {
+        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
         return;
+    }
 
     while (env) {
         if (apic_accept_pic_intr(env))

--------- This is the patch I'd like to see applied ---------

Cheers,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"If Java had true garbage collection, most programs would delete
themselves upon execution." -- Robert Sewell




reply via email to

[Prev in Thread] Current Thread [Next in Thread]