From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85201C77B7C for ; Thu, 3 Jul 2025 11:09:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uXHiX-0004AJ-B1; Thu, 03 Jul 2025 07:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uXHgj-0000HT-61 for qemu-devel@nongnu.org; Thu, 03 Jul 2025 07:01:13 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uXHgg-00040z-Gy for qemu-devel@nongnu.org; Thu, 03 Jul 2025 07:01:08 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45348bff79fso55591725e9.2 for ; Thu, 03 Jul 2025 04:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1751540464; x=1752145264; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wspTc+l3MR08+xJCCFDeyBx7BUrOtzx13ywN/0VFZp4=; b=GWZd8laJn8Fvu2k3jPMn9PsOoH9mBSnukGsfXuA8LBLaYE3qCVk1rJmyAPUK8lHTjR kT1ieTkfsCdYzBzXC6/qPMmlN16EPo05E47N89to3TsfyDstiYdBAp2bIzFXLYZqYHiI 2x/nOv7xBbzaurdby42DoXSppXqZEpdjhUMRvFXiClBS7y+NK/l5eb11v1QZ7O15pA0J Jb9hLzLWeDHTcAQKRcYwkwcTsSBY9fQuyyX+ZRNNV7ayCfwbbsiQYJukjalnvqSpAb8K 1Pr27s8oMxcIuW/egDagwWQ+im4aSUV58Pa2e+s0xMe+AMCsb5DjqW3+//VBnA6UlO2w JRlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751540464; x=1752145264; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wspTc+l3MR08+xJCCFDeyBx7BUrOtzx13ywN/0VFZp4=; b=LUiOLpL6iYOQZHQmmaPGPL8Xxpk6no9XAkbrzT0OVRxjuVgxVts7PaSnpzhg+8rkY8 Dbjz+Ff0JL7rBPK5ydoITrc95drOTg+zGK9ojoyuSKKLtCAMlzYUZSSIf2G78qDT10dO 0oG38l2PO34jgr6bIOtMTurYQuOWtgZvXV1sMUkVK55Tbaec+TpQz8OADBYV3o+8cTYD xHlt8pbH1AF4+xWsPErwT+NirSkC6Fl+N+MkJFgVfh+snCIW1pSKgCdFZVHmHryq9cRT nhmCXfkR4GdjNlG5QWMJ5+R900t6s7oeUPIc3XGc3d9MQWPTXib5CM5kyQ3MetADi/tU nD4w== X-Gm-Message-State: AOJu0YxGDJ/Y7M1QsyrD5z7k8i/5pP15aeDkAyb8n2TxsxVt9rz4nxI+ pwnuJfj2pd+Z2XULqC+du2IOb2oZgUPK6uvvp9akH/jnS6LkmSiRLBpMFniXEFE/823l9iwLLdF I7Y3bclA= X-Gm-Gg: ASbGncutfqqrMl63h2yNw1QClwijDN4EYLqptj3EOA4vK5Pz4p9O3e3A+r6L7UfX+vn k420n8KgHDZU/stbqEYyDqD45UYSMRAu0CDR3dTCvNn33Yhs5O84KqnYBliABpNGiwvUyi/q/6e z92dxB46n142BxJ6ntqAS3D76bWlDNB8F2Dssg/Yx6zAfLK4MGUAojI3uvhwDlcP46wDKPKHtDK QXEr5sn7UTZJzDrSAgA15xj2TEfvVtmI5m1vxf0VPpfzDhpKyvuX9YJDgPOb+bn2w61o2+W3p21 EZxVC9/vV+PWZ/wLZHbYOmVZbuHsa7RRvpGjw0LREfkjjAfU6Dqalw8B5sLOwtS//o5LLiAb+Av qyZtP0cxVnGo= X-Google-Smtp-Source: AGHT+IHAZ1QJQAR/SkCmpVyP5d+/RVl33yWqBUHoBvJQia/1ayRud+BeMI+m9TmrFuVOLmZ8hctUPQ== X-Received: by 2002:a05:600c:3504:b0:43c:ee3f:2c3 with SMTP id 5b1f17b1804b1-454a36e7842mr54691115e9.7.1751540464162; Thu, 03 Jul 2025 04:01:04 -0700 (PDT) Received: from localhost.localdomain ([83.247.137.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-454a9bcebd4sm23536465e9.26.2025.07.03.04.01.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Jul 2025 04:01:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Pierrick Bouvier , kvm@vger.kernel.org, Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Cameron Esfahani , Roman Bolshakov , Phil Dennis-Jordan , Mads Ynddal , Fabiano Rosas , Laurent Vivier , Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , Reinoud Zandijk , Sunil Muthuswamy , xen-devel@lists.xenproject.org Subject: [PATCH v5 61/69] accel: Expose and register generic_handle_interrupt() Date: Thu, 3 Jul 2025 12:55:27 +0200 Message-ID: <20250703105540.67664-62-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250703105540.67664-1-philmd@linaro.org> References: <20250703105540.67664-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In order to dispatch over AccelOpsClass::handle_interrupt(), we need it always defined, not calling a hidden handler under the hood. Make AccelOpsClass::handle_interrupt() mandatory. Expose generic_handle_interrupt() prototype and register it for each accelerator. Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Zhao Liu --- include/system/accel-ops.h | 3 +++ accel/hvf/hvf-accel-ops.c | 1 + accel/kvm/kvm-accel-ops.c | 1 + accel/qtest/qtest.c | 1 + accel/xen/xen-all.c | 1 + system/cpus.c | 9 +++------ target/i386/nvmm/nvmm-accel-ops.c | 1 + target/i386/whpx/whpx-accel-ops.c | 1 + 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h index 6d0791d73a4..dc8df9ba7dd 100644 --- a/include/system/accel-ops.h +++ b/include/system/accel-ops.h @@ -67,6 +67,7 @@ struct AccelOpsClass { void (*synchronize_state)(CPUState *cpu); void (*synchronize_pre_loadvm)(CPUState *cpu); + /* handle_interrupt is mandatory. */ void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask); /* get_vcpu_stats: Append statistics of this @cpu to @buf */ @@ -93,4 +94,6 @@ struct AccelOpsClass { void (*remove_all_breakpoints)(CPUState *cpu); }; +void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask); + #endif /* ACCEL_OPS_H */ diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index b61f08330f1..420630773c8 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -355,6 +355,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data) ops->cpu_thread_routine = hvf_cpu_thread_fn, ops->kick_vcpu_thread = hvf_kick_vcpu_thread; + ops->handle_interrupt = generic_handle_interrupt; ops->synchronize_post_reset = hvf_cpu_synchronize_post_reset; ops->synchronize_post_init = hvf_cpu_synchronize_post_init; diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index 841024148e1..b79c04b6267 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -85,6 +85,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data) ops->synchronize_post_init = kvm_cpu_synchronize_post_init; ops->synchronize_state = kvm_cpu_synchronize_state; ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm; + ops->handle_interrupt = generic_handle_interrupt; #ifdef TARGET_KVM_HAVE_GUEST_DEBUG ops->update_guest_debug = kvm_update_guest_debug_ops; diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index 9f30098d133..47fa9e38ce3 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -68,6 +68,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, const void *data) ops->cpu_thread_routine = dummy_cpu_thread_routine; ops->get_virtual_clock = qtest_get_virtual_clock; ops->set_virtual_clock = qtest_set_virtual_clock; + ops->handle_interrupt = generic_handle_interrupt; }; static const TypeInfo qtest_accel_ops_type = { diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index e2ad42c0d18..a51f4c5b2ad 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -154,6 +154,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data) ops->thread_precreate = dummy_thread_precreate; ops->cpu_thread_routine = dummy_cpu_thread_routine; + ops->handle_interrupt = generic_handle_interrupt; } static const TypeInfo xen_accel_ops_type = { diff --git a/system/cpus.c b/system/cpus.c index 8c2647f5f19..efe1a5e211b 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -246,7 +246,7 @@ int64_t cpus_get_elapsed_ticks(void) return cpu_get_ticks(); } -static void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask) +void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask) { if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(cpu); @@ -261,11 +261,7 @@ void cpu_interrupt(CPUState *cpu, int mask) cpu->interrupt_request |= mask; - if (cpus_accel->handle_interrupt) { - cpus_accel->handle_interrupt(cpu, old_mask, cpu->interrupt_request); - } else { - generic_handle_interrupt(cpu, old_mask, cpu->interrupt_request); - } + cpus_accel->handle_interrupt(cpu, old_mask, cpu->interrupt_request); } /* @@ -674,6 +670,7 @@ void cpus_register_accel(const AccelOpsClass *ops) { assert(ops != NULL); assert(ops->create_vcpu_thread || ops->cpu_thread_routine); + assert(ops->handle_interrupt); cpus_accel = ops; } diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c index bef6f61b776..d568cc737b1 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -77,6 +77,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data) ops->cpu_thread_routine = qemu_nvmm_cpu_thread_fn; ops->kick_vcpu_thread = nvmm_kick_vcpu_thread; + ops->handle_interrupt = generic_handle_interrupt; ops->synchronize_post_reset = nvmm_cpu_synchronize_post_reset; ops->synchronize_post_init = nvmm_cpu_synchronize_post_init; diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c index 8cbc6f4e2d8..fbffd952ac4 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -80,6 +80,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) ops->cpu_thread_routine = whpx_cpu_thread_fn; ops->kick_vcpu_thread = whpx_kick_vcpu_thread; ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle; + ops->handle_interrupt = generic_handle_interrupt; ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset; ops->synchronize_post_init = whpx_cpu_synchronize_post_init; -- 2.49.0