As the next step on the journey to supporting FEAT_LPA2 in KVM, add a flag to struct kvm_pgtable, which functions can then use to select the approprate behavior for either the `classic` or `lpa2` page-table formats. For now, all page-tables remain in the `classic` format. No functional changes are intended. Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx> --- arch/arm64/include/asm/kvm_pgtable.h | 2 ++ arch/arm64/kvm/hyp/pgtable.c | 2 ++ arch/arm64/kvm/mmu.c | 1 + 3 files changed, 5 insertions(+) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 2247ed74871a..744e224d964b 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -157,6 +157,7 @@ typedef bool (*kvm_pgtable_force_pte_cb_t)(u64 addr, u64 end, * @start_level: Level at which the page-table walk starts. * @pgd: Pointer to the first top-level entry of the page-table. * @mm_ops: Memory management callbacks. + * @lpa2_ena: Format used for page-table; false->classic, true->lpa2. * @mmu: Stage-2 KVM MMU struct. Unused for stage-1 page-tables. * @flags: Stage-2 page-table flags. * @force_pte_cb: Function that returns true if page level mappings must @@ -167,6 +168,7 @@ struct kvm_pgtable { u32 start_level; kvm_pte_t *pgd; struct kvm_pgtable_mm_ops *mm_ops; + bool lpa2_ena; /* Stage-2 only */ struct kvm_s2_mmu *mmu; diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 221e0dafb149..c7799cd50af8 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -530,6 +530,7 @@ int kvm_pgtable_hyp_init(struct kvm_pgtable *pgt, u32 va_bits, pgt->ia_bits = va_bits; pgt->start_level = KVM_PGTABLE_MAX_LEVELS - levels; pgt->mm_ops = mm_ops; + pgt->lpa2_ena = false; pgt->mmu = NULL; pgt->force_pte_cb = NULL; @@ -1190,6 +1191,7 @@ int __kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm_s2_mmu *mmu, pgt->ia_bits = ia_bits; pgt->start_level = start_level; pgt->mm_ops = mm_ops; + pgt->lpa2_ena = false; pgt->mmu = mmu; pgt->flags = flags; pgt->force_pte_cb = force_pte_cb; diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 1ef0704420d9..e3fe3e194fd1 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -645,6 +645,7 @@ static int get_user_mapping_size(struct kvm *kvm, u64 addr) .start_level = (KVM_PGTABLE_MAX_LEVELS - CONFIG_PGTABLE_LEVELS), .mm_ops = &kvm_user_mm_ops, + .lpa2_ena = lpa2_is_enabled(), }; kvm_pte_t pte = 0; /* Keep GCC quiet... */ u32 level = ~0; -- 2.25.1 _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm