Re: [PATCH v4 03/23] KVM: PPC: Flush/zap all memslots on kvm_arch_flush_shadow_all()

From: IBM

Date: Tue Nov 03 2026 - 13:13:57 EST


Sean Christopherson <seanjc@xxxxxxxxxx> writes:

> Flush/zap every memslot in kvm_arch_flush_shadow_all(), i.e. when the
> owning userspace process is exiting, as KVM must ensure all associated
> memory is unmapped from the guest.
>

That's true and yes, this looks like a miss. I guess it must have gone
unnoticed because after the owning process exits, and when the vmfd is
closed it will issue a teardown. So the escape is only until the vmfd is
closed...
kvm_arch_destroy_vm() -> kvmppc_free_radix()

The change looks good to me. I have only tested this on my qemu+dev
setup for now. But will give it a try on real hardware as well.

Thanks for taking care of this. Please feel free to add:
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx>


> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
> arch/powerpc/include/asm/kvm_host.h | 1 -
> arch/powerpc/kvm/powerpc.c | 11 +++++++++++
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index 708a32f89776..50a42f80e5f1 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -910,7 +910,6 @@ struct kvm_vcpu_arch {
> #define __KVM_HAVE_CREATE_DEVICE
>
> static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
> -static inline void kvm_arch_flush_shadow_all(struct kvm *kvm) {}
> static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {}
> static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
>
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 9194cf492d1c..9e9d0865c2f6 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -764,6 +764,17 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
> kvmppc_core_commit_memory_region(kvm, old, new, change);
> }
>
> +void kvm_arch_flush_shadow_all(struct kvm *kvm)
> +{
> + struct kvm_memory_slot *slot;
> + struct kvm_memslots *slots;
> + int bkt;
> +
> + slots = kvm_memslots(kvm);
> + kvm_for_each_memslot(slot, bkt, slots)
> + kvmppc_core_flush_memslot(kvm, slot);
> +}
> +
> void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
> struct kvm_memory_slot *slot)
> {
> --
> 2.56.0.385.gac671c819a-goog