Re: [PATCH v8 13/14] x86/kvm: Disable preemption in kvm_flush_tlb_multi()
From: Sebastian Andrzej Siewior
Date: Tue Jun 16 2026 - 09:46:47 EST
On 2026-06-16 19:11:26 [+0800], Chuyi Zhou wrote:
> kvm_flush_tlb_multi() is installed as an x86 PV TLB flush backend, so
> flush_tlb_multi() can reach it through pv_ops when running as a KVM
> guest.
>
> kvm_flush_tlb_multi() uses the per-CPU scratch cpumask __pv_cpu_mask.
> That buffer must remain tied to the current CPU until the mask has been
> copied, filtered, and consumed by native_flush_tlb_multi(). Today the
> x86/mm callers enter flush_tlb_multi() while pinned to a CPU, but a
> subsequent x86/mm change will drop that caller-side CPU pinning before
> issuing the remote TLB flush so the caller can be preempted while waiting
> for remote CPUs.
>
> Make the KVM backend protect its own per-CPU scratch cpumask by disabling
> preemption locally. This is harmless with the current callers, where the
> preemption disable is nested, and makes the KVM pv_ops dependency explicit
> before changing the x86/mm call sites.
>
> Signed-off-by: Chuyi Zhou <zhouchuyi@xxxxxxxxxxxxx>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Sebastian