From: Ryan Roberts <ryan.roberts@arm.com>
To: Marc Zyngier <maz@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
James Morse <james.morse@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
kvmarm@lists.cs.columbia.edu
Subject: [PATCH v1 05/12] KVM: arm64: Maintain page-table format info in struct kvm_pgtable
Date: Tue, 6 Dec 2022 13:59:23 +0000 [thread overview]
Message-ID: <20221206135930.3277585-6-ryan.roberts@arm.com> (raw)
In-Reply-To: <20221206135930.3277585-1-ryan.roberts@arm.com>
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@arm.com>
---
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-12-06 14:02 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 13:59 [PATCH v1 00/12] KVM: arm64: Support FEAT_LPA2 at hyp s1 and vm s2 Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 01/12] arm64/mm: Add FEAT_LPA2 specific ID_AA64MMFR0.TGRAN[2] Ryan Roberts
2022-12-14 19:16 ` Oliver Upton
2022-12-15 0:53 ` Oliver Upton
2022-12-06 13:59 ` [PATCH v1 02/12] arm64/mm: Update tlb invalidation routines for FEAT_LPA2 Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 03/12] KVM: arm64: Add new (V)TCR_EL2 field definitions " Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 04/12] KVM: arm64: Plumbing to enable multiple pgtable formats Ryan Roberts
2022-12-06 13:59 ` Ryan Roberts [this message]
2022-12-19 19:45 ` [PATCH v1 05/12] KVM: arm64: Maintain page-table format info in struct kvm_pgtable Oliver Upton
2022-12-06 13:59 ` [PATCH v1 06/12] KVM: arm64: Use LPA2 page-tables for stage2 if HW supports it Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 07/12] KVM: arm64: Use LPA2 page-tables for hyp stage1 " Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 08/12] KVM: arm64: Insert PS field at TCR_EL2 assembly time Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 09/12] KVM: arm64: Convert translation level parameter to s8 Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 10/12] KVM: arm64: Rework logic to en/decode VTCR_EL2.{SL0, SL2} fields Ryan Roberts
2022-12-20 0:06 ` Oliver Upton
2022-12-20 9:01 ` Ryan Roberts
2022-12-20 18:08 ` Oliver Upton
2022-12-06 13:59 ` [PATCH v1 11/12] KVM: arm64: Support upto 5 levels of translation in kvm_pgtable Ryan Roberts
2022-12-06 13:59 ` [PATCH v1 12/12] KVM: arm64: Allow guests with >48-bit IPA size on FEAT_LPA2 systems Ryan Roberts
2022-12-15 0:52 ` [PATCH v1 00/12] KVM: arm64: Support FEAT_LPA2 at hyp s1 and vm s2 Oliver Upton
2022-12-15 9:33 ` Ryan Roberts
2022-12-15 18:12 ` Oliver Upton
2022-12-20 18:28 ` Oliver Upton
2023-02-20 14:17 ` Ryan Roberts
2023-02-22 20:42 ` Oliver Upton
2023-02-23 9:53 ` Catalin Marinas
2022-12-15 9:35 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221206135930.3277585-6-ryan.roberts@arm.com \
--to=ryan.roberts@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).