KVM: arm64: pmu: Make overflow handler NMI safe
authorJulien Thierry <julien.thierry@arm.com>
Thu, 24 Sep 2020 11:07:04 +0000 (12:07 +0100)
committerWill Deacon <will@kernel.org>
Mon, 28 Sep 2020 18:00:17 +0000 (19:00 +0100)
commit95e92e45a454a10a8114294d0f7aec930fb85891
tree637e482d475bfb14a736e4500be69bea35cc728b
parent05ab72813340d11205556c0d1bc08e6857a3856c
KVM: arm64: pmu: Make overflow handler NMI safe

kvm_vcpu_kick() is not NMI safe. When the overflow handler is called from
NMI context, defer waking the vcpu to an irq_work queue.

A vcpu can be freed while it's not running by kvm_destroy_vm(). Prevent
running the irq_work for a non-existent vcpu by calling irq_work_sync() on
the PMU destroy path.

[Alexandru E.: Added irq_work_sync()]

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Tested-by: Sumit Garg <sumit.garg@linaro.org> (Developerbox)
Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Suzuki K Pouloze <suzuki.poulose@arm.com>
Cc: kvm@vger.kernel.org
Cc: kvmarm@lists.cs.columbia.edu
Link: https://lore.kernel.org/r/20200924110706.254996-6-alexandru.elisei@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kvm/pmu-emul.c
include/kvm/arm_pmu.h