From: Jan Kiszka <jan.kiszka@web.de>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: Breakage with local APIC routing
Date: Wed, 13 Aug 2008 11:08:59 +0200 [thread overview]
Message-ID: <48A2A4AB.6050601@web.de> (raw)
In-Reply-To: <48A297F0.9000700@web.de>
Jan Kiszka wrote:
> Johannes Schindelin wrote:
>> Hi,
>>
>> due to the change in revision 3371 (well, at that time, CVS was used,
>> which was no better than Subversion) installation of win64 is broken in
>> QEmu. The commit message reads like this:
>>
>> Don't route PIC interrupts through the local APIC if the local
>> APIC config says so. By Ari Kivity.
>>
>> A bit of research showed that the patch was actually originally from Qing
>> He, but he told me privately that the part that actually broke win64 (the
>> removal of the call to cpu_reset_interrupt(), as opposed to moving that
>> call into the "else" condition) was not part of his patch.
>>
>> Unfortunately, a lot has been done to the APIC handling in the meantime,
>> so it is not a simple matter of a revert.
>>
>> Being a complete idiot when it comes to APICs, I have no clue how to fix
>> the issue.
>>
>> However, I am quite willing to test whatever patch is thrown at me.
>>
>> Can somebody help?
>
> I recalled some earlier post on this which claimed to fix the issue and
> found it in the archive:
>
> http://permalink.gmane.org/gmane.comp.emulators.qemu/25415
>
> However, no one replied on this, and I'm right now not sure if the fix
> is OK for all cases. But it is a starting point for new discussion about
> what is actually borken here.
This might not be the last word, but my feeling that it's closer to the
actual issue than the older fix. Please give it a try. Comments welcome.
--------
Ensure that PIC-delivered IRQs are properly de-asserted in case the APIC
is in EXTINT or FIXED mode (with level-triggering selected) on LINT0.
Should fix Win64 boot issues. This patch also cleans up a bit the
interface between PIC and APIC, making apic_local_deliver private again.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
hw/apic.c | 23 ++++++++++++++++++++++-
hw/pc.c | 5 +----
hw/pc.h | 4 +---
3 files changed, 24 insertions(+), 8 deletions(-)
Index: b/hw/apic.c
===================================================================
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -166,7 +166,7 @@ static inline void reset_bit(uint32_t *t
tab[i] &= ~mask;
}
-void apic_local_deliver(CPUState *env, int vector)
+static void apic_local_deliver(CPUState *env, int vector)
{
APICState *s = env->apic_state;
uint32_t lvt = s->lvt[vector];
@@ -197,6 +197,27 @@ void apic_local_deliver(CPUState *env, i
}
}
+void apic_deliver_pic_intr(CPUState *env, int level)
+{
+ if (level)
+ apic_local_deliver(env, APIC_LVT_LINT0);
+ else {
+ APICState *s = env->apic_state;
+ uint32_t lvt = s->lvt[APIC_LVT_LINT0];
+
+ switch ((lvt >> 8) & 7) {
+ case APIC_DM_FIXED:
+ if (!(lvt & APIC_LVT_LEVEL_TRIGGER))
+ break;
+ reset_bit(s->irr, lvt & 0xff);
+ /* fall through */
+ case APIC_DM_EXTINT:
+ cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
+ break;
+ }
+ }
+}
+
#define foreach_apic(apic, deliver_bitmask, code) \
{\
int __i, __j, __mask;\
Index: b/hw/pc.c
===================================================================
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -118,12 +118,9 @@ static void pic_irq_request(void *opaque
{
CPUState *env = first_cpu;
- if (!level)
- return;
-
while (env) {
if (apic_accept_pic_intr(env))
- apic_local_deliver(env, APIC_LINT0);
+ apic_deliver_pic_intr(env, level);
env = env->next_cpu;
}
}
Index: b/hw/pc.h
===================================================================
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -40,11 +40,9 @@ void irq_info(void);
/* APIC */
typedef struct IOAPICState IOAPICState;
-#define APIC_LINT0 3
-
int apic_init(CPUState *env);
int apic_accept_pic_intr(CPUState *env);
-void apic_local_deliver(CPUState *env, int vector);
+void apic_deliver_pic_intr(CPUState *env, int level);
int apic_get_interrupt(CPUState *env);
IOAPICState *ioapic_init(void);
void ioapic_set_irq(void *opaque, int vector, int level);
next prev parent reply other threads:[~2008-08-13 9:09 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-11 14:28 [Qemu-devel] Breakage with local APIC routing Johannes Schindelin
2008-08-13 8:14 ` [Qemu-devel] " Jan Kiszka
2008-08-13 9:08 ` Jan Kiszka [this message]
2008-08-17 15:00 ` Johannes Schindelin
2008-08-17 15:28 ` Johannes Schindelin
2008-08-17 16:52 ` Jan Kiszka
2009-08-13 16:21 ` Johannes Schindelin
2009-08-25 6:56 ` Jan Kiszka
2009-08-25 8:24 ` Mohammed Gamal
2009-08-25 8:59 ` Jan Kiszka
2009-08-25 9:09 ` Mohammed Gamal
2009-08-25 9:33 ` Jan Kiszka
2009-08-25 10:16 ` Mohammed Gamal
2009-08-25 10:21 ` Mohammed Gamal
2009-08-25 10:38 ` Jan Kiszka
2009-08-26 22:10 ` Juergen Lock
2009-08-27 17:56 ` Jan Kiszka
2009-08-29 21:18 ` Juergen Lock
2009-08-31 7:47 ` Jan Kiszka
2009-08-31 21:27 ` Juergen Lock
2009-09-01 20:12 ` Juergen Lock
2009-09-07 20:59 ` FreeBSD timing issues and qemu (was: Re: [Qemu-devel] Re: Breakage with local APIC routing) Juergen Lock
2009-09-08 2:17 ` Ryan Stone
2009-09-09 20:15 ` Juergen Lock
2009-09-09 20:39 ` Ryan Stone
2009-09-09 20:46 ` Luigi Rizzo
2009-09-10 17:46 ` Juergen Lock
2009-09-10 19:08 ` Luigi Rizzo
2009-09-10 20:44 ` Juergen Lock
2009-09-11 15:22 ` John Baldwin
2009-09-11 17:03 ` Luigi Rizzo
2009-09-11 17:01 ` John Baldwin
2009-09-12 15:48 ` Luigi Rizzo
2009-08-25 11:48 ` [Qemu-devel] Re: Breakage with local APIC routing Johannes Schindelin
2009-08-25 12:31 ` Jan Kiszka
2009-08-25 13:36 ` Johannes Schindelin
2009-08-26 7:31 ` Jan Kiszka
2009-08-26 9:27 ` Avi Kivity
2009-08-27 18:07 ` Jan Kiszka
2008-08-17 17:32 ` [Qemu-devel] " Stefan Weil
2008-08-17 18:58 ` [Qemu-devel] " Jan Kiszka
2008-08-17 20:40 ` Stefan Weil
2008-08-17 20:23 ` [Qemu-devel] " Aurelien Jarno
2008-08-17 21:10 ` Stefan Weil
2008-08-18 14:27 ` Anthony Liguori
2008-08-17 21:14 ` [Qemu-devel] " Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48A2A4AB.6050601@web.de \
--to=jan.kiszka@web.de \
--cc=Johannes.Schindelin@gmx.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).