From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: David Hildenbrand <david@kernel.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Yosry Ahmed <yosry@kernel.org>,
Ackerley Tng <ackerleytng@google.com>,
Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
Tianrui Zhao <zhaotianrui@loongson.cn>,
Bibo Mao <maobibo@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Anup Patel <anup@brainfault.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>
Subject: [PATCH v2 2/5] KVM: guest_memfd: Move gmem function declarations to dedicated guest_memfd.h
Date: Fri, 31 Jul 2026 10:38:39 -0700 [thread overview]
Message-ID: <20260731173842.2649391-3-seanjc@google.com> (raw)
In-Reply-To: <20260731173842.2649391-1-seanjc@google.com>
Extract the gmem function declarations out of kvm_mm.h and into a dedicated
header, guest_memfd.h. This will allow creating a MAINTAINERS entry for
guest_memfd without having to rely on content pattern matching.
Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
virt/kvm/guest_memfd.c | 1 +
virt/kvm/guest_memfd.h | 34 ++++++++++++++++++++++++++++++++++
virt/kvm/kvm_main.c | 1 +
virt/kvm/kvm_mm.h | 27 ---------------------------
4 files changed, 36 insertions(+), 27 deletions(-)
create mode 100644 virt/kvm/guest_memfd.h
diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index 86690683b2fe..de2585539b25 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -9,6 +9,7 @@
#include <linux/pagemap.h>
#include "kvm_mm.h"
+#include "guest_memfd.h"
static struct vfsmount *kvm_gmem_mnt;
diff --git a/virt/kvm/guest_memfd.h b/virt/kvm/guest_memfd.h
new file mode 100644
index 000000000000..0f9c6f840838
--- /dev/null
+++ b/virt/kvm/guest_memfd.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __KVM_GUEST_MEMFD_H__
+#define __KVM_GUEST_MEMFD_H__
+
+#include <linux/kvm_types.h>
+
+#ifdef CONFIG_KVM_GUEST_MEMFD
+int kvm_gmem_init(struct module *module);
+void kvm_gmem_exit(void);
+int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args);
+int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
+ unsigned int fd, uoff_t offset);
+void kvm_gmem_unbind(struct kvm_memory_slot *slot);
+#else
+static inline int kvm_gmem_init(struct module *module)
+{
+ return 0;
+}
+static inline void kvm_gmem_exit(void) {};
+static inline int kvm_gmem_bind(struct kvm *kvm,
+ struct kvm_memory_slot *slot,
+ unsigned int fd, uoff_t offset)
+{
+ WARN_ON_ONCE(1);
+ return -EIO;
+}
+
+static inline void kvm_gmem_unbind(struct kvm_memory_slot *slot)
+{
+ WARN_ON_ONCE(1);
+}
+#endif /* CONFIG_KVM_GUEST_MEMFD */
+
+#endif /* __KVM_GUEST_MEMFD_H__ */
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e44c20c04961..a2f67623e60a 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -56,6 +56,7 @@
#include "coalesced_mmio.h"
#include "async_pf.h"
+#include "guest_memfd.h"
#include "kvm_mm.h"
#include "vfio.h"
diff --git a/virt/kvm/kvm_mm.h b/virt/kvm/kvm_mm.h
index 7510ca915dd1..c65cfdb14f1c 100644
--- a/virt/kvm/kvm_mm.h
+++ b/virt/kvm/kvm_mm.h
@@ -70,31 +70,4 @@ static inline void gfn_to_pfn_cache_invalidate_start(struct kvm *kvm,
}
#endif /* HAVE_KVM_PFNCACHE */
-#ifdef CONFIG_KVM_GUEST_MEMFD
-int kvm_gmem_init(struct module *module);
-void kvm_gmem_exit(void);
-int kvm_gmem_create(struct kvm *kvm, struct kvm_create_guest_memfd *args);
-int kvm_gmem_bind(struct kvm *kvm, struct kvm_memory_slot *slot,
- unsigned int fd, uoff_t offset);
-void kvm_gmem_unbind(struct kvm_memory_slot *slot);
-#else
-static inline int kvm_gmem_init(struct module *module)
-{
- return 0;
-}
-static inline void kvm_gmem_exit(void) {};
-static inline int kvm_gmem_bind(struct kvm *kvm,
- struct kvm_memory_slot *slot,
- unsigned int fd, uoff_t offset)
-{
- WARN_ON_ONCE(1);
- return -EIO;
-}
-
-static inline void kvm_gmem_unbind(struct kvm_memory_slot *slot)
-{
- WARN_ON_ONCE(1);
-}
-#endif /* CONFIG_KVM_GUEST_MEMFD */
-
#endif /* __KVM_MM_H__ */
--
2.55.0.508.g3f0d502094-goog
next prev parent reply other threads:[~2026-07-31 17:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 17:38 [PATCH v2 0/5] MAINTAINERS: KVM tweaks and additions Sean Christopherson
2026-07-31 17:38 ` [PATCH v2 1/5] MAINTAINERS: Add kvm-x86 tree to KVM x86 entries Sean Christopherson
2026-07-31 17:38 ` Sean Christopherson [this message]
2026-07-31 17:38 ` [PATCH v2 3/5] MAINTAINERS: Add an entry for KVM's guest_memfd Sean Christopherson
2026-07-31 17:38 ` [PATCH v2 4/5] MAINTAINERS: Add David H. as a KVM guest_memfd reviewer Sean Christopherson
2026-07-31 17:38 ` [PATCH v2 5/5] MAINTAINERS: Add myself (Sean) as a reviewer in the main KVM entry Sean Christopherson
2026-07-31 17:43 ` Paolo Bonzini
2026-08-03 7:35 ` Christian Borntraeger
2026-08-03 7:47 ` Bibo Mao
2026-08-03 8:35 ` Anup Patel
2026-08-03 9:01 ` Janosch Frank
2026-08-07 16:25 ` [PATCH v2 0/5] MAINTAINERS: KVM tweaks and additions Sean Christopherson
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=20260731173842.2649391-3-seanjc@google.com \
--to=seanjc@google.com \
--cc=ackerleytng@google.com \
--cc=anup@brainfault.org \
--cc=borntraeger@linux.ibm.com \
--cc=chenhuacai@kernel.org \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maobibo@loongson.cn \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=yosry@kernel.org \
--cc=zhaotianrui@loongson.cn \
/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