[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v2 PATCH 13/13] KVM: Enable memfd based page invalidation/fallo
From: |
Kirill A. Shutemov |
Subject: |
Re: [RFC v2 PATCH 13/13] KVM: Enable memfd based page invalidation/fallocate |
Date: |
Mon, 22 Nov 2021 17:16:47 +0300 |
On Fri, Nov 19, 2021 at 09:47:39PM +0800, Chao Peng wrote:
> Since the memory backing store does not get notified when VM is
> destroyed so need check if VM is still live in these callbacks.
>
> Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---
> virt/kvm/memfd.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/virt/kvm/memfd.c b/virt/kvm/memfd.c
> index bd930dcb455f..bcfdc685ce22 100644
> --- a/virt/kvm/memfd.c
> +++ b/virt/kvm/memfd.c
> @@ -12,16 +12,38 @@
> #include <linux/memfd.h>
> const static struct guest_mem_ops *memfd_ops;
>
> +static bool vm_is_dead(struct kvm *vm)
> +{
> + struct kvm *kvm;
> +
> + list_for_each_entry(kvm, &vm_list, vm_list) {
> + if (kvm == vm)
> + return false;
> + }
I don't think this is enough. The struct kvm can be freed and re-allocated
from the slab and this function will give false-negetive.
Maybe the kvm has to be tagged with a sequential id that incremented every
allocation. This id can be checked here.
> +
> + return true;
> +}
--
Kirill A. Shutemov
- Re: [RFC v2 PATCH 07/13] KVM: Handle page fault for fd based memslot, (continued)
- [RFC v2 PATCH 08/13] KVM: Rename hva memory invalidation code to cover fd-based offset, Chao Peng, 2021/11/19
- [RFC v2 PATCH 09/13] KVM: Introduce kvm_memfd_invalidate_range, Chao Peng, 2021/11/19
- [RFC v2 PATCH 10/13] KVM: Match inode for invalidation of fd-based slot, Chao Peng, 2021/11/19
- [RFC v2 PATCH 11/13] KVM: Add kvm_map_gfn_range, Chao Peng, 2021/11/19
- [RFC v2 PATCH 12/13] KVM: Introduce kvm_memfd_fallocate_range, Chao Peng, 2021/11/19
- [RFC v2 PATCH 13/13] KVM: Enable memfd based page invalidation/fallocate, Chao Peng, 2021/11/19
- Re: [RFC v2 PATCH 13/13] KVM: Enable memfd based page invalidation/fallocate,
Kirill A. Shutemov <=
- Re: [RFC v2 PATCH 13/13] KVM: Enable memfd based page invalidation/fallocate, Paolo Bonzini, 2021/11/23