From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792494333; cv=none; d=zohomail.com; s=zohoarc; b=PRKcQ2gXqrgp2KoL5hYzgcnBSeEKWvx+Los815y7rSAFJgk+WLPyxElqy8fQKVc+hbekRVgHLOabuOVwY03/kuRCvcoiWREKLcIE6tkQnWBY6EoxD6+0khYyyZIPdFoi0/1df7a9mkgFu/+jaezVO9F4jf6anukL0HqAqt9NHnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792494333; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lQ4MX1q3rcBPurkumbq9wX+jGqxuJWd5pa2EGbSUiwo=; b=oGHc8+/eaOwHk+enyJ3TmiAMJETnXmhkfD9DFAz3aK96xtLGtwEy5Cl7uMcSlBdFLI1TuNSkHqF9ykMsBu/QFLVbH5fOXs5bhOVuQvh8ewZOtd/CYD4YNfsPd4PURYR3X8cQoeFHj2CJ/GsKvTL8rTX4JulnLXIblPs/+JZOVGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792494333143717.8370680822355; Tue, 20 Oct 2026 04:05:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Jc-00049d-P3; Tue, 20 Oct 2026 06:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7JX-00046N-VH for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:28 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JU-0004JB-7a for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:27 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-48e0d885929so2345237f8f.3 for ; Tue, 20 Oct 2026 03:43:23 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d80fb69sm4788951f8f.18.2026.10.20.03.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:21 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 57CA35F915; Tue, 20 Oct 2026 11:43:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493003; x=1793097803; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=lQ4MX1q3rcBPurkumbq9wX+jGqxuJWd5pa2EGbSUiwo=; b=PfhsTX4XEwtiyVdTdH9YhbyhJMwq/on2U1XmTH0fElEQ9g28KCWNyTxZOiAzb1zj/P lYqHdU6lHDqIvjjE+LVhc16YcolT/H3tJphMnyC65wbtzQvpKvmQkVmQ5wJpJkAi5998 AqgcCcxBS7wSa8IFTrlkPOmbPd3eb2jc1hw1Q6ieyrb5FbMlFLfuLGT1v++V7W1QdyxS qilrus1NKbdvxFWyRRasn7G44m6qSVGC6YGgNTL+cgUPZNycm43MISafuRXfJQjtLp3x ebKIMVE37wiBPZTU4hXW+ZWFqv4nngLs/SgDLGeyyr9ZIiLnv6EQz7WbSvT2mpoyn1lq pAaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493003; x=1793097803; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=lQ4MX1q3rcBPurkumbq9wX+jGqxuJWd5pa2EGbSUiwo=; b=COp5O71BxIAYzOzm/c7DZdw0S5HQXKia5W+vtdT6RgGrz7JFriYfAJ4D0T97SPGQuj PgQ3NHemi8yVSStR3wML9ZojWV/pLZYdnRR4L5QVBYspb0OMjiXDN9pOg+WJaJhdspzA JL609wkIf9n3+mlZjNWgbZ6l/cfAchi/LTKgNKBS2+M3FaIvQ+cf1OG8ZjyKQtspawVI zclKE2dRLbYwcT1+mFf4oWrGodS8QyoQ7swVc2F3kcnQMQKStTwmsdTWXAwH1MhHWDCr a5LgrxZrSQQOLRowDLN7gQ18o1nQ77C+PZw3N/CaKQIVYVViSMRFEcty/Z7yND4YBPL5 XuNg== X-Gm-Message-State: AFq9FYINZfqm4xKVCZrnLij1jUI9r9gUCvLPBQIYKpABfPxEgNZBeMv0 AaIqyzXgj+Kp2eO8pQpwmcNobJKxRWgVrhXN2mZWo5ozPsganRhhY3Vwh90gHnbUT8k= X-Gm-Gg: AYBFou1V1HBq9tXiqEiU7aybXweWuu9tkFuNiXCXgfNRSvutf/R7DBhN5l2TdXJaEEs GCBsyzDtFPELf1fyvq0baUXE52pm03WPqDDUjLltUxz9Wkz5lcEz1fNNwM3w7fAy4y2+K0VgLdq OEspZPuj2s+hvXHMMxSfD5ZOCcFMIlNuI5943g5ZEtpoKW3D0l6VypC3ODVHUre1sWPRyIU+geN WaRRf28UvEmO8PQMzb0FJJ/dAcS+J0EgX7skxMbCim3kdCi3XScGgc7mYrIx7y35uhyCAqmPP9E B8pls/680EX9+MMs1Gsy6IX1U9aPOTpjRYOhVBOq/KDrXGPiQq++HaMd8ycZaHaujHl+EHUWjMG gtpEi8RmktM0TvTDYVFGdIqKiFDmSWcG+iMVNoIBEE3TiP1UE5SiwqMQvKEPBUl+AzlRTDqcpC/ JeWCl6Ekt+SVANkr/oDnT6b+MwWjkoie3Ik96jTVHdKEwq3LjygAlTGL4fPU7O5kA0rYbPsw== X-Received: by 2002:a05:6000:46cd:b0:48d:f014:63ee with SMTP id ffacd0b85a97d-48e07bbc7d5mr13979635f8f.20.1792493002522; Tue, 20 Oct 2026 03:43:22 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 01/23] accel: introduce KVMAccelClass and KVMCPUOps Date: Tue, 20 Oct 2026 11:42:55 +0100 Message-ID: <20261020104320.3686723-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792494333912158500 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=C3=A9e --- 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 d= oes + * 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 =3D 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 =3D { .abstract =3D true, }; =20 +static const TypeInfo kvm_accel_cpu_type =3D { + .name =3D TYPE_KVM_ACCEL_CPU, + .parent =3D TYPE_ACCEL_CPU, + .class_size =3D sizeof(KVMAccelCPUClass), + .abstract =3D 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); --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493190; cv=none; d=zohomail.com; s=zohoarc; b=mDRRd+WmS2Z92fGlfJabqj3lAe1NjbctDNFaDnKWbh8IA/Yaj1c00dGGpO/ZOoatUAIloeYhfhfPoESxK8gDLYPFzkh/nEQZ2+9t4Xhqa+QuUM9WzHZacGPitcISMIbY8rhorRoqpsEs3mjD795TLnpVYkBs8TfBnbRJJ2tcV8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493190; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GObncgmEUBUSeoRmmw6cdeZcoKrwnIqxlNvyYUwUu+A=; b=OcdJh1GZJ2zJqGvVDAkZyFx5nBhmrNok2kQ4F4Ra6ob/gUp5oZ/OU5Hs/D8orDpA+iAbM0V3U3tq0s6VfxJTP593EAzTwHwNugjmVEMgdseHoSOR0NEAyi6M7wTgMEjRa4otT2hD21otOlGPBqsjU3e4dd5CbCkx2yI7abv+u4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493190635182.7187560911467; Tue, 20 Oct 2026 03:46:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7JX-000468-My; Tue, 20 Oct 2026 06:43:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7JW-00045n-8T for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:26 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JU-0004Ix-24 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:25 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4a018792ab3so23724695e9.0 for ; Tue, 20 Oct 2026 03:43:23 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1f2cc8e98sm67312705e9.9.2026.10.20.03.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:21 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 743535F957; Tue, 20 Oct 2026 11:43:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493002; x=1793097802; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=GObncgmEUBUSeoRmmw6cdeZcoKrwnIqxlNvyYUwUu+A=; b=iCv5mBKZoEQzGYBBQZmyqGREpGZopyN2ntXUYWUEcX8aQz91F0hbnpltOjOv08cHc8 /+JWJjhqjSprGTzGMUZnW+4pRA+22jpAMd87cbvVimzRNtU4LHkQ+9ET/prOiLWESHLA Im4yaPl/N1tp4Hj5anoeay8mxDfwKwrDJzhk7D9qTTBNNNdRB7Y6kx7N6L1rkafo77o/ 77AZRwKN+pyvV1BKoSSUDVc1dHrNX70ALjm7e+r2PxHuWg2aKV90Fn71UQxhSv28EvDu iqHL+No7MqX4djpXlniha+lGDMqbUm22IgSdVR8IKVJYPmb/aU0Hv/IkzHJgjlqjS2+6 rVMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493002; x=1793097802; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=GObncgmEUBUSeoRmmw6cdeZcoKrwnIqxlNvyYUwUu+A=; b=xXl6L3kDKnuKUXmpX0vyzsrHnuWpNLcR9eMomrUTPg2ZvP1CiyaKJNSrtJIJ5ttuMZ rAWSorzoBY/FVWbm1xnHOp6iBuzLKCyb+hH89fgn6utS10xF9oXrTan3ibfHU7yCrPyV UUOqc5gtHsf6F+i8FW5whEIO2z62cAKtXCk3vg/0nwLdXobyHh+StEvT+Wmu6UTSBRJ8 2pOutvMdO+sk7FkyfHkrjmTTdkKg1W1KmI6XoDqVg14nXdRAls9P48mBbEU/egwdoE6A YJ1XywmYWPsQyxSuWD6HeUuw/4/5KP7jWCm39bFnRHi/ts2S4YpU4GPduTYUKjUnchjx wvVQ== X-Gm-Message-State: AFq9FYKcW/RYvkvH9Z+TEGONvuu2GQCYA+AnIcLAemQOFHOOk80NmseH qoAdgQeSHggHtPf2BDyCLkjRrqSXg1Z/QLGiNTxG8zIR2fCGbayjjCOg0Tq8TBAhc70= X-Gm-Gg: AYBFou2RZkQp0nEZC+u8fzUdA3IWWGPWwqHR1uax7kf4BfFdjF7N4ADp3HIX8caNlXw tBgfT71TC29XFFb0TyO2Yyqmol6gw+ZqJVXbt9qa+dkrSVSLdl2K9BvKhnlZLqQKBYBE/yHANS+ ceQgtCkg33ZEC9jWWQGlDXiMEO7t+xMxcR5OKllK3VuvaX0PAQsIvUtugPqy14bUWh/2QiyeSqK Iau5geMLCuUpdV6goguLRJFYAsq4CMENv2q1n2WoEhplrfgaYwf0/RmKXAOXIt2omi/+jnVvodB TY53Po1yg5U221DvlqCox2q87uRaqwNCcfXdoX4kEUe23Li6wU6N4yIs7tUncb3G7FygByFST5M rFQDYipfJfA7HoXdUX1OKPzEebh499GZOimI6H1bWVoqs6dgZvEi+duPvO9TWSemysaGkKRbHKh GoAWU+ruDUAgKRlonVmTkLaSfM90LUoWXehqtanPxy+rkwlDCOqIcleB0V0V0wsv0oEiCNtMUrr uwvo0N0 X-Received: by 2002:a05:600c:c0c7:b0:4a1:d743:77f1 with SMTP id 5b1f17b1804b1-4a1d7bc2e33mr147348455e9.24.1792493001951; Tue, 20 Oct 2026 03:43:21 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 02/23] target/i386: wire up empty KVMAccelCPUClass Date: Tue, 20 Oct 2026 11:42:56 +0100 Message-ID: <20261020104320.3686723-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493190870158500 We will fill in the functions in future commits. Signed-off-by: Alex Benn=C3=A9e --- target/i386/kvm/kvm-cpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index da8d77ade06..9de107a18d5 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -17,6 +17,7 @@ =20 #include "kvm_i386.h" #include "accel/accel-cpu-target.h" +#include "accel/kvm/cpu-ops.h" =20 static void kvm_set_guest_phys_bits(CPUState *cs) { @@ -233,17 +234,22 @@ static void kvm_cpu_instance_init(CPUState *cs) kvm_cpu_xsave_init(); } =20 +static const KVMCPUOps x86_kvm_cpu_ops =3D { +}; + static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) { AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(oc); =20 acc->cpu_target_realize =3D kvm_cpu_realizefn; acc->cpu_instance_init =3D kvm_cpu_instance_init; + kacc->cpu_ops =3D &x86_kvm_cpu_ops; } static const TypeInfo kvm_cpu_accel_type_info =3D { .name =3D ACCEL_CPU_NAME("kvm"), =20 - .parent =3D TYPE_ACCEL_CPU, + .parent =3D TYPE_KVM_ACCEL_CPU, .class_init =3D kvm_cpu_accel_class_init, .abstract =3D true, }; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493280; cv=none; d=zohomail.com; s=zohoarc; b=GmHGEH5rKMbXdhomh2nBRRL9A36rKxpzSEBxE0ioILrs1nHN2cl6dVfh2cn6viJhR7K2dhLpylYRV/iQVvhhtNBPlXD5U/Q4SrW95E0EAYkZ/hyUT2sYqCfCwAfDVP9Ppqd6MDtjB3QgIHqSU2Bsac+Uu2J3imIw5xSBDZmhhHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493280; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EQ7gfcnpJP7Ud8+3W5PCJuKE2nJX2Z7vYXXp9omA0HY=; b=M8CFDS2iDfk1B7XFu/FVIwydp0hLDYPfx+usr4/+j4FZr0MMtEwDoFn2tCD/+4YMi8GBJx0S3TqD7ml9/XciI1YrftSIU9HQKGYWwemjBpUNTy+ELvzNrWuNGANsiwEaHXNloEqT+js8VuBarYWLZ6OAYh5+s7IDcrkFxSWYHU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179249328053888.97010485630994; Tue, 20 Oct 2026 03:48:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Jf-0004Ca-3Y; Tue, 20 Oct 2026 06:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jc-00049r-Ux for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:32 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JV-0004Jt-Eu for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:32 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-48c4649b35bso2532896f8f.3 for ; Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d820822sm5769631f8f.34.2026.10.20.03.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:21 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 92FE85F9E2; Tue, 20 Oct 2026 11:43:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493004; x=1793097804; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=EQ7gfcnpJP7Ud8+3W5PCJuKE2nJX2Z7vYXXp9omA0HY=; b=vPmALV4gDGYamFoTuBJCIb9umi3/Lx5WPLZXtab3ko46NgZcyM9etroNXub7pf2Jtq E8dWdEi/tXNkglzAnczcZNHiAr6ZfSiFnajuH2Y4SfhZNrjvF6Kbn0Sm12QapvCVk9PR zHq2lPWDGgb4Vf/oultd/QGnwUre9kcr5FcPWHo/k7JSFs9R0z5EDdqPIJhhLKYOKWFz vpbF4lata2/hl9H5SzdcLTgCy+StZGUudlGbMPTXQhZukoBCx/Xe1glPalQ7Z/d9kkBt DXD3eQ1k9f3171H1OfZyQy6S4hES4obxDNGH/ypDydsHZOW4WhgBKVI187fJgZaV/QGO rN+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493004; x=1793097804; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EQ7gfcnpJP7Ud8+3W5PCJuKE2nJX2Z7vYXXp9omA0HY=; b=RR5Xxtl+0Uz3uF6KbCYEvD9x1eu5uWVaZDFHv3tcrkz7ZYPf55obKf8kIoj7FAemC6 u7eVhjhtl36lWmMUq8JNF3hzZnpTKOZVuCfQOQ9sDH2D1wm7i97t98D4UP75jhejmDI1 rKqVDY2IxQeLOuinNwT+uLZM/6whtd4EoVdTId83BB4ZCb9v1yfLOdTDNtVVgMQUO091 jCXbpKtR8geptziO0mKmJPzhAQCG13bjU9qECvTQTs2A4riAJd0IBk5uiLNM1LQq6fym NXGsowaC83UsLwtWHsCZdiwJ6m8iqWq8PXKfz7FaCh3A0i6n3YUxlizwbdeR/s4Hf6MA XNOQ== X-Gm-Message-State: AFq9FYIRlMRGDXkxVR8EgUt0goRJgqDT+02NCeOuOaq/N5GXfCzoRtXV DpPQrAvcHSkXroxfF/bEUkHY9AkvIoljoHeOzza57ZPhw/82HYaErDCV3fe6U2gte7Y= X-Gm-Gg: AYBFou1eT2n/cetkjFfSnJB/beo6+7hHXg54UglzvVDzlAp3xFCi0mzf2/J7CNilSRB yax0Li9RkVkhpbVOC+YyJPWxpAaKyqKQdHQnuEjY49Jrt8sbmTcBrouYElD7LWkCC0lI41WJqSv EFP1vkR/+tPbgbRIXYdSJHALB90J3xpEb1ywaOXA5b3iW/SxJBYKYXkIRyC9uF0QTFvZZQvXiv6 Ilda/uJC/zFBgtb5bnmf86rw75HEaAEdekZxxRC92tErg4ebwGeI82ORhrQcTR7tlJO1KIO5Zdy g8F4By/oj5YsvNtcdYu3PEaShtls1kZ77q0DHo3ANjJGtozoyXhUUs/2QKvCvNR8VNX+AHYLYLU /a3ZycC5GE5au3R5U/CeHTmD8AOvBByj7smfvZgDQSsIhYHuvDTP03du1GfQldxVe84X7Q8o8ba 6CJJWCZsV6oyxc9cGF4e2wqk6cFplDnHzJMLgKKUWgyekHxGoKAq7Rb9YV3eXjiNt+HVpkODM= X-Received: by 2002:a05:6000:607:b0:48d:f58f:c91 with SMTP id ffacd0b85a97d-48e07bb5919mr21536746f8f.19.1792493003575; Tue, 20 Oct 2026 03:43:23 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 03/23] target/ppc: wire up empty KVMAccelCPUClass Date: Tue, 20 Oct 2026 11:42:57 +0100 Message-ID: <20261020104320.3686723-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493282990158500 We will fill in the functions in future commits. Signed-off-by: Alex Benn=C3=A9e --- target/ppc/kvm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 8e89a6c665c..8e9328beeb9 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -50,6 +50,7 @@ #include "system/kvm_int.h" #include "system/kvm.h" #include "accel/accel-cpu-target.h" +#include "accel/kvm/cpu-ops.h" =20 #include CONFIG_DEVICES =20 @@ -3080,17 +3081,22 @@ void kvm_arch_accel_class_init(ObjectClass *oc) { } =20 +static const KVMCPUOps ppc_kvm_cpu_ops =3D { +}; + static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) { AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(oc); =20 acc->cpu_target_realize =3D kvmppc_cpu_realize; + kacc->cpu_ops =3D &ppc_kvm_cpu_ops; } =20 static const TypeInfo kvm_cpu_accel_type_info =3D { .name =3D ACCEL_CPU_NAME("kvm"), =20 - .parent =3D TYPE_ACCEL_CPU, + .parent =3D TYPE_KVM_ACCEL_CPU, .class_init =3D kvm_cpu_accel_class_init, .abstract =3D true, }; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493094; cv=none; d=zohomail.com; s=zohoarc; b=ipfL+SsMPg0I4StBk9Zn+wWgS79md4lO54Q+Um3akqDLCSxs4zqGysG6XBy8qpgBSNPWzMWyTcyYYbhP/j3SPIR9HNP47utl+B8AJxcLntapRKXzvbS9/xYellPnjcKtwRo6I3G+QJOUovZX08m8x8KW8hByRP8TRyG+6BZr9+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493094; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W1YwD7IMkeAO6OcLReHpxRqQRfDPA/W1esQDN17JAFU=; b=XQuaJDH7whiL/BCelhf0CYZIZQMK4LiLTbwNPza8iG/BXj2ZgSy9MJoiCS0K3G8codsfWHGfL3BuUkQYlJywy5QLQkxRYY+cJwkARWrtX496BBNt9CEB/d4lgPDfH49bAYiM35CiHGUVR85oA7KGTN6s+tsVxvMQGl4OZYErlLU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493094020642.8817966734205; Tue, 20 Oct 2026 03:44:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Jv-0004ML-9V; Tue, 20 Oct 2026 06:43:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jd-0004BN-Vy for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:34 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JW-0004KK-3G for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:33 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-48e10a70540so1300435f8f.1 for ; Tue, 20 Oct 2026 03:43:25 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1f2c9e9c3sm56999645e9.3.2026.10.20.03.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:21 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B08A65FA43; Tue, 20 Oct 2026 11:43:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493004; x=1793097804; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=W1YwD7IMkeAO6OcLReHpxRqQRfDPA/W1esQDN17JAFU=; b=WLk8/GhnBAieYOmX5YzfTP0mUrMUmVZAg2B+KvR39R/M5uB5DJ+7uF26XOABPfeqeP vRk7l4jSFagwJqIL7hNe7aj5datw3BXx+bb/tQQNL/eI5Gvn+8/NfxEazDUlJCOIHg1P YCWgJyAcISEIgOoNXzFEsTRALa73sK35O5uhgG/LBayB+71L9gnZfJ+A/KVzVk5Gj6GT QsOLGr9OAfBk9IgZb2BL9nnfdE1StgvhNqPjI+llNilprLpnL1Nj2LW8Glu6Bj8oG9qV ZXNEDqDj99KMhX98okb8zcPyBhyh9PO85uHDHwHV7oOxh/mFzfRa6bQkgav02e1dI30o FNGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493004; x=1793097804; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=W1YwD7IMkeAO6OcLReHpxRqQRfDPA/W1esQDN17JAFU=; b=K6vQbdvlAaV01HdiL8vYG/1dLO6q1bhjxvauAWRLNmmLqbTZnPKa6Zb9VT+fz4RnXN 20XqapxXsdQeARxWhngKH4wKqwbazsij4O2mG3nI4Ekp3flG5JQBUlz58mcYHVd6ckKf zufv8Cw8uVhM5UH3auhIsH0uk4ZBs2brn3xJW2QI/FsoSJ7oOK3W82U8OJ4CVIX06KjC i6emp5wLtQkFV+hOKECRuC0GCRDYW92mTLUz8Byg+JFRKVmI8eXL+U1XpWfEHtCTxby0 0GwDQCvkJc49vtBrUsmeodY3GInhPgbVgW6DUO01PPfS+flMNSTpwv0MzrhV22JdxESa lRyg== X-Gm-Message-State: AFq9FYKnAzx2FSEHZPTT2hEvhsS1qY5O/Q573Z6Sr9qJA71zH037vLUE Bp/V+5NBTetHxiUigXXGJzi8Z1HqS2IT46m/J7Cv6ccnJREvmPxo1YDiQonMoZcwibo= X-Gm-Gg: AYBFou2OL5oQkQti9ojQwVZ70895MKyUUPjbXV6dZ0lAET3BY1NP0lExu53oXg084tN a94+YCKgb8xNkY8wy2lr3+Bhkoto8Pg746kdKbGsXwfQ7XR3Da4DcPBwXvTg1I9SH2z89wty73g YPthm1P26pQqb3/e0IA96sEM1/GLxp7WJYHfFrR4RS+UIbiT/nEs/msZSFIUa39PjpSQln9BW/L HIB0SjDnrKLV2lVjb5wd/4LfnT0E9BPbjuPZUg1SOyLP7pWE0QY32dpuJVM7sLujkbkqWMDW6N9 itc2tpz8xlAvftJEp+qbveQFCpE3EiuGsLFlIJfQijpDIJUGnJhClZL4fG7KcKqdW1o2PdqgeOc +FexvcYFCzcw6DZTJrl+LOmgzt/8hnQTejmXDH2xESVyEG8v43XU97g3sFE+/MDS+6K/LYt8WWg OsPFiR4DfflT1M1vfQu6FK691hcBlSANLMexgogHm4I9Rb5YbAoxVwAul1sLVhZJq/69IMww== X-Received: by 2002:a05:600c:8b6f:b0:4a1:d307:d578 with SMTP id 5b1f17b1804b1-4a1d75e6d1amr197176025e9.11.1792493004251; Tue, 20 Oct 2026 03:43:24 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 04/23] target/riscv: wire up empty KVMAccelCPUClass Date: Tue, 20 Oct 2026 11:42:58 +0100 Message-ID: <20261020104320.3686723-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493095573158500 We will fill in the functions in future commits. Signed-off-by: Alex Benn=C3=A9e --- target/riscv/kvm/kvm-cpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 45ad5e1525a..b3fa0548c8a 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -33,6 +33,7 @@ #include "cpu.h" #include "trace.h" #include "accel/accel-cpu-target.h" +#include "accel/kvm/cpu-ops.h" #include "hw/pci/pci.h" #include "exec/memattrs.h" #include "system/address-spaces.h" @@ -2195,18 +2196,23 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu,= Error **errp) kvm_riscv_destroy_scratch_vcpu(&kvmcpu); } =20 +static const KVMCPUOps riscv_kvm_cpu_ops =3D { +}; + static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) { AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(oc); =20 acc->cpu_instance_init =3D kvm_cpu_instance_init; acc->cpu_target_realize =3D kvm_cpu_realize; + kacc->cpu_ops =3D &riscv_kvm_cpu_ops; } =20 static const TypeInfo kvm_cpu_accel_type_info =3D { .name =3D ACCEL_CPU_NAME("kvm"), =20 - .parent =3D TYPE_ACCEL_CPU, + .parent =3D TYPE_KVM_ACCEL_CPU, .class_init =3D kvm_cpu_accel_class_init, .abstract =3D true, }; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493097; cv=none; d=zohomail.com; s=zohoarc; b=ffwzCznaiUQLPBpqJDjtzMPy5xpL4MzdDJk3LEZFUyvOFRCO2mQmIl0vPcfGkSJS+c/BuO3DjWWH3SNUbNsZjcxqSBI5KeC3xV5N536MMovOEI6RyAFifC1doXMwNDSAnwDQqIozjljkQVF+1tWuD4rH/vzNkh0uv9uJic320RM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493097; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xpvK8hxiiby7P5GAABphDAJ86oAgF7lyRnWJr7JT/sM=; b=SDcJmT0VirK6Jscoe2xHBqeUprpy7ZHUyUSRy1guQ4vEqcVkxblEx+tQv6S8OLhO3yoBKQZ3CjsudcvlFT33FEPC7MYxoTV0CB4onwvqkjs5OOkCKe+xLOkd7pqACG3wwaqHN9n/YpUPlYIQDLHvQHChWcpIQcILRhS6vu3NTWc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179249309746579.52551182849368; Tue, 20 Oct 2026 03:44:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Jm-0004HZ-L3; Tue, 20 Oct 2026 06:43:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jf-0004DC-CC for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:35 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JW-0004Ko-MS for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:35 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-48bbb06e746so1592875f8f.3 for ; Tue, 20 Oct 2026 03:43:26 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d818237sm5338778f8f.27.2026.10.20.03.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CBA755FA65; Tue, 20 Oct 2026 11:43:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493005; x=1793097805; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=xpvK8hxiiby7P5GAABphDAJ86oAgF7lyRnWJr7JT/sM=; b=pH4snO+n+tK8npEh5Hcs3JcM0q1mTOJ9zdmziUOKQ3QBteryHWf/cF8v5QFC3V2pzf 71k8E7OOqxh7zbAuxXK+RVTTFUH7z5MnevEmwSbsofHTfL91V0Hixo8cniQHClyZB5hF Tk4NBcCah652FlMstMgCsurf8DuY7V5XtvUzpT8XZ4uDVQwqVbfyH7t5AITo7yHPyGSZ srxrhp3u44+N21zHBy2Hy4WkOI2hEAof70OQ7aBGtsdqUnU8AitYOvjZhXr5iyI8S7L0 ykwIRX0ucApkb5gyy/cKnczdvJW+2yn4Wom4joTGwGdEq3OR6Dyr3jbEJqYUDM6bAThx h9nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493005; x=1793097805; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xpvK8hxiiby7P5GAABphDAJ86oAgF7lyRnWJr7JT/sM=; b=HQGQT0jNuovdODKU7MQG6RJYS/psJQAFiEvfMi+iIiiV2LLUpxQXuJFE5Q2J4qJYZf 5WTighHtFWKsUwjmobgJejtzcM3pKRWFUALIcVX/ooCsI3nFEo2PVtQP18B3L9DnhRcE XgqNA0YLVGwEbylGMH+Ywh/8KHwYta7T87dHYrCZtvGDWjptjXEOQylOp3XPzGcBi79J A3hkssIqkdQmImfXBP7bOnUDka0e6yRFyave1SNT4/Fo2vQuqMeahOZb9UgkHOg8TSS8 ZO2tiqYu3/DHhqg05pKQex+YKs11ajDg8xAQkncW9FDHeSnrZ5Dlkcg0Tx8jliwOTWoq Y59w== X-Gm-Message-State: AFq9FYJ/UPjftcQeX9QmjPUbxzolB0Yctpxs3k8hHEFXnQu5rymBdnho JvTo37yDk+LFAuyCKwtfQ9WeQPvKNZfp32B0hDxBJwHn50YB+9t/m/x/0dcIrqtZNU0= X-Gm-Gg: AYBFou0U+R+4VhrgGeIK5rb+Y2uV8gG++dwwmcu7LED119gDFsly+MESKXNQCUqa/vd 4UBHo/mLUXOZedD90pTcbFRDGCsHZ3QNu+wBp2PFGHAig+wS0D0wCa37Wjc6PhjjtClhEyiNbJd cazeJwD44U3KbMULRExGz110ByPN+cuALOC/jeA1TajWKUMLC5mi907i7aydb/6dd433SnAiwUl p8mO7CcY25qsiA2LrRUyk0OcGyS9WlmNpf6CL/JgLtf/tWlrCzPba8Lw64E5bamRQ/6Bn/rLxxU 7o0PyE2NMFrjUplG+O+g3VngEj54wbRuCHBYJ+1qo/OsPM9Zybw0M6lwQSsLcBuyQqf9BT9+wjm 0bx0QX7fJkNzRAwA5hBZuk4eAoepZEzbRWZigf+9wQihooGfk4hVAi/yy1zvePMcBi6ymAKTM4a QK3uGsEdVwRVRXd6T8Zh9KMwgGsBS1le2JUyUgkaS8WVrW9amPcJ9zHRw5LBkalz0T35BRx+s= X-Received: by 2002:a05:6000:2388:b0:48d:dec7:974c with SMTP id ffacd0b85a97d-48e07985764mr20442510f8f.7.1792493005061; Tue, 20 Oct 2026 03:43:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 05/23] target/arm: wire up empty KVMAccelCPUClass Date: Tue, 20 Oct 2026 11:42:59 +0100 Message-ID: <20261020104320.3686723-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493099353158500 We will fill in the functions in future commits. Signed-off-by: Alex Benn=C3=A9e --- target/arm/kvm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 3d905f8565d..7a3c957c3a5 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -42,6 +42,8 @@ #include "hw/acpi/ghes.h" #include "target/arm/gtimer.h" #include "migration/blocker.h" +#include "accel/accel-cpu-target.h" +#include "accel/kvm/cpu-ops.h" =20 const KVMCapabilityInfo kvm_arch_required_capabilities[] =3D { KVM_CAP_INFO(DEVICE_CTRL), @@ -2662,3 +2664,26 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCap= ability *v3) =20 kvm_arm_destroy_scratch_host_vcpu(fdarray); } + +static const KVMCPUOps arm_kvm_cpu_ops =3D { +}; + +static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) +{ + KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(oc); + + kacc->cpu_ops =3D &arm_kvm_cpu_ops; +} + +static const TypeInfo kvm_cpu_accel_type_info =3D { + .name =3D ACCEL_CPU_NAME("kvm"), + .parent =3D TYPE_KVM_ACCEL_CPU, + .class_init =3D kvm_cpu_accel_class_init, + .abstract =3D true, +}; + +static void kvm_cpu_accel_register_types(void) +{ + type_register_static(&kvm_cpu_accel_type_info); +} +type_init(kvm_cpu_accel_register_types); --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493122; cv=none; d=zohomail.com; s=zohoarc; b=NZATps07qFpx0c9Hw740Lvxph13RcA9FkhzDygN1V3JTbPpmcGNBGGpH6Q/moHxx5bytz7fQ3Fo46SP2pPtQ0afDIAB9XadfgRLk0Didn1WE/Pc5ukzeQRwrGjfsz89vaW0JgZnQsrbo+WgZ1VYrg92acqtgVOLbq87nLe/jwYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493122; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=clY0Exi/Fk2cbqeICRgpqzcE6k7M0cr1lXEHsMtE1Ok=; b=dJo19fP1ytUejWD4D1C6Z7rqz5nyH9q1YG0UxgpbtWNzQ+7uDG8zFiXuK7KhwfaYLh785xqFZZ4o9wFoEBAjpHnu9msvHrw0e6HZbbmpkEe42DFQ0gTGNq3yb3DAtVml8/c9b0c6YFIGDWq8a5Io0CZ6EHWHfjcmvB2ohI1pcwQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493121979704.1245205817287; Tue, 20 Oct 2026 03:45:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7K2-0004Xo-RV; Tue, 20 Oct 2026 06:43:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jh-0004Eu-Bu for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:38 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JX-0004L7-4D for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:36 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4a1698ea378so23153905e9.2 for ; Tue, 20 Oct 2026 03:43:26 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1f2cc809csm64722745e9.8.2026.10.20.03.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id EA3605FAB3; Tue, 20 Oct 2026 11:43:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493005; x=1793097805; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=clY0Exi/Fk2cbqeICRgpqzcE6k7M0cr1lXEHsMtE1Ok=; b=qAfBWoy9q5DhzDzQoUugTRkane1EVfx/uUaOa7JoDNkC7u5sdBMcZ3Iy743WDem/va 81UwaMoT7DfnJobJWl9pKdi27CTOhgLTL+5Gx8L3ScIQiF5VkOQ8YjEvd2qcUjTa9ehn vH6KSFNFLwPFfzakuzg3vX+JTUsH9iu1DpgKz4vX/5GfLo42Q17Y0ZPCaMQZ8FOtVvqg AUR/hyAjQ1PJuacvU+dOyNaD0JHVQw9eX+wPgGJW6SzPEkoiJax7w+5bhRcQ6mD6OWsS hVNdDbl9bD3rrM+RUtXVS/b3kdbP89saygXbcBz1fHvjaLkzVQd5GiAGlNq2A5Ukmfge 7/Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493005; x=1793097805; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=clY0Exi/Fk2cbqeICRgpqzcE6k7M0cr1lXEHsMtE1Ok=; b=KIQnKYlq8tgAznEXXPtvDsuRI48fxx3S8+lWju7eb+6hQpmvDUm4UU65Wz0XAlnP2X oJQy9gGg04JQ+uekFDzcDs51kY3nfqwCXU9jnbRX+5z215mkieJD0BTY8H5nNDWs8d/P /94UgFqePIPeVtGSDhJKnZQimx7pqjwTtOR6l3kJ6LvQA0+2kbhcK/Gph7fo2YkNRi45 GD5E5iIdRAG2aVNI8zauk5BYyzLCUsVkNR4R5PMbQgDwaZ1tqH5LFlSRM5719Ut5rgYr 2hjHV/zG1ipW5xB481qJ9A0aDKAEQD/VCvfjDy1HQ1KkE3m+DMrunfwk711w7/tJh17s KhwA== X-Gm-Message-State: AFq9FYK326HD7MIM6vWpCWwNkfWpnKJ1S0O8KpZyJZRzaPKNTSJ4OfIz Z9Njs/i0FoioXb9/nzCOWIk/5j2m/4S6WRUYZHffGAZ3OisjamGsygnn1LGTUtBkRXg= X-Gm-Gg: AYBFou1x4hIJJLwuz9JLzlaltRQy31m331Ef3J6hhhDwkqS9rwY9KNvQjTOwUCM7+/o jtdW9T4qCLkhbpYg0+pFdN+u2IURmbC4WX1lv+ZFG+YDDHzKk0o2SPTKT4Z0sgBIkMaJV7xAYty t0sO4fi47eXaragd62XpxY/xsEizAQFKHTv7ut8Py5CF0uc07W0pJWUVT7PhEoj0o12ZN1Bl0Ft eci958uTyYsGMF/EU34oE94tKBDO10LIqMHh60+UkQP81G53bcQyJPLuXwrSjHs+YbWO7cUJA6O IIk4ceE92dSOJaUvEyIj+qiUhdWCG380M7b23GgmNomosG4di6RtYSDMv+1uEKV+sugyg5rloIB fWX7NMr/q99vtzkvqbrgskxIaLM0OHiUQAwQDqC9cpN8vEJEXZuQsO4sV40bjEnQAPWEaw4IZu+ pWRkvANs63c2NSSqnH/8JC9TtlseP754hseKf/LAz+COLd4U0le1Wt3sv6ZP8JQERJLktaiQ== X-Received: by 2002:a05:600c:3513:b0:4a1:a39b:e75b with SMTP id 5b1f17b1804b1-4a1d7607560mr224796055e9.21.1792493005376; Tue, 20 Oct 2026 03:43:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 06/23] target/s390x: wire up empty KVMAccelCPUClass Date: Tue, 20 Oct 2026 11:43:00 +0100 Message-ID: <20261020104320.3686723-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493123836158500 We will fill in the functions in future commits. Signed-off-by: Alex Benn=C3=A9e --- target/s390x/kvm/kvm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index dc67e848864..69e49b7d151 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -52,6 +52,8 @@ #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/s390-hypercall.h" #include "target/s390x/kvm/pv.h" +#include "accel/accel-cpu-target.h" +#include "accel/kvm/cpu-ops.h" #include CONFIG_DEVICES =20 #define kvm_vm_check_mem_attr(s, attr) \ @@ -2655,3 +2657,26 @@ int kvm_s390_topology_set_mtcr(uint64_t attr) void kvm_arch_accel_class_init(ObjectClass *oc) { } + +static const KVMCPUOps s390x_kvm_cpu_ops =3D { +}; + +static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) +{ + KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(oc); + + kacc->cpu_ops =3D &s390x_kvm_cpu_ops; +} + +static const TypeInfo kvm_cpu_accel_type_info =3D { + .name =3D ACCEL_CPU_NAME("kvm"), + .parent =3D TYPE_KVM_ACCEL_CPU, + .class_init =3D kvm_cpu_accel_class_init, + .abstract =3D true, +}; + +static void kvm_cpu_accel_register_types(void) +{ + type_register_static(&kvm_cpu_accel_type_info); +} +type_init(kvm_cpu_accel_register_types); --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493095; cv=none; d=zohomail.com; s=zohoarc; b=J3LCaMQKbXr/C0BsHXrOUn8W3ypmElfEVPY1/ux0SrJ4ZDrH7PvnDj4c0/5mNOCVqc6JQpPEpnFPARNW4HG+ZF0Pa2CrMn51qndCvvrzPbOig4P1gDqzyQErYsr3Q9eEBA3qpJY9F/ITP0O2bs50S4Hc+6VHyorZprguBNoqzJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493095; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EmgF4PQPx9bMlndd3x44tzG0fL4M//RuzZARimvwNlE=; b=TU2Zmrlq2HI2OQhcmQxzvN0JnaeAqz0nBR7JQZuJtytCoqpx0OhQtVEHz+rpdy/DBjpM50P4yJC3u6OvGYYhNTSBUwpbaiCbiAmf7qL21v+q/MfO512/fSsj+uxFWXVMOWOSP1dU7pFDlXZu0MBTn12s/L8QD1T3J1WFqcCYBtM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493095746977.4167181896136; Tue, 20 Oct 2026 03:44:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7KH-0004pR-Dk; Tue, 20 Oct 2026 06:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jo-0004Jh-OY for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:46 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JZ-0004NP-GP for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:44 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso26647525e9.3 for ; Tue, 20 Oct 2026 03:43:28 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1f863e709sm9184055e9.3.2026.10.20.03.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 14B1A5FACD; Tue, 20 Oct 2026 11:43:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493008; x=1793097808; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=EmgF4PQPx9bMlndd3x44tzG0fL4M//RuzZARimvwNlE=; b=TvvgZIbMkbY3WFVYt20NT1IYS1J7042qre5IpobbaZqwpqLODE3xG7OKLqGk2ojc07 Okc9LFR0hg3uN1r4ydMslswsFdBuO5KotIwm5gErdEhZPBIht8g5Bv1Ec6I13dIRRDCR 5ZgPoSClLjLgsRhLdM6LMVfm+wg0otdtWixQbR/8A2pUmzrAmUJWArwajfzI3woOc1OH 3G3Z7BYK1mejqu5QJDKNlZE+fXFQsrEh318pfslGcb2YW1soaMvPtkxpi44ifFOPt+ue RE0PL1IUHXANi1TkXdZ/wEEaUU3GHWmgHX/lAxUodysOCU6w8Yc07cUFXgl+c2CZJA+G rSsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493008; x=1793097808; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EmgF4PQPx9bMlndd3x44tzG0fL4M//RuzZARimvwNlE=; b=Yiau4Ma1TdiXb2wDjfk/VYueLCKnaLgWE35qDYy8COjFoi72s2h34BGi2BZcdpMPhs 0k+JcTAf7pi3AZP+V5EgnnyoAodi5XTTWyZpw44Qj331NTyuRUoSZ5keGWz8lK+WQeFV tos8wKn4K6r4uHWYxAJJ+J6bJvKL41uCmxX2BWXlnwotZ2Z02qf/SGgs5hFtSGzIo5kM rr7bkCWrmC+8vbXfrn5xNRSUEUn4lSuDSNju+tU8DhuRA4zXir+OWVY0xQdXKLLI6aBo F1zKVyyFebMQ4sXkgiQbnboRj9JZhYaPbbJJvk8drB3Nez9CxpVwNeEuSWVxpTq5uPEP HmYw== X-Gm-Message-State: AFq9FYJHc09/OH8mceO1mIxsYEMMuLiy5hfJYV1BkyiPZwUFvobR/mOH HBH3pTtOm9dpdCBNDTuEX60+AzUb56J8RxzXjcENq7aOnRBZsAdvaU6LTluFK/fl9/Y= X-Gm-Gg: AYBFou21mND2KxqPsT7JqygDsvqcYpw0GAXzxF6ekWx160e9GqSb9gHXQ1jhTMW4rJA b20J2oKyapvhxSOtwzs7W19lnNArKGAS2GAAmXlhnji1PE20Ed/Y+yRRHkadUNzwQm0+1gO6IHX FjdAXJx4wI+026IUefpwNd4vackRDQL5p5rJRVKnhCfoMk2DLZKMf5KTkf0xoNqP+/EB05iocdC K6TPo3c44HcdzcZkmaqRfW1wCOGmqR4HKlRYfePghd2P4sTw8IZg6pqaPPfI7fwVyiT84Ah/shk H+0p6CM/n6cie9f6eeZveaKIV1ZzbQwhwjUw7Psz1vk81eNO0g+jK/0Lag8hUr95a4xkLN2pvTa IeHGRy4WGc4C2yLil14hPD2LTRpeLgStj6XeTBAWp+9t8EQtmvtI5bMdjcaNsIsC3g9qAjbSVry lsAcxpEDSKlyuKzGO21U4ffk1EIAV+lfBcGbLgn69oMCLTCfCqIfxqVjnM+thgEhbQrs7W/Q== X-Received: by 2002:a05:600d:4187:b0:4a1:f99e:f22d with SMTP id 5b1f17b1804b1-4a1f99ef467mr11426185e9.6.1792493007433; Tue, 20 Oct 2026 03:43:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 07/23] target/loongarch: wire up empty KVMAccelCPUClass Date: Tue, 20 Oct 2026 11:43:01 +0100 Message-ID: <20261020104320.3686723-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493097070158500 We will fill in the functions in future commits. Signed-off-by: Alex Benn=C3=A9e --- target/loongarch/kvm/kvm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 941142305e4..4bc08f195ed 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -29,6 +29,8 @@ #include "cpu-csr.h" #include "kvm_loongarch.h" #include "trace.h" +#include "accel/accel-cpu-target.h" +#include "accel/kvm/cpu-ops.h" =20 static bool cap_has_mp_state; static unsigned int brk_insn; @@ -1648,3 +1650,26 @@ int kvm_loongarch_set_interrupt(LoongArchCPU *cpu, i= nt irq, int level) void kvm_arch_accel_class_init(ObjectClass *oc) { } + +static const KVMCPUOps loongarch_kvm_cpu_ops =3D { +}; + +static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) +{ + KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(oc); + + kacc->cpu_ops =3D &loongarch_kvm_cpu_ops; +} + +static const TypeInfo kvm_cpu_accel_type_info =3D { + .name =3D ACCEL_CPU_NAME("kvm"), + .parent =3D TYPE_KVM_ACCEL_CPU, + .class_init =3D kvm_cpu_accel_class_init, + .abstract =3D true, +}; + +static void kvm_cpu_accel_register_types(void) +{ + type_register_static(&kvm_cpu_accel_type_info); +} +type_init(kvm_cpu_accel_register_types); --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493449; cv=none; d=zohomail.com; s=zohoarc; b=KGkBvQmg1Oxz49Sy8h3p3U0fTnBThQ4X/0jFJPibPDg5uMNU9gI2yQSzQEbQ30EOr/3o5u8k6LB9f8MLWA01EVqwnUTiofv5I7XkCEclsfOt1WbYct2g/6vnMrovumqcpsdKnvFQ1jAM0N/CF+OhBhwCAZIQaFh5lX7Deu6urw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493449; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pr/rnTmIAiW1szyi9rDm/oGmteEimjJL3z+DQYflDO4=; b=ZKHT/+p5EVE/4ICX9+o9zXqn34Krc70iyWlBUcnm97R3eTYAdGqdElCO6cTutWoc4OGxO0ZTBX0vZsjg6a9TZxC43/nLBJqGYoD0NqwsNzDlZGF/EX1esvOKzSg94jcoo71Wlyvf1EmBfb/kRlv2VIfUPxHYxUxYab+cLlbjmTY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493449019102.71174500379732; Tue, 20 Oct 2026 03:50:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7KC-0004lG-Od; Tue, 20 Oct 2026 06:44:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jm-0004Ho-9L for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:43 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JY-0004MZ-L3 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:42 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4a1cef0439aso33845715e9.0 for ; Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1f2d1e8ebsm57351065e9.3.2026.10.20.03.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4DE6B5FB4A; Tue, 20 Oct 2026 11:43:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493007; x=1793097807; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Pr/rnTmIAiW1szyi9rDm/oGmteEimjJL3z+DQYflDO4=; b=myGnMmngIZSiPfrNJjarnw6dnYxESdoBOH6OmjwuCw6BaiRyTf1/WSTcef+NvCL4d/ CiM1mJFF/03ExWqpyOxy5tmvFtfnRLLwEgRFhCxDoqi4Qb7LQZFx7FsxWBGgos+u6/dJ AAKYtp8d13Hfs1VtgEv36KwVsLsxVfvFvoolczFmj90fpZwxs+mmtsuGCLjIM8J+jTgO UoKIarblad2G9jYWMKlsA7nlLs6U7EWkv+6YYO/OZ3fH3DW7i+k2AsIThuhjGRZlJYQ5 lCdXsa9G7fnWF/YVLBdwuvDSRHAx4xzbu+oMU3HcE5lXzitGHVwg9SoUQ20+wqCn/P7J c/Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493007; x=1793097807; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Pr/rnTmIAiW1szyi9rDm/oGmteEimjJL3z+DQYflDO4=; b=Dice9NYjef0zyhWpid3Jpw10BjbrA88PsfkHkNWS02v/KF3uomMrhF/RMgzOin9H2/ EdxkjXLxRRVlGnE/vd0g63TalmhDFYemLs3VsRGJPIm6eeeGqfWQrgPXbyKNAqnKTrlj Rjwjt5WRjm0X8rw1nPTneAbPkaohqC6clDEk0l2NEkguhK8+5ej3pxvgpx2NnIlRFBiF /e2Qcqsvqw1GoGGmaqZU5UWo3Oy666CdWQqhbMDdz+QQwu7dah4Nl5ZguiDlIzcGIMn5 PWM4J0w3Mn64vE6mQW6k6BZTDCz7qjqapkT2L50tzj6jZQROnDxdup4yzo015QQYYUQV 6Gpw== X-Gm-Message-State: AFq9FYJY6WRxh5sfDGEcBFeVoS3RRe8QbgJW5SR2ZWor/QfEiOhmtYeQ s52CVjZ5KSoUH9981Iz5fSOpS2NZmaHhASSCitVOl2+a8u4HH4held6w6lLBWRRpvt4= X-Gm-Gg: AYBFou30wcAaGlBadPLkGS9P+2MxiOGjVKF+LhL/2WHmd3XqlMvS+9rN/jotxPWfobq t8e77L0qQCdDzMQXAY3FGXX3QgRmJ4+QTHUFA5Sa8Wjw4ohoCmTy33KaDpc/SjGYsxVsja4QmS8 0F10izbecpzkoxZm1FpnFZ/xwMapDPmMZ6XMbi72qRCO4cEN54sZGmqmIKi0IkfeGphR3/ij5Ll hkUnrtSFNSMOPhBMrIlg4j0b0IeWFv0bZ8iTAlEdi/t+p4LnX/0NfAtu/owD4ZwTQ0tIwA+RW/2 OzdDAPJY5vZDoMaBCZaCyxyBFkglmdnhEmpi3xoDoppkOdJ7K/VGXL6HivwbIQws/9wizA/MGH5 Y+d5ClR5lg4SB2jGl/47GhQuFr4ImBR+FdnNT+lF1SKLYgdEUiRq+/Vhq/isJK18wb71tx7APJV v5paMGtne5Tqz47So1ImRYL6P8ym9YwCDFf4Jnm/B1ppJ4xK5z88Wh6oiRE+XicNaR4vVsE5c= X-Received: by 2002:a05:600c:8b43:b0:4a1:83f0:7c8a with SMTP id 5b1f17b1804b1-4a1d75ad072mr215240945e9.1.1792493006718; Tue, 20 Oct 2026 03:43:26 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 08/23] accel/kvm: port kvm_arch_pre_run to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:02 +0100 Message-ID: <20261020104320.3686723-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493449942158500 Port our first function. As a number of arches don't do anything at this point they become nops and the call becomes optional. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 11 +++++++++++ include/system/kvm.h | 1 - target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 7 ++++++- accel/tcg/cpu-exec.c | 2 +- target/arm/kvm.c | 3 ++- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/kvm/kvm.c | 4 ---- target/ppc/kvm.c | 4 ---- target/riscv/kvm/kvm-cpu.c | 4 ---- target/s390x/kvm/kvm.c | 4 ---- 12 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index 662d0c553c7..2c04fa5adf5 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -13,10 +13,19 @@ #include "hw/core/cpu.h" #include "accel/accel-cpu-target.h" =20 +struct kvm_run; + /** * struct KVMCPUOps - Target-specific per-vCPU operations for KVM + * + * @pre_run: Optional callback executed immediately prior to entering the + * KVM_RUN ioctl in the vCPU thread loop. Used by architectures + * that need to inject pending events (e.g. x86 NMI/SMI) or veri= fy + * injected exceptions (e.g. ARM external data aborts). + * May be NULL if the target does not require pre-run handling. */ typedef struct KVMCPUOps { + void (*pre_run)(CPUState *cpu, struct kvm_run *run); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" @@ -25,6 +34,8 @@ typedef struct KVMCPUOps { * struct KVMAccelCPUClass - KVM-specific accelerator CPU class * * @parent_class: The parent #AccelCPUClass + * @cpu_ops: Target-specific KVM operations table. Must be non-NULL when + * KVM acceleration is initialized for the target CPU. */ typedef struct KVMAccelCPUClass { AccelCPUClass parent_class; diff --git a/include/system/kvm.h b/include/system/kvm.h index d29624034cb..e9d7b86ea4a 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -333,7 +333,6 @@ extern const KVMCapabilityInfo kvm_arch_required_capabi= lities[]; =20 void kvm_arch_accel_class_init(ObjectClass *oc); =20 -void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run); MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run); =20 int kvm_arch_handle_exit(CPUState *cpu, struct kvm_run *run); diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 2b653442f4d..218ae8f09ce 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -33,6 +33,7 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp= ); =20 int kvm_get_vm_type(MachineState *ms); void kvm_arch_reset_vcpu(X86CPU *cs); +void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index db8fba53f33..4dca5467f4a 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -55,6 +55,8 @@ =20 #include "hw/core/boards.h" #include "system/stats.h" +#include "accel/accel-cpu-target.h" +#include "accel/kvm/cpu-ops.h" =20 /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD @@ -3451,6 +3453,7 @@ out_unref: =20 int kvm_cpu_exec(CPUState *cpu) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); struct kvm_run *run =3D cpu->kvm_run; int ret, run_ret; =20 @@ -3474,7 +3477,9 @@ int kvm_cpu_exec(CPUState *cpu) } } =20 - kvm_arch_pre_run(cpu, run); + if (ops->pre_run) { + ops->pre_run(cpu, run); + } /* Corresponding store-release is in cpu_exit. */ if (qatomic_load_acquire(&cpu->exit_request)) { trace_kvm_interrupt_exit_request(); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 5b4bca5084f..4d2a0aefe89 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -758,7 +758,7 @@ void tcg_kick_vcpu_thread(CPUState *cpu) * Ensure cpu_exec will see the reason why the exit request was set. * FIXME: this is not always needed. Other accelerators instead * read interrupt_request and set exit_request on demand from the - * CPU thread; see kvm_arch_pre_run() for example. + * CPU thread; see KVMCPUOps::pre_run for example. */ qatomic_store_release(&cpu->exit_request, true); =20 diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 7a3c957c3a5..4475fd1a9d9 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1377,7 +1377,7 @@ static bool kvm_arm_verify_ext_dabt_pending(ARMCPU *c= pu) return false; } =20 -void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) +static void arm_kvm_pre_run(CPUState *cs, struct kvm_run *run) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -2666,6 +2666,7 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapa= bility *v3) } =20 static const KVMCPUOps arm_kvm_cpu_ops =3D { + .pre_run =3D arm_kvm_pre_run, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 9de107a18d5..eab5ab46d45 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -235,6 +235,7 @@ static void kvm_cpu_instance_init(CPUState *cs) } =20 static const KVMCPUOps x86_kvm_cpu_ops =3D { + .pre_run =3D x86_kvm_pre_run, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index da922f72d71..e9bcda70dac 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5898,7 +5898,7 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp) return ret; } =20 -void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run) +void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 4bc08f195ed..b8fb2094062 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1517,10 +1517,6 @@ int kvm_arch_irqchip_create(KVMState *s) return kvm_check_extension(s, KVM_CAP_DEVICE_CTRL); } =20 -void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) -{ -} - MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) { return MEMTXATTRS_UNSPECIFIED; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 8e9328beeb9..17b16e33881 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1336,10 +1336,6 @@ int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, i= nt level) return 0; } =20 -void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) -{ -} - MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) { return MEMTXATTRS_UNSPECIFIED; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index b3fa0548c8a..8575e673811 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1640,10 +1640,6 @@ int kvm_arch_process_async_events(CPUState *cs) return 0; } =20 -void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) -{ -} - MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) { return MEMTXATTRS_UNSPECIFIED; diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 69e49b7d151..827816e5b98 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -984,10 +984,6 @@ void kvm_arch_update_guest_debug(CPUState *cpu, struct= kvm_guest_debug *dbg) } } =20 -void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run) -{ -} - MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) { return MEMTXATTRS_UNSPECIFIED; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493094; cv=none; d=zohomail.com; s=zohoarc; b=fvpOqUxc7J1C/T5g1qq15m3H74t434j6lQBnSB9V94BT2Jx/Y+V5CaCDbxpAfVyrWTZdiprB88cksazwQAdPPjzslGDHAcsH2emgm2MJinS/RrsKgBivu9/slAEResjoqEMzU2koNeawDBS6YSbmCYLGLEwsZYN9VxFqMG5Q6Qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493094; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XaCIspnOiGUcI2BoHO8g5A8hP2lh454sdkCiT2j/ODo=; b=esclZF/3J8tGzHMqszfNjXap3RHoQWkDYktqsvuKQGYfJnplaVT9Yupf2rqUQWoUZN9XKxVOumd+LY2zkuHPyIgoWI4ijZ19jC24mzFQRfEL6Hi2DFKqNWGO38G1V86TWZ3URSsJAJuIoYq3vHX8vr/1IsCxAAnzN5XgBj9Y+QQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179249309408975.47659522256379; Tue, 20 Oct 2026 03:44:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7K9-0004g9-3W; Tue, 20 Oct 2026 06:44:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jk-0004HF-IC for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:40 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JY-0004M8-7C for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:40 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-48b042c0728so917722f8f.1 for ; Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d820714sm5176611f8f.35.2026.10.20.03.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 871EE5FB54; Tue, 20 Oct 2026 11:43:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493006; x=1793097806; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=XaCIspnOiGUcI2BoHO8g5A8hP2lh454sdkCiT2j/ODo=; b=Sx2SUMg95c/MQuCE2y3KSOn1ySYbwFIHLcQAJP89Zs7MlH4aV6cycUrGnB3E8Wfwaj GHcVS2ltquv+xz8iLB6IcHs29nw6Aq9/6owebnMzEJSBuN+aLRWqgj6v6OAmXltuM/1s oYQSp2retdaHkSfqANykQftu58GJe1bcc+hVZ+6SjQYZ7RvbcTUQj4NSv1vOjZjoyka4 1WsHkx+lQi8IDe91wFaJ2DIp7LV/BxYjk7vIkoNMQ+h8rGOSnkKTIgepMK1Q/qt+FgSl F6RI3PRM7n5wLd44Vkzbg3P82KLU7E1uxwRiizTE0OnWb++hKac1WayzsWmXNRjpo2Zp ooxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493006; x=1793097806; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XaCIspnOiGUcI2BoHO8g5A8hP2lh454sdkCiT2j/ODo=; b=detaGck5l/2pgtI0LqJSthaSY0tQttBIsDDMI2SKYfCITO1EnymUc26fVilIImj3eG Ef8TxIu+WFrPABvxuDryyUcK0SA2WiSKUGF1ZwVGXn7GZqcchdt9s1GpQTw+gIiKY3f5 fPPjN7jaVMkCbI77ZIBgpsAra9po39KcfDjh84IsWfIoUZenoLPwNhGFoEltM+ZPvOyH FLoSGwX3uj4mzfsq+TM/NoEntokk/XaKbkeHDgc9SqH3BZKoFwKLkzPJDVfCT6xb11u6 VXm7d2qQsu7QgLkHs+cqMsQUvLwoLlnk2W0vg5m1/4zrwph///RMVuxMHchS3cyak5iV kn7w== X-Gm-Message-State: AFq9FYINBx4HEJIOZKEWR+dm9FBfQs/ReL0oCkp0p5xAmc8lABUbqDVl foBKV9zBJINbL7E0QkRSCA3VlXg+kQM7SIVuiJskDL0ndycWSx6NeQu+bYjBbiVUrsI= X-Gm-Gg: AYBFou2KDu2lA9Du55T6J2oXuL++jQek5Gxn7JFTeVgvAfqqQ7w3KaZVk9ou85zegfr /XQcCNjQM8ScZ6XNws7E/v/1kUEWpk9KArET8GbKqLgVbAWLlagjGkom9x3TElwQa3ap36xw2k8 LG1TNEiFulR9A9vG0tsQCI7H465owCBCJ+UV1EcsgvUnCuhYds67nMnyx/uibW3wpW/et4Zqmma xfUJL3sEbshyD2OTUZPgkl4WGhSKp8xrUSm+1XU5gsdIRmK+heEZx/1cMOa3e948MDnYjBmHZYM lszm4il4L7XfgIadpgEISSM7r56eDNGSf4oBpv+UtcEAkJIlRa1NGeLV4gHwo0PWlCxOy+GowCE KDblljoyXm18v5dLc8RGr+s8ljKWq+4+/UfqazZHeZipBdJDnhy3sBuvw9xjqbF5waeskNWg4iy i8jt0YHmnlZKklFCfVP7K0HHucgL5Rs2/8uD7RddIwBuYxuglDuM5gd94ryzFyBnZd43qLG0j8g NWsoLzs X-Received: by 2002:adf:e001:0:10b0:48d:f876:f370 with SMTP id ffacd0b85a97d-48e1bdf80a0mr4553512f8f.48.1792493006379; Tue, 20 Oct 2026 03:43:26 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 09/23] accel/kvm: port kvm_arch_post_run to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:03 +0100 Message-ID: <20261020104320.3686723-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493095675158500 Again not all arches do something for this so default to set MEMTXATTRS_UNSPECIFIED for any potential MMIO we might handle next. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 8 ++++++++ include/system/kvm.h | 2 -- target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 6 +++++- target/arm/kvm.c | 3 ++- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/kvm/kvm.c | 5 ----- target/ppc/kvm.c | 5 ----- target/riscv/kvm/kvm-cpu.c | 5 ----- target/s390x/kvm/kvm.c | 5 ----- 11 files changed, 18 insertions(+), 25 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index 2c04fa5adf5..e74081eb133 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -23,9 +23,17 @@ struct kvm_run; * that need to inject pending events (e.g. x86 NMI/SMI) or veri= fy * injected exceptions (e.g. ARM external data aborts). * May be NULL if the target does not require pre-run handling. + * @post_run: Optional callback executed immediately after the KVM_RUN ioc= tl + * returns in the vCPU thread loop. Used by architectures to + * inspect or process hardware registers/flags (e.g. x86 APIC/T= PR + * or ARM timer interrupt synchronization) and return the + * #MemTxAttrs to use for handling MMIO exits. + * May be NULL if the target does not require post-run handling, + * in which case MEMTXATTRS_UNSPECIFIED is assumed. */ typedef struct KVMCPUOps { void (*pre_run)(CPUState *cpu, struct kvm_run *run); + MemTxAttrs (*post_run)(CPUState *cpu, struct kvm_run *run); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" diff --git a/include/system/kvm.h b/include/system/kvm.h index e9d7b86ea4a..82785d37600 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -333,8 +333,6 @@ extern const KVMCapabilityInfo kvm_arch_required_capabi= lities[]; =20 void kvm_arch_accel_class_init(ObjectClass *oc); =20 -MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run); - int kvm_arch_handle_exit(CPUState *cpu, struct kvm_run *run); =20 int kvm_arch_process_async_events(CPUState *cpu); diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 218ae8f09ce..6fb1da6a40c 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -34,6 +34,7 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp= ); int kvm_get_vm_type(MachineState *ms); void kvm_arch_reset_vcpu(X86CPU *cs); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); +MemTxAttrs x86_kvm_post_run(CPUState *cpu, struct kvm_run *run); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 4dca5467f4a..41229774068 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3500,7 +3500,11 @@ int kvm_cpu_exec(CPUState *cpu) * as true, cpu->exit_request will always read as true. */ =20 - attrs =3D kvm_arch_post_run(cpu, run); + if (ops->post_run) { + attrs =3D ops->post_run(cpu, run); + } else { + attrs =3D MEMTXATTRS_UNSPECIFIED; + } =20 #ifdef KVM_HAVE_MCE_INJECTION if (unlikely(have_sigbus_pending)) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 4475fd1a9d9..d5f9b7c088c 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1404,7 +1404,7 @@ static void arm_kvm_pre_run(CPUState *cs, struct kvm_= run *run) } } =20 -MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) +static MemTxAttrs arm_kvm_post_run(CPUState *cs, struct kvm_run *run) { ARMCPU *cpu; uint32_t switched_level; @@ -2667,6 +2667,7 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapa= bility *v3) =20 static const KVMCPUOps arm_kvm_cpu_ops =3D { .pre_run =3D arm_kvm_pre_run, + .post_run =3D arm_kvm_post_run, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index eab5ab46d45..64af85cd113 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -236,6 +236,7 @@ static void kvm_cpu_instance_init(CPUState *cs) =20 static const KVMCPUOps x86_kvm_cpu_ops =3D { .pre_run =3D x86_kvm_pre_run, + .post_run =3D x86_kvm_post_run, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index e9bcda70dac..a1b91d502f0 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5995,7 +5995,7 @@ static void kvm_rate_limit_on_bus_lock(void) } } =20 -MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run) +MemTxAttrs x86_kvm_post_run(CPUState *cpu, struct kvm_run *run) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index b8fb2094062..192538c0aa9 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1517,11 +1517,6 @@ int kvm_arch_irqchip_create(KVMState *s) return kvm_check_extension(s, KVM_CAP_DEVICE_CTRL); } =20 -MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) -{ - return MEMTXATTRS_UNSPECIFIED; -} - int kvm_arch_process_async_events(CPUState *cs) { return cs->halted; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 17b16e33881..5ef4722cd6f 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1336,11 +1336,6 @@ int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, i= nt level) return 0; } =20 -MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) -{ - return MEMTXATTRS_UNSPECIFIED; -} - int kvm_arch_process_async_events(CPUState *cs) { return cs->halted; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 8575e673811..9580b6c1b20 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1640,11 +1640,6 @@ int kvm_arch_process_async_events(CPUState *cs) return 0; } =20 -MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) -{ - return MEMTXATTRS_UNSPECIFIED; -} - bool kvm_arch_stop_on_emulation_error(CPUState *cs) { return true; diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 827816e5b98..ad1145c4ec1 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -984,11 +984,6 @@ void kvm_arch_update_guest_debug(CPUState *cpu, struct= kvm_guest_debug *dbg) } } =20 -MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) -{ - return MEMTXATTRS_UNSPECIFIED; -} - int kvm_arch_process_async_events(CPUState *cs) { return cs->halted; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493160; cv=none; d=zohomail.com; s=zohoarc; b=KMF1mcW/evFDyXZcEXN2RvVHqFo5RC3f9y3QBL5x2ueL82TYxAe26Q+WAKx6QPcC6M4TR+1us+hrpWISG0TPJYNYcsVRLMWgLpXJMmnYShYeeKPLx8/W7mz+P5iKRGD58YRCVJlQnRvWFr4pLWehBy7HNCTH698esXBiooPC9v8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493160; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7E+F5w0u+AqmY/EykrNZQYWdzxIQe74/AVCrqp8rKyo=; b=B5XkJIED5xzBGGCOSvoEp34G+dW5ob4YwuSsjXPW0vNKwQhRQwHpBS2QWIZCxBMxn4mo0eYbAOwGJQs9e3QQ2tZEf2C+e/0neEfU5s76FZSZqD8dGP+SuHzkCh2La9I6aYiFqJNy3GwY5zaa5Wua2soOQVvoZmY9tRLCCSn1+7g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493160270214.35645659570184; Tue, 20 Oct 2026 03:46:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7K0-0004Sz-Iy; Tue, 20 Oct 2026 06:43:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jj-0004Gs-Pr for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:40 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JY-0004Ld-2T for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:39 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4a16aaf2067so38013115e9.0 for ; Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1f2e8daffsm64233405e9.4.2026.10.20.03.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C26265FC8D; Tue, 20 Oct 2026 11:43:21 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493006; x=1793097806; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7E+F5w0u+AqmY/EykrNZQYWdzxIQe74/AVCrqp8rKyo=; b=ZYbadzpO0Pdaeg3af6Tr6Ks9D7nG59Ksbl0DQ/+Aj3SQpp7fStPAvCyX4RErPnxstK 22kjkFnjuUFI+xGJbetQcosZDGw8zdRuZ6jBaGuyjmcvcSJcht0UV94t/FTVCTPQpAdY xXR8ww8MjDmUE/jtQOSR62pAGUUpXQIuSTrK3prR5+Xp+kAyEfHDvtLDbcMUzdwOaLFz TreWm1efQA96hev0fJRd4TaNMP7LreaCPWUX2C+ibkKBAAHk3N415zQG/BylDWsg31bA eFbcFN6tnzX7iFje/g8KrWa1LzB2rmnESTUpXk/gVF97vIEmcmwPgIJRX2BvCPGd38gw lYuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493006; x=1793097806; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7E+F5w0u+AqmY/EykrNZQYWdzxIQe74/AVCrqp8rKyo=; b=kP2Neum95FM3Ex6aJrVk+YI0cJkCpl48gjixZSxrSQQs+rnrDe3J5up2Ver1D/L+I9 59G3luHOY0nWRP7J9sfLt4iethibdtSvIoMQN+R+MOI4P7YI87sOg+YNhvXjPFm0uLx+ GIuenR81t+kflhRBOtyEOOwj9MO7AUAZs3QRAyUfo5C7ONZg9idB0uboW3ITaUG0TA2h Pnk13Y0VlYP74ltiWvTGSY8dOAXd+cuo15OpL1xDvUGOJjDfIfFMvwMLiAHwsWIwg1He chILE0Cjvh9fx/HNOMeZf/lLsz0zF24eRIZbpcTpELQkrTatAcko482uHBF8shwBX2dp +ujQ== X-Gm-Message-State: AFq9FYIdpN8JDDxuf9xV01QlqnEh//nb0iiLGET6Erh/8ZXkrFFOQOvg zMg/MjzA0pMuoZCPJsqA2HLPW3efSoNgAEz7FCPRpRjVmc3kwrjG9HwK4gGKQnJlS8Q= X-Gm-Gg: AYBFou29lvR8usGPseNvO03iLOj8ZANBYjlkNZvE61K40jO4s+8gEckTEuNzCHdbdSo BFe0ReS1oEMhvj/WiM4byt7dgMh0K1VmjmtwxxXa8DTQmYPYICUa7p9CwBWtiQWetzS+q0Tjmbq hfX1JH97KtLUKy7ihXGx6dDDlTVr8Ez32mtOdbrQZB92peMU7HZRoDD7JAGpF8K/syRF4KdesgK XyQmlJH9Mg4PvBMGBj4FOZ7wlsihlF8d7q5FcNkMN7i4v8E4sOKfK4roCu+Qz1y6bWxI1JCViE5 34yN0EQ9k49M6pxMewWFhRxz4AhmL9RPoQpwXvektK/IuZEwfA+A/hKseXV1eb+5L17gOaOQwFa 2O9DQwQsv1nwVdvtSA5K0HeWUaArcgzeiAoWsbZgJLdSMOeW5fVbxefyQgGrL7dQDp7nJFhIW3i GFWGzRVo+HtKH9+C/PBYdpKav6UWx4l1ISXLJ/n90rMZL8vqGdbsSa2xyt3Hp7Zxsrup7hrg== X-Received: by 2002:a05:600c:138a:b0:4a0:1c94:7042 with SMTP id 5b1f17b1804b1-4a1d7600338mr226292235e9.8.1792493005839; Tue, 20 Oct 2026 03:43:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 10/23] accel/kvm: port kvm_arch_handle_exit to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:04 +0100 Message-ID: <20261020104320.3686723-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493162477158500 This is the first mandatory operation although currently none of our x86 tests trip up this handling. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 6 ++++++ include/system/kvm.h | 2 -- target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 4 ++-- target/arm/kvm.c | 3 ++- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/kvm/kvm.c | 3 ++- target/ppc/kvm.c | 3 ++- target/riscv/kvm/kvm-cpu.c | 3 ++- target/s390x/kvm/kvm.c | 3 ++- 11 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index e74081eb133..8b2aabd3c2f 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -30,10 +30,16 @@ struct kvm_run; * #MemTxAttrs to use for handling MMIO exits. * May be NULL if the target does not require post-run handling, * in which case MEMTXATTRS_UNSPECIFIED is assumed. + * @handle_exit: Mandatory callback executed to handle target-specific VM + * exits from KVM_RUN that are not handled by common KVM code + * (or unhandled sub-cases of KVM_EXIT_SYSTEM_EVENT). + * Returns 0 to continue execution, or an EXCP_* code (or ne= gative + * error code) to exit the CPU execution loop. */ typedef struct KVMCPUOps { void (*pre_run)(CPUState *cpu, struct kvm_run *run); MemTxAttrs (*post_run)(CPUState *cpu, struct kvm_run *run); + int (*handle_exit)(CPUState *cpu, struct kvm_run *run); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" diff --git a/include/system/kvm.h b/include/system/kvm.h index 82785d37600..82d18d79dc0 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -333,8 +333,6 @@ extern const KVMCapabilityInfo kvm_arch_required_capabi= lities[]; =20 void kvm_arch_accel_class_init(ObjectClass *oc); =20 -int kvm_arch_handle_exit(CPUState *cpu, struct kvm_run *run); - int kvm_arch_process_async_events(CPUState *cpu); =20 int kvm_arch_get_registers(CPUState *cpu, Error **errp); diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 6fb1da6a40c..5bcc9b51214 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -35,6 +35,7 @@ int kvm_get_vm_type(MachineState *ms); void kvm_arch_reset_vcpu(X86CPU *cs); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); MemTxAttrs x86_kvm_post_run(CPUState *cpu, struct kvm_run *run); +int x86_kvm_handle_exit(CPUState *cs, struct kvm_run *run); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 41229774068..33fa47bddf0 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3616,7 +3616,7 @@ int kvm_cpu_exec(CPUState *cpu) ret =3D 0; break; default: - ret =3D kvm_arch_handle_exit(cpu, run); + ret =3D ops->handle_exit(cpu, run); break; } break; @@ -3634,7 +3634,7 @@ int kvm_cpu_exec(CPUState *cpu) run->memory_fault.flags & KVM_MEMORY_= EXIT_FLAG_PRIVATE); break; default: - ret =3D kvm_arch_handle_exit(cpu, run); + ret =3D ops->handle_exit(cpu, run); break; } } while (ret =3D=3D 0); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index d5f9b7c088c..914f8e3b089 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1590,7 +1590,7 @@ static bool kvm_arm_handle_debug(ARMCPU *cpu, return false; } =20 -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +static int arm_kvm_handle_exit(CPUState *cs, struct kvm_run *run) { ARMCPU *cpu =3D ARM_CPU(cs); int ret =3D 0; @@ -2668,6 +2668,7 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapa= bility *v3) static const KVMCPUOps arm_kvm_cpu_ops =3D { .pre_run =3D arm_kvm_pre_run, .post_run =3D arm_kvm_post_run, + .handle_exit =3D arm_kvm_handle_exit, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 64af85cd113..6b75eb038e1 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -237,6 +237,7 @@ static void kvm_cpu_instance_init(CPUState *cs) static const KVMCPUOps x86_kvm_cpu_ops =3D { .pre_run =3D x86_kvm_pre_run, .post_run =3D x86_kvm_post_run, + .handle_exit =3D x86_kvm_handle_exit, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a1b91d502f0..dfc70eac3db 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6529,7 +6529,7 @@ static int kvm_handle_hypercall(X86CPU *cpu, struct k= vm_run *run) =20 #define VMX_INVALID_GUEST_STATE 0x80000021 =20 -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +int x86_kvm_handle_exit(CPUState *cs, struct kvm_run *run) { X86CPU *cpu =3D X86_CPU(cs); uint64_t code; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 192538c0aa9..b23031007c2 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1590,7 +1590,7 @@ static bool kvm_loongarch_handle_debug(CPUState *cs, = struct kvm_run *run) return false; } =20 -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +static int loongarch_kvm_handle_exit(CPUState *cs, struct kvm_run *run) { int ret =3D 0; CPULoongArchState *env =3D cpu_env(cs); @@ -1643,6 +1643,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps loongarch_kvm_cpu_ops =3D { + .handle_exit =3D loongarch_kvm_handle_exit, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 5ef4722cd6f..25aaefd7649 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1653,7 +1653,7 @@ static int kvm_handle_debug(PowerPCCPU *cpu, struct k= vm_run *run) return DEBUG_RETURN_GUEST; } =20 -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +static int ppc_kvm_handle_exit(CPUState *cs, struct kvm_run *run) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; @@ -3073,6 +3073,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps ppc_kvm_cpu_ops =3D { + .handle_exit =3D ppc_kvm_handle_exit, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 9580b6c1b20..8944961a939 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1787,7 +1787,7 @@ static bool kvm_riscv_handle_debug(CPUState *cs) return false; } =20 -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +static int riscv_kvm_handle_exit(CPUState *cs, struct kvm_run *run) { int ret =3D 0; switch (run->exit_reason) { @@ -2188,6 +2188,7 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, E= rror **errp) } =20 static const KVMCPUOps riscv_kvm_cpu_ops =3D { + .handle_exit =3D riscv_kvm_handle_exit, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index ad1145c4ec1..967706a87e1 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -1904,7 +1904,7 @@ static int kvm_arch_handle_debug_exit(S390CPU *cpu) return ret; } =20 -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +static int s390x_kvm_handle_exit(CPUState *cs, struct kvm_run *run) { S390CPU *cpu =3D S390_CPU(cs); int ret =3D 0; @@ -2650,6 +2650,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps s390x_kvm_cpu_ops =3D { + .handle_exit =3D s390x_kvm_handle_exit, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792494788; cv=none; d=zohomail.com; s=zohoarc; b=KAX4F7l4GlsMakDWpDhKpLl3Qz3ezjDhW/1JyaVGx1mHTHVHl8C/Q7SsOvKRBIXTF8fxiuJprj2uHi7f/rMAipvGVOyCF77DwxCO5s65l2mPJnEs1cDhfwOvzFfW/vhfxmy4hYVuQYAyC49PVnsnUHw04H62NEHOcgnud0DFYz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792494788; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/9f6mqKQKIDfPizUVF1MsoBaBzc3N5Aydnd1/G+cFzg=; b=XauMmoniDatC7BYK6M3FVL8gYMjuVZp7ATknF2qgA+9lNARB+mFA785HMlQk/kFl5qwdnU7mrOfq0uBehw/Nfs2B3JFRpYU2j85d2B8tfmctl189Y27lwkZkYgGnpBtN8wAwGwf+3gb7CnU783LINY91H8ClVZKS7NRMOqm6u7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792494788372848.8644182723326; Tue, 20 Oct 2026 04:13:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Kt-0005Vx-3X; Tue, 20 Oct 2026 06:44:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jq-0004K1-93 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:47 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7JZ-0004Nc-RA for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:46 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-48c5358fc28so2634618f8f.0 for ; Tue, 20 Oct 2026 03:43:29 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d818d61sm5154655f8f.31.2026.10.20.03.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 08ED15FCBC; Tue, 20 Oct 2026 11:43:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493008; x=1793097808; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=/9f6mqKQKIDfPizUVF1MsoBaBzc3N5Aydnd1/G+cFzg=; b=cobr+hS4wwS3+VY7V0pMDzN1MKUMLuuoi7WH0zlUSbGQWjpw0O9doJFrokyGtaif1Z TfLaYQ1k/E4JtIaJGUfj/YQqiGbYr4tt44zhybWSzfktkdLJamniL4vMvMG1EYFyLHMl lQZKh7D2u8rbEdiFUSGLJWSMahoZnVGWt1MQzH+R9AIbbdAdRMBYc49fUb7QAuprXk1V jTK0eja3JVDnJl5NMsspuVNuVPITwhjCcnt/U3RwUsA1J8f+awNUJJGD5ngEY5D4Zu18 20YN0GBVLBxDmMA/XVDdNsK4mp38i5p6johJ1hFIqeb0pdQKxvMA8fB3MbK1MeAO1VPh i1/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493008; x=1793097808; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/9f6mqKQKIDfPizUVF1MsoBaBzc3N5Aydnd1/G+cFzg=; b=Mpi6zXv4GRa7Yfnyl8jLBg/L7N3G5Nm+QkxQ2qK8JggdB94HCf6ZZswNtsaNiNtayw 7ytHGuxbCYV1kGikivGBaDAGQo1OB7oQh/zECcg+F+dKh6wSf4vC5bXqpw2VzNPvo0K8 Kn2JnKp/8VTU8Q23LxFyCnBN/s1NFnxL3xu7xqKBQrFc/SE+NYNDsIVoco2yA8wAIR3c 1QJwlMsxkdK6nSDCjquT3HJWfMgcTvDyaFSDBz5JlgoN1LtTkiLSRO85cPuvkww7MoEK Efno/VhbxP/yuAvYCUCMdOfA9Rdsvmb28tnDU2nYUhBZGG7EeXOEdt8CPZVOVYRCJ6/6 h8Tg== X-Gm-Message-State: AFq9FYJLrzwDDnWyt7nmPGJ4+6tO1VmcGslSHuMTrVMtgA9Z3hPBsex7 L3lk5iP556xsmmzxSA5VaWVJ44gbHLrkli9pL9Gs0PYyirObxMq2V7gyuIDgo/LgRi4= X-Gm-Gg: AYBFou3HDICdIUpbw12/jCU6KZA5bpLnucP79lH+lkctKjiZXB9ztxgZPwAR+Pwxamb dSsMdyQHVuL1IfcMmiNF7J6Ov0JBmIhhkSFi5qmfJVatanuGLMA5MjYSYdACFGMqJbXFBro2LlS DjpwR8dEWG53U1rDUbx2WhA1I2GqArySwM6m86O9Oeccd6uxZ50uurjpRCFRJXgNWFvOlkYhb7Y xd4rthPnIgw59E5jDVdv9ktCDHw837pf6C0K4x0WjD/Y36AVQaqypiLnMUlwfDIwLkbgqfDfKj5 usUEswuOxZ+5h8qy6em92D07ewVMKW3d+vpa11DUCmDvUzkGY6RbgkJLevaXrY6GwfFhMNoDiFP /1kNP5RYkZW3izsZzAwO+4/Z9gFz/SSIibEMEWJduAtlzxf9SE26xkfJlXOr7gfd1aP58HFikn9 IHGF8DbPPJesXMW+4YdAEKCrLZ/DHEmfWGonPFScqXs4nc2X13uaaKvg/0TPTTXqytiIoaBQ== X-Received: by 2002:adf:f806:0:b0:48d:f99d:a0cf with SMTP id ffacd0b85a97d-48e07bbe7b8mr15132244f8f.16.1792493007847; Tue, 20 Oct 2026 03:43:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 11/23] accel/kvm: port kvm_arch_process_async_events to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:05 +0100 Message-ID: <20261020104320.3686723-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792494790286158500 The most complex async handling is for x86 which checks for various exceptions and if the irqchip is not handled in the kernel for interrupts. Most of the others just reflect if cs->halted has been set. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 9 +++++++++ include/system/kvm.h | 2 -- target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 2 +- target/arm/kvm.c | 5 ----- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/kvm/kvm.c | 3 ++- target/ppc/kvm.c | 3 ++- target/riscv/kvm/kvm-cpu.c | 5 ----- target/s390x/kvm/kvm.c | 3 ++- 11 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index 8b2aabd3c2f..cbd3935ba4d 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -35,11 +35,20 @@ struct kvm_run; * (or unhandled sub-cases of KVM_EXIT_SYSTEM_EVENT). * Returns 0 to continue execution, or an EXCP_* code (or ne= gative * error code) to exit the CPU execution loop. + * @process_async_events: Optional callback executed at the start of + * kvm_cpu_exec() while holding the BQL to process + * pending asynchronous events (such as interrupts, + * resets, or MCEs). Returns non-zero (typically + * cpu->halted) if the vCPU should not run and shou= ld + * return EXCP_HLT, or 0 if execution can proceed. + * May be NULL if the target does not require event + * processing before execution. */ typedef struct KVMCPUOps { void (*pre_run)(CPUState *cpu, struct kvm_run *run); MemTxAttrs (*post_run)(CPUState *cpu, struct kvm_run *run); int (*handle_exit)(CPUState *cpu, struct kvm_run *run); + int (*process_async_events)(CPUState *cpu); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" diff --git a/include/system/kvm.h b/include/system/kvm.h index 82d18d79dc0..8c705d21f79 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -333,8 +333,6 @@ extern const KVMCapabilityInfo kvm_arch_required_capabi= lities[]; =20 void kvm_arch_accel_class_init(ObjectClass *oc); =20 -int kvm_arch_process_async_events(CPUState *cpu); - int kvm_arch_get_registers(CPUState *cpu, Error **errp); =20 typedef enum kvm_put_state { diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 5bcc9b51214..bff587a56de 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -36,6 +36,7 @@ void kvm_arch_reset_vcpu(X86CPU *cs); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); MemTxAttrs x86_kvm_post_run(CPUState *cpu, struct kvm_run *run); int x86_kvm_handle_exit(CPUState *cs, struct kvm_run *run); +int x86_kvm_process_async_events(CPUState *cs); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 33fa47bddf0..e8a26a9f067 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3459,7 +3459,7 @@ int kvm_cpu_exec(CPUState *cpu) =20 trace_kvm_cpu_exec(); =20 - if (kvm_arch_process_async_events(cpu)) { + if (ops->process_async_events && ops->process_async_events(cpu)) { return EXCP_HLT; } =20 diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 914f8e3b089..06b133ebf53 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1619,11 +1619,6 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cs) return true; } =20 -int kvm_arch_process_async_events(CPUState *cs) -{ - return 0; -} - /** * kvm_arm_hw_debug_active: * @cpu: ARMCPU diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 6b75eb038e1..163d60a1060 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -238,6 +238,7 @@ static const KVMCPUOps x86_kvm_cpu_ops =3D { .pre_run =3D x86_kvm_pre_run, .post_run =3D x86_kvm_post_run, .handle_exit =3D x86_kvm_handle_exit, + .process_async_events =3D x86_kvm_process_async_events, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index dfc70eac3db..83c4451cf31 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6040,7 +6040,7 @@ MemTxAttrs x86_kvm_post_run(CPUState *cpu, struct kvm= _run *run) return cpu_get_mem_attrs(env); } =20 -int kvm_arch_process_async_events(CPUState *cs) +int x86_kvm_process_async_events(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index b23031007c2..600903a2280 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1517,7 +1517,7 @@ int kvm_arch_irqchip_create(KVMState *s) return kvm_check_extension(s, KVM_CAP_DEVICE_CTRL); } =20 -int kvm_arch_process_async_events(CPUState *cs) +static int loongarch_kvm_process_async_events(CPUState *cs) { return cs->halted; } @@ -1644,6 +1644,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) =20 static const KVMCPUOps loongarch_kvm_cpu_ops =3D { .handle_exit =3D loongarch_kvm_handle_exit, + .process_async_events =3D loongarch_kvm_process_async_events, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 25aaefd7649..e52f0b84ee3 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1336,7 +1336,7 @@ int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, in= t level) return 0; } =20 -int kvm_arch_process_async_events(CPUState *cs) +static int ppc_kvm_process_async_events(CPUState *cs) { return cs->halted; } @@ -3074,6 +3074,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) =20 static const KVMCPUOps ppc_kvm_cpu_ops =3D { .handle_exit =3D ppc_kvm_handle_exit, + .process_async_events =3D ppc_kvm_process_async_events, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 8944961a939..a5333083765 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1635,11 +1635,6 @@ int kvm_arch_irqchip_create(KVMState *s) return kvm_check_extension(s, KVM_CAP_DEVICE_CTRL); } =20 -int kvm_arch_process_async_events(CPUState *cs) -{ - return 0; -} - bool kvm_arch_stop_on_emulation_error(CPUState *cs) { return true; diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 967706a87e1..420703f7683 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -984,7 +984,7 @@ void kvm_arch_update_guest_debug(CPUState *cpu, struct = kvm_guest_debug *dbg) } } =20 -int kvm_arch_process_async_events(CPUState *cs) +static int s390x_kvm_process_async_events(CPUState *cs) { return cs->halted; } @@ -2651,6 +2651,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) =20 static const KVMCPUOps s390x_kvm_cpu_ops =3D { .handle_exit =3D s390x_kvm_handle_exit, + .process_async_events =3D s390x_kvm_process_async_events, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792494002; cv=none; d=zohomail.com; s=zohoarc; b=cKhKtlWNOjH3pYRFyPUhSZLgr1S3fH9iv655gF5/FTamzfRwlxDMNyeyI7l9Mdd+uNhFLuqDcly2J38fcuPV2ktLdZncfNoG4Zw3cWq8ctm1Tqba33ZNgtPxnH+cuZSh0gDJ94TX+C9hw0RIfJpHEx31oA5WARVAxYS92Z+nhb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792494002; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HO3Ja0+9v+igMSVwX72ixvycLcYQhsP4AuHqtgFe9uk=; b=CujfirLfchndIg0MfN4j84NVrJWEghXx0Fjf+gnWbmquueJnmw+aHBVtfMCu8NEYj+Ngmz8uFoYjGUBjAopF4v6eH7rhyJkA1XoDRd3Pj8EGV5q+WOTb6VjiDQ565FjBKNDCMBJuiFal/uwPbywiSPbtEKgIg9NkxCa41pOQxCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792494002868184.16207638795106; Tue, 20 Oct 2026 04:00:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7KT-0004vd-Tj; Tue, 20 Oct 2026 06:44:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jr-0004K8-1E for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:47 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Ja-0004O5-6d for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:46 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-48c45111bebso1906916f8f.0 for ; Tue, 20 Oct 2026 03:43:29 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d82e8f7sm5296588f8f.48.2026.10.20.03.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:26 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 43CE45F957; Tue, 20 Oct 2026 11:43:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493008; x=1793097808; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HO3Ja0+9v+igMSVwX72ixvycLcYQhsP4AuHqtgFe9uk=; b=g8jgjBQsUyVImJ2A812W/gm7XGW24fkPt5SHURDXOxdTmwgr2vL5LJsLbJ6LR2CWxK IA1UFmkO+UnwhzWR/wG5l2ZPVVbITs4x0rtCj2GX7Shrgald9h9byUJviPlBzpp7GMAI 646mFeGXD2b+o/+gLhX+12Bb7REnzV9qsNbemX8SNl0hIkg415OB0WJz/byK2lJK6AvV QEIABSOrQdg8fZK0FQf02dzM2dLpqHoqlIvqq0yIhgAztvtS/va9KQ4pJEIAwFZWTnL+ ifIv0X8ZvYM+o2y/BeDy3JTUAoc0afOGoK5uuDG1/kVJdxvWzks2vS5GGQ2dCyE0Hpjx uawQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493008; x=1793097808; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HO3Ja0+9v+igMSVwX72ixvycLcYQhsP4AuHqtgFe9uk=; b=kg8KQQelDHpf8PPbC9EPmsM4l7e7vszskzORb8J7NwhLEKTdL9Fv4QCETt1fNoFlwP vnEsU9Gd9O7xvotdGv3PMIhUv2XL5AeM5b/dnJimtdhtYcayH7Win1ou7sPFabD9hQm0 0iMNaTYX7jTgx2mdUOy4ApZoxqppOADNTz0NB2Q3CnPpCzHrhvKQannV73yq2Ft65Tby Mgt8mCqW2Fyp/Cc22e/JqgVWjxi28NsYrAakYM1YjTCV1MxXg2rGyEXwPwaW8R1b346M BhEGL5wDkMAfHTlLBYujVDysu7F5wL+ks3IYow/w+y8TmVThc5HiYKSYdIciXo/jBEf8 5qQQ== X-Gm-Message-State: AFq9FYLohnpMqYij5kgoEE28BeYfEYvMlKxU5eCWevOb17axt8hB7KF3 EbUsPLmh2bcLEpUVFG/el1JCl2Q0+kG4nxPWCC2ftGJcDpKk4wBMIjlTITrGbnpF/Ls= X-Gm-Gg: AYBFou0WF1fM9kdXpeElnbz2FDZdZJB/DbupVRof67g88aloArT/kfiKrr7TK47209T B5iVEypz0ZkiwngzGWzT27UINSFiOMxXiF5Z808KJg3IRQUXuzBSZEiLkeNx5n6/aRxxPAou3q4 ltT/MUc6mUOM8wId26utKmllJ2qWlaNpzj3Ye64XaNnMoU/kd+nryV77hFYUq2POfYgB5R6bzEC Pr4Genko1vZF2FTZkpgLZjEqQuy7HoDOiwWW8e5i56NUmu0nsaatNTHKaEPC11NGYoIga7e6OQj swnB+WmpibQfEDh+rFNlyUGcQggp8WWawnNxyjJEICEuFDZvhnuBV2E8rdED9VKSyo0lUdMxwnO hW2JavzY+kNfkl+kSSVuqYyh50BSH3iINrbgGliKAhMbgZGowP1C27dea3f9yMXav7xWJqvsSKk 5+nfh/MAbJto7NFMSai6qkbPMe1zLSimGbnbOvv4w5OenNIEYWV0CVCTruP2UeL0dX9wMpYQ== X-Received: by 2002:a05:6000:468d:b0:48d:f39b:83de with SMTP id ffacd0b85a97d-48e07b92058mr15645006f8f.3.1792493008429; Tue, 20 Oct 2026 03:43:28 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 12/23] accel/kvm: port kvm_arch_[put|get]_registers to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:06 +0100 Message-ID: <20261020104320.3686723-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792494004456158500 The ability to save and restore register state from KVM is required for both migration and the gdbstub. These hooks are mandatory for any KVM implementation. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 11 +++++++++++ include/system/kvm.h | 4 ---- target/i386/kvm/kvm_i386.h | 2 ++ accel/kvm/kvm-all.c | 6 ++++-- target/arm/kvm.c | 6 ++++-- target/i386/kvm/kvm-cpu.c | 2 ++ target/i386/kvm/kvm.c | 4 ++-- target/loongarch/kvm/kvm.c | 7 +++++-- target/ppc/kvm.c | 6 ++++-- target/riscv/kvm/kvm-cpu.c | 7 +++++-- target/s390x/kvm/kvm.c | 7 +++++-- 11 files changed, 44 insertions(+), 18 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index cbd3935ba4d..b3f6b8e47b7 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -12,12 +12,21 @@ #include "qom/object.h" #include "hw/core/cpu.h" #include "accel/accel-cpu-target.h" +#include "system/kvm.h" =20 struct kvm_run; =20 /** * struct KVMCPUOps - Target-specific per-vCPU operations for KVM * + * @get_registers: Mandatory callback to synchronize architecture-specific + * vCPU register state from KVM into QEMU's CPUState. + * Returns 0 on success, or a negative errno on failure. + * @put_registers: Mandatory callback to synchronize architecture-specific + * vCPU register state from QEMU's CPUState into KVM. + * The @level parameter specifies whether to write runtime, + * reset, or full state. + * Returns 0 on success, or a negative errno on failure. * @pre_run: Optional callback executed immediately prior to entering the * KVM_RUN ioctl in the vCPU thread loop. Used by architectures * that need to inject pending events (e.g. x86 NMI/SMI) or veri= fy @@ -45,6 +54,8 @@ struct kvm_run; * processing before execution. */ typedef struct KVMCPUOps { + int (*get_registers)(CPUState *cpu, Error **errp); + int (*put_registers)(CPUState *cpu, KvmPutState level, Error **errp); void (*pre_run)(CPUState *cpu, struct kvm_run *run); MemTxAttrs (*post_run)(CPUState *cpu, struct kvm_run *run); int (*handle_exit)(CPUState *cpu, struct kvm_run *run); diff --git a/include/system/kvm.h b/include/system/kvm.h index 8c705d21f79..b2d76f99df0 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -333,8 +333,6 @@ extern const KVMCapabilityInfo kvm_arch_required_capabi= lities[]; =20 void kvm_arch_accel_class_init(ObjectClass *oc); =20 -int kvm_arch_get_registers(CPUState *cpu, Error **errp); - typedef enum kvm_put_state { /* state subset only touched by the VCPU itself during runtime */ KVM_PUT_RUNTIME_STATE =3D 1, @@ -344,8 +342,6 @@ typedef enum kvm_put_state { KVM_PUT_FULL_STATE =3D 3, } KvmPutState; =20 -int kvm_arch_put_registers(CPUState *cpu, KvmPutState level, Error **errp); - int kvm_arch_get_default_type(MachineState *ms); =20 int kvm_arch_init(MachineState *ms, KVMState *s); diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index bff587a56de..2c92afc3320 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -33,6 +33,8 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp= ); =20 int kvm_get_vm_type(MachineState *ms); void kvm_arch_reset_vcpu(X86CPU *cs); +int x86_kvm_get_registers(CPUState *cs, Error **errp); +int x86_kvm_put_registers(CPUState *cpu, KvmPutState level, Error **errp); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); MemTxAttrs x86_kvm_post_run(CPUState *cpu, struct kvm_run *run); int x86_kvm_handle_exit(CPUState *cs, struct kvm_run *run); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e8a26a9f067..3de05bb8bb8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3214,8 +3214,9 @@ void kvm_flush_coalesced_mmio_buffer(void) static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data ar= g) { if (!cpu->vcpu_dirty && !kvm_state->guest_state_protected) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); Error *err =3D NULL; - int ret =3D kvm_arch_get_registers(cpu, &err); + int ret =3D ops->get_registers(cpu, &err); if (ret) { if (err) { error_reportf_err(err, "Failed to synchronize CPU state: "= ); @@ -3241,8 +3242,9 @@ void kvm_cpu_synchronize_state(CPUState *cpu) static bool kvm_cpu_synchronize_put(CPUState *cpu, KvmPutState state, const char *desc) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); Error *err =3D NULL; - int ret =3D kvm_arch_put_registers(cpu, state, &err); + int ret =3D ops->put_registers(cpu, state, &err); if (ret) { if (err) { error_reportf_err(err, "Restoring resisters %s: ", desc); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 06b133ebf53..ea8c4d02ee8 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2198,7 +2198,7 @@ static int kvm_arch_put_sve(CPUState *cs, uint32_t vq= , bool have_ffr) return 0; } =20 -int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) +static int arm_kvm_put_registers(CPUState *cs, KvmPutState level, Error **= errp) { uint64_t val; uint32_t fpr; @@ -2383,7 +2383,7 @@ static int kvm_arch_get_sve(CPUState *cs, uint32_t vq= , bool have_ffr) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs, Error **errp) +static int arm_kvm_get_registers(CPUState *cs, Error **errp) { uint64_t val; unsigned int el; @@ -2661,6 +2661,8 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapa= bility *v3) } =20 static const KVMCPUOps arm_kvm_cpu_ops =3D { + .get_registers =3D arm_kvm_get_registers, + .put_registers =3D arm_kvm_put_registers, .pre_run =3D arm_kvm_pre_run, .post_run =3D arm_kvm_post_run, .handle_exit =3D arm_kvm_handle_exit, diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 163d60a1060..08308ef8a80 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -235,6 +235,8 @@ static void kvm_cpu_instance_init(CPUState *cs) } =20 static const KVMCPUOps x86_kvm_cpu_ops =3D { + .get_registers =3D x86_kvm_get_registers, + .put_registers =3D x86_kvm_put_registers, .pre_run =3D x86_kvm_pre_run, .post_run =3D x86_kvm_post_run, .handle_exit =3D x86_kvm_handle_exit, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 83c4451cf31..7ee6d3d4f38 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5712,7 +5712,7 @@ static int kvm_get_nested_state(X86CPU *cpu) return ret; } =20 -int kvm_arch_put_registers(CPUState *cpu, KvmPutState level, Error **errp) +int x86_kvm_put_registers(CPUState *cpu, KvmPutState level, Error **errp) { X86CPU *x86_cpu =3D X86_CPU(cpu); int ret; @@ -5817,7 +5817,7 @@ int kvm_arch_put_registers(CPUState *cpu, KvmPutState= level, Error **errp) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs, Error **errp) +int x86_kvm_get_registers(CPUState *cs, Error **errp) { X86CPU *cpu =3D X86_CPU(cs); int ret; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 600903a2280..1e7565732e8 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -823,7 +823,7 @@ static int kvm_loongarch_put_cpucfg(CPUState *cs) return ret; } =20 -int kvm_arch_get_registers(CPUState *cs, Error **errp) +static int loongarch_kvm_get_registers(CPUState *cs, Error **errp) { int ret; =20 @@ -861,7 +861,8 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp) return ret; } =20 -int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) +static int loongarch_kvm_put_registers(CPUState *cs, KvmPutState level, + Error **errp) { int ret; static int once; @@ -1643,6 +1644,8 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps loongarch_kvm_cpu_ops =3D { + .get_registers =3D loongarch_kvm_get_registers, + .put_registers =3D loongarch_kvm_put_registers, .handle_exit =3D loongarch_kvm_handle_exit, .process_async_events =3D loongarch_kvm_process_async_events, }; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index e52f0b84ee3..25f797cb2d8 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -908,7 +908,7 @@ int kvmppc_put_books_sregs(PowerPCCPU *cpu) return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, &sregs); } =20 -int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) +static int ppc_kvm_put_registers(CPUState *cs, KvmPutState level, Error **= errp) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; @@ -1213,7 +1213,7 @@ static int kvmppc_get_books_sregs(PowerPCCPU *cpu) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs, Error **errp) +static int ppc_kvm_get_registers(CPUState *cs, Error **errp) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; @@ -3073,6 +3073,8 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps ppc_kvm_cpu_ops =3D { + .get_registers =3D ppc_kvm_get_registers, + .put_registers =3D ppc_kvm_put_registers, .handle_exit =3D ppc_kvm_handle_exit, .process_async_events =3D ppc_kvm_process_async_events, }; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index a5333083765..c38c07a563b 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1389,7 +1389,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilitie= s[] =3D { KVM_CAP_LAST_INFO }; =20 -int kvm_arch_get_registers(CPUState *cs, Error **errp) +static int riscv_kvm_get_registers(CPUState *cs, Error **errp) { int ret =3D 0; =20 @@ -1444,7 +1444,8 @@ static int kvm_riscv_put_mp_state(CPUState *cs) return kvm_vcpu_ioctl(cs, KVM_SET_MP_STATE, &mp_state); } =20 -int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) +static int riscv_kvm_put_registers(CPUState *cs, KvmPutState level, + Error **errp) { int ret =3D 0; =20 @@ -2183,6 +2184,8 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, E= rror **errp) } =20 static const KVMCPUOps riscv_kvm_cpu_ops =3D { + .get_registers =3D riscv_kvm_get_registers, + .put_registers =3D riscv_kvm_put_registers, .handle_exit =3D riscv_kvm_handle_exit, }; =20 diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 420703f7683..c85d286288b 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -471,7 +471,8 @@ static int can_sync_regs(CPUState *cs, int regs) KVM_SYNC_CRS | KVM_SYNC_PREFIX | \ KVM_SYNC_PFAULT) =20 -int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) +static int s390x_kvm_put_registers(CPUState *cs, KvmPutState level, + Error **errp) { CPUS390XState *env =3D cpu_env(cs); struct kvm_fpu fpu =3D {}; @@ -582,7 +583,7 @@ int kvm_arch_put_registers(CPUState *cs, KvmPutState le= vel, Error **errp) return 0; } =20 -int kvm_arch_get_registers(CPUState *cs, Error **errp) +static int s390x_kvm_get_registers(CPUState *cs, Error **errp) { CPUS390XState *env =3D cpu_env(cs); struct kvm_fpu fpu; @@ -2650,6 +2651,8 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps s390x_kvm_cpu_ops =3D { + .get_registers =3D s390x_kvm_get_registers, + .put_registers =3D s390x_kvm_put_registers, .handle_exit =3D s390x_kvm_handle_exit, .process_async_events =3D s390x_kvm_process_async_events, }; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493340; cv=none; d=zohomail.com; s=zohoarc; b=ASual32A6qaxrXO3avmzSVvGvO1jvcXI72FgzUh5AlI7nBVt/6orqr5hgPbjRAbmp/EFkpdhycXIyFTNvTEnypPvf5vfTVQpJgHex4vg0kdnYs+Vn9V56KZkqXGZbEvnF/Aqln+xaihzBNBRkKGSbfy7Hs/N4cpc3Cwa3fZeG+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493340; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rlGqnDKcLdvQ6taSdMwsgc96SAB4pCJT2O+A8tIZZ9Y=; b=UvRkx1MIQjTL+HY9bpNBbN98kRsP1du/uOj49OTigtHEu0puRMSIJT+a7eT9Io5vUd1zFv8R8930rSgs/dPBZQSzoIJbp7Vmpoo7miAf6/0xHbO9D8Kvsb5UAkBYFbE8jEwYzsbAN8ZPvC4MMWxc8sMP1vRWJ2WKJonv575Z1qA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493340700673.5329501286949; Tue, 20 Oct 2026 03:49:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Ln-0006Xf-CR; Tue, 20 Oct 2026 06:45:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7K1-0004WF-Kn for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:57 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jg-0004S3-Qp for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:57 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4a171b677d2so18169045e9.0 for ; Tue, 20 Oct 2026 03:43:36 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1df370381sm168472065e9.1.2026.10.20.03.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7C7265FD52; Tue, 20 Oct 2026 11:43:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493015; x=1793097815; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=rlGqnDKcLdvQ6taSdMwsgc96SAB4pCJT2O+A8tIZZ9Y=; b=u7CcBk93x4RJ8AWxVURRqdB+X9squbTKatIQLAjlLbPzbkmhgxiCpt+lClXVkudtYw eNWbxJp+zUsjmcwx64Om0S/GlAln2biXE/sSEa8Q9jVanhSRoytM/JpNUgm1G7GUFsnf b/nF4/mojdryPI5K53EesZP5Va/ALTv3L51VAxKJQjJ+XKYiziP2EXx1li7prr3fQfyG y9kmS1hhVrdxZ0j/NcJaMLxZ4nwCoS8a04H1zpmt2PCDveaJREHsHXrn1YNG7fF05aMf 2cRLa/NrH/nSInXxNzWb7FEnPOcZSF5LSau/izUiLDjFuAjVTE8ICnvMIA0MWBYj2zrQ bQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493015; x=1793097815; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rlGqnDKcLdvQ6taSdMwsgc96SAB4pCJT2O+A8tIZZ9Y=; b=SJ2Ap4oItiZEtF48O8c689eOWhzi28r6WjhHDpv1R1dt48EeAPD7GDdnTlvCroTnql DxITHF6Chqs/cSTih/LEfeAsa/R/gfYnpuqmZja9tI3O6oR4IwN8cwCz0xLHCF6jkaQ8 3O+qYWccBaAia4Pvejxg9B8jLwwOlS/BlQ4/WsO0x9/1SG4ho4TT23tEmMGNnWF6TfGR +5Ugl62A6unOoWMmflT3Kr44jp0uZdYgJ7QqDggdfk1gVW26PXdJFfSq3eKbyKA+kRg/ ckwRS0J2+DP9RTCEAi7UzQGXD9ATc8qG745nx5jqZE4xc9OtlqwiwJFlt7FmqL14icnZ vrSg== X-Gm-Message-State: AFq9FYLQjabbogVqbF04mSru280tctSjp6R6QpO2UJFZg46fzcttkVrK lIC+FtAyVpw81o77oBUf2x0eJTh6vCEj0gJVp5r3te92vwmTzzLYR/tqCfH/fCX3kzY= X-Gm-Gg: AYBFou25H0ZUglulJPtekfDyLsGBG2I2s76DT0nYsQDs/QA3ToZbL5LyVO12zWhvyVK yHG6lDbUMO67yGJ6RuIHA+98lI/SXbrG0H7yskQhnbj1fPsszPpLv6WXqV0gbNXEu20Fh0Etz1x fE4gZ3WVXyE4/70xgmZXTIaZSyXmdT49m/KepQPsuySc1kjV7DgJGYaGyTHkX203Tb/lDFqJBh4 lN0cw00Nq7TOiZT8qvsFTFDdFbYNPqn6+AsxAY1R51kcyoyhqktLAo6vkmdRa2bNcIk6hkF0Vc+ UzIPIrq4kH6Q/yVnYuRRR7AqfPQO1XA4rvxESC1e0pz8q5TJDHnGr4MqJkQv1vdsaNnByf0gF9B O118cgtU1GrKvm8LpRjOrWTwFLWNHe6ZWvBQhuH7Xcni6pQSTeNDr77TR2ylneEuYipkZJ5twXc vCsXfJ7nJZUecEzfWomAnWw/atlm4OZ1f8Ww0SqM0Ndbjw8dRdy8ZYyAzfDkAW4mhFe56oLA== X-Received: by 2002:a05:600c:4e11:b0:49f:e701:51c8 with SMTP id 5b1f17b1804b1-4a1d75f24b4mr214465875e9.9.1792493015117; Tue, 20 Oct 2026 03:43:35 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 13/23] accel/kvm: port kvm_arch_pre_create_vcpu to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:07 +0100 Message-ID: <20261020104320.3686723-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493341967158500 Only x86 actually does anything for this. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 7 +++++++ include/system/kvm.h | 1 - target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 19 +++++++++++++------ target/arm/kvm.c | 5 ----- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/kvm/kvm.c | 5 ----- target/ppc/kvm.c | 5 ----- target/riscv/kvm/kvm-cpu.c | 5 ----- target/s390x/kvm/kvm.c | 5 ----- 11 files changed, 23 insertions(+), 33 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index b3f6b8e47b7..9b8a54253b1 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -19,6 +19,12 @@ struct kvm_run; /** * struct KVMCPUOps - Target-specific per-vCPU operations for KVM * + * @pre_create_vcpu: Optional callback executed before creating the KVM vC= PU + * (via KVM_CREATE_VCPU). Used by architectures that need + * to configure VM-level capabilities or features before + * vCPUs are created (e.g. x86 PMU disable or TDX). + * May be NULL if the target does not require pre-creati= on + * handling. * @get_registers: Mandatory callback to synchronize architecture-specific * vCPU register state from KVM into QEMU's CPUState. * Returns 0 on success, or a negative errno on failure. @@ -54,6 +60,7 @@ struct kvm_run; * processing before execution. */ typedef struct KVMCPUOps { + int (*pre_create_vcpu)(CPUState *cpu, Error **errp); int (*get_registers)(CPUState *cpu, Error **errp); int (*put_registers)(CPUState *cpu, KvmPutState level, Error **errp); void (*pre_run)(CPUState *cpu, struct kvm_run *run); diff --git a/include/system/kvm.h b/include/system/kvm.h index b2d76f99df0..3b08eb4f5d0 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -346,7 +346,6 @@ int kvm_arch_get_default_type(MachineState *ms); =20 int kvm_arch_init(MachineState *ms, KVMState *s); =20 -int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp); int kvm_arch_init_vcpu(CPUState *cpu); int kvm_arch_destroy_vcpu(CPUState *cpu); =20 diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 2c92afc3320..b5dace5d3be 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -33,6 +33,7 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp= ); =20 int kvm_get_vm_type(MachineState *ms); void kvm_arch_reset_vcpu(X86CPU *cs); +int x86_kvm_pre_create_vcpu(CPUState *cpu, Error **errp); int x86_kvm_get_registers(CPUState *cs, Error **errp); int x86_kvm_put_registers(CPUState *cpu, KvmPutState level, Error **errp); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 3de05bb8bb8..dbd4cfc7c7a 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -460,6 +460,8 @@ static int kvm_rebind_vcpus(Error **errp) int kvm_fd, ret =3D 0; =20 CPU_FOREACH(cpu) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); + vcpu_id =3D kvm_arch_vcpu_id(cpu); =20 if (cpu->kvm_fd) { @@ -480,9 +482,11 @@ static int kvm_rebind_vcpus(Error **errp) goto err; } =20 - ret =3D kvm_arch_pre_create_vcpu(cpu, errp); - if (ret < 0) { - goto err; + if (ops->pre_create_vcpu) { + ret =3D ops->pre_create_vcpu(cpu, errp); + if (ret < 0) { + goto err; + } } =20 kvm_fd =3D kvm_vm_ioctl(s, KVM_CREATE_VCPU, vcpu_id); @@ -723,14 +727,17 @@ static int map_kvm_dirty_gfns(KVMState *s, CPUState *= cpu, Error **errp) =20 int kvm_init_vcpu(CPUState *cpu, Error **errp) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); KVMState *s =3D kvm_state; int ret; =20 trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); =20 - ret =3D kvm_arch_pre_create_vcpu(cpu, errp); - if (ret < 0) { - goto err; + if (ops->pre_create_vcpu) { + ret =3D ops->pre_create_vcpu(cpu, errp); + if (ret < 0) { + goto err; + } } =20 ret =3D kvm_create_vcpu(cpu); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ea8c4d02ee8..da6c3e0b3d3 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1994,11 +1994,6 @@ static int kvm_arm_sve_set_vls(ARMCPU *cpu) =20 #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 =20 -int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp) -{ - return 0; -} - int kvm_arch_init_vcpu(CPUState *cs) { int ret; diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 08308ef8a80..e2cf42a126e 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -235,6 +235,7 @@ static void kvm_cpu_instance_init(CPUState *cs) } =20 static const KVMCPUOps x86_kvm_cpu_ops =3D { + .pre_create_vcpu =3D x86_kvm_pre_create_vcpu, .get_registers =3D x86_kvm_get_registers, .put_registers =3D x86_kvm_put_registers, .pre_run =3D x86_kvm_pre_run, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 7ee6d3d4f38..1c53b62a1f7 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2056,7 +2056,7 @@ full: abort(); } =20 -int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp) +int x86_kvm_pre_create_vcpu(CPUState *cpu, Error **errp) { static bool first =3D true; int ret; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 1e7565732e8..9ce6e9e65b4 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1297,11 +1297,6 @@ static int kvm_cpu_check_misc_v1_1(CPUState *cs, Err= or **errp) return 0; } =20 -int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp) -{ - return 0; -} - int kvm_arch_init_vcpu(CPUState *cs) { uint64_t val; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 25f797cb2d8..8a2d2421dc2 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -480,11 +480,6 @@ static void kvmppc_hw_debug_points_init(CPUPPCState *c= env) } } =20 -int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp) -{ - return 0; -} - int kvm_arch_init_vcpu(CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index c38c07a563b..cef9d90c66f 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1579,11 +1579,6 @@ static int kvm_vcpu_enable_sbi_dbcn(RISCVCPU *cpu, C= PUState *cs) return kvm_set_one_reg(cs, kvm_sbi_dbcn.kvm_reg_id, ®); } =20 -int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp) -{ - return 0; -} - int kvm_arch_init_vcpu(CPUState *cs) { int ret =3D 0; diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index c85d286288b..64020450dec 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -400,11 +400,6 @@ unsigned long kvm_arch_vcpu_id(CPUState *cpu) return cpu->cpu_index; } =20 -int kvm_arch_pre_create_vcpu(CPUState *cpu, Error **errp) -{ - return 0; -} - int kvm_arch_init_vcpu(CPUState *cs) { unsigned int max_cpus =3D MACHINE(qdev_get_machine())->smp.max_cpus; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493156; cv=none; d=zohomail.com; s=zohoarc; b=ZzDObCm1768h/9VVeMZWak5piRdoayISiT5AIolcSeXlC43nB1FeAXPYavu0nzBy8cRaTTaaQMqluFnoH4X1V85bcBBk61BSqbEbU+v9AjGEn/30mN9ZkkQPOxkpRSGOlLq8ms/qwH1VGUKXnKW9S3VM/N01EeHLPflJP8IBmNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493156; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K7uFeQPHP03rH0C9IgKY7QD6JlgfGCjHU4q4ZdF6Xyo=; b=KSJCEFT1M1PdRtDM+udDnrzyZfxsD0+4SKwYfaSMrTcd4gT1y/L1sygkwTWcZzs/4IwUORltplyY9y5hT1rzyeapbOhyOLqxlIqhRDaHtJ3njtP52227wdC5TPfjKEkdua4tGOdQgKkPl5a6fOxGYjua+IZFfjd34XyvT0qpOaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493156721936.6333864821463; Tue, 20 Oct 2026 03:45:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7L8-0005zH-Mq; Tue, 20 Oct 2026 06:45:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jt-0004MW-MQ for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:50 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jb-0004P4-Rl for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:49 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-487049569b6so1693243f8f.1 for ; Tue, 20 Oct 2026 03:43:31 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d818237sm5338996f8f.27.2026.10.20.03.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B82675FD54; Tue, 20 Oct 2026 11:43:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493010; x=1793097810; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=K7uFeQPHP03rH0C9IgKY7QD6JlgfGCjHU4q4ZdF6Xyo=; b=Yj+wSB6/oynVPFVCO+NQOqfRJZwUND9pyvqH3dmqSa0/dleOHMcQunS9aGuKPCZFG7 M5US7fxeNcfvJXVXrpHkcVx9ESpv1D3zB2AaUom5a6sdvl1Ra4SouOSpk4T0o4E+yNZz wqFmu2yrA1HHMLmLz2pu5lTvP9BoC47D5kRpP8YTCct4Tg9g0Sg6MnVsiebRZnQt3GbJ 5h+6YlyDxmnmGl2xeEo1o2IGxu7OZzWLvrCaMvTyvp28Mq8K9d1ZuqvTWYPeVYjyVLD1 pBV1m1U6Irhu3tau3HOSR2NXUgNsFI6+J0R61i/WH0hAycejhBtk3U2/vv+q2DHy2SW0 k1mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493010; x=1793097810; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=K7uFeQPHP03rH0C9IgKY7QD6JlgfGCjHU4q4ZdF6Xyo=; b=r2GK3qS6LcXw+wuYJNua+OSqKb9uQ/H4F7mB+PeNCnUsp5OcWDEiA/hTVpRKSsA8s6 eI1AopYUnibE1UPJXqse/Rz+CcIwYPyH4YkiKV5mRwsx8MQyJ75jbNoDsjc1GRxnmkbb zTL9APxC1pyUc/5tVdnDyDdDWcBBKug60ygxkBgZpbxOLmalFekM6MMkKmExUzyjYkq3 Dvjxi5vzDO59fUcfHb367Zx+whKpRMCGTC1K4zxrW1KAfhHi4+h4Gr/WGjjym3Gmd1lX M1+y9zrcjhsZTrFieJYHaPvAIMIthlKxsP2++FaV4fWdhd1W8NTb28XcuwakTyH/tL/h AEMA== X-Gm-Message-State: AFq9FYIF5r7uSsb7YrBp7FtFFecyoWLDbvA0ov7AhDANHgqHnYMGBe4m xGYTOg7I45Z2ECQXKraNic0Qv0FtIFlCX4nuoyD6CADi63vxiTnbsobcOrXzVrbEh1U= X-Gm-Gg: AYBFou2M3BAHAhu/DKE+8DGDN1x7t2m1p9cM0xGgc1fTIhfLkGG49n2Db1xevbUWC5i qZ/bMIDMdVztthFLqmi8o+7+ireALcfRAXrwDhjEQol7JLBmSIYp0fqFI9E7tW3VN4rV9AftToH SPOxV7LA1B+p1aITzp5a5xoNOKeVrG6yiUlrga4ho2xB/77EGJ+1W1ufFx0UMWY7LNIj6teOny5 ZW5xksa7ghrXqKkb7MM4owRyczwzyh4CliMFjEflj/asLcV/bX55ZLTiIWwEBo46EwhVyUHItYA pYqYh+pWUBCBSZ5jRm3K2qLUA7nHPHshEUVV9NqxuoSeQ0rvRl7OaZzw1RIh/2ZK4UO2ZnleSqw DHYnOuFpOD6bQHhakS+ytUnlxfJdRw0A+8tvaKuf6+gnDeqOe2Ls1ZJryFkvjjougiXhNI0OO3J 6ifKcaK0E0cIZurst2YpcW3bCQy2WHUhmtsnji6PZavnW/zXVgSlIN3NMM9eVregQFnk486w== X-Received: by 2002:a05:6000:2c04:b0:48e:1f08:4f05 with SMTP id ffacd0b85a97d-48e1f08504emr4194817f8f.33.1792493009010; Tue, 20 Oct 2026 03:43:29 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 14/23] accel/kvm: port kvm_arch_init_vcpu to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:08 +0100 Message-ID: <20261020104320.3686723-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493158320158500 Every architecture needs to implement this. I did note that loongarch references init_vcpu for feature detection but maybe that should be moved to kvm_arch_pre_create_vcpu? Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 4 ++++ include/system/kvm.h | 1 - target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 8 ++++---- target/arm/kvm.c | 3 ++- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/cpu.c | 8 ++++---- target/loongarch/kvm/kvm.c | 3 ++- target/ppc/kvm.c | 3 ++- target/riscv/kvm/kvm-cpu.c | 3 ++- target/s390x/kvm/kvm.c | 3 ++- 12 files changed, 25 insertions(+), 15 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index 9b8a54253b1..23557a42ba7 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -25,6 +25,9 @@ struct kvm_run; * vCPUs are created (e.g. x86 PMU disable or TDX). * May be NULL if the target does not require pre-creati= on * handling. + * @init_vcpu: Mandatory callback executed to perform architecture-specific + * initialization of a newly created KVM vCPU. + * Returns 0 on success, or a negative errno on failure. * @get_registers: Mandatory callback to synchronize architecture-specific * vCPU register state from KVM into QEMU's CPUState. * Returns 0 on success, or a negative errno on failure. @@ -61,6 +64,7 @@ struct kvm_run; */ typedef struct KVMCPUOps { int (*pre_create_vcpu)(CPUState *cpu, Error **errp); + int (*init_vcpu)(CPUState *cpu); int (*get_registers)(CPUState *cpu, Error **errp); int (*put_registers)(CPUState *cpu, KvmPutState level, Error **errp); void (*pre_run)(CPUState *cpu, struct kvm_run *run); diff --git a/include/system/kvm.h b/include/system/kvm.h index 3b08eb4f5d0..a722f266dae 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -346,7 +346,6 @@ int kvm_arch_get_default_type(MachineState *ms); =20 int kvm_arch_init(MachineState *ms, KVMState *s); =20 -int kvm_arch_init_vcpu(CPUState *cpu); int kvm_arch_destroy_vcpu(CPUState *cpu); =20 #ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index b5dace5d3be..8af5a9dc0ef 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -34,6 +34,7 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp= ); int kvm_get_vm_type(MachineState *ms); void kvm_arch_reset_vcpu(X86CPU *cs); int x86_kvm_pre_create_vcpu(CPUState *cpu, Error **errp); +int x86_kvm_init_vcpu(CPUState *cs); int x86_kvm_get_registers(CPUState *cs, Error **errp); int x86_kvm_put_registers(CPUState *cpu, KvmPutState level, Error **errp); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index dbd4cfc7c7a..d877edaa5e8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -510,10 +510,10 @@ static int kvm_rebind_vcpus(Error **errp) } } =20 - ret =3D kvm_arch_init_vcpu(cpu); + ret =3D ops->init_vcpu(cpu); if (ret < 0) { error_setg_errno(errp, -ret, - "kvm_init_vcpu: kvm_arch_init_vcpu failed (%l= u)", + "kvm_init_vcpu: init_vcpu failed (%lu)", vcpu_id); } =20 @@ -760,10 +760,10 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) } } =20 - ret =3D kvm_arch_init_vcpu(cpu); + ret =3D ops->init_vcpu(cpu); if (ret < 0) { error_setg_errno(errp, -ret, - "kvm_init_vcpu: kvm_arch_init_vcpu failed (%lu)", + "kvm_init_vcpu: init_vcpu failed (%lu)", kvm_arch_vcpu_id(cpu)); } cpu->kvm_vcpu_stats_fd =3D kvm_vcpu_ioctl(cpu, KVM_GET_STATS_FD, NULL); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index da6c3e0b3d3..b62f40623c3 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1994,7 +1994,7 @@ static int kvm_arm_sve_set_vls(ARMCPU *cpu) =20 #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 =20 -int kvm_arch_init_vcpu(CPUState *cs) +static int arm_kvm_init_vcpu(CPUState *cs) { int ret; uint64_t mpidr; @@ -2656,6 +2656,7 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapa= bility *v3) } =20 static const KVMCPUOps arm_kvm_cpu_ops =3D { + .init_vcpu =3D arm_kvm_init_vcpu, .get_registers =3D arm_kvm_get_registers, .put_registers =3D arm_kvm_put_registers, .pre_run =3D arm_kvm_pre_run, diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index e2cf42a126e..6c547f204f8 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -236,6 +236,7 @@ static void kvm_cpu_instance_init(CPUState *cs) =20 static const KVMCPUOps x86_kvm_cpu_ops =3D { .pre_create_vcpu =3D x86_kvm_pre_create_vcpu, + .init_vcpu =3D x86_kvm_init_vcpu, .get_registers =3D x86_kvm_get_registers, .put_registers =3D x86_kvm_put_registers, .pre_run =3D x86_kvm_pre_run, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 1c53b62a1f7..46b7e497aaf 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2218,7 +2218,7 @@ static void kvm_init_pmu_info(struct kvm_cpuid2 *cpui= d, X86CPU *cpu) } } =20 -int kvm_arch_init_vcpu(CPUState *cs) +int x86_kvm_init_vcpu(CPUState *cs) { struct { struct kvm_cpuid2 cpuid; diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 54c26998979..d8f54a5526c 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -177,7 +177,7 @@ static void loongarch_set_lsx(Object *obj, bool value, = Error **errp) } =20 if (kvm_enabled()) { - /* kvm feature detection in function kvm_arch_init_vcpu */ + /* kvm feature detection in loongarch_kvm_init_vcpu */ return; } =20 @@ -213,7 +213,7 @@ static void loongarch_set_lasx(Object *obj, bool value,= Error **errp) } =20 if (kvm_enabled()) { - /* kvm feature detection in function kvm_arch_init_vcpu */ + /* kvm feature detection in loongarch_kvm_init_vcpu */ return; } =20 @@ -241,7 +241,7 @@ static void loongarch_set_msgint(Object *obj, bool valu= e, Error **errp) cpu->msgint =3D value ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; =20 if (kvm_enabled()) { - /* kvm feature detection in function kvm_arch_init_vcpu */ + /* kvm feature detection in loongarch_kvm_init_vcpu */ return; } =20 @@ -260,7 +260,7 @@ static void loongarch_set_ptw(Object *obj, bool value, = Error **errp) cpu->ptw =3D value ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; =20 if (kvm_enabled()) { - /* kvm feature detection in function kvm_arch_init_vcpu */ + /* kvm feature detection in loongarch_kvm_init_vcpu */ return; } =20 diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 9ce6e9e65b4..8f2ceb50a78 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1297,7 +1297,7 @@ static int kvm_cpu_check_misc_v1_1(CPUState *cs, Erro= r **errp) return 0; } =20 -int kvm_arch_init_vcpu(CPUState *cs) +static int loongarch_kvm_init_vcpu(CPUState *cs) { uint64_t val; int ret; @@ -1639,6 +1639,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps loongarch_kvm_cpu_ops =3D { + .init_vcpu =3D loongarch_kvm_init_vcpu, .get_registers =3D loongarch_kvm_get_registers, .put_registers =3D loongarch_kvm_put_registers, .handle_exit =3D loongarch_kvm_handle_exit, diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 8a2d2421dc2..075999b553a 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -480,7 +480,7 @@ static void kvmppc_hw_debug_points_init(CPUPPCState *ce= nv) } } =20 -int kvm_arch_init_vcpu(CPUState *cs) +static int ppc_kvm_init_vcpu(CPUState *cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *cenv =3D &cpu->env; @@ -3068,6 +3068,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps ppc_kvm_cpu_ops =3D { + .init_vcpu =3D ppc_kvm_init_vcpu, .get_registers =3D ppc_kvm_get_registers, .put_registers =3D ppc_kvm_put_registers, .handle_exit =3D ppc_kvm_handle_exit, diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index cef9d90c66f..b202882a155 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1579,7 +1579,7 @@ static int kvm_vcpu_enable_sbi_dbcn(RISCVCPU *cpu, CP= UState *cs) return kvm_set_one_reg(cs, kvm_sbi_dbcn.kvm_reg_id, ®); } =20 -int kvm_arch_init_vcpu(CPUState *cs) +static int riscv_kvm_init_vcpu(CPUState *cs) { int ret =3D 0; RISCVCPU *cpu =3D RISCV_CPU(cs); @@ -2179,6 +2179,7 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu, E= rror **errp) } =20 static const KVMCPUOps riscv_kvm_cpu_ops =3D { + .init_vcpu =3D riscv_kvm_init_vcpu, .get_registers =3D riscv_kvm_get_registers, .put_registers =3D riscv_kvm_put_registers, .handle_exit =3D riscv_kvm_handle_exit, diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 64020450dec..478b21a57fd 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -400,7 +400,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cpu) return cpu->cpu_index; } =20 -int kvm_arch_init_vcpu(CPUState *cs) +static int s390x_kvm_init_vcpu(CPUState *cs) { unsigned int max_cpus =3D MACHINE(qdev_get_machine())->smp.max_cpus; S390CPU *cpu =3D S390_CPU(cs); @@ -2646,6 +2646,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) } =20 static const KVMCPUOps s390x_kvm_cpu_ops =3D { + .init_vcpu =3D s390x_kvm_init_vcpu, .get_registers =3D s390x_kvm_get_registers, .put_registers =3D s390x_kvm_put_registers, .handle_exit =3D s390x_kvm_handle_exit, --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493134; cv=none; d=zohomail.com; s=zohoarc; b=hZAj+kwTXe4WmVd4k2ZDXLbf1ckqPNHGAZmvzNGYiuFnzHadlpTqc55hnN6HqA6hVS1Hb024Uy0u/H+ax1L1NglsVxLas0uSPcGGOLThekNd1zROLx8MWd6JbQ2DeLQurV6ZEwg/7K6jW+PHnF46qDcpFdCxqxdIlg78ulwEhNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493134; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QWwoMa4UZtGGfww2XLbb/N5Nn1L+rU0o0RKmqlS3tj4=; b=AtdANAUyHJNVf4rfOIOds+YquIUO+VNF0H9ZvLudgvs3VfINgC0pi5sKg+6u0fw+k5oeTFUKyGuYTi39H3IrevF+DVWLcOrBgESV9xPnWCg1Vs0WssvbB6x1sfLF+Rg6L+JJJ3bFUQdhy4RWB4YVGCMdiUT4LJb7w7KkUsyfoBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493134449687.9919409744666; Tue, 20 Oct 2026 03:45:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Kr-0005Qe-W1; Tue, 20 Oct 2026 06:44:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jv-0004Oy-E8 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:51 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Je-0004Qb-E9 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:51 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4a1f68a9855so2696505e9.1 for ; Tue, 20 Oct 2026 03:43:33 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d6dc034sm4931794f8f.3.2026.10.20.03.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id EF4CC5F915; Tue, 20 Oct 2026 11:43:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493013; x=1793097813; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=QWwoMa4UZtGGfww2XLbb/N5Nn1L+rU0o0RKmqlS3tj4=; b=Gtl+Fenq5PkQ6oQ9y7Gae84mP3bravru15XmPhTXQlnfmPvyLsput8ITkjrpZaMCqF YxJqZPejQ0+l8JrWxt5sc1e7P27zf/9rJ3HCmi38motSXkUMhQdWDrO+jNkdhXg8YelF 7iEOV2FcDMTDUVKYogATgnKOjc7Sm0H5Tnm8MmtI2lHy2IdkZqzuD+zrxyBDPmVLg7uZ 6B0GuDOd1XgsbDAETCspeOKNQakbpOs5OllHvg3MnPGxgm8/Da9kCPo8bIkeG2n8yU8a g6Ef8vu9dWdwHciQnXjiWfxcixi7gAL5x24HGHxWuJxO+bRcb3HZmJ7clSgDS9n8vhAM Mz5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493013; x=1793097813; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QWwoMa4UZtGGfww2XLbb/N5Nn1L+rU0o0RKmqlS3tj4=; b=PDXR1CXcrDBkd53274ncxpP5p4KSdIvRsYXa0K1WMsufUbYQTektMVeUtyFy1/eQbq S6SPs9z7hLOIqivt8wMW8rsnLLxQgNRwnLwUfFCIfn3fWDWljRd62pkICZpbI6pHyCWJ HGXN6KLEIvrlVD3OczjdFSnBjxl7M7b+FpwBWjy4fY8jnGBmhJ+30d4ctBXV7h/buSfW 29Q9l8pySkto6lsmzGahzSb7vkC3eCxQA8vO9CvMtCXHtNJUOH7dd5/6aFPKGA6F8ZEx U/qLZccuaZzneGW/Y8bevmSrOyopX1Ixz/nT/d2ppqDd6o5/7SB28jDDAAEUdp7tsiHR Lg+g== X-Gm-Message-State: AFq9FYI3uK4lfp01UD0cPVZBfqX/RpZaj/DmBvg2GoWej9R1sDPQ72mK MxOuTyknt/WvJmkoXiYkTZGKiILzCX7VIwoboTKMdcISGFJEDkB/2I34wLygl1QGW28= X-Gm-Gg: AYBFou0zG51vrtBbkMKNUMLUKTJV/QaYuKqmQ0BKYbCE0tsVd/b8WJT5ly+bLu/5UKc /dPEnfygVhF+oT4Iv3WfOZ8g3dUVKvVrqiGA6oBQoJidxBJtCwbfrz7odTFAwGrBmnY3ZCB5LD6 bNFS/3PCNuwNs2IGX/VHisuC+TyB1C+phSgGl1+1yIgdkAD+4w2nlM0us5fBfVd+M3gBe/oqmIo ty1CBAKjtBUk9nVhAxLVW18smtRRD64lV/rmrurDQOy4h5ctHxWybqlayxNrQHu00zxVI2iWqXk 4cq6X/u6ZZISqeEJp4D96K7SexKf55ifg+d+EqfZRAbS6FyqH84H4jhEd2N8JQ6U74Z1jXsSFwH 8Dx5osd9UpC1lrvGWGQLZ0ChziiaKyRHhv8ZMnbYQRJ9qP5R9+DG7ZOCzZHn31UnQzOVTIbSpD9 eTzcSdm9ndsB9Yul5+h280m3XLysPznotyf/jWGialwXMUjTVJS15R48z5keViQgm6/phrGBASA jc8UcL9 X-Received: by 2002:a05:600c:3547:b0:4a1:7c56:d4e2 with SMTP id 5b1f17b1804b1-4a1d7608dcemr216790035e9.16.1792493012821; Tue, 20 Oct 2026 03:43:32 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 15/23] accel/kvm: port kvm_arch_destroy_vcpu to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:09 +0100 Message-ID: <20261020104320.3686723-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493135917158500 Not every architecture was doing something here so we can make it an optional hook. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 6 ++++++ include/system/kvm.h | 2 -- target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 17 +++++++++++------ target/arm/kvm.c | 5 ----- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/kvm/kvm.c | 3 ++- target/ppc/kvm.c | 5 ----- target/riscv/kvm/kvm-cpu.c | 5 ----- target/s390x/kvm/kvm.c | 3 ++- 11 files changed, 24 insertions(+), 26 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index 23557a42ba7..171568e08cb 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -28,6 +28,11 @@ struct kvm_run; * @init_vcpu: Mandatory callback executed to perform architecture-specific * initialization of a newly created KVM vCPU. * Returns 0 on success, or a negative errno on failure. + * @destroy_vcpu: Optional callback executed when destroying a KVM vCPU + * (e.g. to free architecture-specific buffers or deregister + * state change handlers). + * May be NULL if no architecture-specific cleanup is requi= red. + * Returns 0 on success, or a negative errno on failure. * @get_registers: Mandatory callback to synchronize architecture-specific * vCPU register state from KVM into QEMU's CPUState. * Returns 0 on success, or a negative errno on failure. @@ -65,6 +70,7 @@ struct kvm_run; typedef struct KVMCPUOps { int (*pre_create_vcpu)(CPUState *cpu, Error **errp); int (*init_vcpu)(CPUState *cpu); + int (*destroy_vcpu)(CPUState *cpu); int (*get_registers)(CPUState *cpu, Error **errp); int (*put_registers)(CPUState *cpu, KvmPutState level, Error **errp); void (*pre_run)(CPUState *cpu, struct kvm_run *run); diff --git a/include/system/kvm.h b/include/system/kvm.h index a722f266dae..a66344cc70c 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -346,8 +346,6 @@ int kvm_arch_get_default_type(MachineState *ms); =20 int kvm_arch_init(MachineState *ms, KVMState *s); =20 -int kvm_arch_destroy_vcpu(CPUState *cpu); - #ifdef TARGET_KVM_HAVE_RESET_PARKED_VCPU void kvm_arch_reset_parked_vcpu(unsigned long vcpu_id, int kvm_fd); #else diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 8af5a9dc0ef..c7ffed75c1d 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -35,6 +35,7 @@ int kvm_get_vm_type(MachineState *ms); void kvm_arch_reset_vcpu(X86CPU *cs); int x86_kvm_pre_create_vcpu(CPUState *cpu, Error **errp); int x86_kvm_init_vcpu(CPUState *cs); +int x86_kvm_destroy_vcpu(CPUState *cs); int x86_kvm_get_registers(CPUState *cs, Error **errp); int x86_kvm_put_registers(CPUState *cpu, KvmPutState level, Error **errp); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index d877edaa5e8..69117271fa3 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -468,9 +468,11 @@ static int kvm_rebind_vcpus(Error **errp) close(cpu->kvm_fd); } =20 - ret =3D kvm_arch_destroy_vcpu(cpu); - if (ret < 0) { - goto err; + if (ops->destroy_vcpu) { + ret =3D ops->destroy_vcpu(cpu); + if (ret < 0) { + goto err; + } } =20 if (s->coalesced_mmio_ring =3D=3D (void *)cpu->kvm_run + PAGE_SIZE= ) { @@ -647,14 +649,17 @@ static int vcpu_unmap_regions(KVMState *s, CPUState *= cpu) =20 static int do_kvm_destroy_vcpu(CPUState *cpu) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); KVMState *s =3D kvm_state; int ret =3D 0; =20 trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); =20 - ret =3D kvm_arch_destroy_vcpu(cpu); - if (ret < 0) { - goto err; + if (ops->destroy_vcpu) { + ret =3D ops->destroy_vcpu(cpu); + if (ret < 0) { + goto err; + } } =20 /* If I am the CPU that created coalesced_mmio_ring, then discard it */ diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b62f40623c3..042a075e612 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2093,11 +2093,6 @@ static int arm_kvm_init_vcpu(CPUState *cs) return kvm_arm_init_cpreg_list(cpu); } =20 -int kvm_arch_destroy_vcpu(CPUState *cs) -{ - return 0; -} - /* Callers must hold the iothread mutex lock */ static void kvm_inject_arm_sea(CPUState *c) { diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 6c547f204f8..8d250b3a847 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -237,6 +237,7 @@ static void kvm_cpu_instance_init(CPUState *cs) static const KVMCPUOps x86_kvm_cpu_ops =3D { .pre_create_vcpu =3D x86_kvm_pre_create_vcpu, .init_vcpu =3D x86_kvm_init_vcpu, + .destroy_vcpu =3D x86_kvm_destroy_vcpu, .get_registers =3D x86_kvm_get_registers, .put_registers =3D x86_kvm_put_registers, .pre_run =3D x86_kvm_pre_run, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 46b7e497aaf..a8109004e43 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2533,7 +2533,7 @@ int x86_kvm_init_vcpu(CPUState *cs) return r; } =20 -int kvm_arch_destroy_vcpu(CPUState *cs) +int x86_kvm_destroy_vcpu(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 8f2ceb50a78..6705e6698bd 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1437,7 +1437,7 @@ void kvm_loongarch_cpu_post_init(LoongArchCPU *cpu) "Set off to disable KVM steal time."); } =20 -int kvm_arch_destroy_vcpu(CPUState *cs) +static int loongarch_kvm_destroy_vcpu(CPUState *cs) { LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); =20 @@ -1640,6 +1640,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) =20 static const KVMCPUOps loongarch_kvm_cpu_ops =3D { .init_vcpu =3D loongarch_kvm_init_vcpu, + .destroy_vcpu =3D loongarch_kvm_destroy_vcpu, .get_registers =3D loongarch_kvm_get_registers, .put_registers =3D loongarch_kvm_put_registers, .handle_exit =3D loongarch_kvm_handle_exit, diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 075999b553a..cb461963713 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -524,11 +524,6 @@ static int ppc_kvm_init_vcpu(CPUState *cs) return ret; } =20 -int kvm_arch_destroy_vcpu(CPUState *cs) -{ - return 0; -} - static void kvm_sw_tlb_put(PowerPCCPU *cpu) { CPUPPCState *env =3D &cpu->env; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index b202882a155..4247cbec3d9 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1512,11 +1512,6 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_= entry *route, return 0; } =20 -int kvm_arch_destroy_vcpu(CPUState *cs) -{ - return 0; -} - unsigned long kvm_arch_vcpu_id(CPUState *cpu) { return cpu->cpu_index; diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 478b21a57fd..0dcd198afe3 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -409,7 +409,7 @@ static int s390x_kvm_init_vcpu(CPUState *cs) return 0; } =20 -int kvm_arch_destroy_vcpu(CPUState *cs) +static int s390x_kvm_destroy_vcpu(CPUState *cs) { S390CPU *cpu =3D S390_CPU(cs); =20 @@ -2647,6 +2647,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) =20 static const KVMCPUOps s390x_kvm_cpu_ops =3D { .init_vcpu =3D s390x_kvm_init_vcpu, + .destroy_vcpu =3D s390x_kvm_destroy_vcpu, .get_registers =3D s390x_kvm_get_registers, .put_registers =3D s390x_kvm_put_registers, .handle_exit =3D s390x_kvm_handle_exit, --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493287; cv=none; d=zohomail.com; s=zohoarc; b=EK8IxcMNtW3Ltd9BeeiINebWwQqliN3pCUi9SmeCbADPfjl4GK6Wlie97dY1ESI1L1ec5e4vyWiTsjJUDExwQdU/tJn4PrqH8FYDdFdP3c5RTQvgtah6qSvShCXsTHhpsj2gYpJw0MLGrv49JwDN75UTM9//wtjbSZG2EX/ZoTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493287; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QZXTDRJaUlEs/ov0FqhQ2FdMdX9BrJqzlb9mQF9yfxI=; b=QVXzz9gs67Dl+ehDA8q69eLOUgezHqkbbS+/Dhgge1acRFBQNUQhRid6ogq44N8GtEXBN1OVrbjTMoTnv8+AaayurulvKpXx7iuxlqYqdssCoBhzB5dUsv919CxwOY526vrE8QV+V7xi9n+hFWVkMkvcmxpGyE9V3bRT3vRUzTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179249328747591.57216357254015; Tue, 20 Oct 2026 03:48:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7MB-0007Nj-D0; Tue, 20 Oct 2026 06:46:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7K0-0004V0-3N for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:56 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jg-0004Rl-Eo for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:55 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4a1ec92f655so6282515e9.0 for ; Tue, 20 Oct 2026 03:43:35 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d6db78csm5378092f8f.2.2026.10.20.03.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 41F505FD57; Tue, 20 Oct 2026 11:43:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493015; x=1793097815; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=QZXTDRJaUlEs/ov0FqhQ2FdMdX9BrJqzlb9mQF9yfxI=; b=LRpzp6HA50Ut63IU7a449SgV7z1jBxqsCxFDswflSC3v5yDS+AnDll/6JkVmUPsQ8a juM8Hpj5Wu+Q08Op6lhrseKMLYcaRLZY/322HH2OtIF0U4IGI/yRv9LoWuHTooJqNzIy EzpAFuetgaU58CdFNqwChZndD9fmZWuT1o/N0qpH7sZrYTETV7Z4GnB/Q43dqwTxRiZr +Z3PAJN0UbPvYOljSAbdjJttu0ecw/NDYE3krvXcMZGY94m0RDCWkUQl0BH6oamo7HP6 rJzGhK84p/q/7Epyg+fax5WRjHQZ8jfBmKUj5jdqyMLZ3lFWxkWin3mfCaHziJH2GVlq mEOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493015; x=1793097815; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QZXTDRJaUlEs/ov0FqhQ2FdMdX9BrJqzlb9mQF9yfxI=; b=130y7E+nslBBpW2PhLgOw7gSg2o4KB+JC7A74pKI1kmTWIBj3JXJsgtQM8BtReoUWC 4c8u8LECZb/kBHlNAg0/Y5ZEq/2opNGOkasO2yOOuUAKIcVL82zkVSSc0bUryW8/GxRf 4OYQjiMtFfnlU0fCXel/qrUnxMQCO7QZU1Nano4EobqaJ4hoo+UqS2fpGXUmFSp1NKC1 71cltVYHsOe/K+gx1vKCt0tjlFs9iJzHq3ZqpETrJSNvL/h0vAOTwNHrMcJqlpwPG9sz ErRAaXoP3sEToaUPVG0nL5XwqsEH2kAHEeDDgWDJFIYwT1Koq3J+CfJHbwRs+0hzuReW arAA== X-Gm-Message-State: AFq9FYIPrXB6e1bZg8PCRunUtIwbRHrF3vDZxBRqhCbnoOHIcuxFmu+Q pv/oqdUKBjZ/YDe8lILQtmCerytxChxfc4ocAvllm7ftsoRgoa6KM9UUnyWKAY0WKZY= X-Gm-Gg: AYBFou0b7A5jHmpjH/na6NAW98aCuqzU6E+5TE2zK0OEPcbYH4J44UD4bFGgeAJbD0Z C3oV8OuNAmxUDtPk6gIfWqz9oh8ik5QhC/B9LTutNE1JT9qhhuHfjO7NScrFm8C/nTvT16aXyjk okbKKNXucPxiebpR27qK00YDPrpCOr8nxL9i2FIeoC8lU3P6tyasRlA29Ueg9KO/05voaXD9yuw 6sXe2W87ta/xq0GXadf5+5u/KWbPRWhrUqbdrdWl2uP/VkCYUnvKGHsuC3fkrx2WcXLHIrkBQ1o epmYe3bTGPc5Ghw6SLufe1i+w9UOHhR0+2X0KeANixmLidAUYoTPPcEoQg3vIFnC5Z24FjetpRB nGiWULpV8dovomu7g8cZDiUVh1RMhyHH/0Elr4l9Q6fkLwhYJ39ulNsGP9UtFhxUGYSm6XxT0pP IkYf0yoNiIhrFgEqkS22wxjaEHC77sHw0hbmo9xaaBfczTsJ0avYXRiDJJ1rDRcrNu1P/fcA== X-Received: by 2002:a7b:cd99:0:b0:4a1:877b:d4e0 with SMTP id 5b1f17b1804b1-4a1f53bf67emr24825285e9.12.1792493014628; Tue, 20 Oct 2026 03:43:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 16/23] accel/kvm: port kvm_arch_vpcu_id to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:10 +0100 Message-ID: <20261020104320.3686723-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493288832158500 This is probably one of the messier conversions so far because it's a number that is used both by the generic KVM code but also the various target specific interrupt controllers where the direct linking is marginally beneficial. A bunch of the targets just treat cpu->cpu_index directly at the vcpu id so we take advantage of that default implementation with a common helper. **Q** is it worth in-lining the helper or indeed just finding to stash the value in CPUState? Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 6 ++++++ include/system/kvm.h | 2 +- target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 28 +++++++++++++++++++--------- hw/i386/kvm/xen_evtchn.c | 6 +++--- hw/intc/openpic_kvm.c | 4 ++-- hw/intc/spapr_xive_kvm.c | 10 +++++----- hw/intc/xics_kvm.c | 6 +++--- target/arm/kvm.c | 5 ----- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 4 ++-- target/loongarch/kvm/kvm.c | 5 ----- target/ppc/kvm.c | 3 ++- target/riscv/kvm/kvm-cpu.c | 7 +------ target/s390x/kvm/kvm.c | 5 ----- 15 files changed, 46 insertions(+), 47 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index 171568e08cb..be4031d9011 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -33,6 +33,11 @@ struct kvm_run; * state change handlers). * May be NULL if no architecture-specific cleanup is requi= red. * Returns 0 on success, or a negative errno on failure. + * @vcpu_id: Optional callback returning the architecture-specific KVM vCP= U ID + * to be passed to KVM_CREATE_VCPU and associated ioctls (such as + * the APIC ID on x86 or the PPC vcpu_id). + * May be NULL if the target uses cpu->cpu_index directly as the + * vCPU ID. * @get_registers: Mandatory callback to synchronize architecture-specific * vCPU register state from KVM into QEMU's CPUState. * Returns 0 on success, or a negative errno on failure. @@ -71,6 +76,7 @@ typedef struct KVMCPUOps { int (*pre_create_vcpu)(CPUState *cpu, Error **errp); int (*init_vcpu)(CPUState *cpu); int (*destroy_vcpu)(CPUState *cpu); + unsigned long (*vcpu_id)(CPUState *cpu); int (*get_registers)(CPUState *cpu, Error **errp); int (*put_registers)(CPUState *cpu, KvmPutState level, Error **errp); void (*pre_run)(CPUState *cpu, struct kvm_run *run); diff --git a/include/system/kvm.h b/include/system/kvm.h index a66344cc70c..2ecae10cdff 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -357,7 +357,7 @@ static inline void kvm_arch_reset_parked_vcpu(unsigned = long vcpu_id, int kvm_fd) bool kvm_vcpu_id_is_valid(int vcpu_id); =20 /* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */ -unsigned long kvm_arch_vcpu_id(CPUState *cpu); +unsigned long kvm_vcpu_id(CPUState *cpu); =20 void kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); =20 diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index c7ffed75c1d..f189bb92bb9 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -36,6 +36,7 @@ void kvm_arch_reset_vcpu(X86CPU *cs); int x86_kvm_pre_create_vcpu(CPUState *cpu, Error **errp); int x86_kvm_init_vcpu(CPUState *cs); int x86_kvm_destroy_vcpu(CPUState *cs); +unsigned long x86_kvm_vcpu_id(CPUState *cs); int x86_kvm_get_registers(CPUState *cs, Error **errp); int x86_kvm_put_registers(CPUState *cpu, KvmPutState level, Error **errp); void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 69117271fa3..f10d93a98df 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -452,6 +452,16 @@ static void kvm_create_vcpu_internal(CPUState *cpu, KV= MState *s, int kvm_fd) return; } =20 +unsigned long kvm_vcpu_id(CPUState *cpu) +{ + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); + + if (ops && ops->vcpu_id) { + return ops->vcpu_id(cpu); + } + return cpu->cpu_index; +} + static int kvm_rebind_vcpus(Error **errp) { CPUState *cpu; @@ -462,7 +472,7 @@ static int kvm_rebind_vcpus(Error **errp) CPU_FOREACH(cpu) { const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); =20 - vcpu_id =3D kvm_arch_vcpu_id(cpu); + vcpu_id =3D kvm_vcpu_id(cpu); =20 if (cpu->kvm_fd) { close(cpu->kvm_fd); @@ -533,10 +543,10 @@ static void kvm_park_vcpu(CPUState *cpu) { struct KVMParkedVcpu *vcpu; =20 - trace_kvm_park_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); + trace_kvm_park_vcpu(cpu->cpu_index, kvm_vcpu_id(cpu)); =20 vcpu =3D g_malloc0(sizeof(*vcpu)); - vcpu->vcpu_id =3D kvm_arch_vcpu_id(cpu); + vcpu->vcpu_id =3D kvm_vcpu_id(cpu); vcpu->kvm_fd =3D cpu->kvm_fd; QLIST_INSERT_HEAD(&kvm_state->kvm_parked_vcpus, vcpu, node); } @@ -577,7 +587,7 @@ static void kvm_reset_parked_vcpus(KVMState *s) */ static int kvm_create_vcpu(CPUState *cpu) { - unsigned long vcpu_id =3D kvm_arch_vcpu_id(cpu); + unsigned long vcpu_id =3D kvm_vcpu_id(cpu); KVMState *s =3D kvm_state; int kvm_fd; =20 @@ -653,7 +663,7 @@ static int do_kvm_destroy_vcpu(CPUState *cpu) KVMState *s =3D kvm_state; int ret =3D 0; =20 - trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); + trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_vcpu_id(cpu)); =20 if (ops->destroy_vcpu) { ret =3D ops->destroy_vcpu(cpu); @@ -702,7 +712,7 @@ static int map_kvm_run(KVMState *s, CPUState *cpu, Erro= r **errp) ret =3D -errno; error_setg_errno(errp, ret, "kvm_init_vcpu: mmap'ing vcpu state failed (%lu)", - kvm_arch_vcpu_id(cpu)); + kvm_vcpu_id(cpu)); goto err; } =20 @@ -736,7 +746,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) KVMState *s =3D kvm_state; int ret; =20 - trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); + trace_kvm_init_vcpu(cpu->cpu_index, kvm_vcpu_id(cpu)); =20 if (ops->pre_create_vcpu) { ret =3D ops->pre_create_vcpu(cpu, errp); @@ -749,7 +759,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) if (ret < 0) { error_setg_errno(errp, -ret, "kvm_init_vcpu: kvm_create_vcpu failed (%lu)", - kvm_arch_vcpu_id(cpu)); + kvm_vcpu_id(cpu)); goto err; } =20 @@ -769,7 +779,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) if (ret < 0) { error_setg_errno(errp, -ret, "kvm_init_vcpu: init_vcpu failed (%lu)", - kvm_arch_vcpu_id(cpu)); + kvm_vcpu_id(cpu)); } cpu->kvm_vcpu_stats_fd =3D kvm_vcpu_ioctl(cpu, KVM_GET_STATS_FD, NULL); =20 diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index 9379383e532..98630563b6b 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -575,7 +575,7 @@ static int assign_kernel_port(uint16_t type, evtchn_por= t_t port, ha.u.evtchn.type =3D type; ha.u.evtchn.flags =3D 0; ha.u.evtchn.deliver.port.port =3D port; - ha.u.evtchn.deliver.port.vcpu =3D kvm_arch_vcpu_id(cpu); + ha.u.evtchn.deliver.port.vcpu =3D kvm_vcpu_id(cpu); ha.u.evtchn.deliver.port.priority =3D KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_= 2LEVEL; =20 return kvm_vm_ioctl(kvm_state, KVM_XEN_HVM_SET_ATTR, &ha); @@ -937,7 +937,7 @@ static int set_port_pending(XenEvtchnState *s, evtchn_p= ort_t port) } =20 evt.port =3D port; - evt.vcpu =3D kvm_arch_vcpu_id(cpu); + evt.vcpu =3D kvm_vcpu_id(cpu); evt.priority =3D KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL; =20 return kvm_vm_ioctl(kvm_state, KVM_XEN_HVM_EVTCHN_SEND, &evt); @@ -1815,7 +1815,7 @@ int xen_evtchn_translate_pirq_msi(struct kvm_irq_rout= ing_entry *route, =20 route->type =3D KVM_IRQ_ROUTING_XEN_EVTCHN; route->u.xen_evtchn.port =3D port; - route->u.xen_evtchn.vcpu =3D kvm_arch_vcpu_id(cpu); + route->u.xen_evtchn.vcpu =3D kvm_vcpu_id(cpu); route->u.xen_evtchn.priority =3D KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVE= L; =20 return 0; /* Handled */ diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c index b099da20eb9..4131292b02b 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -188,7 +188,7 @@ static int kvm_openpic_handle_vmfd_change(NotifierWithR= eturn *notifier, =20 CPU_FOREACH(cs) { ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_MPIC, 0, opp->fd, - kvm_arch_vcpu_id(cs)); + kvm_vcpu_id(cs)); if (ret < 0) { return ret; } @@ -322,7 +322,7 @@ int kvm_openpic_connect_vcpu(DeviceState *d, CPUState *= cs) KVMOpenPICState *opp =3D KVM_OPENPIC(d); =20 return kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_MPIC, 0, opp->fd, - kvm_arch_vcpu_id(cs)); + kvm_vcpu_id(cs)); } =20 static const Property kvm_openpic_properties[] =3D { diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 26d30b41c15..9cbe536cc7c 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -40,7 +40,7 @@ static QLIST_HEAD(, KVMEnabledCPU) static bool kvm_cpu_is_enabled(CPUState *cs) { KVMEnabledCPU *enabled_cpu; - unsigned long vcpu_id =3D kvm_arch_vcpu_id(cs); + unsigned long vcpu_id =3D kvm_vcpu_id(cs); =20 QLIST_FOREACH(enabled_cpu, &kvm_enabled_cpus, node) { if (enabled_cpu->vcpu_id =3D=3D vcpu_id) { @@ -53,7 +53,7 @@ static bool kvm_cpu_is_enabled(CPUState *cs) static void kvm_cpu_enable(CPUState *cs) { KVMEnabledCPU *enabled_cpu; - unsigned long vcpu_id =3D kvm_arch_vcpu_id(cs); + unsigned long vcpu_id =3D kvm_vcpu_id(cs); =20 enabled_cpu =3D g_malloc(sizeof(*enabled_cpu)); enabled_cpu->vcpu_id =3D vcpu_id; @@ -89,7 +89,7 @@ int kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **err= p) if (ret !=3D 0) { error_setg_errno(errp, -ret, "XIVE: could not restore KVM state of CPU %ld", - kvm_arch_vcpu_id(tctx->cs)); + kvm_vcpu_id(tctx->cs)); return ret; } =20 @@ -108,7 +108,7 @@ int kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **e= rrp) if (ret !=3D 0) { error_setg_errno(errp, -ret, "XIVE: could not capture KVM state of CPU %ld", - kvm_arch_vcpu_id(tctx->cs)); + kvm_vcpu_id(tctx->cs)); return ret; } =20 @@ -162,7 +162,7 @@ int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **err= p) return 0; } =20 - vcpu_id =3D kvm_arch_vcpu_id(tctx->cs); + vcpu_id =3D kvm_vcpu_id(tctx->cs); =20 trace_kvm_xive_cpu_connect(vcpu_id); =20 diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 61f66d1019d..fb16f628eca 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -80,7 +80,7 @@ void icp_get_kvm_state(ICPState *icp) ret =3D kvm_get_one_reg(icp->cs, KVM_REG_PPC_ICP_STATE, &state); if (ret !=3D 0) { error_report("Unable to retrieve KVM interrupt controller state" - " for CPU %ld: %s", kvm_arch_vcpu_id(icp->cs), strerror(er= rno)); + " for CPU %ld: %s", kvm_vcpu_id(icp->cs), strerror(errno)); exit(1); } =20 @@ -127,7 +127,7 @@ int icp_set_kvm_state(ICPState *icp, Error **errp) error_setg_errno(errp, -ret, "Unable to restore KVM interrupt controller state= (0x%" PRIx64 ") for CPU %ld", state, - kvm_arch_vcpu_id(icp->cs)); + kvm_vcpu_id(icp->cs)); return ret; } =20 @@ -148,7 +148,7 @@ void icp_kvm_realize(DeviceState *dev, Error **errp) } =20 cs =3D icp->cs; - vcpu_id =3D kvm_arch_vcpu_id(cs); + vcpu_id =3D kvm_vcpu_id(cs); =20 /* * If we are reusing a parked vCPU fd corresponding to the CPU diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 042a075e612..ad8166e0b41 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -708,11 +708,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return 0; } =20 -unsigned long kvm_arch_vcpu_id(CPUState *cpu) -{ - return cpu->cpu_index; -} - /* We track all the KVM devices which need their memory addresses * passing to the kernel in a list of these structures. * When board init is complete we run through the list and diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 8d250b3a847..6990cd8d5c4 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -238,6 +238,7 @@ static const KVMCPUOps x86_kvm_cpu_ops =3D { .pre_create_vcpu =3D x86_kvm_pre_create_vcpu, .init_vcpu =3D x86_kvm_init_vcpu, .destroy_vcpu =3D x86_kvm_destroy_vcpu, + .vcpu_id =3D x86_kvm_vcpu_id, .get_registers =3D x86_kvm_get_registers, .put_registers =3D x86_kvm_put_registers, .pre_run =3D x86_kvm_pre_run, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a8109004e43..a3076d43b45 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -862,7 +862,7 @@ static void cpu_update_state(void *opaque, bool running= , RunState state) } } =20 -unsigned long kvm_arch_vcpu_id(CPUState *cs) +unsigned long x86_kvm_vcpu_id(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); return cpu->apic_id; @@ -3046,7 +3046,7 @@ static void *kvm_msr_energy_thread(void *data) thd_stat[i].is_vcpu =3D true; thd_stat[i].vcpu_id =3D cpu->cpu_index; pkg_stat[thd_stat[i].pkg_id].nb_vcpu++; - thd_stat[i].acpi_id =3D kvm_arch_vcpu_id(cpu); + thd_stat[i].acpi_id =3D kvm_vcpu_id(cpu); break; } } diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 6705e6698bd..97b6b448edf 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1445,11 +1445,6 @@ static int loongarch_kvm_destroy_vcpu(CPUState *cs) return 0; } =20 -unsigned long kvm_arch_vcpu_id(CPUState *cs) -{ - return cs->cpu_index; -} - int kvm_arch_release_virq_post(int virq) { return 0; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index cb461963713..ffc7a33bf17 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -443,7 +443,7 @@ void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) } #endif /* !defined (TARGET_PPC64) */ =20 -unsigned long kvm_arch_vcpu_id(CPUState *cpu) +static unsigned long ppc_kvm_vcpu_id(CPUState *cpu) { return POWERPC_CPU(cpu)->vcpu_id; } @@ -3064,6 +3064,7 @@ void kvm_arch_accel_class_init(ObjectClass *oc) =20 static const KVMCPUOps ppc_kvm_cpu_ops =3D { .init_vcpu =3D ppc_kvm_init_vcpu, + .vcpu_id =3D ppc_kvm_vcpu_id, .get_registers =3D ppc_kvm_get_registers, .put_registers =3D ppc_kvm_put_registers, .handle_exit =3D ppc_kvm_handle_exit, diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 4247cbec3d9..d9984828048 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1512,11 +1512,6 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_= entry *route, return 0; } =20 -unsigned long kvm_arch_vcpu_id(CPUState *cpu) -{ - return cpu->cpu_index; -} - static void kvm_riscv_vm_state_change(void *opaque, bool running, RunState state) { @@ -1806,7 +1801,7 @@ void kvm_riscv_reset_vcpu(RISCVCPU *cpu) env->gpr[i] =3D 0; } env->pc =3D cpu->env.kernel_addr; - env->gpr[10] =3D kvm_arch_vcpu_id(CPU(cpu)); /* a0 */ + env->gpr[10] =3D kvm_vcpu_id(CPU(cpu)); /* a0 */ env->gpr[11] =3D cpu->env.fdt_addr; /* a1 */ =20 kvm_riscv_reset_regs_csr(env); diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 0dcd198afe3..7400fe41f87 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -395,11 +395,6 @@ int kvm_arch_irqchip_create(KVMState *s) return 0; } =20 -unsigned long kvm_arch_vcpu_id(CPUState *cpu) -{ - return cpu->cpu_index; -} - static int s390x_kvm_init_vcpu(CPUState *cs) { unsigned int max_cpus =3D MACHINE(qdev_get_machine())->smp.max_cpus; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493143; cv=none; d=zohomail.com; s=zohoarc; b=VlKF2Cz3PlOprVvge7RJhT1ElivAz9I18LT14B+THHjy6/8y+H9+CcRex6eVo4TrXKoCNdyHP1O1pwZNFJtuviSF65Tv6Q7GAUTnyfXaJpmrXrcmuJAvT0sZ4GmdsW+iwimdG7//E8xtxlgNryGuoKj3R/ZyoXDoa50LYVP7mgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493143; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BSBV/g6ALpQ14y7y92FmMnIwbYri89hzMlxCn9KKLwg=; b=Pzot42Fd+E3sm95z7YTl4sYbmXBIGVFKxxdePxdRLtMTH67X9ILXt4uUaU/uqZPEqsYA1OuYudoYC7MEg2SJNXIoWjbk34MwyMOqLg0V3ZQXaoQOtKSfKUZas2bj9eWFXzDgdYqWCMPoVizwI+uPCdTZrBgQYTMNL51I/gJQJok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17924931432273.8731548416370742; Tue, 20 Oct 2026 03:45:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7Kp-0005KT-Ro; Tue, 20 Oct 2026 06:44:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Jy-0004Qr-7Y for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:54 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jf-0004RO-Pc for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:53 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4a018dc1f98so21975375e9.3 for ; Tue, 20 Oct 2026 03:43:35 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d830e91sm5425066f8f.54.2026.10.20.03.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7E0E15F8DC; Tue, 20 Oct 2026 11:43:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493014; x=1793097814; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=BSBV/g6ALpQ14y7y92FmMnIwbYri89hzMlxCn9KKLwg=; b=EN8IUvj3UCHggYEy1wvBuXQOwcF6CO3je86+SnlK+Pn9tLPisfoO/tQDwUzNvSVgil xdrHuakjMyLWXyl+mvGrIzQ9PB6VU1q5QvoOBiGMkqgrKubkv7sOfih/mktrcGA7Cpp/ +TIv0NAC5bEXto9n6y2MF31QjXN4hPCgpNsbiVR4U4Okvc7h0CYKRZPCOOxxRMd0ybRa O7Or3rQyrlkGQc82i2s7cNOE5tweHZv/rGFEjptp4q8gpWP1ZJL3D/UqCTVw4HyXxuc/ tkceQakHNhjTmW/VU39e8TlEQwGgQ+YS7tZshK7uXz0OXc5OdY8woyVc/vkpf0au0ZEb rcWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493014; x=1793097814; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BSBV/g6ALpQ14y7y92FmMnIwbYri89hzMlxCn9KKLwg=; b=L0WvciV68Q2lSg45gGw1fBqXO/YOCTpb3lk39/RABf7bEhFHv7HVuSPSXvP0l15ncC T3CPgQwMIhUuLWRMUli85uNmzmQaZvnmYdox6HzwBp2FaFqoMXZ65z3f/bOj7TVjBEMm Ey8wqDWG7L20IZsSGa0gps3lIoyFrPACxrROqhDTjg2upNw8dSojM/bq4Ivpgxdip355 qUaHr2zgF1z32+BxAWGXw1P00fXkDPBg8Tdx7z4m/t/4cjIDC/mJIYwdULACjR0fH1Yb YGeMQ9DSWlPbfGQCUXw9O4ryEAHE/UML6IiMpjhu/wMptaxwflA0poKrIEnr94Db5Ivq idtA== X-Gm-Message-State: AFq9FYKugDWt2GbZfiqRVVimXiRZLZldIj6chwhyAyoGGR5V27vhwqz0 ecLI1oKA6djMxUu/PUu9SsvdwrWa43UyGrjsbqTC+YMOw4KwLdVNbZ8JACTmRKa5ScA= X-Gm-Gg: AYBFou1yo4wEaOcGIMI2rhAav8tsv9eRMsVaUK8dJlysCqfygE7COp//cSihOC93A4R weDOyDzjOIKY9p0C7hpQ5kAFDmJzSf/qSs7THlgqpp9+pOLU5RVMJuXETemhzW2FjxJJwhKmkx8 nCOoZsPHDp7BIXL8f3PkPf2bs4f4P3Gwu4zHV5Ub6yJxl4nsWGuBInXBeIHijZnLGFnzquKaO4A uZEimUkipVov89nVUD4ZfzWQ04AqruXbFW+qGsH1xhHjKm263+CGVQKdslEVjtSsUcjdYNTkLXE A5mwk61IEqgsr7qXrdg+fu6O/Npzj+3uriAn3J4JHr/dnxzw9PlLxM1fqHKVe8CK4WmQEX4rDOF SwMSGRDtCRHYl8G/UmGNYgWAiiDh7yBn6wCmhM6N/HKgmhWhhbbRJQbJHKW3Dw0szYK9IFOIkN8 SWKXGSOPJTOo6xp04wItxAKiCiPeQL21Gi8Zh/e2csgwpFWGFiaa6yX3MHZckl28a3gC1JRA== X-Received: by 2002:a05:600c:8b6f:b0:4a1:ce33:1536 with SMTP id 5b1f17b1804b1-4a1d75e37ecmr193768375e9.9.1792493013721; Tue, 20 Oct 2026 03:43:33 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 17/23] accel/kvm: port kvm_arch_update_guest_debug to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:11 +0100 Message-ID: <20261020104320.3686723-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493144098158500 As well as sw breakpoints. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 17 +++++++++++++++++ include/system/kvm.h | 8 +------- target/i386/kvm/kvm_i386.h | 3 +++ accel/kvm/kvm-all.c | 34 +++++++++++++++++++++++++++++----- target/arm/kvm.c | 12 +++++++++--- target/i386/kvm/kvm-cpu.c | 3 +++ target/i386/kvm/kvm.c | 6 +++--- target/loongarch/kvm/kvm.c | 12 +++++++++--- target/ppc/kvm.c | 12 +++++++++--- target/riscv/kvm/kvm-cpu.c | 19 ++++++++++++++++--- target/s390x/kvm/kvm.c | 12 +++++++++--- 11 files changed, 108 insertions(+), 30 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index be4031d9011..d2374e91cef 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -71,6 +71,20 @@ struct kvm_run; * return EXCP_HLT, or 0 if execution can proceed. * May be NULL if the target does not require event * processing before execution. + * @update_guest_debug: Optional callback executed when updating KVM guest + * debug structures for the vCPU. Used to configure + * architecture-specific debug control flags and hard= ware + * or software breakpoint descriptors in @dbg. + * May be NULL if the target does not require + * architecture-specific guest debug setup. + * @insert_sw_breakpoint: Optional callback to insert an architecture-spec= ific + * software breakpoint instruction at @bp->pc and s= ave + * the overwritten instruction in @bp->saved_insn. + * Returns 0 on success, or a negative errno on fai= lure. + * @remove_sw_breakpoint: Optional callback to remove an architecture-spec= ific + * software breakpoint, restoring @bp->saved_insn at + * @bp->pc. + * Returns 0 on success, or a negative errno on fai= lure. */ typedef struct KVMCPUOps { int (*pre_create_vcpu)(CPUState *cpu, Error **errp); @@ -83,6 +97,9 @@ typedef struct KVMCPUOps { MemTxAttrs (*post_run)(CPUState *cpu, struct kvm_run *run); int (*handle_exit)(CPUState *cpu, struct kvm_run *run); int (*process_async_events)(CPUState *cpu); + void (*update_guest_debug)(CPUState *cpu, struct kvm_guest_debug *dbg); + int (*insert_sw_breakpoint)(CPUState *cpu, struct kvm_sw_breakpoint *b= p); + int (*remove_sw_breakpoint)(CPUState *cpu, struct kvm_sw_breakpoint *b= p); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" diff --git a/include/system/kvm.h b/include/system/kvm.h index 2ecae10cdff..52b7a63a0b3 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -229,7 +229,7 @@ void kvm_irqchip_change_notify(void); * @reinject_trap: KVM trap injection control * * There are usually per-arch specifics which will be handled by - * calling down to kvm_arch_update_guest_debug after the generic + * calling down to the KVMCPUOps::update_guest_debug callback after the ge= neric * fields have been set. */ #ifdef TARGET_KVM_HAVE_GUEST_DEBUG @@ -394,18 +394,12 @@ struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUS= tate *cpu, =20 int kvm_sw_breakpoints_active(CPUState *cpu); =20 -int kvm_arch_insert_sw_breakpoint(CPUState *cpu, - struct kvm_sw_breakpoint *bp); -int kvm_arch_remove_sw_breakpoint(CPUState *cpu, - struct kvm_sw_breakpoint *bp); int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, GdbBreakpointType type); int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, GdbBreakpointType type); void kvm_arch_remove_all_gdbstub_hw_breakpoints(void); =20 -void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *db= g); - bool kvm_arch_stop_on_emulation_error(CPUState *cpu); =20 int kvm_vm_check_extension(KVMState *s, unsigned int extension); diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index f189bb92bb9..27eea1f65ff 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -43,6 +43,9 @@ void x86_kvm_pre_run(CPUState *cpu, struct kvm_run *run); MemTxAttrs x86_kvm_post_run(CPUState *cpu, struct kvm_run *run); int x86_kvm_handle_exit(CPUState *cs, struct kvm_run *run); int x86_kvm_process_async_events(CPUState *cs); +void x86_kvm_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg= ); +int x86_kvm_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *b= p); +int x86_kvm_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *b= p); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f10d93a98df..24ded4b1804 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3866,6 +3866,7 @@ static void kvm_invoke_set_guest_debug(CPUState *cpu,= run_on_cpu_data data) =20 int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); struct kvm_set_guest_debug_data data; =20 data.dbg.control =3D reinject_trap; @@ -3877,7 +3878,9 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned lo= ng reinject_trap) data.dbg.control |=3D KVM_GUESTDBG_BLOCKIRQ; } } - kvm_arch_update_guest_debug(cpu, &data.dbg); + if (ops && ops->update_guest_debug) { + ops->update_guest_debug(cpu, &data.dbg); + } =20 run_on_cpu(cpu, kvm_invoke_set_guest_debug, RUN_ON_CPU_HOST_PTR(&data)); @@ -3891,16 +3894,22 @@ int kvm_insert_gdbstub_breakpoint(CPUState *cpu, Gd= bBreakpointType type, int err; =20 if (type =3D=3D GDB_BREAKPOINT_SW) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); + bp =3D kvm_find_sw_breakpoint(cpu, addr); if (bp) { bp->use_count++; return 0; } =20 + if (!ops || !ops->insert_sw_breakpoint) { + return -ENOSYS; + } + bp =3D g_new(struct kvm_sw_breakpoint, 1); bp->pc =3D addr; bp->use_count =3D 1; - err =3D kvm_arch_insert_sw_breakpoint(cpu, bp); + err =3D ops->insert_sw_breakpoint(cpu, bp); if (err) { g_free(bp); return err; @@ -3930,6 +3939,8 @@ int kvm_remove_gdbstub_breakpoint(CPUState *cpu, GdbB= reakpointType type, int err; =20 if (type =3D=3D GDB_BREAKPOINT_SW) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); + bp =3D kvm_find_sw_breakpoint(cpu, addr); if (!bp) { return -ENOENT; @@ -3940,7 +3951,11 @@ int kvm_remove_gdbstub_breakpoint(CPUState *cpu, Gdb= BreakpointType type, return 0; } =20 - err =3D kvm_arch_remove_sw_breakpoint(cpu, bp); + if (!ops || !ops->remove_sw_breakpoint) { + return -ENOSYS; + } + + err =3D ops->remove_sw_breakpoint(cpu, bp); if (err) { return err; } @@ -3965,15 +3980,24 @@ int kvm_remove_gdbstub_breakpoint(CPUState *cpu, Gd= bBreakpointType type, =20 void kvm_remove_all_gdbstub_breakpoints(CPUState *cpu) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); struct kvm_sw_breakpoint *bp, *next; KVMState *s =3D cpu->kvm_state; CPUState *tmpcpu; =20 QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { - if (kvm_arch_remove_sw_breakpoint(cpu, bp) !=3D 0) { + int ret =3D -ENOENT; + + if (ops && ops->remove_sw_breakpoint) { + ret =3D ops->remove_sw_breakpoint(cpu, bp); + } + if (ret !=3D 0) { /* Try harder to find a CPU that currently sees the breakpoint= . */ CPU_FOREACH(tmpcpu) { - if (kvm_arch_remove_sw_breakpoint(tmpcpu, bp) =3D=3D 0) { + const KVMCPUOps *tmpops =3D kvm_get_cpu_ops(tmpcpu); + + if (tmpops && tmpops->remove_sw_breakpoint && + tmpops->remove_sw_breakpoint(tmpcpu, bp) =3D=3D 0) { break; } } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ad8166e0b41..a4f063f2efb 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1649,7 +1649,8 @@ static void kvm_arm_copy_hw_debug_data(struct kvm_gue= st_debug_arch *ptr) } } =20 -void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) +static void arm_kvm_update_guest_debug(CPUState *cs, + struct kvm_guest_debug *dbg) { if (kvm_sw_breakpoints_active(cs)) { dbg->control |=3D KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP; @@ -2538,7 +2539,8 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) /* C6.6.29 BRK instruction */ static const uint32_t brk_insn =3D 0xd4200000; =20 -int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int arm_kvm_insert_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) = || cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) { @@ -2547,7 +2549,8 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struc= t kvm_sw_breakpoint *bp) return 0; } =20 -int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int arm_kvm_remove_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { static uint32_t brk; =20 @@ -2652,6 +2655,9 @@ static const KVMCPUOps arm_kvm_cpu_ops =3D { .pre_run =3D arm_kvm_pre_run, .post_run =3D arm_kvm_post_run, .handle_exit =3D arm_kvm_handle_exit, + .update_guest_debug =3D arm_kvm_update_guest_debug, + .insert_sw_breakpoint =3D arm_kvm_insert_sw_breakpoint, + .remove_sw_breakpoint =3D arm_kvm_remove_sw_breakpoint, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 6990cd8d5c4..0cd0884be30 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -245,6 +245,9 @@ static const KVMCPUOps x86_kvm_cpu_ops =3D { .post_run =3D x86_kvm_post_run, .handle_exit =3D x86_kvm_handle_exit, .process_async_events =3D x86_kvm_process_async_events, + .update_guest_debug =3D x86_kvm_update_guest_debug, + .insert_sw_breakpoint =3D x86_kvm_insert_sw_breakpoint, + .remove_sw_breakpoint =3D x86_kvm_remove_sw_breakpoint, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a3076d43b45..4ee7f53c2a8 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6128,7 +6128,7 @@ static int kvm_handle_tpr_access(X86CPU *cpu) return 1; } =20 -int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +int x86_kvm_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *b= p) { static const uint8_t int3 =3D 0xcc; =20 @@ -6139,7 +6139,7 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struc= t kvm_sw_breakpoint *bp) return 0; } =20 -int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +int x86_kvm_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *b= p) { uint8_t int3; =20 @@ -6292,7 +6292,7 @@ static int kvm_handle_debug(X86CPU *cpu, return ret; } =20 -void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *db= g) +void x86_kvm_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg) { const uint8_t type_code[] =3D { [GDB_BREAKPOINT_HW] =3D 0x0, diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 97b6b448edf..0899aef552e 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1518,14 +1518,16 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cs) return true; } =20 -void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *db= g) +static void loongarch_kvm_update_guest_debug(CPUState *cpu, + struct kvm_guest_debug *dbg) { if (kvm_sw_breakpoints_active(cpu)) { dbg->control |=3D KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP; } } =20 -int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int loongarch_kvm_insert_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) = || cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) { @@ -1535,7 +1537,8 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struc= t kvm_sw_breakpoint *bp) return 0; } =20 -int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int loongarch_kvm_remove_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { static uint32_t brk; =20 @@ -1640,6 +1643,9 @@ static const KVMCPUOps loongarch_kvm_cpu_ops =3D { .put_registers =3D loongarch_kvm_put_registers, .handle_exit =3D loongarch_kvm_handle_exit, .process_async_events =3D loongarch_kvm_process_async_events, + .update_guest_debug =3D loongarch_kvm_update_guest_debug, + .insert_sw_breakpoint =3D loongarch_kvm_insert_sw_breakpoint, + .remove_sw_breakpoint =3D loongarch_kvm_remove_sw_breakpoint, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index ffc7a33bf17..4b2e42ef163 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1366,7 +1366,8 @@ static int kvmppc_handle_dcr_write(CPUPPCState *env, return 0; } =20 -int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int ppc_kvm_insert_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { /* Mixed endian case is not handled */ uint32_t sc =3D debug_inst_opcode; @@ -1380,7 +1381,8 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struc= t kvm_sw_breakpoint *bp) return 0; } =20 -int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int ppc_kvm_remove_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { uint32_t sc; =20 @@ -1515,7 +1517,8 @@ void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) nb_hw_breakpoint =3D nb_hw_watchpoint =3D 0; } =20 -void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) +static void ppc_kvm_update_guest_debug(CPUState *cs, + struct kvm_guest_debug *dbg) { int n; =20 @@ -3069,6 +3072,9 @@ static const KVMCPUOps ppc_kvm_cpu_ops =3D { .put_registers =3D ppc_kvm_put_registers, .handle_exit =3D ppc_kvm_handle_exit, .process_async_events =3D ppc_kvm_process_async_events, + .update_guest_debug =3D ppc_kvm_update_guest_debug, + .insert_sw_breakpoint =3D ppc_kvm_insert_sw_breakpoint, + .remove_sw_breakpoint =3D ppc_kvm_remove_sw_breakpoint, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index d9984828048..8a82160a7bf 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -2168,11 +2168,21 @@ void riscv_kvm_cpu_finalize_features(RISCVCPU *cpu,= Error **errp) kvm_riscv_destroy_scratch_vcpu(&kvmcpu); } =20 +static int riscv_kvm_insert_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp); +static int riscv_kvm_remove_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp); +static void riscv_kvm_update_guest_debug(CPUState *cs, + struct kvm_guest_debug *dbg); + static const KVMCPUOps riscv_kvm_cpu_ops =3D { .init_vcpu =3D riscv_kvm_init_vcpu, .get_registers =3D riscv_kvm_get_registers, .put_registers =3D riscv_kvm_put_registers, .handle_exit =3D riscv_kvm_handle_exit, + .update_guest_debug =3D riscv_kvm_update_guest_debug, + .insert_sw_breakpoint =3D riscv_kvm_insert_sw_breakpoint, + .remove_sw_breakpoint =3D riscv_kvm_remove_sw_breakpoint, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) @@ -2225,7 +2235,8 @@ DEFINE_TYPES(riscv_kvm_cpu_type_infos) static const uint32_t ebreak_insn =3D 0x00100073; static const uint16_t c_ebreak_insn =3D 0x9002; =20 -int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int riscv_kvm_insert_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 2, 0))= { return -EINVAL; @@ -2245,7 +2256,8 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struc= t kvm_sw_breakpoint *bp) return 0; } =20 -int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int riscv_kvm_remove_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { uint32_t ebreak; uint16_t c_ebreak; @@ -2286,7 +2298,8 @@ void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) /* TODO; To be implemented later. */ } =20 -void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) +static void riscv_kvm_update_guest_debug(CPUState *cs, + struct kvm_guest_debug *dbg) { if (kvm_sw_breakpoints_active(cs)) { dbg->control |=3D KVM_GUESTDBG_ENABLE; diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 7400fe41f87..12695376442 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -825,7 +825,8 @@ static void determine_sw_breakpoint_instr(void) } } =20 -int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int s390x_kvm_insert_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { determine_sw_breakpoint_instr(); =20 @@ -837,7 +838,8 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct = kvm_sw_breakpoint *bp) return 0; } =20 -int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +static int s390x_kvm_remove_sw_breakpoint(CPUState *cs, + struct kvm_sw_breakpoint *bp) { uint8_t t[MAX_ILEN]; =20 @@ -956,7 +958,8 @@ void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) hw_breakpoints =3D NULL; } =20 -void kvm_arch_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *db= g) +static void s390x_kvm_update_guest_debug(CPUState *cpu, + struct kvm_guest_debug *dbg) { int i; =20 @@ -2647,6 +2650,9 @@ static const KVMCPUOps s390x_kvm_cpu_ops =3D { .put_registers =3D s390x_kvm_put_registers, .handle_exit =3D s390x_kvm_handle_exit, .process_async_events =3D s390x_kvm_process_async_events, + .update_guest_debug =3D s390x_kvm_update_guest_debug, + .insert_sw_breakpoint =3D s390x_kvm_insert_sw_breakpoint, + .remove_sw_breakpoint =3D s390x_kvm_remove_sw_breakpoint, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792494189; cv=none; d=zohomail.com; s=zohoarc; b=HuuFgAp+Trlz7FC5Y2YDzMWxwNCDG1CddbEt84xOkHfTV7TZwiH0IuqrCWnF44DU6IYbcfGLDcXa6bvLhaPcZmA0OwcOUstBW6ReZJ/jp/Gq1NzPHVOOVYjeB6/E1/AkiBeLMa5DAp/6E41by/r7MYXImqIuDr4aQJT8hJO6TLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792494189; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CI4y4+8QDNrII/yQJeeQ7eR8U6iPwLtUl1oInnwM8Os=; b=SbpfCmVkcIYn9eL+K76i19crVScd0+Vp80LSsx8PFlaccTon+oMXwPx6krW0yln1YzvcT2srBvUuG/1NRde1lrkKeLjZtAlhhphxpSobWpTHVD0Cz6mm1X+U419ukzqMx0oRUU42Lp8L/f0lfF9Qp2wLcD5b+nat5B6v7NJ8ZjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179249418970684.86178229880818; Tue, 20 Oct 2026 04:03:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7LR-00065E-Qk; Tue, 20 Oct 2026 06:45:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7K7-0004gU-Ji for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:04 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jj-0004Tc-G2 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:03 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-48e10a70540so1300570f8f.1 for ; Tue, 20 Oct 2026 03:43:38 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d80feb1sm5497671f8f.12.2026.10.20.03.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B7A725FE0E; Tue, 20 Oct 2026 11:43:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493017; x=1793097817; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=CI4y4+8QDNrII/yQJeeQ7eR8U6iPwLtUl1oInnwM8Os=; b=kaJtRSXsFBfKDO5yVoh1lgKynrsM6QzcILKR9/Vk/wY1fNQvtMjIpkaZqA41PS9fIX KkvekhZ75bb4mwqlxE/94tHJ/W8ZOIcA3sLJPT0l44CCXnOmZnTCHjMqsp/G8h97Ss8x 8AwXSfxsKrihxIlk/WjdWbGW9kS1fHlunOUm8iJQXCxOGScLPKVgFXeUvUFp+amGoGju PHmXvSC2nSWCWblSGdi8AlthQEp55nShhKAFhodToFiFw90M98klToWoSLQnYLyqdvio vRdzx6GufWn2UtxcsRvg5XQxQ1uScZxFWFWiE9EIz4bkMxhoHO57DZb5MDmpHepC03eZ /mNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493017; x=1793097817; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CI4y4+8QDNrII/yQJeeQ7eR8U6iPwLtUl1oInnwM8Os=; b=fKDfd/fvXtldTZgvB52ti5lHgE1es+V7C/pZKjA7tCohoB7nvjhjj/u6e2XV/3L0aW Ya8/CHqG1vBRJ6Q7NMb3w85/Ohe+iLPIlN5Pc5t/zceCgE85PI6JMHi7cEC5a5YZQGkI FNF1O+T+yO9mD8SefFQzyD9ooYbxymhKddm4ujVWC0AJ2buKRgMgbWpyeKcbk54aWCoE qQy9ClqWScE5mtJo8ExmvzHrHe6b3wHjAhzWPFEIxRVUd8sreb2RD4hx56Jw0cdNfonI 7yolAxoyCMLv1CsrpUPoQBtJOxQj+ffNSLE5LuLTBKuWzcNQ6xhO9QmAth0RuxnYKijf Veug== X-Gm-Message-State: AFq9FYLjQyYIPsLMGyzQahKFvyIhG4l06v7IIBqQX/TmgiSpzLIYTlJt cGT81/3RN0ANQneesMSHnlSS2/sL6S8eJAbWgntz2RFg3JpX4qV8CG3QS9yB6FS3nD8= X-Gm-Gg: AYBFou300sVukb37dLxQWQ+dpjovLIy02RZ/1jko4wFZPvlxnnmisgRXGRiOa8wbWDD p9oJD53RFxDl8SMDAze4S+9LPLmwFq3nL80yBVLhqVauoX/1Rbn76VDwd/wpjSGsgEv+ceoNdeY grgYgBDvXlfe6rz1S3LO90VSUQVsQerfGuXpj6Oxdcx0msrBIj6V7n+SqxOyzzo8QR5XRmNRl9G bCwSL7jmPCABYLwaJDC2KdHVEXupJQ2Te2wyBmbPUUN/fU7i7fyiadeyx/o+1gr3xwuMG6lBg/4 A0dFD55c2tPjMXIL/8cT0Vd1Pn3+5TETCwnFe7NUsDujasFXzZhblz3MLpFMscrbeJ+ENuYJHFw HRrCyUcVC530rzUPXCmuPPbve0Enwb3Z1++wStMinkZL+XKSz68lsVy3w/5+0E6e8HE/u0r3bd6 XxkzKkN4iXD2LH0EKNk97UsOdgq4oa4J+qu8Ef/u8a//bJxCYUGz8b7KMV4e++9efK4O0eioaR7 zyBbIoa X-Received: by 2002:a05:6000:4a0e:b0:48b:1119:5756 with SMTP id ffacd0b85a97d-48e07bbd34bmr18765919f8f.17.1792493017263; Tue, 20 Oct 2026 03:43:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 18/23] accel/kvm: port kvm_arch_[insert|remove]_hw_breakpoints to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:12 +0100 Message-ID: <20261020104320.3686723-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792494191697158500 We are able to eliminate some NOP implementations with a default fallback. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 15 +++++++++++++++ include/system/kvm.h | 6 ------ target/i386/kvm/kvm_i386.h | 5 +++++ accel/kvm/kvm-all.c | 18 ++++++++++++++---- target/arm/kvm.c | 13 ++++++++----- target/i386/kvm/kvm-cpu.c | 3 +++ target/i386/kvm/kvm.c | 10 +++++----- target/loongarch/kvm/kvm.c | 16 ---------------- target/ppc/kvm.c | 13 ++++++++----- target/riscv/kvm/kvm-cpu.c | 19 ------------------- target/s390x/kvm/kvm.c | 9 ++++++--- 11 files changed, 64 insertions(+), 63 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index d2374e91cef..23a83eee6ed 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -85,6 +85,16 @@ struct kvm_run; * software breakpoint, restoring @bp->saved_insn at * @bp->pc. * Returns 0 on success, or a negative errno on fai= lure. + * @insert_hw_breakpoint: Optional callback to insert an architecture-spec= ific + * hardware breakpoint or watchpoint at address @ad= dr + * with length @len and type @type. + * Returns 0 on success, or a negative errno on fai= lure. + * @remove_hw_breakpoint: Optional callback to remove an architecture-spec= ific + * hardware breakpoint or watchpoint at address @ad= dr + * with length @len and type @type. + * Returns 0 on success, or a negative errno on fai= lure. + * @remove_all_hw_breakpoints: Optional callback to remove all architectur= e- + * specific hardware breakpoints and watchpoin= ts. */ typedef struct KVMCPUOps { int (*pre_create_vcpu)(CPUState *cpu, Error **errp); @@ -100,6 +110,11 @@ typedef struct KVMCPUOps { void (*update_guest_debug)(CPUState *cpu, struct kvm_guest_debug *dbg); int (*insert_sw_breakpoint)(CPUState *cpu, struct kvm_sw_breakpoint *b= p); int (*remove_sw_breakpoint)(CPUState *cpu, struct kvm_sw_breakpoint *b= p); + int (*insert_hw_breakpoint)(CPUState *cpu, vaddr addr, vaddr len, + GdbBreakpointType type); + int (*remove_hw_breakpoint)(CPUState *cpu, vaddr addr, vaddr len, + GdbBreakpointType type); + void (*remove_all_hw_breakpoints)(CPUState *cpu); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" diff --git a/include/system/kvm.h b/include/system/kvm.h index 52b7a63a0b3..cfc0144d9a5 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -394,12 +394,6 @@ struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUSt= ate *cpu, =20 int kvm_sw_breakpoints_active(CPUState *cpu); =20 -int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type); -int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type); -void kvm_arch_remove_all_gdbstub_hw_breakpoints(void); - bool kvm_arch_stop_on_emulation_error(CPUState *cpu); =20 int kvm_vm_check_extension(KVMState *s, unsigned int extension); diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 27eea1f65ff..e2ae601100c 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -46,6 +46,11 @@ int x86_kvm_process_async_events(CPUState *cs); void x86_kvm_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg= ); int x86_kvm_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *b= p); int x86_kvm_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *b= p); +int x86_kvm_insert_hw_breakpoint(CPUState *cs, vaddr addr, vaddr len, + GdbBreakpointType type); +int x86_kvm_remove_hw_breakpoint(CPUState *cs, vaddr addr, vaddr len, + GdbBreakpointType type); +void x86_kvm_remove_all_hw_breakpoints(CPUState *cs); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 24ded4b1804..3bd61264a7e 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3917,7 +3917,12 @@ int kvm_insert_gdbstub_breakpoint(CPUState *cpu, Gdb= BreakpointType type, =20 QTAILQ_INSERT_HEAD(&cpu->kvm_state->kvm_sw_breakpoints, bp, entry); } else { - err =3D kvm_arch_insert_gdbstub_hw_breakpoint(addr, len, type); + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); + + if (!ops || !ops->insert_hw_breakpoint) { + return -ENOSYS; + } + err =3D ops->insert_hw_breakpoint(cpu, addr, len, type); if (err) { return err; } @@ -3937,9 +3942,9 @@ int kvm_remove_gdbstub_breakpoint(CPUState *cpu, GdbB= reakpointType type, { struct kvm_sw_breakpoint *bp; int err; + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); =20 if (type =3D=3D GDB_BREAKPOINT_SW) { - const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); =20 bp =3D kvm_find_sw_breakpoint(cpu, addr); if (!bp) { @@ -3963,7 +3968,10 @@ int kvm_remove_gdbstub_breakpoint(CPUState *cpu, Gdb= BreakpointType type, QTAILQ_REMOVE(&cpu->kvm_state->kvm_sw_breakpoints, bp, entry); g_free(bp); } else { - err =3D kvm_arch_remove_gdbstub_hw_breakpoint(addr, len, type); + if (!ops || !ops->remove_hw_breakpoint) { + return -ENOSYS; + } + err =3D ops->remove_hw_breakpoint(cpu, addr, len, type); if (err) { return err; } @@ -4005,7 +4013,9 @@ void kvm_remove_all_gdbstub_breakpoints(CPUState *cpu) QTAILQ_REMOVE(&s->kvm_sw_breakpoints, bp, entry); g_free(bp); } - kvm_arch_remove_all_gdbstub_hw_breakpoints(); + if (ops && ops->remove_all_hw_breakpoints) { + ops->remove_all_hw_breakpoints(cpu); + } =20 CPU_FOREACH(cpu) { kvm_update_guest_debug(cpu, 0); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index a4f063f2efb..5c0ccfc11cd 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1821,8 +1821,8 @@ void kvm_arch_accel_class_init(ObjectClass *oc) "Eager Page Split chunk size for hugepages. (default: 0, disabled)= "); } =20 -int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) +static int arm_kvm_insert_hw_breakpoint(CPUState *cs, vaddr addr, vaddr le= n, + GdbBreakpointType type) { switch (type) { case GDB_BREAKPOINT_HW: @@ -1837,8 +1837,8 @@ int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr,= vaddr len, } } =20 -int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) +static int arm_kvm_remove_hw_breakpoint(CPUState *cs, vaddr addr, vaddr le= n, + GdbBreakpointType type) { switch (type) { case GDB_BREAKPOINT_HW: @@ -1852,7 +1852,7 @@ int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr,= vaddr len, } } =20 -void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) +static void arm_kvm_remove_all_hw_breakpoints(CPUState *cs) { if (cur_hw_wps > 0) { g_array_remove_range(hw_watchpoints, 0, cur_hw_wps); @@ -2658,6 +2658,9 @@ static const KVMCPUOps arm_kvm_cpu_ops =3D { .update_guest_debug =3D arm_kvm_update_guest_debug, .insert_sw_breakpoint =3D arm_kvm_insert_sw_breakpoint, .remove_sw_breakpoint =3D arm_kvm_remove_sw_breakpoint, + .insert_hw_breakpoint =3D arm_kvm_insert_hw_breakpoint, + .remove_hw_breakpoint =3D arm_kvm_remove_hw_breakpoint, + .remove_all_hw_breakpoints =3D arm_kvm_remove_all_hw_breakpoints, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 0cd0884be30..baaee0c7e71 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -248,6 +248,9 @@ static const KVMCPUOps x86_kvm_cpu_ops =3D { .update_guest_debug =3D x86_kvm_update_guest_debug, .insert_sw_breakpoint =3D x86_kvm_insert_sw_breakpoint, .remove_sw_breakpoint =3D x86_kvm_remove_sw_breakpoint, + .insert_hw_breakpoint =3D x86_kvm_insert_hw_breakpoint, + .remove_hw_breakpoint =3D x86_kvm_remove_hw_breakpoint, + .remove_all_hw_breakpoints =3D x86_kvm_remove_all_hw_breakpoints, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 4ee7f53c2a8..78c06a07bd6 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6176,8 +6176,8 @@ static int find_hw_breakpoint(target_ulong addr, int = len, GdbBreakpointType type return -1; } =20 -int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) +int x86_kvm_insert_hw_breakpoint(CPUState *cs, vaddr addr, vaddr len, + GdbBreakpointType type) { switch (type) { case GDB_BREAKPOINT_HW: @@ -6217,8 +6217,8 @@ int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr,= vaddr len, return 0; } =20 -int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) +int x86_kvm_remove_hw_breakpoint(CPUState *cs, vaddr addr, vaddr len, + GdbBreakpointType type) { int n; =20 @@ -6232,7 +6232,7 @@ int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr,= vaddr len, return 0; } =20 -void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) +void x86_kvm_remove_all_hw_breakpoints(CPUState *cs) { nb_hw_breakpoint =3D 0; } diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index 0899aef552e..b15f60bd2c3 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1551,22 +1551,6 @@ static int loongarch_kvm_remove_sw_breakpoint(CPUSta= te *cs, return 0; } =20 -int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) -{ - return -ENOSYS; -} - -int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) -{ - return -ENOSYS; -} - -void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) -{ -} - static bool kvm_loongarch_handle_debug(CPUState *cs, struct kvm_run *run) { LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 4b2e42ef163..548bf3e00ad 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1438,8 +1438,8 @@ static int find_hw_watchpoint(target_ulong addr, int = *flag) return -1; } =20 -int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) +static int ppc_kvm_insert_hw_breakpoint(CPUState *cs, vaddr addr, vaddr le= n, + GdbBreakpointType type) { const unsigned breakpoint_index =3D nb_hw_breakpoint + nb_hw_watchpoin= t; if (breakpoint_index >=3D ARRAY_SIZE(hw_debug_points)) { @@ -1483,8 +1483,8 @@ int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr,= vaddr len, return 0; } =20 -int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) +static int ppc_kvm_remove_hw_breakpoint(CPUState *cs, vaddr addr, vaddr le= n, + GdbBreakpointType type) { int n; =20 @@ -1512,7 +1512,7 @@ int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr,= vaddr len, return 0; } =20 -void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) +static void ppc_kvm_remove_all_hw_breakpoints(CPUState *cs) { nb_hw_breakpoint =3D nb_hw_watchpoint =3D 0; } @@ -3075,6 +3075,9 @@ static const KVMCPUOps ppc_kvm_cpu_ops =3D { .update_guest_debug =3D ppc_kvm_update_guest_debug, .insert_sw_breakpoint =3D ppc_kvm_insert_sw_breakpoint, .remove_sw_breakpoint =3D ppc_kvm_remove_sw_breakpoint, + .insert_hw_breakpoint =3D ppc_kvm_insert_hw_breakpoint, + .remove_hw_breakpoint =3D ppc_kvm_remove_hw_breakpoint, + .remove_all_hw_breakpoints =3D ppc_kvm_remove_all_hw_breakpoints, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 8a82160a7bf..aeb049c0c71 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -2279,25 +2279,6 @@ static int riscv_kvm_remove_sw_breakpoint(CPUState *= cs, return 0; } =20 -int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) -{ - /* TODO; To be implemented later. */ - return -EINVAL; -} - -int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, - GdbBreakpointType type) -{ - /* TODO; To be implemented later. */ - return -EINVAL; -} - -void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) -{ - /* TODO; To be implemented later. */ -} - static void riscv_kvm_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) { diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 12695376442..ccdc85900ba 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -902,7 +902,7 @@ static int insert_hw_breakpoint(vaddr addr, int len, in= t type) return 0; } =20 -int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, vaddr len, +static int s390x_kvm_insert_hw_breakpoint(CPUState *cs, vaddr addr, vaddr = len, GdbBreakpointType type) { switch (type) { @@ -921,7 +921,7 @@ int kvm_arch_insert_gdbstub_hw_breakpoint(vaddr addr, v= addr len, return insert_hw_breakpoint(addr, len, type); } =20 -int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len, +static int s390x_kvm_remove_hw_breakpoint(CPUState *cs, vaddr addr, vaddr = len, GdbBreakpointType type) { int size; @@ -951,7 +951,7 @@ int kvm_arch_remove_gdbstub_hw_breakpoint(vaddr addr, v= addr len, return 0; } =20 -void kvm_arch_remove_all_gdbstub_hw_breakpoints(void) +static void s390x_kvm_remove_all_hw_breakpoints(CPUState *cs) { nb_hw_breakpoints =3D 0; g_free(hw_breakpoints); @@ -2653,6 +2653,9 @@ static const KVMCPUOps s390x_kvm_cpu_ops =3D { .update_guest_debug =3D s390x_kvm_update_guest_debug, .insert_sw_breakpoint =3D s390x_kvm_insert_sw_breakpoint, .remove_sw_breakpoint =3D s390x_kvm_remove_sw_breakpoint, + .insert_hw_breakpoint =3D s390x_kvm_insert_hw_breakpoint, + .remove_hw_breakpoint =3D s390x_kvm_remove_hw_breakpoint, + .remove_all_hw_breakpoints =3D s390x_kvm_remove_all_hw_breakpoints, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493194; cv=none; d=zohomail.com; s=zohoarc; b=LLEb1oIowgBlzUpJdREOt0LHe9O+tDmwIIwRsiAL5AmwwRmMS9wZjEm4BrrM+vSh4giGmuTVRIslmYgZ53vSxwmGVir55qz+H44AbYUfBtcOR9r7JqfqLY6Bp2O8MOIJhFpPleZbDmzlATP5GPDEByMd1K269hf0Qf55f+EQAbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493194; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3nKJ8HDcn3r8uziE9nKrYpZyKDrGZlceKJ4Jq+Ujj9I=; b=M4yeDh/ailb2eIiOr/Ri2E7Z/ZI5opDHwNpve9QiJO5CEJwMS4mXmfwKjCBhebQxv5wpLJIWoRtPQqahRRVq7jVVs+rRHABhAlXf8PT8p4n5K00OAhGA11NgYUEVWQjuRDhOccuZyKAL15+2a9CJs0IJYrfjnrvmSrSxEoOwhCY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493194600373.654275367256; Tue, 20 Oct 2026 03:46:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7M9-0007L3-QC; Tue, 20 Oct 2026 06:46:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7K3-0004an-KC for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:59 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jh-0004SW-G3 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:43:59 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-48dfdd0678dso2059500f8f.0 for ; Tue, 20 Oct 2026 03:43:36 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d80fafdsm5465775f8f.9.2026.10.20.03.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 015BD5F9E2; Tue, 20 Oct 2026 11:43:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493016; x=1793097816; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=3nKJ8HDcn3r8uziE9nKrYpZyKDrGZlceKJ4Jq+Ujj9I=; b=FAi8dsPny1TdtJ58mji3uQb8+iZr/Xfv4hKXEr6R+o/J5n0bEscpa2cw6HqI5YUM9X A4ccdAS7ydpnh7a1haZ76kqnIL/8XuqddsgiCdHy3yhJLoZ67udjulYG/F6qI5yIVgyx iG0mthnLDwCIgwrpQZWGffoX9bbdpA7azIi+M9Pw73hy03nZoqu/t88Qk/yEoTAv0KiE MYNP2jgRCyhLDcNDf/stUJrGmZJREhlnDw1g3b8qYLGW/4ZSXANmWJU4ceiaHKjKnYH1 R9MKnXzK2kOt8LwqBcvSjE7GA2be+nqvYEfgiYoYyKS/1UReMG9jmUZah+X/41KXW7UA PslA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493016; x=1793097816; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3nKJ8HDcn3r8uziE9nKrYpZyKDrGZlceKJ4Jq+Ujj9I=; b=SGiA0FXhG3sks+eD8u0/vscRK3Nh0pJfyNpEBMyMFmZID0wpa6kKTKf1o2eixrSr7e M236QwaoY57TsB148Hb04+7i4nUiqSWoYp5Cz8aeOcu5Dc6DjAT7cxU8O4o4JSsjeZdO Oncco9A7K7FxAFB+7K7Se3mBzdpKsYstY4S6aSnQd9kGIF00Vo+F0kVjUmPYdIaJ+2qu 91TjSqKvi8W8bo538tUlKKOvWy4oOHCoahy00QMt/YYhSPIq94DhEyjTYIuniF07YUQ1 b2Ilhiu6638enJDICqNSoUSgfbSr0uX6j87XtKDhuqPRDHE6n7W9JRQZU2qZbkyHAu2G za5w== X-Gm-Message-State: AFq9FYJ2oNM7BvkEVILgLSg7UiOFhEKrwHR3KQKZNCo+6maHc/tYc+9L 3AWvNT5R3RPU6NfYpJsOlO79bAhkHFC4FCAsqQF7ksU/V5EAWclmj2IQLP+JjiZxsE0= X-Gm-Gg: AYBFou1aZNB1Nc5UH1pYxfnHa5IP+zbHFyT2phWu3gcFf2wQQkgYIIONbO/xeDw0wir VBEav+eL7EIVxc6op+jdHmBNoNHNqaaepTwCL4el4aFrpsi0Jl/SuUqJJYsTNjKw4gfnjXzv3l9 diubWxI7IBAmVgkpjNS2Zd+dzzrypOWQvbVvKcJB16MFf0irr3ZeNyrxJlmzoOTEygR0VT+Xv73 ksf98bqilxRYUh8kTos5gHlYydq5VDlVgYKkj28C5JlyGgawU8xk4P+94V1TYCuEnCl3JlvGIKa 1s3IHHixjfuDLDIjz8FxvxTIMunsS/F8spVB64otwQdFFqSS8FFlfzP6+U3Katubsg1cc3k7z8p brmS6HIaWOdmwZ+srKjzPDkfjRpSunWsMt7dQszSmJHFY9j8eY8NpH2kYHUvn8zVflXBT24NaO3 kWELH7U8MufRmeu0rpJv7HAbDocw0WtfdSA2ce+06hYvWKW9G4v5urEn0OVrUelcNBpsjVkg== X-Received: by 2002:a05:6000:5ca:b0:48d:ff06:c626 with SMTP id ffacd0b85a97d-48e07f9eacbmr20650207f8f.35.1792493015656; Tue, 20 Oct 2026 03:43:35 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 19/23] accel/kvm: remove TARGET_KVM_HAVE_GUEST_DEBUG Date: Tue, 20 Oct 2026 11:43:13 +0100 Message-ID: <20261020104320.3686723-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493195035158500 With guest debug and breakpoint handling now migrated to struct KVMCPUOps, accel/kvm dispatches dynamically via ops. If an architecture does not support guest debug or breakpoints, the callbacks are simply NULL and common code handles this gracefully. As a result we can drop TARGET_KVM_HAVE_GUEST_DEBUG. Remove it from target configs and eliminate the #ifdef guards. Signed-off-by: Alex Benn=C3=A9e --- configs/targets/aarch64-softmmu.mak | 1 - configs/targets/i386-softmmu.mak | 1 - configs/targets/loongarch64-softmmu.mak | 1 - configs/targets/ppc-softmmu.mak | 1 - configs/targets/ppc64-softmmu.mak | 1 - configs/targets/riscv64-softmmu.mak | 1 - configs/targets/s390x-softmmu.mak | 1 - configs/targets/x86_64-softmmu.mak | 1 - include/system/kvm.h | 7 ------- include/system/kvm_int.h | 2 -- accel/kvm/kvm-accel-ops.c | 4 ---- accel/kvm/kvm-all.c | 15 +++++---------- 12 files changed, 5 insertions(+), 31 deletions(-) diff --git a/configs/targets/aarch64-softmmu.mak b/configs/targets/aarch64-= softmmu.mak index d34aead41c4..6f60ca6505c 100644 --- a/configs/targets/aarch64-softmmu.mak +++ b/configs/targets/aarch64-softmmu.mak @@ -1,6 +1,5 @@ TARGET_ARCH=3Daarch64 TARGET_BASE_ARCH=3Darm -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_XML_FILES=3D aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.= xml arm-vfp3.xml arm-vfp-sysregs.xml arm-neon.xml arm-m-profile.xml arm-m-p= rofile-mve.xml aarch64-pauth.xml aarch64-sme2.xml # needed by boot.c TARGET_NEED_FDT=3Dy diff --git a/configs/targets/i386-softmmu.mak b/configs/targets/i386-softmm= u.mak index 38a8f85201f..2eef68dc55e 100644 --- a/configs/targets/i386-softmmu.mak +++ b/configs/targets/i386-softmmu.mak @@ -1,5 +1,4 @@ TARGET_ARCH=3Di386 -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_KVM_HAVE_RESET_PARKED_VCPU=3Dy TARGET_XML_FILES=3D i386-32bit.xml TARGET_LONG_BITS=3D32 diff --git a/configs/targets/loongarch64-softmmu.mak b/configs/targets/loon= garch64-softmmu.mak index a425b3dbaae..3b3a9021980 100644 --- a/configs/targets/loongarch64-softmmu.mak +++ b/configs/targets/loongarch64-softmmu.mak @@ -1,6 +1,5 @@ TARGET_ARCH=3Dloongarch64 TARGET_BASE_ARCH=3Dloongarch -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_XML_FILES=3D loongarch-base32.xml loongarch-base64.xml loongarch-fp= u.xml loongarch-lsx.xml loongarch-lasx.xml # all boards require libfdt TARGET_NEED_FDT=3Dy diff --git a/configs/targets/ppc-softmmu.mak b/configs/targets/ppc-softmmu.= mak index 867898bd47c..c47887f8992 100644 --- a/configs/targets/ppc-softmmu.mak +++ b/configs/targets/ppc-softmmu.mak @@ -1,5 +1,4 @@ TARGET_ARCH=3Dppc TARGET_BIG_ENDIAN=3Dy -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_XML_FILES=3D power-core.xml power-fpu.xml power-altivec.xml power-s= pe.xml TARGET_LONG_BITS=3D32 diff --git a/configs/targets/ppc64-softmmu.mak b/configs/targets/ppc64-soft= mmu.mak index 10d7a2681e7..8c6dc84b821 100644 --- a/configs/targets/ppc64-softmmu.mak +++ b/configs/targets/ppc64-softmmu.mak @@ -1,7 +1,6 @@ TARGET_ARCH=3Dppc64 TARGET_BASE_ARCH=3Dppc TARGET_BIG_ENDIAN=3Dy -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_XML_FILES=3D power64-core.xml power-fpu.xml power-altivec.xml power= -spe.xml power-vsx.xml # all boards require libfdt TARGET_NEED_FDT=3Dy diff --git a/configs/targets/riscv64-softmmu.mak b/configs/targets/riscv64-= softmmu.mak index a10dc03c04c..18b674230ab 100644 --- a/configs/targets/riscv64-softmmu.mak +++ b/configs/targets/riscv64-softmmu.mak @@ -1,6 +1,5 @@ TARGET_ARCH=3Driscv64 TARGET_BASE_ARCH=3Driscv -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_XML_FILES=3D riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fp= u.xml riscv-64bit-virtual.xml riscv-32bit-cpu.xml riscv-32bit-virtual.xml # needed by boot.c TARGET_NEED_FDT=3Dy diff --git a/configs/targets/s390x-softmmu.mak b/configs/targets/s390x-soft= mmu.mak index 478988e6d4a..6a629c6479e 100644 --- a/configs/targets/s390x-softmmu.mak +++ b/configs/targets/s390x-softmmu.mak @@ -1,6 +1,5 @@ TARGET_ARCH=3Ds390x TARGET_BIG_ENDIAN=3Dy -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_XML_FILES=3D s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml= s390-cr.xml s390-virt.xml s390-virt-kvm.xml s390-gs.xml TARGET_LONG_BITS=3D64 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=3Dy diff --git a/configs/targets/x86_64-softmmu.mak b/configs/targets/x86_64-so= ftmmu.mak index c7f8746b4f5..491173df466 100644 --- a/configs/targets/x86_64-softmmu.mak +++ b/configs/targets/x86_64-softmmu.mak @@ -1,6 +1,5 @@ TARGET_ARCH=3Dx86_64 TARGET_BASE_ARCH=3Di386 -TARGET_KVM_HAVE_GUEST_DEBUG=3Dy TARGET_KVM_HAVE_RESET_PARKED_VCPU=3Dy TARGET_XML_FILES=3D i386-64bit.xml i386-64bit-apx.xml TARGET_LONG_BITS=3D64 diff --git a/include/system/kvm.h b/include/system/kvm.h index cfc0144d9a5..1a52e7e5261 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -232,14 +232,7 @@ void kvm_irqchip_change_notify(void); * calling down to the KVMCPUOps::update_guest_debug callback after the ge= neric * fields have been set. */ -#ifdef TARGET_KVM_HAVE_GUEST_DEBUG int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap); -#else -static inline int kvm_update_guest_debug(CPUState *cpu, unsigned long rein= ject_trap) -{ - return -EINVAL; -} -#endif =20 /* internal API */ =20 diff --git a/include/system/kvm_int.h b/include/system/kvm_int.h index 0876aac938d..9d1d3fd3deb 100644 --- a/include/system/kvm_int.h +++ b/include/system/kvm_int.h @@ -113,9 +113,7 @@ struct KVMState struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; bool coalesced_flush_in_progress; int vcpu_events; -#ifdef TARGET_KVM_HAVE_GUEST_DEBUG QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; -#endif int max_nested_state_len; int kvm_shadow_mem; bool kernel_irqchip_allowed; diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index 445d7d7f545..ab10de6ac30 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -86,12 +86,10 @@ static bool kvm_cpus_are_resettable(void) return !kvm_enabled() || !kvm_state->guest_state_protected; } =20 -#ifdef TARGET_KVM_HAVE_GUEST_DEBUG static void kvm_update_guest_debug_ops(CPUState *cpu) { kvm_update_guest_debug(cpu, 0); } -#endif =20 static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data) { @@ -106,12 +104,10 @@ static void kvm_accel_ops_class_init(ObjectClass *oc,= const void *data) ops->synchronize_pre_loadvm =3D kvm_cpu_synchronize_pre_loadvm; ops->handle_interrupt =3D generic_handle_interrupt; =20 -#ifdef TARGET_KVM_HAVE_GUEST_DEBUG ops->update_guest_debug =3D kvm_update_guest_debug_ops; ops->insert_gdbstub_breakpoint =3D kvm_insert_gdbstub_breakpoint; ops->remove_gdbstub_breakpoint =3D kvm_remove_gdbstub_breakpoint; ops->remove_all_gdbstub_breakpoints =3D kvm_remove_all_gdbstub_breakpo= ints; -#endif } =20 static const TypeInfo kvm_accel_ops_type =3D { diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 3bd61264a7e..5b96fac513e 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2964,9 +2964,7 @@ static int kvm_init(AccelState *as, MachineState *ms) s->sigmask_len =3D 8; accel_blocker_init(); =20 -#ifdef TARGET_KVM_HAVE_GUEST_DEBUG QTAILQ_INIT(&s->kvm_sw_breakpoints); -#endif QLIST_INIT(&s->kvm_parked_vcpus); s->fd =3D qemu_open_old(s->device ?: "/dev/kvm", O_RDWR); if (s->fd =3D=3D -1) { @@ -3077,7 +3075,6 @@ static int kvm_init(AccelState *as, MachineState *ms) kvm_vm_attributes_allowed =3D (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0); =20 -#ifdef TARGET_KVM_HAVE_GUEST_DEBUG if (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0) { as->gdbstub.sstep_flags =3D SSTEP_ENABLE; =20 @@ -3088,7 +3085,6 @@ static int kvm_init(AccelState *as, MachineState *ms) as->gdbstub.sstep_flags |=3D SSTEP_NOIRQ; } } -#endif =20 kvm_state =3D s; =20 @@ -3832,7 +3828,6 @@ bool kvm_arm_supports_user_irq(void) return kvm_check_extension(kvm_state, KVM_CAP_ARM_USER_IRQ); } =20 -#ifdef TARGET_KVM_HAVE_GUEST_DEBUG struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *cpu, vaddr pc) { struct kvm_sw_breakpoint *bp; @@ -3869,6 +3864,10 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned l= ong reinject_trap) const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); struct kvm_set_guest_debug_data data; =20 + if (!ops || !ops->update_guest_debug) { + return -EINVAL; + } + data.dbg.control =3D reinject_trap; =20 if (cpu_single_stepping(cpu)) { @@ -3878,9 +3877,7 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned lo= ng reinject_trap) data.dbg.control |=3D KVM_GUESTDBG_BLOCKIRQ; } } - if (ops && ops->update_guest_debug) { - ops->update_guest_debug(cpu, &data.dbg); - } + ops->update_guest_debug(cpu, &data.dbg); =20 run_on_cpu(cpu, kvm_invoke_set_guest_debug, RUN_ON_CPU_HOST_PTR(&data)); @@ -4022,8 +4019,6 @@ void kvm_remove_all_gdbstub_breakpoints(CPUState *cpu) } } =20 -#endif /* !TARGET_KVM_HAVE_GUEST_DEBUG */ - static int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset) { KVMState *s =3D kvm_state; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493379; cv=none; d=zohomail.com; s=zohoarc; b=bMriPoXwJqPwKcbONzn4MK2dYqn3xPqPbYwbseTRQtjzWXUPXMjJPVB2VYAB4jZlmWKwD9VeKVHq+9sTs53BENi3GXlLWYf5xf332Pny8S6zkNZr1aynFZ2CVAl86GxhCksOP+yl9IP0tL9z+1jibw9DH0VEo/H5EZOEts1NEA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493379; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d8sAo4RHPko4hi2qqkKFKsivhsO5nInc2hxbjXJGN8Q=; b=YFyIhGmYwJORpuL591OcLd4F8LS9Q9oRdUzXLW2Y0D6urTi7vqloGQyEosQIRXH30cxvqOZexxxsg6XZ7bi9v8aQ2aCckjjGdlWO9hM5zCGmIgwIKdFBpvn8Cad4KkWqrkvO1VX4ZoCTW4VnG29+dRoGwu6gOyisu8velJLPSWY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493378905154.22599481433213; Tue, 20 Oct 2026 03:49:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7MD-0007dO-QO; Tue, 20 Oct 2026 06:46:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7K5-0004ea-Cu for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:01 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jh-0004Su-Uv for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:01 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a0e1b0681bso21476645e9.3 for ; Tue, 20 Oct 2026 03:43:37 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1f2cc809csm64726835e9.8.2026.10.20.03.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:27 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3C5355FED7; Tue, 20 Oct 2026 11:43:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493016; x=1793097816; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=d8sAo4RHPko4hi2qqkKFKsivhsO5nInc2hxbjXJGN8Q=; b=Rereew3zk7nbq1e011lhNNyHP3+BpssnertXAM5/QgUYAXUerG9LcFsQ0hx8sjsOT3 k1eTGXdgp0x60+rqOsoXL0bsCHAktIolDYO6PYqan1uJJM2dnAdjP+MYYOGsgcbVsJj6 rMhA7VMguNjSVNR0XeEqmT9Y+V0B1xn78TS8Vtl52qKSA3i0fgvV3q0QmDBLXnXVicLK d2zwuBsuZiGF8pOyqbvTtwTmerj3eaC7sA7j6zacTGneZb2X2cA6VxP3e1IrmOolZjJn 3e2h/iEiW1YWB7uU0YEIHMoNUKCphmkUx2PI7mStYqqVfo7rSCINeLXRpRBDMM9eBLlK /Qdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493016; x=1793097816; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=d8sAo4RHPko4hi2qqkKFKsivhsO5nInc2hxbjXJGN8Q=; b=0QsgrsnBYy3wpN/plEh0CYoMWEICPZ/4aDEsk7YJx2Uw9WG1yyUzDDBJl35OT66m3/ iyAk7AstyZYKoNo2hF8IMXwK1H4Lj7bYWHwsW4u/ia29mhOFEp6oNW8WzAnSqt+cA42L n6A9+gIPbJ5IROjOZpQM4e4NQ/rjbSt9yhE7hucdWUE5wE6Lt0wCKHnSoz+xFcarSVgD XD4DE4mUyBo7WPSCgk6Q1UMJN/CXnJReBLgA0E2NDTgGoZHqP0g022o/VKzRpq9SdxCD giUlRZS7mOE2+AXk8QQ7QXLNdmZ4jHN1YbZ1tBDn0gCLotBGEYkdO2Bg2352xXaM2fNB 6tCw== X-Gm-Message-State: AFq9FYIhu7o4jK7YU3DneWliJ7et4kMvQZJMVFNwBoGSh0AUqKyfiaG4 xEzle3+i94Qq0pNHiRjWALQ3+np7qPd7L4IyChai9IKr4q9O6BVn/Po1JWaYGwG4Q5M= X-Gm-Gg: AYBFou0d/vxgz2IZrt8iRY1NyN/UikVnu/nD+MnquWqxLn9kBccjTi94U8OQ7PrsAnw +pjxFOF6bzjWdVP7JC+EyTfucwvKTlqiJjAHRClhncRrGpjkPRkaKvD8h8iYPQsaxAqCz+AT0Zz Wr3S81PjxdADk9yW+l6hk/eV3g8IAzj51l88uRHpNgFzYDlvvokgyMo6Ckr9JcgASeyYG2bJ2ob iMywy9l4FRzd/4NtmCJopUN7h1my2HthslffRV3l3d7cY62GjY15XtAAIUh0tP7tmccE6Sb7i0l LFiVGN8p2WuJ4h7YFl0aczf4y714p5QD8bcl5y6n2in6MNbScwDNTJDzToCzwmJ1uShnFQr56gq KOum9hRns+4H8bfiNSYsOSAHVfTmtFc+g33bMODuIecSEUr83SRUK7ghXjRBxEiKVHE4L0oyOfg 6ZTOQd5YO+r5/7lDgpxgF3tElLht/7g0uImytjFqTHvJXaAc02phyJ8Lxs928bqNhsKGKTZA== X-Received: by 2002:a05:600d:82c5:b0:4a1:e575:33dd with SMTP id 5b1f17b1804b1-4a1e57533efmr143324095e9.18.1792493016088; Tue, 20 Oct 2026 03:43:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 20/23] accel/kvm: port kvm_arch_stop_on_emulation_error to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:14 +0100 Message-ID: <20261020104320.3686723-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493380687158500 Really only x86 is doing much complicated, everyone else defaults to stop. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 7 +++++++ include/system/kvm.h | 2 -- target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 8 +++++++- target/arm/kvm.c | 5 ----- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- target/loongarch/kvm/kvm.c | 5 ----- target/ppc/kvm.c | 5 ----- target/riscv/kvm/kvm-cpu.c | 5 ----- target/s390x/kvm/kvm.c | 5 ----- 11 files changed, 17 insertions(+), 29 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index 23a83eee6ed..c2ae74f2b87 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -95,6 +95,12 @@ struct kvm_run; * Returns 0 on success, or a negative errno on fai= lure. * @remove_all_hw_breakpoints: Optional callback to remove all architectur= e- * specific hardware breakpoints and watchpoin= ts. + * @stop_on_emulation_error: Optional callback executed when KVM encounter= s an + * internal emulation failure (such as + * KVM_INTERNAL_ERROR_EMULATION) to decide wheth= er + * execution should stop. + * Returns true to stop the VM, or false to dump= state + * and continue. If NULL, defaults to true. */ typedef struct KVMCPUOps { int (*pre_create_vcpu)(CPUState *cpu, Error **errp); @@ -115,6 +121,7 @@ typedef struct KVMCPUOps { int (*remove_hw_breakpoint)(CPUState *cpu, vaddr addr, vaddr len, GdbBreakpointType type); void (*remove_all_hw_breakpoints)(CPUState *cpu); + bool (*stop_on_emulation_error)(CPUState *cpu); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" diff --git a/include/system/kvm.h b/include/system/kvm.h index 1a52e7e5261..719ae1c71fb 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -387,8 +387,6 @@ struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUSta= te *cpu, =20 int kvm_sw_breakpoints_active(CPUState *cpu); =20 -bool kvm_arch_stop_on_emulation_error(CPUState *cpu); - int kvm_vm_check_extension(KVMState *s, unsigned int extension); =20 #define kvm_vm_enable_cap(s, capability, cap_flags, ...) \ diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index e2ae601100c..9d4be604443 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -51,6 +51,7 @@ int x86_kvm_insert_hw_breakpoint(CPUState *cs, vaddr addr= , vaddr len, int x86_kvm_remove_hw_breakpoint(CPUState *cs, vaddr addr, vaddr len, GdbBreakpointType type); void x86_kvm_remove_all_hw_breakpoints(CPUState *cs); +bool x86_kvm_stop_on_emulation_error(CPUState *cs); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 5b96fac513e..62ebb3458c8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3183,8 +3183,14 @@ static int kvm_handle_internal_error(CPUState *cpu, = struct kvm_run *run) i, (uint64_t)run->internal.data[i]); } if (run->internal.suberror =3D=3D KVM_INTERNAL_ERROR_EMULATION) { + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); + bool stop =3D true; + fprintf(stderr, "emulation failure\n"); - if (!kvm_arch_stop_on_emulation_error(cpu)) { + if (ops && ops->stop_on_emulation_error) { + stop =3D ops->stop_on_emulation_error(cpu); + } + if (!stop) { cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); return EXCP_INTERRUPT; } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 5c0ccfc11cd..ed99699098c 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1609,11 +1609,6 @@ static int arm_kvm_handle_exit(CPUState *cs, struct = kvm_run *run) return ret; } =20 -bool kvm_arch_stop_on_emulation_error(CPUState *cs) -{ - return true; -} - /** * kvm_arm_hw_debug_active: * @cpu: ARMCPU diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index baaee0c7e71..c9340183eaf 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -251,6 +251,7 @@ static const KVMCPUOps x86_kvm_cpu_ops =3D { .insert_hw_breakpoint =3D x86_kvm_insert_hw_breakpoint, .remove_hw_breakpoint =3D x86_kvm_remove_hw_breakpoint, .remove_all_hw_breakpoints =3D x86_kvm_remove_all_hw_breakpoints, + .stop_on_emulation_error =3D x86_kvm_stop_on_emulation_error, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 78c06a07bd6..e419af944cb 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6661,7 +6661,7 @@ int x86_kvm_handle_exit(CPUState *cs, struct kvm_run = *run) return ret; } =20 -bool kvm_arch_stop_on_emulation_error(CPUState *cs) +bool x86_kvm_stop_on_emulation_error(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index b15f60bd2c3..fd0f3a82a6b 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -1513,11 +1513,6 @@ static int loongarch_kvm_process_async_events(CPUSta= te *cs) return cs->halted; } =20 -bool kvm_arch_stop_on_emulation_error(CPUState *cs) -{ - return true; -} - static void loongarch_kvm_update_guest_debug(CPUState *cpu, struct kvm_guest_debug *dbg) { diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 548bf3e00ad..f5f2f82a4d8 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2840,11 +2840,6 @@ int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint= 32_t index, return 0; } =20 -bool kvm_arch_stop_on_emulation_error(CPUState *cpu) -{ - return true; -} - void kvm_arch_init_irq_routing(KVMState *s) { } diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index aeb049c0c71..6a88fe761c0 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1621,11 +1621,6 @@ int kvm_arch_irqchip_create(KVMState *s) return kvm_check_extension(s, KVM_CAP_DEVICE_CTRL); } =20 -bool kvm_arch_stop_on_emulation_error(CPUState *cs) -{ - return true; -} - static void kvm_riscv_handle_sbi_dbcn(CPUState *cs, struct kvm_run *run) { const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index ccdc85900ba..e0373d05515 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -1935,11 +1935,6 @@ static int s390x_kvm_handle_exit(CPUState *cs, struc= t kvm_run *run) return ret; } =20 -bool kvm_arch_stop_on_emulation_error(CPUState *cpu) -{ - return true; -} - void kvm_s390_enable_css_support(S390CPU *cpu) { int r; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493725; cv=none; d=zohomail.com; s=zohoarc; b=OyEf88h/lvTljBmjuMVHgpSDbT2D131b8Xu72egbkwfs51Png6gLjPISDcXhHKbghZu3jnNQILTvSoFZhOqSLshVCLbc09YmZ0ZM1CWiMYdVqo9s0AH/OJQb6W70ZaV2FjPrcC2wcANPcpjsujXtkPpl0TusEBfCGsUDNQof6Ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493725; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IZVpnwXNEyCCWDW5qZNv/CPNg86yVg361tAI8kFJxDQ=; b=JRKqOreenlePHlIsDgDH0LGfPTziMwK4kSFGBTvjY9dMVhBaEoGTUMAnjPXKKaRZxgdJT3bJ+HTfJd1uRShB/GCGqYtz+AW2sKVLn4tgaw9eScKxGTbXM481/lvipdFkmGyi/LzTNmXauTUq2uPA0g/gLz18DDlPbFavuvT/Vd8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493725686315.5648332040955; Tue, 20 Oct 2026 03:55:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7MP-0000By-1x; Tue, 20 Oct 2026 06:46:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7KB-0004k1-76 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:07 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jk-0004Ts-9s for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:06 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4a1dec056ddso17535195e9.1 for ; Tue, 20 Oct 2026 03:43:39 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1dc952d63sm346602105e9.2.2026.10.20.03.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6F0A45FF88; Tue, 20 Oct 2026 11:43:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493018; x=1793097818; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=IZVpnwXNEyCCWDW5qZNv/CPNg86yVg361tAI8kFJxDQ=; b=YiVqQ2Ptvl1J0XlPGPNw+2LkQVoOZ8kzpbUZaqeeHlnuBJwK/HQQ33f3RvqTOTxgjf hwKiiajyuIC66nA9GzxjmCTbYo0dtqOv/A146S2NuihSqU/4B+jjCTvodUehD2AAALbA Ury2kanXzuC5O9EeY3wvBtfElqtYFcniJsuWw9HMX8/y62Zf1TrWgSwv7igQtHuLWY6m KmzuJA4e++18caMWTRmkoQ1Q0rHgKukLfjqHaYN34L9R4mve6kEg3C3JQmGFnXE5iN9N ueps+t/YOzo4scwS23F5w0apQx3sgopH5kfNGmT+bWFc98IINJ1p6pBOz0r2Mi4y1zB7 rxRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493018; x=1793097818; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IZVpnwXNEyCCWDW5qZNv/CPNg86yVg361tAI8kFJxDQ=; b=ovEpszzxO32E9JdvMK2vk2poIakA2T5L530r3L7euScc6ZadHb3Txw1uPm/R50PMXM HxJ6x9qZrnOlwP7u47eQjIdifiZcrcL5IiWAxBnsDOgpo/YQX4rRFTnOBh4QiJ5TH5bH 2ABEBACi4oLnpziJgNNZVjZjKilf99A6FNvOHeBgCZhvkAltlBAJ+UzFeXRJFlD+aahi +mANsLujMOqNycgmWbzEji9BctkLBPKuVpmUp8BzePICftMVJSRSSJOt929fa/50/btO lgJ2erNCQWb92deG5MyDas3n7+KQ02Tfv87fyQDSF8qDLkDqQIxjLvZikORvqjkpaPr1 IJXQ== X-Gm-Message-State: AFq9FYLUotXFuFPK8kW5vsWFJjylHtF7AD/KqNSZFxIGwa08ZSR29KR2 avjXkIzJJ6Csr4EmUsnv+xMlrZ8H2gSTKGZOa4FflOCPu0i9/T9422zx3vR3IWpKFEg= X-Gm-Gg: AYBFou2z7gMMyY5OBOSbLYFipZqwODaB3ZULFxz7gkNjHztRPWcAw2gcCypfFXpIcKw YWAXTFVYaT0ECBtIV5h6MaidQ+RgzMXYMb2M1SiGsWgKC3lh754CRilCGDIjnxAWOtZ7cpStBYp nOohJdikd4+7hILDeW4/k2aY+VmAElq2Sc40YVbu8iJTMHJAilnpLI2apYtb9gd1my6WMfF24zF Lyp2z9v/FYizLCqobROh9wkBDoQzIoVA3WiTdkAJ6bCWrxE58DO+V7h4mI8Xu7IA9uV+CY7rZQX aetuAy0m8duT7GfcLGxgvshbOjeidBJqNDl4zOmMjG2rkNNE6+4ONB4hN5/retQ/LBKYiU5IBbe T/qzqbrKyjUtwKaKPx1Wrs/nGKgWvakQ/sgs8hTicxUTacmRQfXHVCKgRXafj5XQ4e0JMpjlq6N HiC3wLf7Bdr3dggSsX5fbjb1oNgLqk8UwL9gv5K7lZK3y+17d4UgJyVETJ1qPly0aVMHXbeQ== X-Received: by 2002:a05:600c:4455:b0:4a1:e225:b122 with SMTP id 5b1f17b1804b1-4a1e225b8d7mr156541115e9.14.1792493017818; Tue, 20 Oct 2026 03:43:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 21/23] accel/kvm: port kvm_arch_on_sigbus_vcpu to KVMCPUOps Date: Tue, 20 Oct 2026 11:43:15 +0100 Message-ID: <20261020104320.3686723-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493727398158500 This leaves hanging the question of if we should clean-up KVM_HAVE_MCE_INJECTION? It is poisoned to avoid entering generic code. Signed-off-by: Alex Benn=C3=A9e --- docs/specs/acpi_hest_ghes.rst | 3 ++- include/accel/kvm/cpu-ops.h | 6 ++++++ include/system/kvm.h | 2 -- target/i386/kvm/kvm_i386.h | 1 + accel/kvm/kvm-all.c | 19 ++++++++++++++++--- target/arm/kvm.c | 3 ++- target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 2 +- 8 files changed, 29 insertions(+), 8 deletions(-) diff --git a/docs/specs/acpi_hest_ghes.rst b/docs/specs/acpi_hest_ghes.rst index aaf7b1ad11a..dfb319dc3b4 100644 --- a/docs/specs/acpi_hest_ghes.rst +++ b/docs/specs/acpi_hest_ghes.rst @@ -114,5 +114,6 @@ Design Details kernel, on receiving notification, guest APEI driver could read the C= PER error and take appropriate action. =20 -(11) kvm_arch_on_sigbus_vcpu() reports RAS errors via a SEA notifications, + +(11) The KVMCPUops::on_sigbus_vcpu callback reports RAS errors via a SEA n= otifications, when a SIGBUS event is triggered. diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index c2ae74f2b87..d43bc845ad5 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -101,6 +101,11 @@ struct kvm_run; * execution should stop. * Returns true to stop the VM, or false to dump= state * and continue. If NULL, defaults to true. + * @on_sigbus_vcpu: Optional callback executed when a SIGBUS signal is rec= eived + * to inject an architecture-specific hardware memory err= or + * (e.g. MCE on x86 or SEA on ARM) into the guest. + * May be NULL if the target does not support hardware er= ror + * injection. */ typedef struct KVMCPUOps { int (*pre_create_vcpu)(CPUState *cpu, Error **errp); @@ -122,6 +127,7 @@ typedef struct KVMCPUOps { GdbBreakpointType type); void (*remove_all_hw_breakpoints)(CPUState *cpu); bool (*stop_on_emulation_error)(CPUState *cpu); + void (*on_sigbus_vcpu)(CPUState *cpu, int code, void *addr); } KVMCPUOps; =20 #define TYPE_KVM_ACCEL_CPU "kvm-accel-cpu" diff --git a/include/system/kvm.h b/include/system/kvm.h index 719ae1c71fb..98ef937eff1 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -352,8 +352,6 @@ bool kvm_vcpu_id_is_valid(int vcpu_id); /* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */ unsigned long kvm_vcpu_id(CPUState *cpu); =20 -void kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); - void kvm_arch_init_irq_routing(KVMState *s); =20 int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route, diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 9d4be604443..88aa0699c28 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -52,6 +52,7 @@ int x86_kvm_remove_hw_breakpoint(CPUState *cs, vaddr addr= , vaddr len, GdbBreakpointType type); void x86_kvm_remove_all_hw_breakpoints(CPUState *cs); bool x86_kvm_stop_on_emulation_error(CPUState *cs); +void x86_kvm_on_sigbus_vcpu(CPUState *c, int code, void *addr); void kvm_arch_after_reset_vcpu(X86CPU *cpu); void kvm_arch_do_init_vcpu(X86CPU *cs); uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 62ebb3458c8..5189cdc6a01 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3535,8 +3535,10 @@ int kvm_cpu_exec(CPUState *cpu) #ifdef KVM_HAVE_MCE_INJECTION if (unlikely(have_sigbus_pending)) { bql_lock(); - kvm_arch_on_sigbus_vcpu(cpu, pending_sigbus_code, + if (ops->on_sigbus_vcpu) { + ops->on_sigbus_vcpu(cpu, pending_sigbus_code, pending_sigbus_addr); + } have_sigbus_pending =3D false; bql_unlock(); } @@ -4080,6 +4082,11 @@ void kvm_init_cpu_signals(CPUState *cpu) int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr) { #ifdef KVM_HAVE_MCE_INJECTION + const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); + + if (!ops || !ops->on_sigbus_vcpu) { + return 1; + } if (have_sigbus_pending) { return 1; } @@ -4097,13 +4104,19 @@ int kvm_on_sigbus_vcpu(CPUState *cpu, int code, voi= d *addr) int kvm_on_sigbus(int code, void *addr) { #ifdef KVM_HAVE_MCE_INJECTION + const KVMCPUOps *ops; + /* Action required MCE kills the process if SIGBUS is blocked. Because * that's what happens in the I/O thread, where we handle MCE via sign= alfd, * we can only get action optional here. */ assert(code !=3D BUS_MCEERR_AR); - kvm_arch_on_sigbus_vcpu(first_cpu, code, addr); - return 0; + ops =3D kvm_get_cpu_ops(first_cpu); + if (ops && ops->on_sigbus_vcpu) { + ops->on_sigbus_vcpu(first_cpu, code, addr); + return 0; + } + return 1; #else return 1; #endif diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ed99699098c..563b331a7cf 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2486,7 +2486,7 @@ static int arm_kvm_get_registers(CPUState *cs, Error = **errp) return ret; } =20 -void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) +static void arm_kvm_on_sigbus_vcpu(CPUState *c, int code, void *addr) { ram_addr_t ram_addr; hwaddr paddr; @@ -2656,6 +2656,7 @@ static const KVMCPUOps arm_kvm_cpu_ops =3D { .insert_hw_breakpoint =3D arm_kvm_insert_hw_breakpoint, .remove_hw_breakpoint =3D arm_kvm_remove_hw_breakpoint, .remove_all_hw_breakpoints =3D arm_kvm_remove_all_hw_breakpoints, + .on_sigbus_vcpu =3D arm_kvm_on_sigbus_vcpu, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index c9340183eaf..e876ec6b794 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -252,6 +252,7 @@ static const KVMCPUOps x86_kvm_cpu_ops =3D { .remove_hw_breakpoint =3D x86_kvm_remove_hw_breakpoint, .remove_all_hw_breakpoints =3D x86_kvm_remove_all_hw_breakpoints, .stop_on_emulation_error =3D x86_kvm_stop_on_emulation_error, + .on_sigbus_vcpu =3D x86_kvm_on_sigbus_vcpu, }; =20 static void kvm_cpu_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index e419af944cb..26d30629272 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -767,7 +767,7 @@ static void hardware_memory_error(void *host_addr) exit(1); } =20 -void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) +void x86_kvm_on_sigbus_vcpu(CPUState *c, int code, void *addr) { X86CPU *cpu =3D X86_CPU(c); CPUX86State *env =3D &cpu->env; --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792494680; cv=none; d=zohomail.com; s=zohoarc; b=KNMghuc7HEkUVXq+rItpedj/wwg7YZDu5UyUW8BvIMXDjsKNJpZ7rGX964EpYHul5E5JQzh3io1htzCAN3Q96zeDHgD0MAAoowl9lo4RpvNyreWce1zOu9vuvnS+pygKiM9DqOtb8SXl8qaPHGz6HdnXk7efgtSXF5oWXRf8KQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792494680; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ko6yZh9M1s2VW5tIdG2OCTSHQVjujibVM95DZEJ7phw=; b=XH48yJh4KFZwfwzxPjwhanlDH6mCC6S85TRxkwrU+kRSl5+hh/v0au3P7DacPNjAO5lcAmo9jLD0E0Ke8RECTd2YwrFnaySb4/joA20tgt8hrXIzcK4+ZySMxFRiZHr0jcspCUA85R5QFvVWdtCm+jlWMkLZQfd+9lzhgHcGyv0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792494680835514.1838048821177; Tue, 20 Oct 2026 04:11:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7U6-0004x6-DR; Tue, 20 Oct 2026 06:54:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7Ru-0001Dp-S3 for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:52:07 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Rp-0006fh-Of for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:52:06 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-48e0d1c095dso1759568f8f.1 for ; Tue, 20 Oct 2026 03:51:55 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d80f9cdsm5176970f8f.11.2026.10.20.03.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:51:53 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 95B4C5FA43; Tue, 20 Oct 2026 11:43:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493515; x=1793098315; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Ko6yZh9M1s2VW5tIdG2OCTSHQVjujibVM95DZEJ7phw=; b=MhdW5VBk8JK1lv2xTomhmWZhsPiHismVa7v5GiTIPMguVKMSPwssovYYGWygTESLDV fnfZwkMaxL33cF9wdoiGWAcNLT2R1VPIK2V4nyGwWnM/iDOnrSNZ1Fi1JLxUZTswRxq+ guqYugaYSZ2YNdZZ+efhdI/rBgUfSZEYbdNDyxxKD0A1k08+7o+9OMHonvYfilUL0A/5 1DjFbsdHscFiwy+io2/gw6Bzz7UC+QRUpEJO40OhqX3gVF4KKrCKijHo4U4zGI/WxDnC ao3wAQTH5Il4NvXQIhefK4hah7F2BcIxCSExU4wF+D0lRgSJsOLanoGEA52KVCkiONBx tahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493515; x=1793098315; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Ko6yZh9M1s2VW5tIdG2OCTSHQVjujibVM95DZEJ7phw=; b=z7N2wXt+eANpfBZwKJDURznpJtv9x7lRWCCMcqWUaJnzLKP+TXGS+c+YWgioiYUdHw 1O63ApFmBc/MO/VQR0CyN86WylZowG/lCw2c8HgXQ84+/NOnBZvkdp+eCAXRkBTRpsCy uQHrYDr8YDOk32Levlj6B9jUSQ+B2MdDHNBcHZgQOjZ/RF4s/gx5H3k/8B1ACq6zD7ny U2OIJER07+ttjTPc5EMX/O7EqQAFcWv9vBQ+0/UG7jO0kgYtBMHM7fsVju35nJg0IVAI 8lQiO7lgarloG5eCDxa1X/t37LSuuNjq7s7T5zoIHMyU6EH8GOdf8603avgHGov6WEMm tOwg== X-Gm-Message-State: AFq9FYLyIZEbq1LGlnv5QsDIHQKr96wRtbMffFTZit2lk3llLa18MFAn RJf1dJt0ZKlBcuReumgSsamtu8NmLI6xRJ2wmDgvZEZInCTGDd+otl19QzKkNRct5Ug= X-Gm-Gg: AYBFou08yxcqt14LKV6SAzsEg1eBEpjoCG0fZWjzD4i2j7yfx2MmWf8pRQ+BuChFD/7 faMQcZf73+xE5oXxgazpVgwet1NYyhI3+L07g4KB47LjH6pMOq1UNi7Y2K3uBNFGICewcnhrp6n +nTILSpphbBJs3nrWKa1dIJdDdwu4nQKCPBsBr/d6hE27al083c/w9AEBOQ/Vsf3E0gmEqRygzK 2N0OBbtdnotNSRzijWL5ZrC4Vpx5aylaY6syPqxHi3MA3yqeBobqbJkvM8zTfN1wJK0CQphQPSN 57KzFCBS9TSfRf08No3TLp3UPoriRvhN/PFBllVZJSFWFEQDNF5zPyWV6BEPzDAfScomAV5IUcm 8cPXI85jTNlGFNAZvjFiZuY0XV7PD34pBRKwt0fVmTdjVzS2hAayjZlnJfCwCawJYzmzGPjf+wI U8Rt3+/A3ugzO7Pi9Z2mKW03aATKBBgrNB+IeKFK2io/JBpR3GeZpPduL7ppK/VcCc5Cgj8g== X-Received: by 2002:a05:6000:29d2:b0:48b:f93:3b87 with SMTP id ffacd0b85a97d-48e07fc7a04mr13714326f8f.30.1792493514603; Tue, 20 Oct 2026 03:51:54 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 22/23] accel/kvm: cache KVMCPUOps Date: Tue, 20 Oct 2026 11:43:16 +0100 Message-ID: <20261020104320.3686723-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792494682393158500 Doing a QOM cast each time we need KVMCPUOps is overkill, especially considering it is a single static assignment when we configure the accelerator. Cache the value on kvm_init_vcpu and use it. We also assert that anytime the system asks for KVMCPUOps it should be at a point we can honour the request. Signed-off-by: Alex Benn=C3=A9e --- include/accel/kvm/cpu-ops.h | 13 +++++++++---- include/hw/core/cpu.h | 3 +++ accel/kvm/kvm-all.c | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/accel/kvm/cpu-ops.h b/include/accel/kvm/cpu-ops.h index d43bc845ad5..075bac1d494 100644 --- a/include/accel/kvm/cpu-ops.h +++ b/include/accel/kvm/cpu-ops.h @@ -156,11 +156,16 @@ DECLARE_CLASS_CHECKERS(KVMAccelCPUClass, KVM_ACCEL_CP= U, TYPE_KVM_ACCEL_CPU) */ static inline const KVMCPUOps *kvm_get_cpu_ops(const CPUState *cpu) { - if (cpu->cc->accel_cpu) { - KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(cpu->cc->accel_cpu); - return kacc->cpu_ops; + if (cpu) { + if (cpu->kvm_cpu_ops) { + return cpu->kvm_cpu_ops; + } + if (cpu->cc->accel_cpu) { + KVMAccelCPUClass *kacc =3D KVM_ACCEL_CPU_CLASS(cpu->cc->accel_= cpu); + return kacc->cpu_ops; + } } - return NULL; + g_assert_not_reached(); } =20 #endif /* ACCEL_KVM_CPU_OPS_H */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 456154df6f6..1e164036286 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -473,6 +473,8 @@ struct qemu_work_item; * ring is enabled. * @kvm_fetch_index: Keeps the index that we last fetched from the per-vCPU * dirty ring structure. + * @kvm_cpu_ops: Cached pointer to the KVMCPUOps table to avoid QOM lookups + * in the run loop. * * @neg_align: The CPUState is the common part of a concrete ArchCPU * which is allocated when an individual CPU instance is created. As @@ -554,6 +556,7 @@ struct CPUState { uint32_t kvm_fetch_index; uint64_t dirty_pages; int kvm_vcpu_stats_fd; + const struct KVMCPUOps *kvm_cpu_ops; =20 /* Use by accel-block: CPU is executing an ioctl() */ QemuLockCnt in_ioctl_lock; diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 5189cdc6a01..041113ed9b5 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -746,6 +746,9 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) KVMState *s =3D kvm_state; int ret; =20 + assert(ops); + cpu->kvm_cpu_ops =3D ops; + trace_kvm_init_vcpu(cpu->cpu_index, kvm_vcpu_id(cpu)); =20 if (ops->pre_create_vcpu) { @@ -4111,6 +4114,7 @@ int kvm_on_sigbus(int code, void *addr) * we can only get action optional here. */ assert(code !=3D BUS_MCEERR_AR); + assert(first_cpu); ops =3D kvm_get_cpu_ops(first_cpu); if (ops && ops->on_sigbus_vcpu) { ops->on_sigbus_vcpu(first_cpu, code, addr); --=20 2.47.3 From nobody Mon Nov 23 04:44:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1792493693; cv=none; d=zohomail.com; s=zohoarc; b=nMt2JqkCx6hl9DNDkTl2HGVgU8GQw2yhaw3cTundziJ6vsmlUMpcwVczU3+ZXBFGGaeVv2zG3bitoPel4wvFek8ukmG1pMzpPTVh3Q/JWfSwR1OSOjlHsorFc1GvltvxVu3l84qmOIx7vs8V3IXeoHIz2e+G+PsttqIVvY1MHkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792493693; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FGqirORdiYAHpa8WKE6kkRgcY8UYqpJTtFDjbgGTNq4=; b=BtrBCCl1H3khSCOGbf2JzXO12uXMoUlAJa1qVYyEA6z3lPELu+KFnclDtLBpTzdJgKTUZv8BIBb/c/vDGV4zh83s1r0cbE6gm7KAhzBG2OL9WU9tbTAxGwvwemcIQq63JJCtjUkAPoYJyd2ndw+iUOx1a46wtUCAKh8Afnb4vY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792493693463178.02207549848993; Tue, 20 Oct 2026 03:54:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJ7ML-0008Ew-4C; Tue, 20 Oct 2026 06:46:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJ7K9-0004gv-3V for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:06 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xJ7Jk-0004US-8j for qemu-devel@nongnu.org; Tue, 20 Oct 2026 06:44:04 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-48b060ec084so2157157f8f.0 for ; Tue, 20 Oct 2026 03:43:39 -0700 (PDT) Received: from draig.lan ([185.124.0.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e1d83a338sm5303864f8f.59.2026.10.20.03.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2026 03:43:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B49C25FF9E; Tue, 20 Oct 2026 11:43:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1792493018; x=1793097818; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=FGqirORdiYAHpa8WKE6kkRgcY8UYqpJTtFDjbgGTNq4=; b=gQNXc43Xd1+ACu6H7IdDP7o3weBOa8ijZDg2K0BK3aZeuVZ5GH2iStovwFmNldp3LM xtFceYeo6X+15ZaMtXMafXdd5sk8miAF6jR+ufjJo7fl/Fh0VlzUGdafx+0Ggxx3eR5G 2rXBU8qPVk5pff7vBBY2vz8B4NifgsEIiYc+bjcHxdJ2zAXnp/3n9we5pIpWCQgka2+Q 7W8EkTuI08kyV2TpanoDo3FTTNv35bXNf841xo/RrCtCc6sbTVta7SzYWtAfoQxFM3xK Cp+DH4EA8jUku0DWyVfB2TdgiZf//MA0SbCdwPLVkFVzmnciB8tq+naxFf3jF0j21N00 hJTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792493018; x=1793097818; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FGqirORdiYAHpa8WKE6kkRgcY8UYqpJTtFDjbgGTNq4=; b=ENtdLA4pdnA8dRYuk9ZWaQBIHEw45FPPTTAXf5c7Tss1ru3vdHYXrnKwLBr7Jaf3/4 GckO9m5Q/B4gLDQGzj0T7N4aqmiBOtiS3Wjj4NoK59v1n5GIl99jPRoP1bDcUcIup37J 8y50SOQQZPks7Fdxr0yNemUliPsuyTvX92BEfvymCNnk7COhA8tP1S8WRV6BmUs6qTOq HN8MsP8eQcqb6i8+MEFC5XEMk8KDDO/Iqiquj2D3b1WaxEHe54QzAwgp5vuMJoekXCWC jLAFJSF61JYCLt3tJjGGBslCg4XQuli3xjqFiR1ME+3K0ShE0bXKlEZJDNIRWSGGtA45 Cv7A== X-Gm-Message-State: AFq9FYKdIs/+bl7ftaCkdHUUOzfb5+Qw2Lt7rI0I+V6wTZ69oJ4cd0bH SpEBNLPWIaJTLy/YgfyFOQQMx05IllWkZtfXr0FG4mmhqGU/kITxcwvcfC2lDIPOi2A= X-Gm-Gg: AYBFou37lQxhW9ACGx9WiMrWp4nWW/SyXRMKqrMTBZ3jPpk1mnaMR+U9d8pZLijyMmX KkYIacp6u34ZdtP23iRW17zxa54GUtAgdz6NNZxjY2baJmWnAr63qbqZYuCwYqI+Cd2oS9iPk5p 5GHQCg6WD65TEUby1dfpX1OnSxDQLPELsSotQQ9qC/7pjnJoXE/7Ue6Xn+bmVchz7iNVyXcTlDp LXYJ/zJp9hKyBv8csrl1QP2SZ5ileFNSPAD+RCSmZj6DFiKDZJ0kIdXKPL+ZK9huXJaCTn8beRp WxTzGaFAv58Avc8wZAdlmd7iUywap/TzANZ5M+2WHPJnJA9gSW4+SuygemTcNs2/rcZ2j09HsS2 ojyIV3sBDFBpAzUekHKPaVqXFGix4aihWxrXUpcQhSWZhXiHGbJVKPMd1QWkMwdQA1L5a25buwk OyNw+mXb/DnPkrKqbsNi3OzDH1UzxnBoxxVJifwdIHjveK4VFl8M7Txh/o5XNa6MIhE1J2Eg== X-Received: by 2002:a05:6000:186e:b0:48d:ee0d:8b3d with SMTP id ffacd0b85a97d-48e07f9d49fmr23637520f8f.28.1792493018396; Tue, 20 Oct 2026 03:43:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Bibo Mao , Christian Borntraeger , Ilya Leoshkevich , Alistair Francis , Richard Henderson , Daniel Henrique Barboza , Paolo Bonzini , Eric Farman , Song Gao <17746591750@163.com>, Harsh Prateek Bora , David Hildenbrand , Bernhard Beschow , Halil Pasic , Nicholas Piggin , Paul Durrant , =?UTF-8?q?Bj=C3=B6rn=20Walk?= , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , qemu-ppc@nongnu.org, Marcelo Tosatti , kvm@vger.kernel.org, qemu-arm@nongnu.org, linux-edac@vger.kernel.org, Glenn Miles , Chao Liu , Cornelia Huck , Gautam Menghani , Xianglai Li , Pierrick Bouvier , Chinmay Rath , "Michael S. Tsirkin" , Matthew Rosato , Amit Machhiwal , Zhao Liu , Weiwei Li , Peter Maydell , Mauro Carvalho Chehab , qemu-riscv@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 23/23] accel/kvm: remove redundant ops checks for kvm_get_cpu_ops Date: Tue, 20 Oct 2026 11:43:17 +0100 Message-ID: <20261020104320.3686723-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020104320.3686723-1-alex.bennee@linaro.org> References: <20261020104320.3686723-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1792493694551158500 We assert that we should always be able to retrieve KVMCPUOps on an initialised system so remove the redundant checks. Signed-off-by: Alex Benn=C3=A9e --- accel/kvm/kvm-all.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 041113ed9b5..8b719d6eb44 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -455,11 +455,7 @@ static void kvm_create_vcpu_internal(CPUState *cpu, KV= MState *s, int kvm_fd) unsigned long kvm_vcpu_id(CPUState *cpu) { const KVMCPUOps *ops =3D kvm_get_cpu_ops(cpu); - - if (ops && ops->vcpu_id) { - return ops->vcpu_id(cpu); - } - return cpu->cpu_index; + return ops->vcpu_id ? ops->vcpu_id(cpu) : cpu->cpu_index; } =20 static int kvm_rebind_vcpus(Error **errp) @@ -3190,7 +3186,7 @@ static int kvm_handle_internal_error(CPUState *cpu, s= truct kvm_run *run) bool stop =3D true; =20 fprintf(stderr, "emulation failure\n"); - if (ops && ops->stop_on_emulation_error) { + if (ops->stop_on_emulation_error) { stop =3D ops->stop_on_emulation_error(cpu); } if (!stop) { @@ -4004,7 +4000,7 @@ void kvm_remove_all_gdbstub_breakpoints(CPUState *cpu) QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { int ret =3D -ENOENT; =20 - if (ops && ops->remove_sw_breakpoint) { + if (ops->remove_sw_breakpoint) { ret =3D ops->remove_sw_breakpoint(cpu, bp); } if (ret !=3D 0) { @@ -4021,7 +4017,7 @@ void kvm_remove_all_gdbstub_breakpoints(CPUState *cpu) QTAILQ_REMOVE(&s->kvm_sw_breakpoints, bp, entry); g_free(bp); } - if (ops && ops->remove_all_hw_breakpoints) { + if (ops->remove_all_hw_breakpoints) { ops->remove_all_hw_breakpoints(cpu); } =20 @@ -4116,7 +4112,7 @@ int kvm_on_sigbus(int code, void *addr) assert(code !=3D BUS_MCEERR_AR); assert(first_cpu); ops =3D kvm_get_cpu_ops(first_cpu); - if (ops && ops->on_sigbus_vcpu) { + if (ops->on_sigbus_vcpu) { ops->on_sigbus_vcpu(first_cpu, code, addr); return 0; } --=20 2.47.3