From patchwork Thu Jun 20 15:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=y8kGqvgm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4klJ1RVQz20KL for ; Fri, 21 Jun 2024 01:23:08 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcK-0005lv-Gr; Thu, 20 Jun 2024 11:22:28 -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 1sKJcJ-0005kw-Jf for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:27 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcH-0007uU-RX for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:27 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-57cf8880f95so1162321a12.3 for ; Thu, 20 Jun 2024 08:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896944; x=1719501744; 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=2yimdE3nPFUILo7awwhHRy/OflE23PtwusH0HEIKw8g=; b=y8kGqvgmunhoK6+Qx6ouVwHXfJobJfIzSioXKnjErGdhu6UH6m8nHOu5JvnIorlU+Y yVdug8rmWHpMqqKF2RQ9CY+HB+VYs1EKQH1q4TwLNKm87IEGurQRuOcHDHL2a5zYZCEn QPujWboLvLqe2KCp9UFhkWi9F+KEpwG6gFaz8shEzbcJWcsrsl4j/FU/69MPMZVXEeF9 JXA6KGtze5YMVk6MYmdheGqXiiAYEjXzto6oNhdcXXdvojCFEB1afJRTv0HmlfxT6v4e hTbfhNnitErRXaYd6VnUSAMgsdwNqT4inE/sDOEwKx0k7VdSX6U0y2YuMRMe97zmEIH8 zjAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896944; x=1719501744; 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=2yimdE3nPFUILo7awwhHRy/OflE23PtwusH0HEIKw8g=; b=tdevPXixjhbXFEjB2H/c0pTIjw7DqLFUCErbV6/TDQ4oFghtVXNN6uSIzN08KFZbMc j5Q0MKBGSomwN6a1xxE/DgPPNI8aWSYDNC5qtRMGdti9XXcUEBnt6LaALNdvYoA4bHbD uXYyVLvrQoNeUjf54j47kNgSToJGBbfqAcK5SMfoeruzPfp2c76Vqsx/LOe15l2mgVAh sEB3zypWMuTymnde6a08wqn6WTzonelvzJ7C2mdAMxnOWwtGKT2DqcncoiPQJjE4hYBK HrDQkIyXZ6T+jxAvCgfvnqbe/Hoib7EM2+u/IFCFx9FuxrmnvmMvwIlJRe7FrAjFMJNh k2FA== X-Gm-Message-State: AOJu0YwGF2HddK2R7S08wQLKkyy+q5Fg+cRXUDacO6NpOwxD6Tt+f/fw VmgHSJm4lPjNnLD6nWsPkFy5fh3m4GOU1kPDvhhOgKxeigcxsRSJTfXYadEgDtA= X-Google-Smtp-Source: AGHT+IF0pT64lOwvmgjrnZz5oRbIp3FmEbDr7uORUII+TZgPVQWBUAxVEabv+gd2aImTVoquazQfRQ== X-Received: by 2002:a50:8704:0:b0:57d:3ea:3862 with SMTP id 4fb4d7f45d1cf-57d07ed410dmr4532022a12.27.1718896943048; Thu, 20 Jun 2024 08:22:23 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d21df986esm1006464a12.72.2024.06.20.08.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:22 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 137115F892; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 01/12] include/exec: add missing include guard comment Date: Thu, 20 Jun 2024 16:22:09 +0100 Message-Id: <20240620152220.2192768-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x533.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Message-Id: <20240612153508.1532940-2-alex.bennee@linaro.org> Reviewed-by: Pierrick Bouvier Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index eb14b91139..008a92198a 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -144,4 +144,4 @@ void gdb_set_stop_cpu(CPUState *cpu); /* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ extern const GDBFeature gdb_static_features[]; -#endif +#endif /* GDBSTUB_H */ From patchwork Thu Jun 20 15:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=JhgrPMpc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4km41jwxz20KL for ; Fri, 21 Jun 2024 01:23:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcL-0005np-VA; Thu, 20 Jun 2024 11:22:29 -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 1sKJcK-0005m4-Pe for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:28 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcH-0007uj-Uq for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:28 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-57cfe600cbeso1199997a12.2 for ; Thu, 20 Jun 2024 08:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896944; x=1719501744; 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=LOX8Q5w9ilc+mTdUjLpvpvMTTAOVE9Tn6EBHwdgleNg=; b=JhgrPMpcw9MvfOis0ZG6VkQ1Yu3mR8A2YHgcNN/MIMGxJmCpWWjTisS/dhHjufWzvb U35BxPASPl9+nta7CTxxwuyud8RkPd7Gz6udYw2rde9N8Kmlv6VcXvJfYfs9140zWM5E rNDKcta/kbF0HVwgvi0vuVGeuULHQB6KDfqpCJAbYn/Vj0um0ksCll0+m+FeB3oxsyry z5LBiwvHPAoQXT1A4Kh4j+DUJAcxWWuMgciSnpyLpA0/t6sh3n6o0UzBAUV1oLq3hJpw dst/+tvd56PzzfmAaQHVEujHDsEvWa0Q3V6LeLW5tuFrKr0m0p+vSdYUhBJS03AY87IE It9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896944; x=1719501744; 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=LOX8Q5w9ilc+mTdUjLpvpvMTTAOVE9Tn6EBHwdgleNg=; b=H4cMaZ88Y7tgbMT62iAqmmCKqfz55R+FoEr0Qfbw0Sk814TegrlGLKSOMt0gd7BJjR 8y9GwWcG3CrbSf2r7qV10USImI5BuKI2UCWcbCQq6e6UQkTkndli4qiUBYjT6sEJIqHr vkuAmQfrEATpcvap8A/ScVps0TodHlzb6+LGFVyvGlFEVyjncV0gVomT3cOxieRTAgFw QvDKWN/7coqlHPvg6pyzF/4S/UjFdIZuQckuCIghMgwu0pg7OmC40Qvd7lRC17VIykcd RIXDHC4X44MPbGTSY7CEZWcjKoXKDjMwClt9C/Om0ePuIQvS59F7ehL17kgE/v+O+iqS lYog== X-Gm-Message-State: AOJu0YzRv6OtWj3M0j7AExS5+EJIPOItzGEIPVmk30J4IkoJidRrQfU9 zgpB0zvg6LDSsYhzPsSBX+6FYusOdm+a545OuBSh6KTZQWklPcvqzefq2haK+O4= X-Google-Smtp-Source: AGHT+IH8hZbaChjM3AJnO+aTrpsliFi4MfatJ5ruTS8TFIL6GBCuxi+m7UFhpS7uCY4WZIHcqJtRQw== X-Received: by 2002:a17:906:d8a:b0:a6f:4c90:7951 with SMTP id a640c23a62f3a-a6fab60bcc3mr306422166b.8.1718896943901; Thu, 20 Jun 2024 08:22:23 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56ecd5bfsm774823766b.113.2024.06.20.08.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:22 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3A38F5F9F3; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 02/12] gdbstub: move enums into separate header Date: Thu, 20 Jun 2024 16:22:10 +0100 Message-Id: <20240620152220.2192768-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is an experiment to further reduce the amount we throw into the exec headers. It might not be as useful as I initially thought because just under half of the users also need gdbserver_start(). Message-Id: <20240612153508.1532940-3-alex.bennee@linaro.org> Reviewed-by: Pierrick Bouvier Signed-off-by: Alex Bennée --- include/exec/gdbstub.h | 9 --------- include/gdbstub/enums.h | 21 +++++++++++++++++++++ accel/hvf/hvf-accel-ops.c | 2 +- accel/kvm/kvm-all.c | 2 +- accel/tcg/tcg-accel-ops.c | 2 +- gdbstub/user.c | 1 + monitor/hmp-cmds.c | 3 ++- system/vl.c | 1 + target/arm/hvf/hvf.c | 2 +- target/arm/hyp_gdbstub.c | 2 +- target/arm/kvm.c | 2 +- target/i386/kvm/kvm.c | 2 +- target/ppc/kvm.c | 2 +- target/s390x/kvm/kvm.c | 2 +- 14 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 include/gdbstub/enums.h diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 008a92198a..1bd2c4ec2a 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -1,15 +1,6 @@ #ifndef GDBSTUB_H #define GDBSTUB_H -#define DEFAULT_GDBSTUB_PORT "1234" - -/* GDB breakpoint/watchpoint types */ -#define GDB_BREAKPOINT_SW 0 -#define GDB_BREAKPOINT_HW 1 -#define GDB_WATCHPOINT_WRITE 2 -#define GDB_WATCHPOINT_READ 3 -#define GDB_WATCHPOINT_ACCESS 4 - typedef struct GDBFeature { const char *xmlname; const char *xml; diff --git a/include/gdbstub/enums.h b/include/gdbstub/enums.h new file mode 100644 index 0000000000..c4d54a1d08 --- /dev/null +++ b/include/gdbstub/enums.h @@ -0,0 +1,21 @@ +/* + * gdbstub enums + * + * Copyright (c) 2024 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef GDBSTUB_ENUMS_H +#define GDBSTUB_ENUMS_H + +#define DEFAULT_GDBSTUB_PORT "1234" + +/* GDB breakpoint/watchpoint types */ +#define GDB_BREAKPOINT_SW 0 +#define GDB_BREAKPOINT_HW 1 +#define GDB_WATCHPOINT_WRITE 2 +#define GDB_WATCHPOINT_READ 3 +#define GDB_WATCHPOINT_ACCESS 4 + +#endif /* GDBSTUB_ENUMS_H */ diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index b2a37a2229..ac08cfb9f3 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -52,7 +52,7 @@ #include "qemu/main-loop.h" #include "exec/address-spaces.h" #include "exec/exec-all.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "sysemu/cpus.h" #include "sysemu/hvf.h" #include "sysemu/hvf_int.h" diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 854cb86b22..2b4ab89679 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -27,7 +27,7 @@ #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/s390x/adapter.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "sysemu/kvm_int.h" #include "sysemu/runstate.h" #include "sysemu/cpus.h" diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 1433e38f40..3c19e68a79 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -35,7 +35,7 @@ #include "exec/exec-all.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "hw/core/cpu.h" diff --git a/gdbstub/user.c b/gdbstub/user.c index edeb72efeb..e34b58b407 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -18,6 +18,7 @@ #include "exec/gdbstub.h" #include "gdbstub/syscalls.h" #include "gdbstub/user.h" +#include "gdbstub/enums.h" #include "hw/core/cpu.h" #include "trace.h" #include "internals.h" diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 45ee3a9e1f..f601d06ab8 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -15,8 +15,9 @@ #include "qemu/osdep.h" #include "exec/address-spaces.h" -#include "exec/gdbstub.h" #include "exec/ioport.h" +#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "monitor/hmp.h" #include "qemu/help_option.h" #include "monitor/monitor-internal.h" diff --git a/system/vl.c b/system/vl.c index a3eede5fa5..cfcb674425 100644 --- a/system/vl.c +++ b/system/vl.c @@ -68,6 +68,7 @@ #include "sysemu/numa.h" #include "sysemu/hostmem.h" #include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "qemu/timer.h" #include "chardev/char.h" #include "qemu/bitmap.h" diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 45e2218be5..ef9bc42738 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -33,7 +33,7 @@ #include "trace/trace-target_arm_hvf.h" #include "migration/vmstate.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #define MDSCR_EL1_SS_SHIFT 0 #define MDSCR_EL1_MDE_SHIFT 15 diff --git a/target/arm/hyp_gdbstub.c b/target/arm/hyp_gdbstub.c index ebde2899cd..f120d55caa 100644 --- a/target/arm/hyp_gdbstub.c +++ b/target/arm/hyp_gdbstub.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "internals.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" /* Maximum and current break/watch point counts */ int max_hw_bps, max_hw_wps; diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 7cf5cf31de..70f79eda33 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -31,7 +31,7 @@ #include "hw/pci/pci.h" #include "exec/memattrs.h" #include "exec/address-spaces.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "hw/boards.h" #include "hw/irq.h" #include "qapi/visitor.h" diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 7ad8072748..dd8b0f3313 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -38,7 +38,7 @@ #include "hyperv.h" #include "hyperv-proto.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "qemu/host-utils.h" #include "qemu/main-loop.h" #include "qemu/ratelimit.h" diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 005f2239f3..2c3932200b 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -39,7 +39,7 @@ #include "migration/qemu-file-types.h" #include "sysemu/watchdog.h" #include "trace.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "exec/memattrs.h" #include "exec/ram_addr.h" #include "sysemu/hostmem.h" diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 1b494ecc20..94181d9281 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -40,7 +40,7 @@ #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" #include "sysemu/device_tree.h" -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" #include "exec/ram_addr.h" #include "trace.h" #include "hw/s390x/s390-pci-inst.h" From patchwork Thu Jun 20 15:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=JQ9QJAAF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4kn70QYHz20KL for ; Fri, 21 Jun 2024 01:24:43 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcP-0005pv-Bb; Thu, 20 Jun 2024 11:22:33 -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 1sKJcN-0005of-8c for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:31 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcL-0007x7-KX for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:30 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-57d15b85a34so1204595a12.3 for ; Thu, 20 Jun 2024 08:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896948; x=1719501748; 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=GJDItK1lJ7pU44CkysDABVIUb9quWUurAs3tDshcfJY=; b=JQ9QJAAFPFPmroROCjiWION6Zc+40YqR1RJTI5pKkcc2/e188KLCYZ/MBLnC0Qvvd7 1drXd2pKKoA4PATTo5kRPcJlYLy+o4zx39Y67L9I1MejolRIU7hThnDUplijKN8/f6JF rMZGOzvk84yHiC6GYfw2baJMwtYJgtXs35Mp7m0oh9LCkrG5j4SB3LFYbZaxAbYGrgo4 FHUuIucSxDZ02a7SuI4jI8GnqZMPuqVNRg/PsflfpWsn1T2n9xm01tMMnCGGtG8EY08R Fzkvy9v8HdumUPYQjprRgd8JR2C7VH5v1jmT/PnP/YJ5NT5LUNApraM1u6dfK8SgeyFm n1WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896948; x=1719501748; 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=GJDItK1lJ7pU44CkysDABVIUb9quWUurAs3tDshcfJY=; b=sTPaWE6995LyT2JaV1AbGahJrcXmVANcqJjLQYKWzsUEZFjxTeddrjozmGqTl2ivVs crFvLzESCUkPsohgo9IJuEbYHXqmvDXoKK0BnEMPilstNue2ctzGo3dX5J6sbW3HcSvY SqVkhhbXHtD6qooN6s06vZ3yZHpGtdYIllhtmZ0ZgIFIOpGJ5VRZXtd0DEpdzl0Vqg6v 8nPc+Vp+BhWhN8k7xbMp6eO5xPswBizbRKSPmABhmfb2bQzuFpVDSNv9sWdWDR1/zgf1 e82q1A+8AnijiNibyrD+ZguxATTxDviAT4MOBJLUVJlV2/kbyPVlh84EQyCNnRBHnJ38 UHew== X-Gm-Message-State: AOJu0YyefX0ISJyFHJy7XKbwywugBm8nwP8c/rKQ58WdErJT7YeJYX5h K2PpeDDMQeqp+EZEVhixaVV2DV8iXq4CUN90TKgPNcP0hRYYiMD463BVjsTKOf0= X-Google-Smtp-Source: AGHT+IH0DozvQRi/LaMdJtXI1+l7Oz911+HmQ8KveXTxshkIx5oakUEt56iH61txi2255uJDmlcM0w== X-Received: by 2002:a50:cd97:0:b0:57d:61a:7f20 with SMTP id 4fb4d7f45d1cf-57d07e6ba6cmr3862286a12.3.1718896948159; Thu, 20 Jun 2024 08:22:28 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d16160c18sm1609800a12.26.2024.06.20.08.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:22 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 51EE45F9F4; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Akihiko Odaki Subject: [PATCH v2 03/12] plugins: Ensure register handles are not NULL Date: Thu, 20 Jun 2024 16:22:11 +0100 Message-Id: <20240620152220.2192768-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x531.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, T_SCC_BODY_TEXT_LINE=-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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Akihiko Odaki Ensure register handles are not NULL so that a plugin can assume NULL is invalid as a register handle. Signed-off-by: Akihiko Odaki Reviewed-by: Pierrick Bouvier Message-Id: <20240612153508.1532940-4-alex.bennee@linaro.org> Message-Id: <20240229-null-v1-1-e716501d981e@daynix.com> Signed-off-by: Alex Bennée --- plugins/api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/api.c b/plugins/api.c index 5a0a7f8c71..6bdb26bbe3 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -507,7 +507,7 @@ static GArray *create_register_handles(GArray *gdbstub_regs) } /* Create a record for the plugin */ - desc.handle = GINT_TO_POINTER(grd->gdb_reg); + desc.handle = GINT_TO_POINTER(grd->gdb_reg + 1); desc.name = g_intern_string(grd->name); desc.feature = g_intern_string(grd->feature_name); g_array_append_val(find_data, desc); @@ -528,7 +528,7 @@ int qemu_plugin_read_register(struct qemu_plugin_register *reg, GByteArray *buf) { g_assert(current_cpu); - return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg)); + return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg) - 1); } struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_size) From patchwork Thu Jun 20 15:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950237 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=H0tVDB9+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4kmv6DyJz20XW for ; Fri, 21 Jun 2024 01:24:31 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcQ-0005qW-Fe; Thu, 20 Jun 2024 11:22:34 -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 1sKJcO-0005p8-Te for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:32 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcM-0007xk-NE for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:32 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-57d0eca877cso1157638a12.2 for ; Thu, 20 Jun 2024 08:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896949; x=1719501749; 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=/X0IxOQD+UVox1iqgN/w4twKxD3yeUu+cfpZug2C5Oo=; b=H0tVDB9+7kuD8x7uXDZ79zkZgHFwKgo82FgNOgxBZ0KNBryUNvMD//aLkrmHsM2Gl+ jy3895wUQ5FBqREJ08qbmwCOJ0GHUL07CJltkP2wXov/mwms21hkCKNjJBcdlRJI1crL rbiHBDyrsQ+yhYPk1XAWIm6R96q8afNxeO8z7xjnzpHq0IBpbc5WcDLAIOSA0CxQWHD4 fLCPCAODeSJPPUhG/3OHXB8qg0TxRIzaH1XD9Xfq8pULYervLCMwt02JbUplf4Ncq02o nvsHjZ4elRNfcTbCtEM/BReGmLwFHCilOlLKiPmz80gP3Kj1xHDnx3yMcSykBmCnv+XH 4Ymg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896949; x=1719501749; 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=/X0IxOQD+UVox1iqgN/w4twKxD3yeUu+cfpZug2C5Oo=; b=oi2T6ylKLsMOkO9Il0kANvyUEu6hyYLcEtBfMK5Sfi4umYByHKodYFeoDS0j9xYVp3 7jEvwnQZkkpaNTIs89Rfd6AeNkIDMyzYploM64y0nyQ38CNT7fycRsvW7D3ODS2/hdKf jZJwnfxLS3iNAUDYY0c2Ryb4uqYB+Z6dBl/qHA8gMsGkkpL9QOhzS13IZm3Y0yH5sB58 hSfreoW7hzq24L/2w3749Kb69oq4dt2wFfSW94GEbvjkIV42E4DciOx9NM3aw6ilsRj+ d/CfsiNPwXA/7LADzq0rQ/BeF+lT7LTwmVKgftAMtio76nzb/jiH38MIWPz+BBPHvFnZ wlWA== X-Gm-Message-State: AOJu0YwzTYFCvcAVQlJjoFsrfBSLXWqtFYW8Xc5pdW15dQEAWD8Uq0f/ r0Qd4THc31wuXD4GJknFWCqo5BsdvbbaEZy31ww0qVXJlt0kLgcGkrfAiCHOegw= X-Google-Smtp-Source: AGHT+IFnftecJ/1MRTQF1ZOm+xWFpcYdRKEdC+4UG5LvASjIC+lNz5bhVZnty9lEhOtdxKLlbFvYZw== X-Received: by 2002:a50:ccca:0:b0:57a:2475:6a16 with SMTP id 4fb4d7f45d1cf-57d07e7bc1bmr5166576a12.11.1718896948929; Thu, 20 Jun 2024 08:22:28 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72e9943sm9855578a12.51.2024.06.20.08.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:22 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6C5285F9FB; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 04/12] sysemu: add set_virtual_time to accel ops Date: Thu, 20 Jun 2024 16:22:12 +0100 Message-Id: <20240620152220.2192768-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x531.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, T_SCC_BODY_TEXT_LINE=-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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We are about to remove direct calls to individual accelerators for this information and will need a central point for plugins to hook into time changes. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Pierrick Bouvier Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20240530220610.1245424-2-pierrick.bouvier@linaro.org> --- include/sysemu/accel-ops.h | 18 +++++++++++++++++- include/sysemu/cpu-timers.h | 3 ++- ...et-virtual-clock.c => cpus-virtual-clock.c} | 5 +++++ system/cpus.c | 11 +++++++++++ stubs/meson.build | 2 +- 5 files changed, 36 insertions(+), 3 deletions(-) rename stubs/{cpus-get-virtual-clock.c => cpus-virtual-clock.c} (68%) diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index ef91fc28bb..a088672230 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -20,7 +20,12 @@ typedef struct AccelOpsClass AccelOpsClass; DECLARE_CLASS_CHECKERS(AccelOpsClass, ACCEL_OPS, TYPE_ACCEL_OPS) -/* cpus.c operations interface */ +/** + * struct AccelOpsClass - accelerator interfaces + * + * This structure is used to abstract accelerator differences from the + * core CPU code. Not all have to be implemented. + */ struct AccelOpsClass { /*< private >*/ ObjectClass parent_class; @@ -44,7 +49,18 @@ struct AccelOpsClass { void (*handle_interrupt)(CPUState *cpu, int mask); + /** + * @get_virtual_clock: fetch virtual clock + * @set_virtual_clock: set virtual clock + * + * These allow the timer subsystem to defer to the accelerator to + * fetch time. The set function is needed if the accelerator wants + * to track the changes to time as the timer is warped through + * various timer events. + */ int64_t (*get_virtual_clock)(void); + void (*set_virtual_clock)(int64_t time); + int64_t (*get_elapsed_ticks)(void); /* gdbstub hooks */ diff --git a/include/sysemu/cpu-timers.h b/include/sysemu/cpu-timers.h index d86738a378..7bfa960fbd 100644 --- a/include/sysemu/cpu-timers.h +++ b/include/sysemu/cpu-timers.h @@ -96,8 +96,9 @@ int64_t cpu_get_clock(void); void qemu_timer_notify_cb(void *opaque, QEMUClockType type); -/* get the VIRTUAL clock and VM elapsed ticks via the cpus accel interface */ +/* get/set VIRTUAL clock and VM elapsed ticks via the cpus accel interface */ int64_t cpus_get_virtual_clock(void); +void cpus_set_virtual_clock(int64_t new_time); int64_t cpus_get_elapsed_ticks(void); #endif /* SYSEMU_CPU_TIMERS_H */ diff --git a/stubs/cpus-get-virtual-clock.c b/stubs/cpus-virtual-clock.c similarity index 68% rename from stubs/cpus-get-virtual-clock.c rename to stubs/cpus-virtual-clock.c index fd447d53f3..af7c1a1d40 100644 --- a/stubs/cpus-get-virtual-clock.c +++ b/stubs/cpus-virtual-clock.c @@ -6,3 +6,8 @@ int64_t cpus_get_virtual_clock(void) { return cpu_get_clock(); } + +void cpus_set_virtual_clock(int64_t new_time) +{ + /* do nothing */ +} diff --git a/system/cpus.c b/system/cpus.c index f8fa78f33d..d3640c9503 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -229,6 +229,17 @@ int64_t cpus_get_virtual_clock(void) return cpu_get_clock(); } +/* + * Signal the new virtual time to the accelerator. This is only needed + * by accelerators that need to track the changes as we warp time. + */ +void cpus_set_virtual_clock(int64_t new_time) +{ + if (cpus_accel && cpus_accel->set_virtual_clock) { + cpus_accel->set_virtual_clock(new_time); + } +} + /* * return the time elapsed in VM between vm_start and vm_stop. Unless * icount is active, cpus_get_elapsed_ticks() uses units of the host CPU cycle diff --git a/stubs/meson.build b/stubs/meson.build index f15b48d01f..772a3e817d 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -29,7 +29,7 @@ endif if have_block or have_ga stub_ss.add(files('replay-tools.c')) # stubs for hooks in util/main-loop.c, util/async.c etc. - stub_ss.add(files('cpus-get-virtual-clock.c')) + stub_ss.add(files('cpus-virtual-clock.c')) stub_ss.add(files('icount.c')) stub_ss.add(files('graph-lock.c')) if linux_io_uring.found() From patchwork Thu Jun 20 15:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=TQfrIIcM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4knP5p48z20KL for ; Fri, 21 Jun 2024 01:24:57 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcX-00060c-Ua; Thu, 20 Jun 2024 11:22:41 -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 1sKJcW-0005xF-1M for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:40 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcS-000808-56 for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:39 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-57d1d45ba34so1111732a12.3 for ; Thu, 20 Jun 2024 08:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896954; x=1719501754; 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=bRGnfZngJdWMgOcvZ7TtStbP9AmubDNWr9Hu5lfqXOc=; b=TQfrIIcMPQNzMrq1HAoou3OeloPIpZ5lqYyD8XbTptKRd7iLdzYAiDaNqRhMNXt/hD GV0OXTr1wtO8GfAuApDxq8hKCmMkif+Ilbs/HsnU1A6+vRoMOONwrHa500sD0B0/WK+y FHqal7HmCQ0ckUi1GR+Kms1vsQTp6V5Xxw/qz8xoDvvLr6LPmluwvtgpYGSmSf16bM3Y Re5NFwcrX+1Z7QucGMx+BBKxnRWBKqRx2F+C+SsTu0bGd9i0jtdsm0nSWHj+VSyzKIvU ZfOh11SY7ws0xImkXRpfl11mgK5iVGz0KnhZ0IiNl+sOfZzSuJCC8+7zqYocX9RJIFED WfmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896954; x=1719501754; 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=bRGnfZngJdWMgOcvZ7TtStbP9AmubDNWr9Hu5lfqXOc=; b=TdbBRAxrkaXs9Wfc6zOlH3jRDqbLtRiRLlkxnIvqyPmCNQNdgqGt7TynPDcRANMyIS jqj8Hc1quvfRTrAiitPFY5yoe23TgPPRd/ETyfoRX819tvCs/wsD5K5EdGZ3wldQQfb+ YzZyfn+ll7yZnWQqry5gu37j1k/JRhbTsgUlsL2bj7g0wwEwMZIfOHE3ytX2Ivwcq59F qXODwVMk/pdyxqglWQ51F661Lab8E+og48Q7WyDQFzLsEJg+A4he9dE995yQQ72RQwht ggOfX5n92PVgP/U+9F2vtCH3A58KVTG85Iu4dHP39KYokaWg8Jg00GC2h1Lm6DJctUDT SPnw== X-Gm-Message-State: AOJu0Yy+Edq06lxh2lDFqQrorBHP3VFHmnY0H9zRAzugmOBbp3YpGfmy eMcn5R0zUCztktCApo68Za7lSpOAu5GROvvAvr4tO1EtsXODj9c8tdNCAKB71c4= X-Google-Smtp-Source: AGHT+IEiVE4x6H+fZARaO4Zg3BaGTcyG+2ERR3isx5aQQpt7wxoNKnSQpwaFZQ2FBRWx1WpkNkdG7g== X-Received: by 2002:a50:9f4a:0:b0:57d:5ac:7426 with SMTP id 4fb4d7f45d1cf-57d07e66c47mr3246096a12.9.1718896954416; Thu, 20 Jun 2024 08:22:34 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72e9115sm9869605a12.46.2024.06.20.08.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 81C2E5F9FF; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 05/12] qtest: use cpu interface in qtest_clock_warp Date: Thu, 20 Jun 2024 16:22:13 +0100 Message-Id: <20240620152220.2192768-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This generalises the qtest_clock_warp code to use the AccelOps handlers for updating its own sense of time. This will make the next patch which moves the warp code closer to pure code motion. From: Alex Bennée Acked-by: Thomas Huth Signed-off-by: Pierrick Bouvier Signed-off-by: Alex Bennée Message-Id: <20240530220610.1245424-3-pierrick.bouvier@linaro.org> --- include/sysemu/qtest.h | 1 + accel/qtest/qtest.c | 1 + system/qtest.c | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index b5d5fd3463..45f3b7e1df 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -36,6 +36,7 @@ void qtest_server_set_send_handler(void (*send)(void *, const char *), void qtest_server_inproc_recv(void *opaque, const char *buf); int64_t qtest_get_virtual_clock(void); +void qtest_set_virtual_clock(int64_t count); #endif #endif diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index f6056ac836..53182e6c2a 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -52,6 +52,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, void *data) ops->create_vcpu_thread = dummy_start_vcpu_thread; ops->get_virtual_clock = qtest_get_virtual_clock; + ops->set_virtual_clock = qtest_set_virtual_clock; }; static const TypeInfo qtest_accel_ops_type = { diff --git a/system/qtest.c b/system/qtest.c index 507a358f3b..5be66b0140 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -332,14 +332,14 @@ int64_t qtest_get_virtual_clock(void) return qatomic_read_i64(&qtest_clock_counter); } -static void qtest_set_virtual_clock(int64_t count) +void qtest_set_virtual_clock(int64_t count) { qatomic_set_i64(&qtest_clock_counter, count); } static void qtest_clock_warp(int64_t dest) { - int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + int64_t clock = cpus_get_virtual_clock(); AioContext *aio_context; assert(qtest_enabled()); aio_context = qemu_get_aio_context(); @@ -348,7 +348,7 @@ static void qtest_clock_warp(int64_t dest) QEMU_TIMER_ATTR_ALL); int64_t warp = qemu_soonest_timeout(dest - clock, deadline); - qtest_set_virtual_clock(qtest_get_virtual_clock() + warp); + cpus_set_virtual_clock(cpus_get_virtual_clock() + warp); qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL); timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]); From patchwork Thu Jun 20 15:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=RFAuZ3eW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4klq69Fyz20XW for ; Fri, 21 Jun 2024 01:23:35 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcU-0005uJ-Kg; Thu, 20 Jun 2024 11:22:38 -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 1sKJcS-0005s6-Ae for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:36 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcP-0007yi-It for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:36 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-57d1679ee6eso2487694a12.1 for ; Thu, 20 Jun 2024 08:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896951; x=1719501751; 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=oUsmThce/MAXtT1TzjuV9l3/1dXmfT3EJ/fU+1YA9l4=; b=RFAuZ3eWKqjn4fiw2U7sdeS3BZEAGFXH83pDLo1prJFt9wgbTctkCDRgkzQhXbOf8i 8R+SrFIk433e7IlZDaQaxFjJJPD8wFMEvysdggm/PdpNZgLle+T/Qv/nCs9yyeXUiHCr jrZF/mWrUyvRmgdaHtebHOixXWGCqyCSuU0Uk3sCEe4AMVWLwIkkBO5BwW9OUC+eKJon N8WQg5S5uRNsi17dtOLmBmlfJRaIdXiXmq7iLaOe9jftcUzjalinMEHwxWC+TrnGOMDH g5QbHnqyG68XkRm7KflCBxHTtaSQz4jof/GGIuwIxNmvn23y72WhV31yCHukjdwrTok/ DO0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896951; x=1719501751; 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=oUsmThce/MAXtT1TzjuV9l3/1dXmfT3EJ/fU+1YA9l4=; b=QdZ0KoHykGWeXamgYxBNM429xKyDFqeTxXmICOr8SBMQD2tYI7/UdqT7qv/6oEoIUe pN0kn+uOF16LODltJ+3HC2DJqf3ZVR9CqG8qF3XFNiIAjofAJTZWbe8zBmWNwi5gC6ic VNTScnEVToj4m9G16DVZZZYNDqZ/jq5KJTcSZ/XMs3Yb8LxYzN17d02B/1j2JQXlWxys D0QCq/rYbRGKJ1vUbaDYmGHTgFDtHMETpsSjbyNSjq96u/ts27PiEB6WuxBjQO3pTG1o 49z2CkSIWJO7ttNkRRkCulcsc8Kx41EheX95mdvFzxf0C8DsfdIkh3t0GVi2AEsXtZ3t IFnw== X-Gm-Message-State: AOJu0YxZoUJYpPlxfC+1+bbv4AdGG2U6x3zo2DONLf4fJLNPOSSRvUfE +7am9T5wvtU/QiUZFJOsIn1i2LG1k3JommtLB3uE4EAx9btZ7HAJBeGHoqqlfnk= X-Google-Smtp-Source: AGHT+IGBJTUn4G0TBWUY3naga/9fZR+Z7x69pBYcJ3DVPNOToXNR3nJuUN8FrHtPnIvFdocGF8wdUQ== X-Received: by 2002:a17:907:d042:b0:a6f:9550:c0ee with SMTP id a640c23a62f3a-a6fa430f3f1mr452004166b.18.1718896950979; Thu, 20 Jun 2024 08:22:30 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56f416dfsm775943366b.164.2024.06.20.08.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9CFFA5FA01; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 06/12] sysemu: generalise qtest_warp_clock as qemu_clock_advance_virtual_time Date: Thu, 20 Jun 2024 16:22:14 +0100 Message-Id: <20240620152220.2192768-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x530.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, T_SCC_BODY_TEXT_LINE=-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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Move the key functionality of moving time forward into the clock sub-system itself. This will allow us to plumb in time control into plugins. Signed-off-by: Pierrick Bouvier Signed-off-by: Alex Bennée Message-Id: <20240530220610.1245424-4-pierrick.bouvier@linaro.org> --- v2 - use target_ns in docs and signature --- include/qemu/timer.h | 15 +++++++++++++++ system/qtest.c | 25 +++---------------------- util/qemu-timer.c | 26 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 9a366e551f..5ce83c7911 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -245,6 +245,21 @@ bool qemu_clock_run_timers(QEMUClockType type); */ bool qemu_clock_run_all_timers(void); +/** + * qemu_clock_advance_virtual_time(): advance the virtual time tick + * @target_ns: target time in nanoseconds + * + * This function is used where the control of the flow of time has + * been delegated to outside the clock subsystem (be it qtest, icount + * or some other external source). You can ask the clock system to + * return @early at the first expired timer. + * + * Time can only move forward, attempts to reverse time would lead to + * an error. + * + * Returns: new virtual time. + */ +int64_t qemu_clock_advance_virtual_time(int64_t target_ns); /* * QEMUTimerList diff --git a/system/qtest.c b/system/qtest.c index 5be66b0140..8cb98966b4 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -337,26 +337,6 @@ void qtest_set_virtual_clock(int64_t count) qatomic_set_i64(&qtest_clock_counter, count); } -static void qtest_clock_warp(int64_t dest) -{ - int64_t clock = cpus_get_virtual_clock(); - AioContext *aio_context; - assert(qtest_enabled()); - aio_context = qemu_get_aio_context(); - while (clock < dest) { - int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, - QEMU_TIMER_ATTR_ALL); - int64_t warp = qemu_soonest_timeout(dest - clock, deadline); - - cpus_set_virtual_clock(cpus_get_virtual_clock() + warp); - - qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL); - timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]); - clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - } - qemu_clock_notify(QEMU_CLOCK_VIRTUAL); -} - static bool (*process_command_cb)(CharBackend *chr, gchar **words); void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words)) @@ -751,7 +731,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words) ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, QEMU_TIMER_ATTR_ALL); } - qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); + qemu_clock_advance_virtual_time( + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); qtest_send_prefix(chr); qtest_sendf(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); @@ -777,7 +758,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) g_assert(words[1]); ret = qemu_strtoi64(words[1], NULL, 0, &ns); g_assert(ret == 0); - qtest_clock_warp(ns); + qemu_clock_advance_virtual_time(ns); qtest_send_prefix(chr); qtest_sendf(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 6a0de33dd2..213114be68 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -645,6 +645,11 @@ int64_t qemu_clock_get_ns(QEMUClockType type) } } +static void qemu_virtual_clock_set_ns(int64_t time) +{ + return cpus_set_virtual_clock(time); +} + void init_clocks(QEMUTimerListNotifyCB *notify_cb) { QEMUClockType type; @@ -675,3 +680,24 @@ bool qemu_clock_run_all_timers(void) return progress; } + +int64_t qemu_clock_advance_virtual_time(int64_t dest) +{ + int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + AioContext *aio_context; + aio_context = qemu_get_aio_context(); + while (clock < dest) { + int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); + int64_t warp = qemu_soonest_timeout(dest - clock, deadline); + + qemu_virtual_clock_set_ns(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + warp); + + qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL); + timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]); + clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + } + qemu_clock_notify(QEMU_CLOCK_VIRTUAL); + + return clock; +} From patchwork Thu Jun 20 15:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950236 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=p9TrWohc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4kmv196hz20KL for ; Fri, 21 Jun 2024 01:24:31 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcV-0005uy-1v; Thu, 20 Jun 2024 11:22:39 -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 1sKJcT-0005t9-8e for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:37 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcP-0007yW-IG for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:36 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52cc14815c3so1063507e87.0 for ; Thu, 20 Jun 2024 08:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896952; x=1719501752; 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=a0NIpkhyGGYgnbxSmBPfzzcGZB9GrmkEzQVe5cCnoVc=; b=p9TrWohcr0ofM0C0tvh8djX/Ijp5UfvKqp+rLMhEnmfAW8mjqiamcyXWvG4PVh/i3n pGr4viTQGv+6lUoJcE8yGTgF7z5+9fMs0MzkG9AqMxPI1EFGxUPum6ksgQl0ZePQZUhG 7YnpnLLTCe4jP0XuR41PgAi5qYouJo4yRXa4Jp6WbmKx+0mCmf5tSYQFgQ6zMccsBorQ Lqj/D+d8QEAyITPyiiDULFNeGrSJtuzhxsPvU1wXtBp6Hv0SlwW3q3pLrztJ8UIcl5t8 zyk+Wpr2W6Er+98RmRgeZ9a9jaJ8rQ2ZIQr7b2dU3oajF+92lVLnMIrmlMj1jvPEWind xnFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896952; x=1719501752; 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=a0NIpkhyGGYgnbxSmBPfzzcGZB9GrmkEzQVe5cCnoVc=; b=ugQFj5KT3XYtgmt9SbFzOvuLXL5ZsDonk3arWk5g79RAif9Vl8pDLMuo8gdy+WhjHo qZNSkFCvyF2RGoJOHwsC4bJj20dTi6la5o9xf0CenXUIUVoqgIIpkw7XhOOAPqTuQmke iHwL4JFjNX+OGLRifQygII6+s4EbBb3bLRPybigpSKQl6hzQ6UAVUHC63+VBBNnfkaUa 5p9tt0ko626h1JHijR+mmBjTPAQWKQ8Lhobkplu+5RGOrhk2u3dnF+bajvDAxCkJy3Wy IAnAdATB6qLNSYkbxrexZ2N1vGHUftOuCFM3Rvtf4g1p4kGVnRyNndN1SvQxCtqSHtWA unXg== X-Gm-Message-State: AOJu0YzZOsmjK3HJgGLz1sNBW80mtu4/8iLOcuCE4KJuwTkOr6yt5dt1 +hJ8E5+e89xZZ7Fucj0gDgFyKprDmMTNofU/LSRPrswnqCgm4wy5mkEuF4GmTsE= X-Google-Smtp-Source: AGHT+IF/Ow3t51hj2zvFm2LAur2fftlTRBJVGqnvOSs+DkFtw+O0hxF8fAtrEgLsUxfRTp/WRXnwOw== X-Received: by 2002:a05:6512:6d3:b0:52c:7f7f:dc1f with SMTP id 2adb3069b0e04-52ccaa5c755mr4114734e87.61.1718896951767; Thu, 20 Jun 2024 08:22:31 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56ed0f2asm783454366b.131.2024.06.20.08.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B3C945FA03; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 07/12] qtest: move qtest_{get, set}_virtual_clock to accel/qtest/qtest.c Date: Thu, 20 Jun 2024 16:22:15 +0100 Message-Id: <20240620152220.2192768-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x136.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Pierrick Bouvier Signed-off-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240530220610.1245424-5-pierrick.bouvier@linaro.org> --- include/sysemu/qtest.h | 3 --- accel/qtest/qtest.c | 12 ++++++++++++ system/qtest.c | 12 ------------ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index 45f3b7e1df..c161d75165 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -34,9 +34,6 @@ void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error ** void qtest_server_set_send_handler(void (*send)(void *, const char *), void *opaque); void qtest_server_inproc_recv(void *opaque, const char *buf); - -int64_t qtest_get_virtual_clock(void); -void qtest_set_virtual_clock(int64_t count); #endif #endif diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index 53182e6c2a..bf14032d29 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -24,6 +24,18 @@ #include "qemu/main-loop.h" #include "hw/core/cpu.h" +static int64_t qtest_clock_counter; + +static int64_t qtest_get_virtual_clock(void) +{ + return qatomic_read_i64(&qtest_clock_counter); +} + +static void qtest_set_virtual_clock(int64_t count) +{ + qatomic_set_i64(&qtest_clock_counter, count); +} + static int qtest_init_accel(MachineState *ms) { return 0; diff --git a/system/qtest.c b/system/qtest.c index 8cb98966b4..12703a2045 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -325,18 +325,6 @@ static void qtest_irq_handler(void *opaque, int n, int level) } } -static int64_t qtest_clock_counter; - -int64_t qtest_get_virtual_clock(void) -{ - return qatomic_read_i64(&qtest_clock_counter); -} - -void qtest_set_virtual_clock(int64_t count) -{ - qatomic_set_i64(&qtest_clock_counter, count); -} - static bool (*process_command_cb)(CharBackend *chr, gchar **words); void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words)) From patchwork Thu Jun 20 15:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950242 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ukhJ2k9n; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4knJ4t7yz20KL for ; Fri, 21 Jun 2024 01:24:52 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcW-0005xI-3b; Thu, 20 Jun 2024 11:22:40 -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 1sKJcU-0005uc-PC for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:38 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcR-000801-Kf for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:38 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a6f1da33826so130637966b.0 for ; Thu, 20 Jun 2024 08:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896954; x=1719501754; 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=6bnw8wtrxQn8og2FDwWWp7AmT3nbEagSCExx0Sw+yVA=; b=ukhJ2k9nXkE8KQXr1cJY6xkgU8hcFQKG7rpHvUtxqb0CjsxZVKybF6Z+LKvcYfU3FD qW8p1p6UFStWu/vhN4vVWd/uKbqEcazAyf937fBtmw6FVq6ARjFvsyMTuOj0k5sKmb/z TEqS+T12i9Vo33OC7oEJ9XUWLFxOYN6byY5aGkUlJqu4lx0Euw/Fo4pf/JzPs6nuQ94l sKD3ZO0yqmRNo8KVmBekoGYxIaephoTm0p2n5JmcUZGVpz+zsrlV4MXmzLqMcvnGy7il gRnLuXpIafgsHlvgyX3qXONbz5Fe4iJlAkuuMJ3EHTx8fxV5VNqHxRkEZKVg4vCfHRF3 ciBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896954; x=1719501754; 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=6bnw8wtrxQn8og2FDwWWp7AmT3nbEagSCExx0Sw+yVA=; b=WXCxBSAk3rkCaeIRLAszZMdfzNuLQDPJNmDrrce/HLU+gulb0sYbkGXqVAMcZiE87m KttYaLxVvpkm/PlYMiVFMwF765W79oEpKa/TU9b+7UBjn5vFrRoKyqXPI30Z3NBUYx6J J51U7vgZ9UwhyaDjHdorsp/A218PQmhDMeRAEM1XqvaHKDY7krUt9L9fzszsCK7veX4d Owl6X2yzSN0PQx9TymM5Z3AUGMTt084RPFKOQWj4w/bB/x2CFr6+XejBYPPlgZ160xD0 gSW7kGm3+AH9J0/HSE8riKahudfX5cS2sT/Oo6vPqLfTtld7bgDfidxTDTe8UU7uIzMd 7UPg== X-Gm-Message-State: AOJu0YyohEur9KFhmQB5WIJWJKnOQrt1GFPuQRouXPI57TPyd8Rbc2N/ qCS7Ts52oGyhI6ksepF4/nVCCOujxUU05SEUJc25Cw9RvM4NvorqAIqUa/aHy74= X-Google-Smtp-Source: AGHT+IH2DovLg9WwgVHZUoNTkAIC+HvMNQYXd4BSqH/mpbcJPFM2PUXUQxyUB+bFIycF54XbJ/zPYg== X-Received: by 2002:a17:907:a787:b0:a6f:ad2f:ac4b with SMTP id a640c23a62f3a-a6fad2fad01mr374136066b.2.1718896953649; Thu, 20 Jun 2024 08:22:33 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56db5b98sm774609266b.86.2024.06.20.08.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CDBB15FA06; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 08/12] plugins: add time control API Date: Thu, 20 Jun 2024 16:22:16 +0100 Message-Id: <20240620152220.2192768-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Expose the ability to control time through the plugin API. Only one plugin can control time so it has to request control when loaded. There are probably more corner cases to catch here. Signed-off-by: Pierrick Bouvier [AJB: tweaked user-mode handling, merged QEMU_PLUGIN_API fix] Signed-off-by: Alex Bennée Message-Id: <20240530220610.1245424-6-pierrick.bouvier@linaro.org> Reviewed-by: Alwalid Salama --- plugins/next - make qemu_plugin_update_ns a NOP in user-mode v2 - remove From: header - merged in plugins: missing QEMU_PLUGIN_API for time control --- include/qemu/qemu-plugin.h | 27 +++++++++++++++++++++++++++ plugins/api.c | 35 +++++++++++++++++++++++++++++++++++ plugins/qemu-plugins.symbols | 2 ++ 3 files changed, 64 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 95703d8fec..c71c705b69 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -661,6 +661,33 @@ void qemu_plugin_register_vcpu_mem_inline_per_vcpu( qemu_plugin_u64 entry, uint64_t imm); +/** + * qemu_plugin_request_time_control() - request the ability to control time + * + * This grants the plugin the ability to control system time. Only one + * plugin can control time so if multiple plugins request the ability + * all but the first will fail. + * + * Returns an opaque handle or NULL if fails + */ +QEMU_PLUGIN_API +const void *qemu_plugin_request_time_control(void); + +/** + * qemu_plugin_update_ns() - update system emulation time + * @handle: opaque handle returned by qemu_plugin_request_time_control() + * @time: time in nanoseconds + * + * This allows an appropriately authorised plugin (i.e. holding the + * time control handle) to move system time forward to @time. For + * user-mode emulation the time is not changed by this as all reported + * time comes from the host kernel. + * + * Start time is 0. + */ +QEMU_PLUGIN_API +void qemu_plugin_update_ns(const void *handle, int64_t time); + typedef void (*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_index, int64_t num, uint64_t a1, uint64_t a2, diff --git a/plugins/api.c b/plugins/api.c index 6bdb26bbe3..4431a0ea7e 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -39,6 +39,7 @@ #include "qemu/main-loop.h" #include "qemu/plugin.h" #include "qemu/log.h" +#include "qemu/timer.h" #include "tcg/tcg.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" @@ -583,3 +584,37 @@ uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry) } return total; } + +/* + * Time control + */ +static bool has_control; + +const void *qemu_plugin_request_time_control(void) +{ + if (!has_control) { + has_control = true; + return &has_control; + } + return NULL; +} + +#ifdef CONFIG_SOFTMMU +static void advance_virtual_time__async(CPUState *cpu, run_on_cpu_data data) +{ + int64_t new_time = data.host_ulong; + qemu_clock_advance_virtual_time(new_time); +} +#endif + +void qemu_plugin_update_ns(const void *handle, int64_t new_time) +{ +#ifdef CONFIG_SOFTMMU + if (handle == &has_control) { + /* Need to execute out of cpu_exec, so bql can be locked. */ + async_run_on_cpu(current_cpu, + advance_virtual_time__async, + RUN_ON_CPU_HOST_ULONG(new_time)); + } +#endif +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index aa0a77a319..ca773d8d9f 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -38,6 +38,7 @@ qemu_plugin_register_vcpu_tb_exec_cond_cb; qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; + qemu_plugin_request_time_control; qemu_plugin_reset; qemu_plugin_scoreboard_free; qemu_plugin_scoreboard_find; @@ -51,5 +52,6 @@ qemu_plugin_u64_set; qemu_plugin_u64_sum; qemu_plugin_uninstall; + qemu_plugin_update_ns; qemu_plugin_vcpu_for_each; }; From patchwork Thu Jun 20 15:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=qyTwHgqY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4kmP2hs9z20KL for ; Fri, 21 Jun 2024 01:24:05 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcZ-00064M-Ro; Thu, 20 Jun 2024 11:22:43 -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 1sKJcX-0005zm-Iv for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:41 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcU-00081J-BT for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:41 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a6fb341a7f2so130464666b.1 for ; Thu, 20 Jun 2024 08:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896957; x=1719501757; 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=ZQ8CEbgFXQ50Jx+/zMrlpDCus+bU22jqqVwm5sZfxvc=; b=qyTwHgqYX6E3DfIN8VEFe6Y71TU8F1nmaGduFYVpRCLkMoaXz96+iyyJkslvLOpOp4 FF6nJjLkfCfRa7E5aEdJXHH95U5DYD6cvHa66P5t8rvUYTnjJdfet2SCynF4UBXXDYrZ aS5zd96v3Qof9gigW6Q12xT7tEmM/oQj5zBEgRdzFaWC3zk0f6hOzm3tBEP0dDX67vnl 40vEMer0v09Z2vn0AykHjiuKoAvdFl6rUPv+eeAUx1kkFTQMI/MZBleEKSTKoakEWBZc WRpE7epu6uFMgu1urh9ZHM2zVTyFA8m0y+UVGgrk7y8rg9QqS698kAzlu8JF3WbXcV5q AGhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896957; x=1719501757; 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=ZQ8CEbgFXQ50Jx+/zMrlpDCus+bU22jqqVwm5sZfxvc=; b=aX8Ogj4VUdPP+PB/m7GkaOvtt8q4vBey5l22sRYE9RCbc+j/bHDMc15enMG8vOYeK5 DK3jzI58h2sQdYHE5AyiWPadC+15EqT/tcykGYBymAuaUg6hOZcCvYUaxYRYJ+BwzvAL 6fd6TPaJMDcnEq6y6Bc/lMsmecUOAtnd/xNoHWl6Ci4hosZNZ+0vTedhNZfFiecgTZTN UJTaA4qbxjI+y1O1meMOR9nbmFEnpipfnPV1I0XVckFgqsMnTMCiOLV86rN9/FWbZiIU xqhjBRDLbQsLH52BGWsT3gS/iwTHvxFGJkhvZPHn+3FQshkNw8+PieQH+OhhqP0tY1U3 7HZw== X-Gm-Message-State: AOJu0YyOzbB/+Q9UBDURMXIuBJuscHLHL5mW+9zzwNYCFc2wx2rXhF3B 6fS3ZSYuog7wV/4/n7mt3MqLCKR3Sf49QlC5BgqRNjdTm/ZkSDYo4G0bCU4hXtk= X-Google-Smtp-Source: AGHT+IH9ydE3ImEmECu/jTqHbMKjkbdYKCQBP9DWZg1r82biwaNCpjgKg3b6KL1DuAkpxGXNwAJwVg== X-Received: by 2002:a17:907:a092:b0:a6f:4ae3:5327 with SMTP id a640c23a62f3a-a6fab609e5dmr478736466b.15.1718896956518; Thu, 20 Jun 2024 08:22:36 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56ed3590sm782032166b.98.2024.06.20.08.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:29 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E6E735FA08; Thu, 20 Jun 2024 16:22:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 09/12] plugins: add migration blocker Date: Thu, 20 Jun 2024 16:22:17 +0100 Message-Id: <20240620152220.2192768-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x634.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If the plugin in controlling time there is some state that might be missing from the plugin tracking it. Migration is unlikely to work in this case so lets put a migration blocker in to let the user know if they try. Signed-off-by: Alex Bennée Suggested-by: "Dr. David Alan Gilbert" Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson Reviewed-by: Alwalid Salama --- plugins/api.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/api.c b/plugins/api.c index 4431a0ea7e..c4239153af 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -47,6 +47,8 @@ #include "disas/disas.h" #include "plugin.h" #ifndef CONFIG_USER_ONLY +#include "qapi/error.h" +#include "migration/blocker.h" #include "exec/ram_addr.h" #include "qemu/plugin-memory.h" #include "hw/boards.h" @@ -589,11 +591,17 @@ uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry) * Time control */ static bool has_control; +Error *migration_blocker; const void *qemu_plugin_request_time_control(void) { if (!has_control) { has_control = true; +#ifdef CONFIG_SOFTMMU + error_setg(&migration_blocker, + "TCG plugin time control does not support migration"); + migrate_add_blocker(&migration_blocker, NULL); +#endif return &has_control; } return NULL; From patchwork Thu Jun 20 15:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950221 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=d5uksvkY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4klQ30KPz20XW for ; Fri, 21 Jun 2024 01:23:14 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJca-00065r-JL; Thu, 20 Jun 2024 11:22:44 -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 1sKJcZ-00063Y-6X for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:43 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcV-00081d-41 for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:42 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52bc27cfb14so1407221e87.0 for ; Thu, 20 Jun 2024 08:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896957; x=1719501757; 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=aTqVMPQXWo8mkGU1ZZQCTroEdUrbxvLcJ6ei12/57OI=; b=d5uksvkY3FBaCKVQz4bZ0+EHZEK+yup7oPLybmPtY8AfpExGc4lfiJCw6jhQ7ChbRk +fpwnJPRI3tudfvZtnZnen7hrZRSR+tjkbTEKS4kzJ0ogR8IgSbznrZO5I5R5oA3ZGs/ xZWO8TLp3bxJgDF0AFJ4QI6xLCWCbYNQFaHECGP42+kwSKJtGSGPtPpN3cFEyLwLvQRy oF/XJYyc+z+PJ3UsPpvcJhmRBL1uYZglEH1B7UDG8yHpSKm+PVs0mBxwkoLLydb7EKSo fRkKzelUFTrtBlR9JBiq7UO8oas218dacl+1X+xTtmR5P6HPlnTvhkXzfOF7o1CHCL41 Ri1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896957; x=1719501757; 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=aTqVMPQXWo8mkGU1ZZQCTroEdUrbxvLcJ6ei12/57OI=; b=V4xfOuyYSQwxryRIIK5uMMXjjhBCFMQUjT4KEu2Lt8cQeieVtcK9ps+KK8II/Qr+Lp iVmZvz0yzk5PqtiAdgBTtc5jOOSW/Nx8qpGE3Ne/kAK7UJ4an/tC0R4XL6aICELvk9+e Vl/1Pg5H0uHO5yPbEWaaQaAUyCMBGfHOikVm1EE45NT8sb66lkleb0rYTiHeRGsmHBHZ UjhAbXWP39W8DgE/SUqNIdSaB7H/g6B1hLsB6gGFsPAEDNO0aJvTa8N83bcUatyvJHlu PPo5JUmn4/9NC+cA6NUVO2vM+jLlDy/hA4HGu8NZxScJJNpAuZcAqx94kaX0+TVuLqru 3w2A== X-Gm-Message-State: AOJu0YzKofaMvpTyO8Q5EkObvGcgdziKqOZbRHcooHonIthF4I8vicCi XNIRLsZHR64IwaBht+HQYcg3DPwseSQ5YYGvLtfRO6TO2mNbmzaHXmjgB10LmpQ= X-Google-Smtp-Source: AGHT+IF6+wEHSuI7S/SNc8KgBe4bVoRR9T1WyMx8dtnAy/pGDd8PXI3gNYJwem0B1HteMfPE9Z02lA== X-Received: by 2002:a05:6512:3994:b0:52c:cb8d:637d with SMTP id 2adb3069b0e04-52ccb8d6426mr5442380e87.5.1718896957381; Thu, 20 Jun 2024 08:22:37 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f756ee325sm552818766b.90.2024.06.20.08.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0C60D5FA0A; Thu, 20 Jun 2024 16:22:22 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 10/12] contrib/plugins: add Instructions Per Second (IPS) example for cost modeling Date: Thu, 20 Jun 2024 16:22:18 +0100 Message-Id: <20240620152220.2192768-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x133.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Pierrick Bouvier This plugin uses the new time control interface to make decisions about the state of time during the emulation. The algorithm is currently very simple. The user specifies an ips rate which applies per core. If the core runs ahead of its allocated execution time the plugin sleeps for a bit to let real time catch up. Either way time is updated for the emulation as a function of total executed instructions with some adjustments for cores that idle. Examples -------- Slow down execution of /bin/true: $ num_insn=$(./build/qemu-x86_64 -plugin ./build/tests/plugin/libinsn.so -d plugin /bin/true |& grep total | sed -e 's/.*: //') $ time ./build/qemu-x86_64 -plugin ./build/contrib/plugins/libips.so,ips=$(($num_insn/4)) /bin/true real 4.000s Boot a Linux kernel simulating a 250MHz cpu: $ /build/qemu-system-x86_64 -kernel /boot/vmlinuz-6.1.0-21-amd64 -append "console=ttyS0" -plugin ./build/contrib/plugins/libips.so,ips=$((250*1000*1000)) -smp 1 -m 512 check time until kernel panic on serial0 Tested in system mode by booting a full debian system, and using: $ sysbench cpu run Performance decrease linearly with the given number of ips. Signed-off-by: Pierrick Bouvier Signed-off-by: Alex Bennée Message-Id: <20240530220610.1245424-7-pierrick.bouvier@linaro.org> Reviewed-by: Alwalid Salama --- v2 - more explicit Instructions Per Second (IPS)! --- contrib/plugins/ips.c | 164 +++++++++++++++++++++++++++++++++++++++ contrib/plugins/Makefile | 1 + 2 files changed, 165 insertions(+) create mode 100644 contrib/plugins/ips.c diff --git a/contrib/plugins/ips.c b/contrib/plugins/ips.c new file mode 100644 index 0000000000..29fa556d0f --- /dev/null +++ b/contrib/plugins/ips.c @@ -0,0 +1,164 @@ +/* + * Instructions Per Second (IPS) rate limiting plugin. + * + * This plugin can be used to restrict the execution of a system to a + * particular number of Instructions Per Second (IPS). This controls + * time as seen by the guest so while wall-clock time may be longer + * from the guests point of view time will pass at the normal rate. + * + * This uses the new plugin API which allows the plugin to control + * system time. + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; + +/* how many times do we update time per sec */ +#define NUM_TIME_UPDATE_PER_SEC 10 +#define NSEC_IN_ONE_SEC (1000 * 1000 * 1000) + +static GMutex global_state_lock; + +static uint64_t max_insn_per_second = 1000 * 1000 * 1000; /* ips per core, per second */ +static uint64_t max_insn_per_quantum; /* trap every N instructions */ +static int64_t virtual_time_ns; /* last set virtual time */ + +static const void *time_handle; + +typedef struct { + uint64_t total_insn; + uint64_t quantum_insn; /* insn in last quantum */ + int64_t last_quantum_time; /* time when last quantum started */ +} vCPUTime; + +struct qemu_plugin_scoreboard *vcpus; + +/* return epoch time in ns */ +static int64_t now_ns(void) +{ + return g_get_real_time() * 1000; +} + +static uint64_t num_insn_during(int64_t elapsed_ns) +{ + double num_secs = elapsed_ns / (double) NSEC_IN_ONE_SEC; + return num_secs * (double) max_insn_per_second; +} + +static int64_t time_for_insn(uint64_t num_insn) +{ + double num_secs = (double) num_insn / (double) max_insn_per_second; + return num_secs * (double) NSEC_IN_ONE_SEC; +} + +static void update_system_time(vCPUTime *vcpu) +{ + int64_t elapsed_ns = now_ns() - vcpu->last_quantum_time; + uint64_t max_insn = num_insn_during(elapsed_ns); + + if (vcpu->quantum_insn >= max_insn) { + /* this vcpu ran faster than expected, so it has to sleep */ + uint64_t insn_advance = vcpu->quantum_insn - max_insn; + uint64_t time_advance_ns = time_for_insn(insn_advance); + int64_t sleep_us = time_advance_ns / 1000; + g_usleep(sleep_us); + } + + vcpu->total_insn += vcpu->quantum_insn; + vcpu->quantum_insn = 0; + vcpu->last_quantum_time = now_ns(); + + /* based on total number of instructions, what should be the new time? */ + int64_t new_virtual_time = time_for_insn(vcpu->total_insn); + + g_mutex_lock(&global_state_lock); + + /* Time only moves forward. Another vcpu might have updated it already. */ + if (new_virtual_time > virtual_time_ns) { + qemu_plugin_update_ns(time_handle, new_virtual_time); + virtual_time_ns = new_virtual_time; + } + + g_mutex_unlock(&global_state_lock); +} + +static void vcpu_init(qemu_plugin_id_t id, unsigned int cpu_index) +{ + vCPUTime *vcpu = qemu_plugin_scoreboard_find(vcpus, cpu_index); + vcpu->total_insn = 0; + vcpu->quantum_insn = 0; + vcpu->last_quantum_time = now_ns(); +} + +static void vcpu_exit(qemu_plugin_id_t id, unsigned int cpu_index) +{ + vCPUTime *vcpu = qemu_plugin_scoreboard_find(vcpus, cpu_index); + update_system_time(vcpu); +} + +static void every_quantum_insn(unsigned int cpu_index, void *udata) +{ + vCPUTime *vcpu = qemu_plugin_scoreboard_find(vcpus, cpu_index); + g_assert(vcpu->quantum_insn >= max_insn_per_quantum); + update_system_time(vcpu); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n_insns = qemu_plugin_tb_n_insns(tb); + qemu_plugin_u64 quantum_insn = + qemu_plugin_scoreboard_u64_in_struct(vcpus, vCPUTime, quantum_insn); + /* count (and eventually trap) once per tb */ + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, quantum_insn, n_insns); + qemu_plugin_register_vcpu_tb_exec_cond_cb( + tb, every_quantum_insn, + QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_COND_GE, + quantum_insn, max_insn_per_quantum, NULL); +} + +static void plugin_exit(qemu_plugin_id_t id, void *udata) +{ + qemu_plugin_scoreboard_free(vcpus); +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, int argc, + char **argv) +{ + for (int i = 0; i < argc; i++) { + char *opt = argv[i]; + g_auto(GStrv) tokens = g_strsplit(opt, "=", 2); + if (g_strcmp0(tokens[0], "ips") == 0) { + max_insn_per_second = g_ascii_strtoull(tokens[1], NULL, 10); + if (!max_insn_per_second && errno) { + fprintf(stderr, "%s: couldn't parse %s (%s)\n", + __func__, tokens[1], g_strerror(errno)); + return -1; + } + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + vcpus = qemu_plugin_scoreboard_new(sizeof(vCPUTime)); + max_insn_per_quantum = max_insn_per_second / NUM_TIME_UPDATE_PER_SEC; + + time_handle = qemu_plugin_request_time_control(); + g_assert(time_handle); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); + qemu_plugin_register_vcpu_exit_cb(id, vcpu_exit); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index 0b64d2c1e3..449ead1130 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -27,6 +27,7 @@ endif NAMES += hwprofile NAMES += cache NAMES += drcov +NAMES += ips ifeq ($(CONFIG_WIN32),y) SO_SUFFIX := .dll From patchwork Thu Jun 20 15:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=tRgGGgEo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4kmH44Ykz20KL for ; Fri, 21 Jun 2024 01:23:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJci-0006B6-Br; Thu, 20 Jun 2024 11:22:52 -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 1sKJca-00065z-QE for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:44 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcX-00082t-M3 for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:44 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a6ef46d25efso118102966b.0 for ; Thu, 20 Jun 2024 08:22:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896960; x=1719501760; 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=97cycViE9OQK6SdY90/SywB1oI0H0vp7Y3hsl3HXbfM=; b=tRgGGgEoQAPPranslMuJkrxERNVKM4LbFwoJjPjOGAyBDshZJOhoO1/t7YNLPbzkIs 71QE062moNcbGO+9BCSE6z2yC+VvpnSax30w38Kap1BOG6J6XGneKPwqREoQ3i4+1oXm eAq7d4nfO5RVhBNQvZVD/+n0NV1iDw4bNKTSi+uLJ9IQ33UzFK3cXUGlwfrYbfOaVC8G r3DFnwtzq0kicQX8JATzqreOIiVzZ373w4nN5j2vnDpRYU2Rxzzv2uxLlatJtvUDOhoa KfrYDDgAA5oemJBM1LN4U6O4px1rJ4TjbVfinHUyJOD8rn2EfUGj67SihAJZ7gVy6Ja1 h3aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896960; x=1719501760; 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=97cycViE9OQK6SdY90/SywB1oI0H0vp7Y3hsl3HXbfM=; b=YZtKT+vaK6bUhibqv8FPc8ezIDTW2CuzOnKwoU+xZ7Ax2U9+LZRqHBfwQ39qywCFGB LmGV6U5JZGOWKSg8nNxZpV0YSmoYrWBa3QysJkCEWXsj6A8hwrelcMkfFqg7d24ewdzE +URaZHfb5Gj1xvuI5izkF0Ltqjsb5d/vAcn5Y+s0DwfcRbHmCXB+qukpbbvDfUX4Kgv1 n4hcMxCWQ7JeZr0X7yX+y7393b9MHxsXxdtrmCkDKOoY/NW0M/SUIUJ170h0nQxQ0OQN +pUSJnQ9tAohlsjnGHa77qytqEPDoqFVlsxDRZ8GVMfer+bhTivEoPzSZFwIK+/0B3Zt Evqw== X-Gm-Message-State: AOJu0YyKeg3wR0mDrdFQ7kVMJRG0htS5F2fuGO2xr9fAVmaSj5hf7DYX vW0nDD6q5AwvbhnWexFnJ5b2AWRfrxEUqSj/kKFT73m1JeZOKA1lZ2VElchB7zU= X-Google-Smtp-Source: AGHT+IHWqQ+U5RDCXqQGFMJSuSV70/qn1Ko7rwj6FST0rE/66lYbJ0eLG09x1vJsHqa3Ib9AVn4fpA== X-Received: by 2002:a17:906:c1d1:b0:a6f:b9d3:343a with SMTP id a640c23a62f3a-a6fb9d3383cmr198180066b.71.1718896960112; Thu, 20 Jun 2024 08:22:40 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56ed369bsm771539666b.100.2024.06.20.08.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 259085FA0C; Thu, 20 Jun 2024 16:22:22 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v2 11/12] plugins: fix inject_mem_cb rw masking Date: Thu, 20 Jun 2024 16:22:19 +0100 Message-Id: <20240620152220.2192768-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62f.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Pierrick Bouvier These are not booleans, but masks. Issue found by Richard Henderson. Fixes: f86fd4d8721 ("plugins: distinct types for callbacks") Signed-off-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240612195147.93121-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée Reviewed-by: Alwalid Salama --- accel/tcg/plugin-gen.c | 4 ++-- plugins/core.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index cc1634e7a6..b6bae32b99 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -240,13 +240,13 @@ static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb, { switch (cb->type) { case PLUGIN_CB_MEM_REGULAR: - if (rw && cb->regular.rw) { + if (rw & cb->regular.rw) { gen_mem_cb(&cb->regular, meminfo, addr); } break; case PLUGIN_CB_INLINE_ADD_U64: case PLUGIN_CB_INLINE_STORE_U64: - if (rw && cb->inline_insn.rw) { + if (rw & cb->inline_insn.rw) { inject_cb(cb); } break; diff --git a/plugins/core.c b/plugins/core.c index badede28cf..9d737d8278 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -589,7 +589,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, switch (cb->type) { case PLUGIN_CB_MEM_REGULAR: - if (rw && cb->regular.rw) { + if (rw & cb->regular.rw) { cb->regular.f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi, rw), vaddr, cb->regular.userp); @@ -597,7 +597,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, break; case PLUGIN_CB_INLINE_ADD_U64: case PLUGIN_CB_INLINE_STORE_U64: - if (rw && cb->inline_insn.rw) { + if (rw & cb->inline_insn.rw) { exec_inline_op(cb->type, &cb->inline_insn, cpu->cpu_index); } break; From patchwork Thu Jun 20 15:22:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1950231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZzvT2ZFa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W4kmH4MnJz20XW for ; Fri, 21 Jun 2024 01:23:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKJcb-00067Q-Tz; Thu, 20 Jun 2024 11:22:45 -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 1sKJcZ-00064R-Q1 for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:43 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKJcX-00082h-B7 for qemu-devel@nongnu.org; Thu, 20 Jun 2024 11:22:43 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-57d1679ee83so1032100a12.2 for ; Thu, 20 Jun 2024 08:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896960; x=1719501760; 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=mk0X1Wnynj7dOIA6noc/XZNsTzvKKxUiDNUzj/HAsA8=; b=ZzvT2ZFaSIK0esGkPGcp/rGrJMYSL1ju0zZyVgnEZDZxEykadTO9B4Whacak2AuT99 EeXn0/T8Ql3WS5h8tRongY7fc50CI2/+dxlgsz/qOP1seRnDIlL/71TIlYrxX2dwGHxo vrywgIuvMZ55iqy8uhL8VuHmSLNBB/Y38NmFbIKZAormTyIprZfov271xShdCLqJl1kA aOXvSGJVC84pVvcPPTPnvApRMxtYb2ZX1Mdte1OvApq74fh9iJtJidJWhHMFQO6heH9r 4wJJjyKJxcKwUdzdzmkI9n7BagHL/YItf079DQo11cH8vy1w3roOtikMEYiUdCuI8j74 siHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718896960; x=1719501760; 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=mk0X1Wnynj7dOIA6noc/XZNsTzvKKxUiDNUzj/HAsA8=; b=sMTaQdA7yWi2Ew+v33sWPNWA3ypVZIB9rShZ/GBK3ku0CWr53rwplA9X195nDDbozk m4HFKx+x3+LHQLS5GUWqfQANb+f9m6iCXLG4MtxIxjNlIBOtf0OaDv+qErL5F6Qf7JQ7 1ncWHrcKFZJTInzBgJgF0zkWGXnEQfXC9XwS1o/MnW5ZJVgMtO2e+dE/2rlIOLNqDolo RQhywpqW6hnJbuTYeXTwIdkSH+SdK9gYz3k6laos1F/mmW5DVv7kMfkymCId8wyITTLf 8ok3rtD+r+jK+c//ap9g2EsSafbzE8b038Dr0LiKAuxt01IwhKXdUeoPaB9tY5BBq8NQ Oojg== X-Gm-Message-State: AOJu0Yze3G1MRhcYXQzSKQxI7TFgGsX7AFilMXMl0cgC/RosHBKTw64/ GKDsOZrRJKNpGQwn8njD4HimS91kMIn6GSoctJ/OLbN052LBIgro6iwbe/kdiG0= X-Google-Smtp-Source: AGHT+IH9pCECdMbMVVhjjvf6u9eh17rATloLp9u6G8EZyVpWPyMAS/cVnhG2jsc1yqsUpAe4BtIosw== X-Received: by 2002:a50:d595:0:b0:57c:5874:4f74 with SMTP id 4fb4d7f45d1cf-57d07ed24b8mr3437569a12.28.1718896959461; Thu, 20 Jun 2024 08:22:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm9758038a12.22.2024.06.20.08.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:22:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3BD7D5FA0E; Thu, 20 Jun 2024 16:22:22 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Christian Borntraeger , Paolo Bonzini , Jamie Iles , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mark Burton , Daniel Henrique Barboza , qemu-arm@nongnu.org, Laurent Vivier , Alexander Graf , Ilya Leoshkevich , Richard Henderson , Marco Liebel , Halil Pasic , Thomas Huth , qemu-s390x@nongnu.org, Cameron Esfahani , Alexandre Iooss , Nicholas Piggin , Roman Bolshakov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Mahmoud Mandour , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Max Chou , Frank Chang Subject: [PATCH v2 12/12] accel/tcg: Avoid unnecessary call overhead from qemu_plugin_vcpu_mem_cb Date: Thu, 20 Jun 2024 16:22:20 +0100 Message-Id: <20240620152220.2192768-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620152220.2192768-1-alex.bennee@linaro.org> References: <20240620152220.2192768-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x534.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Max Chou If there are not any QEMU plugin memory callback functions, checking before calling the qemu_plugin_vcpu_mem_cb function can reduce the function call overhead. Signed-off-by: Max Chou Reviewed-by: Richard Henderson Reviewed-by: Frank Chang Message-Id: <20240613175122.1299212-2-max.chou@sifive.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alwalid Salama --- accel/tcg/ldst_common.c.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc index c82048e377..87ceb95487 100644 --- a/accel/tcg/ldst_common.c.inc +++ b/accel/tcg/ldst_common.c.inc @@ -125,7 +125,9 @@ void helper_st_i128(CPUArchState *env, uint64_t addr, Int128 val, MemOpIdx oi) static void plugin_load_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + } } uint8_t cpu_ldb_mmu(CPUArchState *env, abi_ptr addr, MemOpIdx oi, uintptr_t ra) @@ -188,7 +190,9 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr, static void plugin_store_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); + } } void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val,