KVM: arm64: nv: Handle HCR_EL2.{API,APK} independently
authorMarc Zyngier <maz@kernel.org>
Fri, 19 Apr 2024 10:29:29 +0000 (11:29 +0100)
committerMarc Zyngier <maz@kernel.org>
Sat, 20 Apr 2024 11:42:51 +0000 (12:42 +0100)
commit279946ada1f26a905061d0d6f134fff9e7b14239
treeee16ab9ada2fb90f41d7f0eb1f45a445b09b03d2
parent4cc3f31914d6df9dba8825db933d19c60028f5a8
KVM: arm64: nv: Handle HCR_EL2.{API,APK} independently

Although KVM couples API and APK for simplicity, the architecture
makes no such requirement, and the two can be independently set or
cleared.

Check for which of the two possible reasons we have trapped here,
and if the corresponding L1 control bit isn't set, delegate the
handling for forwarding.

Otherwise, set this exact bit in HCR_EL2 and resume the guest.
Of course, in the non-NV case, we keep setting both bits and
be done with it. Note that the entry core already saves/restores
the keys should any of the two control bits be set.

This results in a bit of rework, and the removal of the (trivial)
vcpu_ptrauth_enable() helper.

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240419102935.1935571-10-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/kvm/hyp/include/hyp/switch.h