]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Commit pending PC adjustemnts before returning to userspace
authorMarc Zyngier <maz@kernel.org>
Thu, 6 May 2021 14:20:12 +0000 (15:20 +0100)
committerMarc Zyngier <maz@kernel.org>
Sat, 15 May 2021 09:27:59 +0000 (10:27 +0100)
commit26e0aabb38a683ebfd1db1d51b3e116624e049b7
treefc5788ff8c741e307d83e72deffa646cee28797c
parent619fd5cfbdc43696aae34dbc63f769a57c5e5cfd
KVM: arm64: Commit pending PC adjustemnts before returning to userspace

KVM currently updates PC (and the corresponding exception state)
using a two phase approach: first by setting a set of flags,
then by converting these flags into a state update when the vcpu
is about to enter the guest.

However, this creates a disconnect with userspace if the vcpu thread
returns there with any exception/PC flag set. In this case, the exposed
context is wrong, as userspace doesn't have access to these flags
(they aren't architectural). It also means that these flags are
preserved across a reset, which isn't expected.

To solve this problem, force an explicit synchronisation of the
exception state on vcpu exit to userspace. As an optimisation
for nVHE systems, only perform this when there is something pending.

Reported-by: Zenghui Yu <yuzenghui@huawei.com>
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Tested-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org # 5.11
arch/arm64/include/asm/kvm_asm.h
arch/arm64/kvm/arm.c
arch/arm64/kvm/hyp/exception.c
arch/arm64/kvm/hyp/nvhe/hyp-main.c