Skip to content
Snippets Groups Projects
Commit 8a48cb55 authored by Glauber Costa's avatar Glauber Costa Committed by Pekka Enberg
Browse files

apic: fix allbutself delivery mode


Our APIC code is so wrong, but so wrong, that it even produce incorrect
results.  X2APIC is fine, but XAPIC is using xapic::ipi() for all its
interrupts. The problem with that, is that the costumary place for "vector" is
inverted in the case of allbutself delivery mode, and therefore, we're sending
these IPIs to God Knows Where - not to the processors, that is for sure.
As a result, we would spin waiting for IRQ acks that would never arrive.

I could invert and reorganize the parameters and comment this out, but I've
decided it is a lot clearer just to open code it. Also, there is no need at all
to set ICR2 for allbutself, because the destination is already embedded in the
firing mode.

One issue: NMI is copied over because it is also wrong by the same reasons, so
I fixed. But I don't have a test case for this.

Fixes #110

Signed-off-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 587063a8
No related branches found
No related tags found
No related merge requests found
......@@ -62,12 +62,9 @@ public:
virtual void init_ipi(unsigned apic_id, unsigned vector)
{ xapic::ipi(apic_id, vector);}
virtual void ipi_allbutself(unsigned vector)
{ xapic::ipi(APIC_ICR_TYPE_FIXED | APIC_SHORTHAND_ALLBUTSELF, vector); }
virtual void ipi_allbutself(unsigned vector);
virtual void nmi_allbutself()
{ xapic::ipi(APIC_ICR_TYPE_FIXED | APIC_SHORTHAND_ALLBUTSELF,
apic_delivery(NMI_DELIVERY)); }
virtual void nmi_allbutself();
virtual void ipi(unsigned apic_id, unsigned vector);
......@@ -117,6 +114,18 @@ void xapic::enable()
software_enable();
}
void xapic::nmi_allbutself()
{
xapic::write(apicreg::ICR, APIC_ICR_TYPE_FIXED | APIC_SHORTHAND_ALLBUTSELF |
apic_delivery(NMI_DELIVERY));
}
void xapic::ipi_allbutself(unsigned vector)
{
xapic::write(apicreg::ICR, APIC_ICR_TYPE_FIXED | APIC_SHORTHAND_ALLBUTSELF |
vector | APIC_ICR_LEVEL_ASSERT);
}
void xapic::ipi(unsigned apic_id, unsigned vector)
{
xapic::write(apicreg::ICR2, apic_id << ICR2_DESTINATION_SHIFT);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment