From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: seanjc@google.com, npiggin@gmail.com, maddy@linux.ibm.com,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] KVM: PPC: implement .flush_memslot for BookE and Book3S-PR
Date: Fri, 20 Nov 2026 14:36:23 +0100 [thread overview]
Message-ID: <20261120133623.479601-1-pbonzini@redhat.com> (raw)
kvm_arch_flush_shadow_memslot() is called when memslots are deleted and
moved, with no MMU notifier invalidation. This means that the shadow
pages (HPTEs for PR, TLB entries for e500) retain mappings from host
pfns to the old slot's gfns.
Implement the callback by unmapping the GFNs in the same way that Book3S-HV
does it. Note that kvmppc_core_flush_memslot_pr() does not need TLB
invalidation, because kvmppc_mmu_pte_pflush() calls invalidate_pte()
on the entries, and that in turn invalidates the entry through either
the tlbie instruction or mmu_hash_ops.hpte_invalidate().
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/powerpc/kvm/book3s_pr.c | 8 +++++++-
arch/powerpc/kvm/booke.c | 8 ++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 1894968f2c25..66a9e446ab64 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -1893,7 +1893,13 @@ static int kvm_vm_ioctl_get_dirty_log_pr(struct kvm *kvm,
static void kvmppc_core_flush_memslot_pr(struct kvm *kvm,
struct kvm_memory_slot *memslot)
{
- return;
+ struct kvm_gfn_range range = {
+ .slot = memslot,
+ .start = memslot->base_gfn,
+ .end = memslot->base_gfn + memslot->npages,
+ };
+
+ kvm_unmap_gfn_range_pr(kvm, &range);
}
static int kvmppc_core_prepare_memory_region_pr(struct kvm *kvm,
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index ba762ac1fb56..fffb28fe9a0f 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -1844,6 +1844,14 @@ void kvmppc_core_commit_memory_region(struct kvm *kvm,
void kvmppc_core_flush_memslot(struct kvm *kvm, struct kvm_memory_slot *memslot)
{
+ struct kvm_gfn_range range = {
+ .slot = memslot,
+ .start = memslot->base_gfn,
+ .end = memslot->base_gfn + memslot->npages,
+ };
+
+ if (kvm_unmap_gfn_range(kvm, &range))
+ kvm_flush_remote_tlbs(kvm);
}
void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr)
--
2.56.0
reply other threads:[~2026-11-20 13:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261120133623.479601-1-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=seanjc@google.com \
/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
all inboxes | Powered by JetHome®