From: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
To: maz@kernel.org
Cc: d.scott.phillips@amperecomputing.com, kvm@vger.kernel.org,
catalin.marinas@arm.com, darren@os.amperecomputing.com,
andre.przywara@arm.com, gankulkarni@os.amperecomputing.com,
will@kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] KVM: arm64: Use appropriate mmu pointer in stage2 page table init.
Date: Mon, 22 Nov 2021 01:58:02 -0800 [thread overview]
Message-ID: <20211122095803.28943-2-gankulkarni@os.amperecomputing.com> (raw)
In-Reply-To: <20211122095803.28943-1-gankulkarni@os.amperecomputing.com>
The kvm_pgtable_stage2_init/kvm_pgtable_stage2_init_flags function
assume arch->mmu is same across all stage 2 mmu and initializes
the pgt(page table) using arch->mmu.
Using armc->mmu is not appropriate when nested virtualization is enabled
since there are multiple stage 2 mmu tables are initialized to manage
Guest-Hypervisor as well as Nested VM for the same vCPU.
Add a mmu argument to kvm_pgtable_stage2_init that can be used during
initialization. This patch is a preparatory patch for the
nested virtualization series and no functional changes.
Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
---
arch/arm64/include/asm/kvm_pgtable.h | 6 ++++--
arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +-
arch/arm64/kvm/hyp/pgtable.c | 3 ++-
arch/arm64/kvm/mmu.c | 2 +-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h
index 4f432ea3094c..9c0c380f8e3b 100644
--- a/arch/arm64/include/asm/kvm_pgtable.h
+++ b/arch/arm64/include/asm/kvm_pgtable.h
@@ -223,16 +223,18 @@ u64 kvm_get_vtcr(u64 mmfr0, u64 mmfr1, u32 phys_shift);
* @arch: Arch-specific KVM structure representing the guest virtual
* machine.
* @mm_ops: Memory management callbacks.
+ * @mmu: The pointer to the s2 MMU structure
* @flags: Stage-2 configuration flags.
*
* Return: 0 on success, negative error code on failure.
*/
int kvm_pgtable_stage2_init_flags(struct kvm_pgtable *pgt, struct kvm_arch *arch,
struct kvm_pgtable_mm_ops *mm_ops,
+ struct kvm_s2_mmu *mmu,
enum kvm_pgtable_stage2_flags flags);
-#define kvm_pgtable_stage2_init(pgt, arch, mm_ops) \
- kvm_pgtable_stage2_init_flags(pgt, arch, mm_ops, 0)
+#define kvm_pgtable_stage2_init(pgt, arch, mm_ops, mmu) \
+ kvm_pgtable_stage2_init_flags(pgt, arch, mm_ops, mmu, 0)
/**
* kvm_pgtable_stage2_destroy() - Destroy an unused guest stage-2 page-table.
diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
index 4b60c0056c04..cf7e034a0453 100644
--- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
+++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
@@ -99,7 +99,7 @@ int kvm_host_prepare_stage2(void *mem_pgt_pool, void *dev_pgt_pool)
return ret;
ret = kvm_pgtable_stage2_init_flags(&host_kvm.pgt, &host_kvm.arch,
- &host_kvm.mm_ops, KVM_HOST_S2_FLAGS);
+ &host_kvm.mm_ops, mmu, KVM_HOST_S2_FLAGS);
if (ret)
return ret;
diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index fa85da30c9b8..85acd9e19ed0 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -1018,6 +1018,7 @@ int kvm_pgtable_stage2_flush(struct kvm_pgtable *pgt, u64 addr, u64 size)
int kvm_pgtable_stage2_init_flags(struct kvm_pgtable *pgt, struct kvm_arch *arch,
struct kvm_pgtable_mm_ops *mm_ops,
+ struct kvm_s2_mmu *mmu,
enum kvm_pgtable_stage2_flags flags)
{
size_t pgd_sz;
@@ -1034,7 +1035,7 @@ int kvm_pgtable_stage2_init_flags(struct kvm_pgtable *pgt, struct kvm_arch *arch
pgt->ia_bits = ia_bits;
pgt->start_level = start_level;
pgt->mm_ops = mm_ops;
- pgt->mmu = &arch->mmu;
+ pgt->mmu = mmu;
pgt->flags = flags;
/* Ensure zeroed PGD pages are visible to the hardware walker */
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 0cf6ab944adc..6cf86cafc65a 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -495,7 +495,7 @@ int kvm_init_stage2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu)
if (!pgt)
return -ENOMEM;
- err = kvm_pgtable_stage2_init(pgt, &kvm->arch, &kvm_s2_mm_ops);
+ err = kvm_pgtable_stage2_init(pgt, &kvm->arch, &kvm_s2_mm_ops, mmu);
if (err)
goto out_free_pgtable;
--
2.27.0
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2021-11-22 10:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 9:58 [PATCH 0/2] KVM: arm64: nv: Fix issue with Stage 2 MMU init for Nested case Ganapatrao Kulkarni
2021-11-22 9:58 ` Ganapatrao Kulkarni [this message]
2021-11-25 13:49 ` [PATCH 1/2] KVM: arm64: Use appropriate mmu pointer in stage2 page table init Marc Zyngier
2021-11-26 5:45 ` Ganapatrao Kulkarni
2021-11-26 10:50 ` Marc Zyngier
2021-11-26 16:51 ` Ganapatrao Kulkarni
2021-11-22 9:58 ` [PATCH 2/2] KVM: arm64: nv: fixup! Support multiple nested Stage-2 mmu structures Ganapatrao Kulkarni
2021-11-25 14:23 ` Marc Zyngier
2021-11-26 5:59 ` Ganapatrao Kulkarni
2021-11-26 19:20 ` Marc Zyngier
2021-11-29 6:00 ` Ganapatrao Kulkarni
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=20211122095803.28943-2-gankulkarni@os.amperecomputing.com \
--to=gankulkarni@os.amperecomputing.com \
--cc=andre.przywara@arm.com \
--cc=catalin.marinas@arm.com \
--cc=d.scott.phillips@amperecomputing.com \
--cc=darren@os.amperecomputing.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--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