KVM: arm/arm64: Reset the VCPU without preemption and vcpu state loaded
authorChristoffer Dall <christoffer.dall@arm.com>
Thu, 20 Dec 2018 11:44:05 +0000 (12:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 19:09:43 +0000 (20:09 +0100)
commitdfe9b4d992cab1e336af90b359412a269cd5d328
tree10c5517675a8b5a61b20ac31a77b614d55ef1a8d
parent20604435e2f450332f7758ce8365764f99969c62
KVM: arm/arm64: Reset the VCPU without preemption and vcpu state loaded

[ Upstream commit e761a927bc9a7ee6ceb7c4f63d5922dbced87f0d ]

We have two ways to reset a vcpu:
- either through VCPU_INIT
- or through a PSCI_ON call

The first one is easy to reason about. The second one is implemented
in a more bizarre way, as it is the vcpu that handles PSCI_ON that
resets the vcpu that is being powered-on. As we need to turn the logic
around and have the target vcpu to reset itself, we must take some
preliminary steps.

Resetting the VCPU state modifies the system register state in memory,
but this may interact with vcpu_load/vcpu_put if running with preemption
disabled, which in turn may lead to corrupted system register state.

Address this by disabling preemption and doing put/load if required
around the reset logic.

Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm64/kvm/reset.c