Add handling of edge triggered interrupts in function pic_irq_request.
This fixes a regression that prevents Win XP64 from installing and running under Qemu. The original breakage happened in the transition fron SVN revision 3371 to 3372.
--- hw/pc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/pc.c +3 -1
@@ -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))
Quoted 4 lines · Erik de Castro Lopo
This fixes a regression that prevents Win XP64 from installing and running under Qemu. The original breakage happened in the transition fron SVN revision 3371 to 3372.
Sorry, this patch needs more testing.
Erik
Signature · 6 lines
----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- Greenspun's Tenth Rule: Any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp.
Quoted 1 line · Erik de Castro Lopo
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 -------
pc.c (revision 3371) renamed from pc.c (revision 3370) +1 -3
@@ -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 -------
pc.c 2008-05-15 01:00:53 +0000 renamed from pc.c 2008-05-15 01:00:12 +0000 +2 -0
@@ -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 ---------
hw/pc.c +3 -1
@@ -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
Signature · 5 lines
----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell