So i've gotten my SMP setup working, all the cores are trampolining into long mode and configuring their PAT, local apic, mtrrs etc and the locking is in place.
I've followed Brendan's notes about the INIT-SIPI-SIPI procedure with the relevant delays, synchronization etc.
My local apic code supports both xapic and x2apic mode. All my emulators only run xapic mode while my real machines run x2apic. If I leave the init in xapic all runs as planned, the second I switch to x2apic mode (and on real h/w) configuring the lint0 and lint1 in any way seem to cause a GPF. (If I leave them masked and not setup in any way everything runs through as planned - with one small catch.. the timer (pit) no longer runs at all so the delays don't work.. I can comment those out and purely by good fortune the cores even on real h/w still fire up).
I am assuming the following:
1) From the MADT entries I find the local apic and x2apic entries which I use during configuration.
2) I find the local apic NMI and x2apic nmi entries which tell me which of lint0 or lint1 should be configured as the nmi type (with settings for level/edge, active low/high taken from the respective entry).
3) I then assume that the remaining lint should be configured as extINT (to handle the 8259a while I still haven't configured the ioapic).
So assuming the MADT entry tells me LINT1 is the NMI:
Code: Select all
mov rcx,MSR_IA32_EXT_XAPIC_LVT_LINT0
rdmsr
mov eax,0x2700 ;vector=0, extINT,edge, active low
wrmsr
mov rcx,MSR_IA32_EXT_XAPIC_LVT_LINT1
rdmsr
mov eax,0x2400 ;vector=0, NMI, edge, active low
wrmsr
Note I also only configure this block for the BSP (as only one processor should respond to the legacy 8259a stuff and that would be the BSP).
4) I also can't quite figure from the manuals exactly which interrupts or IRQs should then also send the local apic EOI (Is it all IRQ handlers) or IRQ handlers, softints and LVTs excluding (Performance,Thermal etc)
The manual says it shouldn't be sent for types SMI,NMI,extInt,startup etc but since those registers above ignore any vector I assume they don't directly have a handler either?
If I for example put the x2apic eoi on the timer IRQ (as below) then once again i start getting a GPF.
Code: Select all
xor eax,eax
xor edx,edx
mov rcx,MSR_IA32_EXT_XAPIC_EOI
wrmsr
6) Assuming the ioapic is configured and 8259a is history, what settings should the lint(0/1) be configured for then? (I assume still the same and the ioapic goes directly to the lapic.. bypassing the lint pin?)