Linux EDAC development
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Bibo Mao" <maobibo@loongson.cn>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Song Gao" <17746591750@163.com>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Bernhard Beschow" <shentey@gmail.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Paul Durrant" <paul@xen.org>, "Björn Walk" <bwalk@linux.ibm.com>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	qemu-s390x@nongnu.org, "David Woodhouse" <dwmw2@infradead.org>,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	qemu-ppc@nongnu.org, "Marcelo Tosatti" <mtosatti@redhat.com>,
	kvm@vger.kernel.org, qemu-arm@nongnu.org,
	linux-edac@vger.kernel.org, "Glenn Miles" <milesg@linux.ibm.com>,
	"Chao Liu" <chao.liu@processmission.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Gautam Menghani" <gautam@linux.ibm.com>,
	"Xianglai Li" <lixianglai@loongson.cn>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Chinmay Rath" <rathc@linux.ibm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Matthew Rosato" <mjrosato@linux.ibm.com>,
	"Amit Machhiwal" <amachhiw@linux.ibm.com>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	qemu-riscv@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [PATCH 01/23] accel: introduce KVMAccelClass and KVMCPUOps
Date: Tue, 20 Oct 2026 11:42:55 +0100	[thread overview]
Message-ID: <20261020104320.3686723-2-alex.bennee@linaro.org> (raw)
In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org>

Introduce a new class derived from AccelCPUClass. It only exists to to
contain the new KVMCPUOps which will allow for a QOM-ified access to
what was previously kvm_arch_foo direct linking. This anticipates a
world where we have a KVM interface capable of launching multiple
architectures.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/accel/kvm/cpu-ops.h | 53 +++++++++++++++++++++++++++++++++++++
 accel/kvm/kvm-accel-ops.c   |  9 +++++++
 2 files changed, 62 insertions(+)
 create mode 100644 include/accel/kvm/cpu-ops.h

diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h
new file mode 100644
index 00000000000..662d0c553c7
--- /dev/null
+++ b/include/accel/kvm/cpu-ops.h
@@ -0,0 +1,53 @@
+/*
+ * KVM CPU-specific operations
+ *
+ * Copyright 2026 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef ACCEL_KVM_CPU_OPS_H
+#define ACCEL_KVM_CPU_OPS_H
+
+#include "qom/object.h"
+#include "hw/core/cpu.h"
+#include "accel/accel-cpu-target.h"
+
+/**
+ * struct KVMCPUOps - Target-specific per-vCPU operations for KVM
+ */
+typedef struct KVMCPUOps {
+} KVMCPUOps;
+
+#define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu"
+
+/**
+ * struct KVMAccelCPUClass - KVM-specific accelerator CPU class
+ *
+ * @parent_class: The parent #AccelCPUClass
+ */
+typedef struct KVMAccelCPUClass {
+    AccelCPUClass parent_class;
+
+    const KVMCPUOps *cpu_ops;
+} KVMAccelCPUClass;
+
+DECLARE_CLASS_CHECKERS(KVMAccelCPUClass, KVM_ACCEL_CPU, TYPE_KVM_ACCEL_CPU)
+
+/**
+ * kvm_get_cpu_ops - Retrieve the KVMCPUOps table for a CPU
+ * @cpu: The #CPUState
+ *
+ * Returns: A pointer to the active #KVMCPUOps, or NULL if the CPU class does
+ *          not have an attached KVM accelerator class.
+ */
+static inline const KVMCPUOps *kvm_get_cpu_ops(const CPUState *cpu)
+{
+    if (cpu->cc->accel_cpu) {
+        KVMAccelCPUClass *kacc = KVM_ACCEL_CPU_CLASS(cpu->cc->accel_cpu);
+        return kacc->cpu_ops;
+    }
+    return NULL;
+}
+
+#endif /* ACCEL_KVM_CPU_OPS_H */
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 47244d33f7d..445d7d7f545 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -18,6 +18,7 @@
 #include "qemu/main-loop.h"
 #include "exec/cpu-common.h"
 #include "accel/accel-cpu-ops.h"
+#include "accel/kvm/cpu-ops.h"
 #include "system/kvm.h"
 #include "system/kvm_int.h"
 #include "system/runstate.h"
@@ -121,8 +122,16 @@ static const TypeInfo kvm_accel_ops_type = {
     .abstract = true,
 };
 
+static const TypeInfo kvm_accel_cpu_type = {
+    .name = TYPE_KVM_ACCEL_CPU,
+    .parent = TYPE_ACCEL_CPU,
+    .class_size = sizeof(KVMAccelCPUClass),
+    .abstract = true,
+};
+
 static void kvm_accel_ops_register_types(void)
 {
     type_register_static(&kvm_accel_ops_type);
+    type_register_static(&kvm_accel_cpu_type);
 }
 type_init(kvm_accel_ops_register_types);
-- 
2.47.3


  reply	other threads:[~2026-10-20 10:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 10:42 [PATCH 00/23] kvm: introduce KVMCPUOps Alex Bennée
2026-10-20 10:42 ` Alex Bennée [this message]
2026-10-20 10:42 ` [PATCH 02/23] target/i386: wire up empty KVMAccelCPUClass Alex Bennée
2026-10-20 10:42 ` [PATCH 03/23] target/ppc: " Alex Bennée
2026-10-20 10:42 ` [PATCH 04/23] target/riscv: " Alex Bennée
2026-10-20 10:42 ` [PATCH 05/23] target/arm: " Alex Bennée
2026-10-20 10:43 ` [PATCH 06/23] target/s390x: " Alex Bennée
2026-10-20 10:43 ` [PATCH 07/23] target/loongarch: " Alex Bennée
2026-10-20 10:43 ` [PATCH 08/23] accel/kvm: port kvm_arch_pre_run to KVMCPUOps Alex Bennée
2026-10-20 10:43 ` [PATCH 09/23] accel/kvm: port kvm_arch_post_run " Alex Bennée
2026-10-20 10:43 ` [PATCH 10/23] accel/kvm: port kvm_arch_handle_exit " Alex Bennée
2026-10-20 10:43 ` [PATCH 11/23] accel/kvm: port kvm_arch_process_async_events " Alex Bennée
2026-10-20 10:43 ` [PATCH 12/23] accel/kvm: port kvm_arch_[put|get]_registers " Alex Bennée
2026-10-20 10:43 ` [PATCH 13/23] accel/kvm: port kvm_arch_pre_create_vcpu " Alex Bennée
2026-10-20 10:43 ` [PATCH 14/23] accel/kvm: port kvm_arch_init_vcpu " Alex Bennée
2026-10-20 10:43 ` [PATCH 15/23] accel/kvm: port kvm_arch_destroy_vcpu " Alex Bennée
2026-10-20 10:43 ` [PATCH 16/23] accel/kvm: port kvm_arch_vpcu_id " Alex Bennée
2026-10-20 10:43 ` [PATCH 17/23] accel/kvm: port kvm_arch_update_guest_debug " Alex Bennée
2026-10-20 10:43 ` [PATCH 18/23] accel/kvm: port kvm_arch_[insert|remove]_hw_breakpoints " Alex Bennée
2026-10-20 10:43 ` [PATCH 19/23] accel/kvm: remove TARGET_KVM_HAVE_GUEST_DEBUG Alex Bennée
2026-10-20 10:43 ` [PATCH 20/23] accel/kvm: port kvm_arch_stop_on_emulation_error to KVMCPUOps Alex Bennée
2026-10-20 10:43 ` [PATCH 21/23] accel/kvm: port kvm_arch_on_sigbus_vcpu " Alex Bennée
2026-10-20 10:43 ` [PATCH 22/23] accel/kvm: cache KVMCPUOps Alex Bennée
2026-10-20 10:43 ` [PATCH 23/23] accel/kvm: remove redundant ops checks for kvm_get_cpu_ops Alex Bennée
2026-10-20 11:21 ` [PATCH 00/23] kvm: introduce KVMCPUOps Alex Bennée
2026-10-21 16:47   ` Paolo Bonzini
2026-10-22  4:47     ` Cornelia Huck
2026-10-22  8:06       ` Andreas Grapentin

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=20261020104320.3686723-2-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=17746591750@163.com \
    --cc=alistair.francis@wdc.com \
    --cc=amachhiw@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=bwalk@linux.ibm.com \
    --cc=chao.liu@processmission.com \
    --cc=cohuck@redhat.com \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=david@kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=farman@linux.ibm.com \
    --cc=gautam@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=liwei1518@gmail.com \
    --cc=lixianglai@loongson.cn \
    --cc=maobibo@loongson.cn \
    --cc=mchehab+huawei@kernel.org \
    --cc=milesg@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pasic@linux.ibm.com \
    --cc=paul@xen.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rathc@linux.ibm.com \
    --cc=richard.henderson@linaro.org \
    --cc=shentey@gmail.com \
    --cc=zhao1.liu@intel.com \
    --cc=zhiwei_liu@linux.alibaba.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