From: Steffen Eiden <seiden@linux.ibm.com>
To: kvm@vger.kernel.org, kvmarm@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Alexander Gordeev <agordeev@linux.ibm.com>,
Andreas Grapentin <gra@linux.ibm.com>,
Arnd Bergmann <arnd@arndb.de>,
Catalin Marinas <catalin.marinas@arm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Friedrich Welter <fritz@linux.ibm.com>,
Fuad Tabba <tabba@google.com>, Gautam Gala <ggala@linux.ibm.com>,
Hariharan Mari <hari55@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Hendrik Brueckner <brueckner@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Joey Gouly <joey.gouly@arm.com>, Marc Zyngier <maz@kernel.org>,
Nico Boehr <nrb@linux.ibm.com>,
Nina Schoetterl-Glausch <oss@nina.schoetterlglausch.eu>,
Oliver Upton <oupton@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>, Will Deacon <will@kernel.org>,
Zenghui Yu <yuzenghui@huawei.com>
Subject: [PATCH v9 01/24] KVM: Make device name configurable
Date: Wed, 30 Sep 2026 19:34:16 +0200 [thread overview]
Message-ID: <20260930173441.66762-2-seiden@linux.ibm.com> (raw)
In-Reply-To: <20260930173441.66762-1-seiden@linux.ibm.com>
Allow KVM implementations to choose alternative device names. This is
especially useful for architectures providing multiple KVM
implementations simultaneously. Architectures providing multiple KVM
implementations must compile the KVM common code once per implementation
and mangle symbols.
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
---
arch/s390/kvm/gmap/trace_gmap.h | 4 +++-
arch/s390/kvm/s390/Makefile | 2 +-
include/linux/kvm_host.h | 4 ++++
include/trace/events/kvm.h | 8 +++++++-
virt/kvm/Makefile.kvm | 5 +++++
virt/kvm/async_pf.c | 5 ++++-
virt/kvm/eventfd.c | 3 ++-
virt/kvm/kvm_main.c | 32 +++++++++++++++++---------------
8 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/arch/s390/kvm/gmap/trace_gmap.h b/arch/s390/kvm/gmap/trace_gmap.h
index 15ec88bdce55..78d26dae59f9 100644
--- a/arch/s390/kvm/gmap/trace_gmap.h
+++ b/arch/s390/kvm/gmap/trace_gmap.h
@@ -4,8 +4,10 @@
#include <linux/tracepoint.h>
+#undef UNPACK_KVM
+#define UNPACK_KVM(name) name
#undef TRACE_SYSTEM
-#define TRACE_SYSTEM kvm
+#define TRACE_SYSTEM UNPACK_KVM(KVM_DEV_NAME)
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH ../gmap
#undef TRACE_INCLUDE_FILE
diff --git a/arch/s390/kvm/s390/Makefile b/arch/s390/kvm/s390/Makefile
index 762a63826423..b91334db90a2 100644
--- a/arch/s390/kvm/s390/Makefile
+++ b/arch/s390/kvm/s390/Makefile
@@ -4,7 +4,7 @@ KVM := ../../../../virt/kvm
include $(srctree)/virt/kvm/Makefile.kvm
include $(srctree)/arch/s390/kvm/gmap/Makefile
-ccflags-y := -I$(src) -I$(srctree)/arch/s390/kvm/gmap
+ccflags-y += -I$(src) -I$(srctree)/arch/s390/kvm/gmap
kvm-y += s390.o intercept.o interrupt.o priv.o sigp.o
kvm-y += diag.o gaccess.o guestdbg.o vsie.o pv.o
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 586f6e8bb81b..160e3e64ec6d 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -45,6 +45,10 @@
#include <asm/kvm_host.h>
#include <linux/kvm_dirty_ring.h>
+#define __KVM_DEV_STRING(name, x) __stringify(name ## _ ## x)
+#define _KVM_DEV_STRING(name, x) __KVM_DEV_STRING(name, x)
+#define KVM_DEV_STRING(x) _KVM_DEV_STRING(KVM_DEV_NAME, x)
+
#ifndef KVM_MAX_VCPU_IDS
#define KVM_MAX_VCPU_IDS KVM_MAX_VCPUS
#endif
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index b282e3a86769..f37582730ffc 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -4,8 +4,14 @@
#include <linux/tracepoint.h>
+#undef UNPACK_KVM
+#define UNPACK_KVM(name) name
#undef TRACE_SYSTEM
-#define TRACE_SYSTEM kvm
+#define TRACE_SYSTEM UNPACK_KVM(KVM_DEV_NAME)
+#undef TRACE_SYSTEM_VAR
+#define TRACE_SYSTEM_VAR kvm
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE kvm
#define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
diff --git a/virt/kvm/Makefile.kvm b/virt/kvm/Makefile.kvm
index d047d4cf58c9..b39f7b2a5f6e 100644
--- a/virt/kvm/Makefile.kvm
+++ b/virt/kvm/Makefile.kvm
@@ -5,6 +5,11 @@
KVM ?= ../../../virt/kvm
+KVM_DEV_NAME ?= kvm
+KVM_DEV_MINOR ?= KVM_MINOR
+
+ccflags-y +=-DKVM_DEV_NAME=$(KVM_DEV_NAME) -DKVM_DEV_MINOR=$(KVM_DEV_MINOR)
+
kvm-y := $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/binary_stats.o
kvm-$(CONFIG_KVM_VFIO) += $(KVM)/vfio.o
kvm-$(CONFIG_KVM_MMIO) += $(KVM)/coalesced_mmio.o
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index b8aaa96b799b..6b3b6353cb9d 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -21,7 +21,10 @@ static struct kmem_cache *async_pf_cache;
int kvm_async_pf_init(void)
{
- async_pf_cache = KMEM_CACHE(kvm_async_pf, 0);
+ async_pf_cache = kmem_cache_create(KVM_DEV_STRING(async_pf),
+ sizeof(struct kvm_async_pf),
+ __alignof__(struct kvm_async_pf),
+ 0, NULL);
if (!async_pf_cache)
return -ENOMEM;
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 93ad2ebc963f..f43b8b25bc85 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -711,7 +711,8 @@ bool kvm_notify_irqfd_resampler(struct kvm *kvm,
*/
int kvm_irqfd_init(void)
{
- irqfd_cleanup_wq = alloc_workqueue("kvm-irqfd-cleanup", WQ_PERCPU, 0);
+ irqfd_cleanup_wq = alloc_workqueue(__stringify(KVM_DEV_NAME) "-irqfd-cleanup",
+ WQ_PERCPU, 0);
if (!irqfd_cleanup_wq)
return -ENOMEM;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 60e614795a36..f62901b7e23d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -10,6 +10,8 @@
* Yaniv Kamay <yaniv@qumranet.com>
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <kvm/iodev.h>
#include <linux/kvm_host.h>
@@ -1013,7 +1015,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, const char *fdname)
mutex_lock(&kvm_debugfs_lock);
dent = debugfs_lookup(dir_name, kvm_debugfs_dir);
if (dent) {
- pr_warn_ratelimited("KVM: debugfs: duplicate directory %s\n", dir_name);
+ pr_warn_ratelimited("debugfs: duplicate directory %s\n", dir_name);
dput(dent);
mutex_unlock(&kvm_debugfs_lock);
return 0;
@@ -4138,9 +4140,9 @@ static struct file_operations kvm_vcpu_fops = {
*/
static int create_vcpu_fd(struct kvm_vcpu *vcpu)
{
- char name[8 + 1 + ITOA_MAX_LEN + 1];
+ char name[sizeof(__stringify(KVM_DEV_NAME) "-vcpu:") + ITOA_MAX_LEN + 1];
- snprintf(name, sizeof(name), "kvm-vcpu:%d", vcpu->vcpu_id);
+ snprintf(name, sizeof(name), __stringify(KVM_DEV_NAME) "-vcpu:%d", vcpu->vcpu_id);
return anon_inode_getfd(name, &kvm_vcpu_fops, vcpu, O_RDWR | O_CLOEXEC);
}
@@ -4353,9 +4355,9 @@ static int kvm_vcpu_ioctl_get_stats_fd(struct kvm_vcpu *vcpu)
{
int fd;
struct file *file;
- char name[15 + ITOA_MAX_LEN + 1];
+ char name[sizeof(__stringify(KVM_DEV_NAME) "-vcpu-stats:") + ITOA_MAX_LEN + 1];
- snprintf(name, sizeof(name), "kvm-vcpu-stats:%d", vcpu->vcpu_id);
+ snprintf(name, sizeof(name), __stringify(KVM_DEV_NAME) "-vcpu-stats:%d", vcpu->vcpu_id);
fd = get_unused_fd_flags(O_CLOEXEC);
if (fd < 0)
@@ -5168,7 +5170,7 @@ static int kvm_vm_ioctl_get_stats_fd(struct kvm *kvm)
if (fd < 0)
return fd;
- file = anon_inode_getfile_fmode("kvm-vm-stats",
+ file = anon_inode_getfile_fmode(__stringify(KVM_DEV_NAME) "-vm-stats",
&kvm_vm_stats_fops, kvm, O_RDONLY, FMODE_PREAD);
if (IS_ERR(file)) {
put_unused_fd(fd);
@@ -5545,7 +5547,7 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
goto put_fd;
}
- file = anon_inode_getfile("kvm-vm", &kvm_vm_fops, kvm, O_RDWR);
+ file = anon_inode_getfile(__stringify(KVM_DEV_NAME) "-vm", &kvm_vm_fops, kvm, O_RDWR);
if (IS_ERR(file)) {
r = PTR_ERR(file);
goto put_kvm;
@@ -5613,8 +5615,8 @@ static struct file_operations kvm_chardev_ops = {
};
static struct miscdevice kvm_dev = {
- KVM_MINOR,
- "kvm",
+ KVM_DEV_MINOR,
+ __stringify(KVM_DEV_NAME),
&kvm_chardev_ops,
};
@@ -5648,7 +5650,7 @@ static int kvm_enable_virtualization_cpu(void)
return 0;
if (kvm_arch_enable_virtualization_cpu()) {
- pr_info("kvm: enabling virtualization on CPU%d failed\n",
+ pr_info("enabling virtualization on CPU%d failed\n",
raw_smp_processor_id());
return -EIO;
}
@@ -5695,7 +5697,7 @@ static void kvm_shutdown(void *data)
* is used for both shutdown and reboot scenarios, i.e. neither name is
* 100% comprehensive.
*/
- pr_info("kvm: exiting hardware virtualization\n");
+ pr_info("exiting hardware virtualization\n");
on_each_cpu(kvm_disable_virtualization_cpu, NULL, 1);
}
@@ -6106,7 +6108,7 @@ int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
* attached devices. Otherwise, destroy the caller's device only.
*/
if (!new_bus) {
- pr_err("kvm: failed to shrink bus, removing it completely\n");
+ pr_err("failed to shrink bus, removing it completely\n");
kvm_io_bus_destroy(bus);
return -ENOMEM;
}
@@ -6393,7 +6395,7 @@ static void kvm_init_debug(void)
const struct kvm_stats_desc *pdesc;
int i;
- kvm_debugfs_dir = debugfs_create_dir("kvm", NULL);
+ kvm_debugfs_dir = debugfs_create_dir(__stringify(KVM_DEV_NAME), NULL);
for (i = 0; i < kvm_vm_stats_header.num_desc; ++i) {
pdesc = &kvm_vm_stats_desc[i];
@@ -6538,7 +6540,7 @@ int kvm_init(unsigned vcpu_size, unsigned vcpu_align, struct module *module)
if (!vcpu_align)
vcpu_align = __alignof__(struct kvm_vcpu);
kvm_vcpu_cache =
- kmem_cache_create_usercopy("kvm_vcpu", vcpu_size, vcpu_align,
+ kmem_cache_create_usercopy(KVM_DEV_STRING(vcpu), vcpu_size, vcpu_align,
SLAB_ACCOUNT,
offsetof(struct kvm_vcpu, arch),
offsetofend(struct kvm_vcpu, stats_id)
@@ -6591,7 +6593,7 @@ int kvm_init(unsigned vcpu_size, unsigned vcpu_align, struct module *module)
*/
r = misc_register(&kvm_dev);
if (r) {
- pr_err("kvm: misc device register failed\n");
+ pr_err("misc device register failed\n");
goto err_register;
}
--
2.53.0
next prev parent reply other threads:[~2026-09-30 17:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 17:34 [PATCH v9 00/24] KVM: s390: Introduce arm64 KVM Steffen Eiden
2026-09-30 17:34 ` Steffen Eiden [this message]
2026-09-30 17:34 ` [PATCH v9 02/24] KVM: Move architecture capability Kconfigs to header defines Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 03/24] KVM: Replace CONFIG_KVM_MMIO with KVM_NO_MMIO Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 04/24] arm64: Use proper include variant Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 05/24] arm64: ptrace: Use constants for compat register numbers Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 06/24] arm64: sysreg: Convert SPSR_ELx to automatic register generation Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 07/24] KVM: arm64: Access elements of vcpu_gp_regs individually Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 08/24] KVM: arm64: Use accessor functions for core regs Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 09/24] arm64: Prepare sharing arm64 headers with s390 Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 10/24] arm64: Share " Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 11/24] KVM: arm64: Share arm64 code " Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 12/24] s390/Kconfig: remove PCI dependency from HAS_IOMEM Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 13/24] KVM: s390: Use dedicated function for migration mode Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 14/24] s390/tools: Use arm64 headers Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 15/24] KVM: s390: Use arm64 code Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 16/24] s390: Introduce Start Arm Execution instruction Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 17/24] KVM: s390: arm64: Introduce host definitions Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 18/24] s390/hwcaps: Report SAE support as hwcap Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 19/24] KVM: s390: Add basic arm64 kvm module Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 20/24] KVM: s390: arm64: Implement required functions Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 21/24] KVM: s390: arm64: Implement vm/vcpu create destroy Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 22/24] KVM: s390: arm64: Implement vCPU IOCTLs Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 23/24] KVM: s390: arm64: Implement basic page fault handler Steffen Eiden
2026-09-30 17:34 ` [PATCH v9 24/24] KVM: s390: arm64: Integrate arm on s390 Steffen Eiden
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=20260930173441.66762-2-seiden@linux.ibm.com \
--to=seiden@linux.ibm.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=arnd@arndb.de \
--cc=borntraeger@linux.ibm.com \
--cc=brueckner@linux.ibm.com \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=fritz@linux.ibm.com \
--cc=ggala@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=gra@linux.ibm.com \
--cc=hari55@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=maz@kernel.org \
--cc=nrb@linux.ibm.com \
--cc=oss@nina.schoetterlglausch.eu \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=suzuki.poulose@arm.com \
--cc=svens@linux.ibm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.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®