KVM: arm64: Don't mask softirq with IRQs disabled in vcpu_put()
authorDave Martin <Dave.Martin@arm.com>
Fri, 15 Jun 2018 15:47:24 +0000 (16:47 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Thu, 21 Jun 2018 08:14:44 +0000 (09:14 +0100)
commitb045e4d0f392cbdab2674b0aa78c8d2b187e4e27
tree259e6aa1cd8a909f719b7d23a26453294b1570e5
parent6ebdf4db8fa564a150f46d32178af0873eb5abbb
KVM: arm64: Don't mask softirq with IRQs disabled in vcpu_put()

Commit e6b673b ("KVM: arm64: Optimise FPSIMD handling to reduce
guest/host thrashing") introduces a specific helper
kvm_arch_vcpu_put_fp() for saving the vcpu FPSIMD state during
vcpu_put().

This function uses local_bh_disable()/_enable() to protect the
FPSIMD context manipulation from interruption by softirqs.

This approach is not correct, because vcpu_put() can be invoked
either from the KVM host vcpu thread (when exiting the vcpu run
loop), or via a preempt notifier.  In the former case, only
preemption is disabled.  In the latter case, the function is called
from inside __schedule(), which means that IRQs are disabled.

Use of local_bh_disable()/_enable() with IRQs disabled is considerd
an error, resulting in lockdep splats while running VMs if lockdep
is enabled.

This patch disables IRQs instead of attempting to disable softirqs,
avoiding the problem of calling local_bh_enable() with IRQs
disabled in the __schedule() path.  This creates an additional
interrupt blackout during vcpu run loop exit, but this is the rare
case and the blackout latency is still less than that of
__schedule().

Fixes: e6b673b741ea ("KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing")
Reported-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/kvm/fpsimd.c