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 D5277C77B7C for ; Wed, 2 Jul 2025 19:09:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uX2hW-0008Gy-0G; Wed, 02 Jul 2025 15:00:58 -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 1uX2gy-00076v-04 for qemu-devel@nongnu.org; Wed, 02 Jul 2025 15:00:29 -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 1uX2gr-0003Uz-ID for qemu-devel@nongnu.org; Wed, 02 Jul 2025 15:00:23 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-451ebd3d149so26705335e9.2 for ; Wed, 02 Jul 2025 12:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1751482815; x=1752087615; 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=qjqfaworQi5+uUmLYrSAUcjlpIaexJI+AEwRhAoMmIE=; b=UzEIJANnqou8ATPWzu4zAIvMPkk51tm3Moyvctne4GtprzaFz3F8ZkgG/955XiVob0 tDEIt/koToyjT42JGaMd/tjpXBxC3LM33ctlu7dGsy/cCnf242dtB2+5q973nmW8NG16 DnYP0tyJ6p9Tkw0G5K0rVqFpTIDbQb53ZAEz41hXz4ZpmoUKktB8nt+cchKJqN3WtsPI 0CwP/KbwrHUricV62VdY0aNAfclfFPOwb7tQVnytEtlZr3YwWgz9S+GaXkyfkGnJ3lsR OMzmcyNE+uXt6cHiv0Yvh2jaPAvraX/x7ueJmMV0pcbeYO8EtSY9zUrg0VfIltsqdCUi PcQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751482815; x=1752087615; 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=qjqfaworQi5+uUmLYrSAUcjlpIaexJI+AEwRhAoMmIE=; b=s9bmP1d7XzKowX1E9MS1Fb/G2pgwqUYMlI4TfGDhemDH8qoSxLFvE7HzArgTMG7ZRB JGCgFj1EPYYvjCgIKtxeSmvr13N3crzuKdknz4Ks3+6xV2wFegbUsAEZOIjCAIxlrs4G sDHR6TFildfvgxU5g4XhmC6CXRGi9EVtTuvp1gVbb10zdcqU322OmMx5CpewolqJx+Sb sD2TpAygITlH1hK24/EtKEA3B0Da3WXSVy7d6QnZ/VZitPHfKVGnaKKgoABX6jbvnwpg C4iuIMpwuMe2vYDHOSuTjWHGQJaD0C8zT9nUqs30jlf/AQhTA9msZHniQLBaM+Sm/HbC HvBQ== X-Gm-Message-State: AOJu0YxcTrYf4tU0zcGNlc8Fu72qDs+r/lKgQtfyBfZm89AHuwM0Xl8q iF/oeWimsNp7MopGa3v8VkOKsHyvzQ1cT6LXp6AOkTqsuBl8kpPLhI8OsIm9dEkdMSjkGF9MuIo ierP4 X-Gm-Gg: ASbGncu0WZaN1136qRKKLBDryq9Lx4l4o5txp4kf6QTuYysh4HZB8nLcsmI+HVplWDJ cd6r3cpyJMntkQ7F+IS8FCYgS2j+IszaeubFPsUXJwe798FN49PU9LQt3IU43YgNLUz+XmUZawH AtT5FSjH7uyuMpi62HAePYO5OGQ7NfqLa7MaVhLFANmHLhNcyxttt6p8X3bB70fPo1+ZrX1illK kWfespVZEaOKL8pnNxl02naNXWbUeMvDrfKThrnxy2q35H4g8Ka+/1ZfYzsQrTlJKaOMtTGsNwg mdTbscCg36V8ZdfRRt1kCVzhjUmAqiJyV5iqOTuGbwXTaZTChEeMb8gS7YoO0G2nGy059jHftKK 9MNKGLC/D+Nqs12hCLVPQdlmv1tQ4bn0yNxG1 X-Google-Smtp-Source: AGHT+IEMsqDmMhc/MmoijRDQjf3Y2fDb5Gx/YmjzjJrapmNl0kjGvDhI6axGOrVibgjZIifLKxTGyg== X-Received: by 2002:a05:600c:6309:b0:445:1984:247d with SMTP id 5b1f17b1804b1-454aa185780mr4322005e9.7.1751482815180; Wed, 02 Jul 2025 12:00:15 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-454a997b492sm5832775e9.13.2025.07.02.12.00.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Jul 2025 12:00:14 -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 , Richard Henderson , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , 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 , kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler Date: Wed, 2 Jul 2025 20:53:20 +0200 Message-ID: <20250702185332.43650-59-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250702185332.43650-1-philmd@linaro.org> References: <20250702185332.43650-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::32d; envelope-from=philmd@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, T_SPF_TEMPERROR=0.01 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::get_elapsed_ticks(), we need it always defined, not calling a hidden handler under the hood. Make AccelOpsClass::get_elapsed_ticks() mandatory. Register the default cpus_kick_thread() for each accelerator. Signed-off-by: Philippe Mathieu-Daudé --- include/system/accel-ops.h | 1 + accel/hvf/hvf-accel-ops.c | 2 ++ accel/kvm/kvm-accel-ops.c | 3 +++ accel/qtest/qtest.c | 2 ++ accel/tcg/tcg-accel-ops.c | 3 +++ accel/xen/xen-all.c | 2 ++ system/cpus.c | 6 ++---- target/i386/nvmm/nvmm-accel-ops.c | 3 +++ target/i386/whpx/whpx-accel-ops.c | 3 +++ 9 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h index e1e6985a27c..8683cd37716 100644 --- a/include/system/accel-ops.h +++ b/include/system/accel-ops.h @@ -86,6 +86,7 @@ struct AccelOpsClass { int64_t (*get_virtual_clock)(void); void (*set_virtual_clock)(int64_t time); + /* get_elapsed_ticks is mandatory. */ int64_t (*get_elapsed_ticks)(void); /* gdbstub hooks */ diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 420630773c8..17776e700eb 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -54,6 +54,7 @@ #include "gdbstub/enums.h" #include "exec/cpu-common.h" #include "system/accel-ops.h" +#include "system/cpu-timers.h" #include "system/cpus.h" #include "system/hvf.h" #include "system/hvf_int.h" @@ -367,6 +368,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data) ops->remove_all_breakpoints = hvf_remove_all_breakpoints; ops->update_guest_debug = hvf_update_guest_debug; + ops->get_elapsed_ticks = cpu_get_ticks; ops->get_vcpu_stats = hvf_get_vcpu_stats; }; diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index a4bcaa87c8d..f27228d4cd9 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -17,6 +17,7 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "system/accel-ops.h" +#include "system/cpu-timers.h" #include "system/kvm.h" #include "system/kvm_int.h" #include "system/runstate.h" @@ -94,6 +95,8 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data) ops->remove_breakpoint = kvm_remove_breakpoint; ops->remove_all_breakpoints = kvm_remove_all_breakpoints; #endif + + ops->get_elapsed_ticks = cpu_get_ticks; } static const TypeInfo kvm_accel_ops_type = { diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index 8e2379d6e37..b019cf69412 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -20,6 +20,7 @@ #include "qemu/accel.h" #include "system/accel-ops.h" #include "system/qtest.h" +#include "system/cpu-timers.h" #include "system/cpus.h" #include "qemu/guest-random.h" #include "qemu/main-loop.h" @@ -67,6 +68,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, const void *data) ops->thread_precreate = dummy_thread_precreate; ops->cpu_thread_routine = dummy_cpu_thread_routine; ops->kick_vcpu_thread = cpus_kick_thread; + ops->get_elapsed_ticks = cpu_get_ticks; ops->get_virtual_clock = qtest_get_virtual_clock; ops->set_virtual_clock = qtest_set_virtual_clock; ops->handle_interrupt = generic_handle_interrupt; diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index a8c24cf8a4c..f22f5d73abe 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -27,6 +27,7 @@ #include "qemu/osdep.h" #include "system/accel-ops.h" +#include "system/cpu-timers.h" #include "system/tcg.h" #include "system/replay.h" #include "exec/icount.h" @@ -205,6 +206,7 @@ static void tcg_accel_ops_init(AccelClass *ac) ops->cpu_thread_routine = mttcg_cpu_thread_routine; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; ops->handle_interrupt = tcg_handle_interrupt; + ops->get_elapsed_ticks = cpu_get_ticks; } else { ops->create_vcpu_thread = rr_start_vcpu_thread; ops->kick_vcpu_thread = rr_kick_vcpu_thread; @@ -215,6 +217,7 @@ static void tcg_accel_ops_init(AccelClass *ac) ops->get_elapsed_ticks = icount_get; } else { ops->handle_interrupt = tcg_handle_interrupt; + ops->get_elapsed_ticks = cpu_get_ticks; } } diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 18ae0d82db5..48d458bc4c7 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -20,6 +20,7 @@ #include "qemu/accel.h" #include "accel/dummy-cpus.h" #include "system/accel-ops.h" +#include "system/cpu-timers.h" #include "system/cpus.h" #include "system/xen.h" #include "system/runstate.h" @@ -156,6 +157,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data) ops->cpu_thread_routine = dummy_cpu_thread_routine; ops->kick_vcpu_thread = cpus_kick_thread; ops->handle_interrupt = generic_handle_interrupt; + ops->get_elapsed_ticks = cpu_get_ticks; } static const TypeInfo xen_accel_ops_type = { diff --git a/system/cpus.c b/system/cpus.c index 6c64ffccbb3..d32b89ecf7b 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -240,10 +240,7 @@ void cpus_set_virtual_clock(int64_t new_time) */ int64_t cpus_get_elapsed_ticks(void) { - if (cpus_accel->get_elapsed_ticks) { - return cpus_accel->get_elapsed_ticks(); - } - return cpu_get_ticks(); + return cpus_accel->get_elapsed_ticks(); } void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask) @@ -668,6 +665,7 @@ void cpus_register_accel(const AccelOpsClass *ops) assert(ops->create_vcpu_thread || ops->cpu_thread_routine); assert(ops->kick_vcpu_thread); assert(ops->handle_interrupt); + assert(ops->get_elapsed_ticks); cpus_accel = ops; } diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c index d568cc737b1..4deff57471c 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -11,6 +11,7 @@ #include "system/kvm_int.h" #include "qemu/main-loop.h" #include "system/accel-ops.h" +#include "system/cpu-timers.h" #include "system/cpus.h" #include "qemu/guest-random.h" @@ -83,6 +84,8 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data) ops->synchronize_post_init = nvmm_cpu_synchronize_post_init; ops->synchronize_state = nvmm_cpu_synchronize_state; ops->synchronize_pre_loadvm = nvmm_cpu_synchronize_pre_loadvm; + + ops->get_elapsed_ticks = cpu_get_ticks; } static const TypeInfo nvmm_accel_ops_type = { diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c index fbffd952ac4..f47033a502c 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -12,6 +12,7 @@ #include "system/kvm_int.h" #include "qemu/main-loop.h" #include "system/accel-ops.h" +#include "system/cpu-timers.h" #include "system/cpus.h" #include "qemu/guest-random.h" @@ -86,6 +87,8 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) ops->synchronize_post_init = whpx_cpu_synchronize_post_init; ops->synchronize_state = whpx_cpu_synchronize_state; ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm; + + ops->get_elapsed_ticks = cpu_get_ticks; } static const TypeInfo whpx_accel_ops_type = { -- 2.49.0