Skip to content

Commit fe677be

Browse files
Marc Zyngierwilldeacon
authored andcommitted
KVM: arm64: Move __load_guest_stage2 to kvm_mmu.h
Having __load_guest_stage2 in kvm_hyp.h is quickly going to trigger a circular include problem. In order to avoid this, let's move it to kvm_mmu.h, where it will be a better fit anyway. In the process, drop the __hyp_text annotation, which doesn't help as the function is marked as __always_inline. Reviewed-by: Suzuki K Poulose <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 02ab1f5 commit fe677be

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

arch/arm64/include/asm/kvm_hyp.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/compiler.h>
1111
#include <linux/kvm_host.h>
1212
#include <asm/alternative.h>
13-
#include <asm/kvm_mmu.h>
1413
#include <asm/sysreg.h>
1514

1615
#define __hyp_text __section(.hyp.text) notrace
@@ -88,22 +87,5 @@ void deactivate_traps_vhe_put(void);
8887
u64 __guest_enter(struct kvm_vcpu *vcpu, struct kvm_cpu_context *host_ctxt);
8988
void __noreturn __hyp_do_panic(unsigned long, ...);
9089

91-
/*
92-
* Must be called from hyp code running at EL2 with an updated VTTBR
93-
* and interrupts disabled.
94-
*/
95-
static __always_inline void __hyp_text __load_guest_stage2(struct kvm *kvm)
96-
{
97-
write_sysreg(kvm->arch.vtcr, vtcr_el2);
98-
write_sysreg(kvm_get_vttbr(kvm), vttbr_el2);
99-
100-
/*
101-
* ARM errata 1165522 and 1530923 require the actual execution of the
102-
* above before we can switch to the EL1/EL0 translation regime used by
103-
* the guest.
104-
*/
105-
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT));
106-
}
107-
10890
#endif /* __ARM64_KVM_HYP_H__ */
10991

arch/arm64/include/asm/kvm_mmu.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,5 +604,22 @@ static __always_inline u64 kvm_get_vttbr(struct kvm *kvm)
604604
return kvm_phys_to_vttbr(baddr) | vmid_field | cnp;
605605
}
606606

607+
/*
608+
* Must be called from hyp code running at EL2 with an updated VTTBR
609+
* and interrupts disabled.
610+
*/
611+
static __always_inline void __load_guest_stage2(struct kvm *kvm)
612+
{
613+
write_sysreg(kvm->arch.vtcr, vtcr_el2);
614+
write_sysreg(kvm_get_vttbr(kvm), vttbr_el2);
615+
616+
/*
617+
* ARM errata 1165522 and 1530923 require the actual execution of the
618+
* above before we can switch to the EL1/EL0 translation regime used by
619+
* the guest.
620+
*/
621+
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT));
622+
}
623+
607624
#endif /* __ASSEMBLY__ */
608625
#endif /* __ARM64_KVM_MMU_H__ */

0 commit comments

Comments
 (0)