lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABgObfYPpmyTyC94OgSqRPmR_ejuhHg4f_gLL=fo1vb4u8n35w@mail.gmail.com>
Date: Wed, 26 Nov 2025 09:33:20 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [GIT PULL] KVM: guest_memfd: NUMA support and other changes for 6.19

On Wed, Nov 26, 2025 at 2:45 AM Sean Christopherson <seanjc@...gle.com> wrote:
>
> Please pull NUMA mempolicy guest_memfd support, along with a handful of
> guest_memfd cleanups and some tangentially related additions to KVM selftests
> infrastructure.
>
> This will conflict with kvm/master due to commit ae431059e75d ("KVM:
> guest_memfd: Remove bindings on memslot deletion when gmem is dying").  The
> resolution I've been using for linux-next is below.

Pulled, thanks.

Paolo

> --
> diff --cc virt/kvm/guest_memfd.c
> index ffadc5ee8e04,427c0acee9d7..fdaea3422c30
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@@ -623,53 -708,31 +708,49 @@@ err
>         return r;
>   }
>
> - static void __kvm_gmem_unbind(struct kvm_memory_slot *slot, struct kvm_gmem *gmem)
>  -void kvm_gmem_unbind(struct kvm_memory_slot *slot)
> ++static void __kvm_gmem_unbind(struct kvm_memory_slot *slot, struct gmem_file *f)
>   {
>         unsigned long start = slot->gmem.pgoff;
>         unsigned long end = start + slot->npages;
>  -      struct gmem_file *f;
>
> -       xa_store_range(&gmem->bindings, start, end - 1, NULL, GFP_KERNEL);
>  -      /*
>  -       * Nothing to do if the underlying file was already closed (or is being
>  -       * closed right now), kvm_gmem_release() invalidates all bindings.
>  -       */
>  -      CLASS(gmem_get_file, file)(slot);
>  -      if (!file)
>  -              return;
>  -
>  -      f = file->private_data;
>  -
>  -      filemap_invalidate_lock(file->f_mapping);
> +       xa_store_range(&f->bindings, start, end - 1, NULL, GFP_KERNEL);
>
>         /*
>          * synchronize_srcu(&kvm->srcu) ensured that kvm_gmem_get_pfn()
>          * cannot see this memslot.
>          */
>         WRITE_ONCE(slot->gmem.file, NULL);
>  +}
>  +
>  +void kvm_gmem_unbind(struct kvm_memory_slot *slot)
>  +{
> -       struct file *file;
> -
>  +      /*
>  +       * Nothing to do if the underlying file was _already_ closed, as
>  +       * kvm_gmem_release() invalidates and nullifies all bindings.
>  +       */
>  +      if (!slot->gmem.file)
>  +              return;
>  +
> -       file = kvm_gmem_get_file(slot);
> ++      CLASS(gmem_get_file, file)(slot);
>  +
>  +      /*
>  +       * However, if the file is _being_ closed, then the bindings need to be
>  +       * removed as kvm_gmem_release() might not run until after the memslot
>  +       * is freed.  Note, modifying the bindings is safe even though the file
>  +       * is dying as kvm_gmem_release() nullifies slot->gmem.file under
>  +       * slots_lock, and only puts its reference to KVM after destroying all
>  +       * bindings.  I.e. reaching this point means kvm_gmem_release() hasn't
>  +       * yet destroyed the bindings or freed the gmem_file, and can't do so
>  +       * until the caller drops slots_lock.
>  +       */
>  +      if (!file) {
>  +              __kvm_gmem_unbind(slot, slot->gmem.file->private_data);
>  +              return;
>  +      }
>  +
>  +      filemap_invalidate_lock(file->f_mapping);
>  +      __kvm_gmem_unbind(slot, file->private_data);
>         filemap_invalidate_unlock(file->f_mapping);
> -
> -       fput(file);
>   }
>
>   /* Returns a locked folio on success.  */
>
>
> The following changes since commit 211ddde0823f1442e4ad052a2f30f050145ccada:
>
>   Linux 6.18-rc2 (2025-10-19 15:19:16 -1000)
>
> are available in the Git repository at:
>
>   https://github.com/kvm-x86/linux.git tags/kvm-x86-gmem-6.19
>
> for you to fetch changes up to 83e0e12219a402bf7b8fdef067e51f945a92fd26:
>
>   KVM: selftests: Rename "guest_paddr" variables to "gpa" (2025-11-03 12:54:21 -0800)
>
> ----------------------------------------------------------------
> KVM guest_memfd changes for 6.19:
>
>  - Add NUMA mempolicy support for guest_memfd, and clean up a variety of
>    rough edges in guest_memfd along the way.
>
>  - Define a CLASS to automatically handle get+put when grabbing a guest_memfd
>    from a memslot to make it harder to leak references.
>
>  - Enhance KVM selftests to make it easer to develop and debug selftests like
>    those added for guest_memfd NUMA support, e.g. where test and/or KVM bugs
>    often result in hard-to-debug SIGBUS errors.
>
>  - Misc cleanups.
>
> ----------------------------------------------------------------
> Ackerley Tng (1):
>       KVM: guest_memfd: Use guest mem inodes instead of anonymous inodes
>
> Matthew Wilcox (2):
>       mm/filemap: Add NUMA mempolicy support to filemap_alloc_folio()
>       mm/filemap: Extend __filemap_get_folio() to support NUMA memory policies
>
> Pedro Demarchi Gomes (1):
>       KVM: guest_memfd: use folio_nr_pages() instead of shift operation
>
> Sean Christopherson (10):
>       KVM: guest_memfd: Drop a superfluous local var in kvm_gmem_fault_user_mapping()
>       KVM: guest_memfd: Rename "struct kvm_gmem" to "struct gmem_file"
>       KVM: guest_memfd: Add macro to iterate over gmem_files for a mapping/inode
>       KVM: selftests: Define wrappers for common syscalls to assert success
>       KVM: selftests: Report stacktraces SIGBUS, SIGSEGV, SIGILL, and SIGFPE by default
>       KVM: selftests: Add additional equivalents to libnuma APIs in KVM's numaif.h
>       KVM: selftests: Use proper uAPI headers to pick up mempolicy.h definitions
>       KVM: guest_memfd: Add gmem_inode.flags field instead of using i_private
>       KVM: guest_memfd: Define a CLASS to get+put guest_memfd file from a memslot
>       KVM: selftests: Rename "guest_paddr" variables to "gpa"
>
> Shivank Garg (7):
>       mm/mempolicy: Export memory policy symbols
>       KVM: guest_memfd: move kvm_gmem_get_index() and use in kvm_gmem_prepare_folio()
>       KVM: guest_memfd: remove redundant gmem variable initialization
>       KVM: guest_memfd: Add slab-allocated inode cache
>       KVM: guest_memfd: Enforce NUMA mempolicy using shared policy
>       KVM: selftests: Add helpers to probe for NUMA support, and multi-node systems
>       KVM: selftests: Add guest_memfd tests for mmap and NUMA policy support
>
>  fs/btrfs/compression.c                                         |   4 +-
>  fs/btrfs/verity.c                                              |   2 +-
>  fs/erofs/zdata.c                                               |   2 +-
>  fs/f2fs/compress.c                                             |   2 +-
>  include/linux/pagemap.h                                        |  18 +++--
>  include/uapi/linux/magic.h                                     |   1 +
>  mm/filemap.c                                                   |  23 ++++---
>  mm/mempolicy.c                                                 |   6 ++
>  mm/readahead.c                                                 |   2 +-
>  tools/testing/selftests/kvm/arm64/vgic_irq.c                   |   2 +-
>  tools/testing/selftests/kvm/guest_memfd_test.c                 |  98 +++++++++++++++++++++++++++
>  tools/testing/selftests/kvm/include/kvm_syscalls.h             |  81 ++++++++++++++++++++++
>  tools/testing/selftests/kvm/include/kvm_util.h                 |  39 ++---------
>  tools/testing/selftests/kvm/include/numaif.h                   | 110 ++++++++++++++++++------------
>  tools/testing/selftests/kvm/kvm_binary_stats_test.c            |   4 +-
>  tools/testing/selftests/kvm/lib/kvm_util.c                     | 101 +++++++++++++++-------------
>  tools/testing/selftests/kvm/x86/private_mem_conversions_test.c |   9 +--
>  tools/testing/selftests/kvm/x86/xapic_ipi_test.c               |   5 +-
>  virt/kvm/guest_memfd.c                                         | 374 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
>  virt/kvm/kvm_main.c                                            |   7 +-
>  virt/kvm/kvm_mm.h                                              |   9 +--
>  21 files changed, 646 insertions(+), 253 deletions(-)
>  create mode 100644 tools/testing/selftests/kvm/include/kvm_syscalls.h
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ