x86/apic: Split out spurious handling code