Three interrupt related fixes for X86:

 - Move disabling of the local APIC after invoking fixup_irqs() to ensure
   that interrupts which are incoming are noted in the IRR and not ignored.

 - Unbreak affinity setting. The rework of the entry code reused the
   regular exception entry code for device interrupts. The vector number is
   pushed into the errorcode slot on the stack which is then lifted into an
   argument and set to -1 because that's regs->orig_ax which is used in
   quite some places to check whether the entry came from a syscall. But it
   was overlooked that orig_ax is used in the affinity cleanup code to
   validate whether the interrupt has arrived on the new target. It turned
   out that this vector check is pointless because interrupts are never
   moved from one vector to another on the same CPU. That check is a
   historical leftover from the time where x86 supported multi-CPU
   affinities, but not longer needed with the now strict single CPU
   affinity. Famous last words ...

 - Add a missing check for an empty cpumask into the matrix allocator. The
   affinity change added a warning to catch the case where an interrupt is
   moved on the same CPU to a different vector. This triggers because a
   condition with an empty cpumask returns an assignment from the allocator
   as the allocator uses for_each_cpu() without checking the cpumask for
   being empty. The historical inconsistent for_each_cpu() behaviour of
   ignoring the cpumask and unconditionally claiming that CPU0 is in the
   mask striked again. Sigh.
genirq/matrix: Deal with the sillyness of for_each_cpu() on UP

Most of the CPU mask operations behave the same way, but for_each_cpu() and
it's variants ignore the cpumask argument and claim that CPU0 is always in
the mask. This is historical, inconsistent and annoying behaviour.

The matrix allocator uses for_each_cpu() and can be called on UP with an
empty cpumask. The calling code does not expect that this succeeds but
until commit e027fffff799 ("x86/irq: Unbreak interrupt affinity setting")
this went unnoticed. That commit added a WARN_ON() to catch cases which
move an interrupt from one vector to another on the same CPU. The warning
triggers on UP.

Add a check for the cpumask being empty to prevent this.

Fixes: 2f75d9e1c905 ("genirq: Implement bitmap matrix allocator")
Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
1 file changed