]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Handle PtrAuth traps early
authorMarc Zyngier <maz@kernel.org>
Thu, 4 Jun 2020 10:14:00 +0000 (11:14 +0100)
committerMarc Zyngier <maz@kernel.org>
Tue, 9 Jun 2020 09:59:52 +0000 (10:59 +0100)
commit36a0efd0d07c739a1f9f38b6be28f5de622fe456
tree1aaa34366253af947959bea389bd21d51e9fc687
parente7c7f9cf78dbfe30d34dca04260ce3037f20592a
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>
arch/arm64/kvm/arm.c
arch/arm64/kvm/handle_exit.c
arch/arm64/kvm/hyp/switch.c
arch/arm64/kvm/sys_regs.c