WSL2-Linux-Kernel/arch/x86
Dongli Zhang 9eeda3e007 genirq/cpuhotplug, x86/vector: Prevent vector leak during CPU offline
commit a6c11c0a5235fb144a65e0cb2ffd360ddc1f6c32 upstream.

The absence of IRQD_MOVE_PCNTXT prevents immediate effectiveness of
interrupt affinity reconfiguration via procfs. Instead, the change is
deferred until the next instance of the interrupt being triggered on the
original CPU.

When the interrupt next triggers on the original CPU, the new affinity is
enforced within __irq_move_irq(). A vector is allocated from the new CPU,
but the old vector on the original CPU remains and is not immediately
reclaimed. Instead, apicd->move_in_progress is flagged, and the reclaiming
process is delayed until the next trigger of the interrupt on the new CPU.

Upon the subsequent triggering of the interrupt on the new CPU,
irq_complete_move() adds a task to the old CPU's vector_cleanup list if it
remains online. Subsequently, the timer on the old CPU iterates over its
vector_cleanup list, reclaiming old vectors.

However, a rare scenario arises if the old CPU is outgoing before the
interrupt triggers again on the new CPU.

In that case irq_force_complete_move() is not invoked on the outgoing CPU
to reclaim the old apicd->prev_vector because the interrupt isn't currently
affine to the outgoing CPU, and irq_needs_fixup() returns false. Even
though __vector_schedule_cleanup() is later called on the new CPU, it
doesn't reclaim apicd->prev_vector; instead, it simply resets both
apicd->move_in_progress and apicd->prev_vector to 0.

As a result, the vector remains unreclaimed in vector_matrix, leading to a
CPU vector leak.

To address this issue, move the invocation of irq_force_complete_move()
before the irq_needs_fixup() call to reclaim apicd->prev_vector, if the
interrupt is currently or used to be affine to the outgoing CPU.

Additionally, reclaim the vector in __vector_schedule_cleanup() as well,
following a warning message, although theoretically it should never see
apicd->move_in_progress with apicd->prev_cpu pointing to an offline CPU.

Fixes: f0383c24b4 ("genirq/cpuhotplug: Add support for cleaning up move in progress")
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240522220218.162423-1-dongli.zhang@oracle.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-06-16 13:39:52 +02:00
..
boot arch: Introduce CONFIG_FUNCTION_ALIGNMENT 2024-04-10 16:18:49 +02:00
configs
crypto crypto: x86/sha512-avx2 - add missing vzeroupper 2024-06-16 13:39:17 +02:00
entry x86/mm: Remove broken vsyscall emulation code from the page fault code 2024-06-16 13:39:15 +02:00
events perf/x86: Fix out of range data 2024-04-17 11:15:16 +02:00
hyperv x86/hyperv: Remove unregister syscore call from Hyper-V cleanup 2022-12-31 13:14:39 +01:00
ia32
include x86/mm: Remove broken vsyscall emulation code from the page fault code 2024-06-16 13:39:15 +02:00
kernel genirq/cpuhotplug, x86/vector: Prevent vector leak during CPU offline 2024-06-16 13:39:52 +02:00
kvm KVM: x86: Don't advertise guest.MAXPHYADDR as host.MAXPHYADDR in CPUID 2024-06-16 13:39:52 +02:00
lib x86/insn: Fix PUSH instruction in x86 instruction decoder opcode map 2024-06-16 13:39:31 +02:00
math-emu
mm x86/mm: Remove broken vsyscall emulation code from the page fault code 2024-06-16 13:39:15 +02:00
net x86/returnthunk: Allow different return thunks 2024-03-01 13:21:49 +01:00
pci x86/PCI: Add quirk for AMD XHCI controller that loses MSI-X state in D3hot 2023-04-20 12:13:55 +02:00
platform
power x86/pm: Add enumeration check before spec MSRs save/restore setup 2022-12-02 17:41:09 +01:00
purgatory x86/purgatory: Switch to the position-independent small code model 2024-06-16 13:39:22 +02:00
ras
realmode
tools x86/boot: Ignore relocations in .notes sections in walk_relocs() too 2024-06-16 13:39:18 +02:00
um x86: um: vdso: Add '%rcx' and '%r11' to the syscall clobber list 2023-03-11 13:57:26 +01:00
video
xen x86/xen: Add some null pointer checking to smp.c 2024-03-26 18:21:12 -04:00
.gitignore
Kbuild
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-05-02 16:24:48 +02:00
Kconfig.assembler
Kconfig.cpu x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6 2024-02-23 08:55:08 +01:00
Kconfig.debug x86/kconfig: Select ARCH_WANT_FRAME_POINTERS again when UNWINDER_FRAME_POINTER=y 2024-06-16 13:39:46 +02:00
Makefile
Makefile.um
Makefile_32.cpu