Skip to content

Commit 923a547

Browse files
author
Marc Zyngier
committed
KVM: arm64: Move kern_hyp_va() usage in __load_guest_stage2() into the callers
It is a bit awkward to use kern_hyp_va() in __load_guest_stage2(), specially as the helper is shared between VHE and nVHE. Instead, move the use of kern_hyp_va() in the nVHE code, and pass a pointer to the kvm->arch structure instead. Although this may look a bit awkward, it allows for some further simplification. Cc: Catalin Marinas <[email protected]> Cc: Jade Alglave <[email protected]> Cc: Shameer Kolothum <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c500bee commit 923a547

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

arch/arm64/include/asm/kvm_mmu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,10 @@ static __always_inline void __load_stage2(struct kvm_s2_mmu *mmu, unsigned long
280280
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT));
281281
}
282282

283-
static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu)
283+
static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu,
284+
struct kvm_arch *arch)
284285
{
285-
__load_stage2(mmu, kern_hyp_va(mmu->arch)->vtcr);
286+
__load_stage2(mmu, arch->vtcr);
286287
}
287288

288289
static inline struct kvm *kvm_s2_mmu_to_kvm(struct kvm_s2_mmu *mmu)

arch/arm64/kvm/hyp/nvhe/switch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
170170
{
171171
struct kvm_cpu_context *host_ctxt;
172172
struct kvm_cpu_context *guest_ctxt;
173+
struct kvm_s2_mmu *mmu;
173174
bool pmu_switch_needed;
174175
u64 exit_code;
175176

@@ -213,7 +214,8 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
213214
__sysreg32_restore_state(vcpu);
214215
__sysreg_restore_state_nvhe(guest_ctxt);
215216

216-
__load_guest_stage2(kern_hyp_va(vcpu->arch.hw_mmu));
217+
mmu = kern_hyp_va(vcpu->arch.hw_mmu);
218+
__load_guest_stage2(mmu, kern_hyp_va(mmu->arch));
217219
__activate_traps(vcpu);
218220

219221
__hyp_vgic_restore_state(vcpu);

arch/arm64/kvm/hyp/nvhe/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void __tlb_switch_to_guest(struct kvm_s2_mmu *mmu,
3939
* ensuring that we always have an ISB, but not two ISBs back
4040
* to back.
4141
*/
42-
__load_guest_stage2(mmu);
42+
__load_guest_stage2(mmu, kern_hyp_va(mmu->arch));
4343
asm(ALTERNATIVE("isb", "nop", ARM64_WORKAROUND_SPECULATIVE_AT));
4444
}
4545

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int __kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu)
128128
* __load_guest_stage2 configures stage 2 translation, and
129129
* __activate_traps clear HCR_EL2.TGE (among other things).
130130
*/
131-
__load_guest_stage2(vcpu->arch.hw_mmu);
131+
__load_guest_stage2(vcpu->arch.hw_mmu, vcpu->arch.hw_mmu->arch);
132132
__activate_traps(vcpu);
133133

134134
__kvm_adjust_pc(vcpu);

arch/arm64/kvm/hyp/vhe/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void __tlb_switch_to_guest(struct kvm_s2_mmu *mmu,
5353
* place before clearing TGE. __load_guest_stage2() already
5454
* has an ISB in order to deal with this.
5555
*/
56-
__load_guest_stage2(mmu);
56+
__load_guest_stage2(mmu, mmu->arch);
5757
val = read_sysreg(hcr_el2);
5858
val &= ~HCR_TGE;
5959
write_sysreg(val, hcr_el2);

0 commit comments

Comments
 (0)