KVM: arm64: Save the host's PtrAuth keys in non-preemptible context
authorMarc Zyngier <maz@kernel.org>
Wed, 3 Jun 2020 17:24:01 +0000 (18:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jun 2020 14:40:38 +0000 (16:40 +0200)
commitd96ef8fa953428fe5cf050bd3ed31ac11fb8bfe9
tree53a15e41f546a9db85b3d4e388305994f7477136
parent812857678847423d44b18bdb68522f9c2e9c3dc9
KVM: arm64: Save the host's PtrAuth keys in non-preemptible context

commit ef3e40a7ea8dbe2abd0a345032cd7d5023b9684f upstream.

When using the PtrAuth feature in a guest, we need to save the host's
keys before allowing the guest to program them. For that, we dump
them in a per-CPU data structure (the so called host context).

But both call sites that do this are in preemptible context,
which may end up in disaster should the vcpu thread get preempted
before reentering the guest.

Instead, save the keys eagerly on each vcpu_load(). This has an
increased overhead, but is at least safe.

Cc: stable@vger.kernel.org
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/include/asm/kvm_emulate.h
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/kvm/handle_exit.c
virt/kvm/arm/arm.c