2.4.17/2.5.1 apic.c LVTERR fixes
Quoted 12 lines · Maciej W. Rozycki
Review line 93
Quoted 7 lines
(quoted diff) +2
-0@@ -84,6 +88,8 @@ apic_write_around(APIC_LVTERR, APIC_LVT_MASKED); if (maxlvt >= 4) apic_write_around(APIC_LVTPC, APIC_LVT_MASKED); + apic_write(APIC_ESR, 0); + v = apic_read(APIC_ESR); }You mustn't access the ESR unconditionally -- it doesn't exist in the i82489DX. Also check the Pentium erratum 3AP for possible issues (I can't recall if writing is safe -- possibly only the contents are lost).
Quoted 2 lines
Also note that's really an APIC and not a kernel bug -- writing a previously read value to a register is defined as valid by Intel.
Can you quote chapter and verse on that last statement? (Preferably from IA32 Vol3.) Writes to APIC registers obviously _do_ cause side-effects in some cases...
Pentium erratum 3AP can be ignored, since the whole purpose of the two ESR accesses is to clear ESR. Unfortunately, Pentium erratum 11AP does apply, since there are back-to-back APIC writes (first to LVTERR, then to ESR).
The patch below fixes the 11AP and 82489DX issues. It has the usual test before the write to ESR, which avoids both erratum 11AP (should the code be moved around) and 3AP (redundantly, to avoid confusion).
(Linus, please apply.)
/Mikael
arch/i386/kernel/apic.c renamed from arch/i386/kernel/apic.c.~1~ +6 -2
@@ -88,8 +88,12 @@apic_write_around (APIC_LVTERR ,APIC_LVT_MASKED );if (maxlvt >=4 )apic_write_around (APIC_LVTPC ,APIC_LVT_MASKED ); -apic_write (APIC_ESR ,0 ); - v =apic_read (APIC_ESR ); + v =GET_APIC_VERSION (apic_read (APIC_LVR )); +if (APIC_INTEGRATED (v)) {/* !82489DX */ +if (maxlvt >3 )/* Due to Pentium errata 3AP and 11AP. */ +apic_write (APIC_ESR ,0 ); +apic_read (APIC_ESR ); + } }void __init connect_bsp_APIC (void )
Quoted 6 lines · Mikael Pettersson
Quoted 2 lines
Also note that's really an APIC and not a kernel bug -- writing a previously read value to a register is defined as valid by Intel.
Can you quote chapter and verse on that last statement? (Preferably from IA32 Vol3.) Writes to APIC registers obviously _do_ cause side-effects in some cases...
Obviously I confused defined bits with reserved ones, sorry. Still the
APIC looks insane for me -- it should really signal an error only once an interrupt is received, like it does for interrupts from remote sources.
Quoted 4 lines
Pentium erratum 3AP can be ignored, since the whole purpose of the two ESR accesses is to clear ESR. Unfortunately, Pentium erratum 11AP does apply, since there are back-to-back APIC writes (first to LVTERR, then to ESR).
I checked 3AP and you are right, since we don't need the ESR's value.
arch/i386/kernel/apic.c line 94
Quoted 2 lines
arch/i386/kernel/apic.c renamed from arch/i386/kernel/apic.c.~1~ +2
-0+if (maxlvt >3 )/* Due to Pentium errata 3AP and 11AP. */ +apic_write (APIC_ESR ,0 );
Use apic_write_around() instead as the 11AP workaround -- it was
introduced specifically for this purpose. Using anything else doesn't guarantee no back-to-back APIC writes due to interrupts (specifically writes to the EOI register).
Signature · 3 lines
+ Maciej W. Rozycki, Technical University of Gdansk, Poland + +--------------------------------------------------------------+ + e-mail: [email protected], PGP key available +