KVM: arm64: Check HCR_EL2 instead of shadow copy to swap PtrAuth registers
authorMarc Zyngier <maz@kernel.org>
Thu, 11 Jun 2020 10:26:09 +0000 (11:26 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 22 Jun 2020 10:42:50 +0000 (11:42 +0100)
When save/restoring PtrAuth registers between host and guest, it is
pretty useless to fetch the in-memory state, while we have the right
state in the HCR_EL2 system register. Use that instead.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_ptrauth.h

index 6301813..f183017 100644 (file)
@@ -74,7 +74,7 @@ alternative_if_not ARM64_HAS_ADDRESS_AUTH_IMP_DEF
        b       1001f
 alternative_else_nop_endif
 1000:
-       ldr     \reg1, [\g_ctxt, #(VCPU_HCR_EL2 - VCPU_CONTEXT)]
+       mrs     \reg1, hcr_el2
        and     \reg1, \reg1, #(HCR_API | HCR_APK)
        cbz     \reg1, 1001f
        add     \reg1, \g_ctxt, #CPU_APIAKEYLO_EL1
@@ -90,7 +90,7 @@ alternative_if_not ARM64_HAS_ADDRESS_AUTH_IMP_DEF
        b       2001f
 alternative_else_nop_endif
 2000:
-       ldr     \reg1, [\g_ctxt, #(VCPU_HCR_EL2 - VCPU_CONTEXT)]
+       mrs     \reg1, hcr_el2
        and     \reg1, \reg1, #(HCR_API | HCR_APK)
        cbz     \reg1, 2001f
        add     \reg1, \g_ctxt, #CPU_APIAKEYLO_EL1