summaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm/handle_exit.c
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2020-06-04 11:14:00 +0100
committerMarc Zyngier <maz@kernel.org>2020-06-09 10:59:52 +0100
commit29eb5a3c57f7e06d803bb44a0ce2f9ed79f39cd9 (patch)
tree1aaa34366253af947959bea389bd21d51e9fc687 /arch/arm64/kvm/handle_exit.c
parentef3e40a7ea8dbe2abd0a345032cd7d5023b9684f (diff)
downloadlinux-29eb5a3c57f7e06d803bb44a0ce2f9ed79f39cd9.tar.gz
linux-29eb5a3c57f7e06d803bb44a0ce2f9ed79f39cd9.tar.bz2
linux-29eb5a3c57f7e06d803bb44a0ce2f9ed79f39cd9.zip
KVM: arm64: Handle PtrAuth traps early
The current way we deal with PtrAuth is a bit heavy handed: - We forcefully save the host's keys on each vcpu_load() - Handling the PtrAuth trap forces us to go all the way back to the exit handling code to just set the HCR bits Overall, this is pretty cumbersome. A better approach would be to handle it the same way we deal with the FPSIMD registers: - On vcpu_load() disable PtrAuth for the guest - On first use, save the host's keys, enable PtrAuth in the guest Crucially, this can happen as a fixup, which is done very early on exit. We can then reenter the guest immediately without leaving the hypervisor role. Another thing is that it simplify the rest of the host handling: exiting all the way to the host means that the only possible outcome for this trap is to inject an UNDEF. Reviewed-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org>
Diffstat (limited to 'arch/arm64/kvm/handle_exit.c')
-rw-r--r--arch/arm64/kvm/handle_exit.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 065251efa2e6..5a02d4c90559 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -163,24 +163,13 @@ static int handle_sve(struct kvm_vcpu *vcpu, struct kvm_run *run)
}
/*
- * Handle the guest trying to use a ptrauth instruction, or trying to access a
- * ptrauth register.
- */
-void kvm_arm_vcpu_ptrauth_trap(struct kvm_vcpu *vcpu)
-{
- if (vcpu_has_ptrauth(vcpu))
- vcpu_ptrauth_enable(vcpu);
- else
- kvm_inject_undefined(vcpu);
-}
-
-/*
* Guest usage of a ptrauth instruction (which the guest EL1 did not turn into
- * a NOP).
+ * a NOP). If we get here, it is that we didn't fixup ptrauth on exit, and all
+ * that we can do is give the guest an UNDEF.
*/
static int kvm_handle_ptrauth(struct kvm_vcpu *vcpu, struct kvm_run *run)
{
- kvm_arm_vcpu_ptrauth_trap(vcpu);
+ kvm_inject_undefined(vcpu);
return 1;
}