aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/include/asm/kvm_mmu.h
diff options
context:
space:
mode:
authorWill Deacon <will@kernel.org>2020-05-28 18:02:51 +0100
committerWill Deacon <will@kernel.org>2020-05-28 18:02:51 +0100
commitc350717ec7de67daad26d996efe7f3d97d95aa9c (patch)
treed52adde14dec02a415ef4a255027997c160452bc /arch/arm64/include/asm/kvm_mmu.h
parentMerge branch 'for-next/bti' into for-next/core (diff)
parentKVM: arm64: Move __load_guest_stage2 to kvm_mmu.h (diff)
downloadlinux-dev-c350717ec7de67daad26d996efe7f3d97d95aa9c.tar.xz
linux-dev-c350717ec7de67daad26d996efe7f3d97d95aa9c.zip
Merge branch 'for-next/kvm/errata' into for-next/core
KVM CPU errata rework (Andrew Scull and Marc Zyngier) * for-next/kvm/errata: KVM: arm64: Move __load_guest_stage2 to kvm_mmu.h arm64: Unify WORKAROUND_SPECULATIVE_AT_{NVHE,VHE}
Diffstat (limited to 'arch/arm64/include/asm/kvm_mmu.h')
-rw-r--r--arch/arm64/include/asm/kvm_mmu.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
index a7137e144b97..85da6befe76e 100644
--- a/arch/arm64/include/asm/kvm_mmu.h
+++ b/arch/arm64/include/asm/kvm_mmu.h
@@ -604,5 +604,22 @@ static __always_inline u64 kvm_get_vttbr(struct kvm *kvm)
return kvm_phys_to_vttbr(baddr) | vmid_field | cnp;
}
+/*
+ * Must be called from hyp code running at EL2 with an updated VTTBR
+ * and interrupts disabled.
+ */
+static __always_inline void __load_guest_stage2(struct kvm *kvm)
+{
+ write_sysreg(kvm->arch.vtcr, vtcr_el2);
+ write_sysreg(kvm_get_vttbr(kvm), vttbr_el2);
+
+ /*
+ * ARM errata 1165522 and 1530923 require the actual execution of the
+ * above before we can switch to the EL1/EL0 translation regime used by
+ * the guest.
+ */
+ asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT));
+}
+
#endif /* __ASSEMBLY__ */
#endif /* __ARM64_KVM_MMU_H__ */