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: 13705691 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7CFA27456 for ; Thu, 20 Jun 2024 15:22:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896947; cv=none; b=FhrSmegpaqwlpsNqDsjXU0Rok66ZlBMNJ5htP4aQexlyVcr5ZTznKLQB9aun20uS6vOt2N3/0/U1NrYWfhXmN+b2Zs/fPVBN6jwQGruMKlUBVgyb5D3nd6aa9SQ1i4fKPOv1xuh+GxO34Qyyu+XYHJcBUgFmq9Tvnf8Nc+jg2qM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896947; c=relaxed/simple; bh=pUz3SnmllUrGDeG+bNxHf12f3fiSeqd2Z7ynU3lmtVM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=I5kJDxmW5J2ExIyTrPQSYItquUjrHymtuFvglhOztbLZdhtM2OEwNWwtO+SwoWzGFRqyf1V3E8IP4Z0uOSDNlsnIbFex/2sSC17wnneGohcFuzSHwf/YjfHv394od/YtkNDfBbzQu2Jy/p6n0dyROurbObi3fZwexbOPbvgb9RM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=IqltoBOW; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IqltoBOW" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57d0eca877cso1157534a12.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=vger.kernel.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=IqltoBOWpa/yGMCP1J/WOgTMd/xtDrmm8F1e/jQoXvvBow5dEl1xgSYWqwApjvWDJN TYIrL68hWrwrXNKKu2CR8fGTTWq0kaaZlUxTg+LHd6UWmjv55q93XQ6FRsQFbx6dTdJl g9WYg2zY/4QvSNq2E/52F2sACG2UoUhykFEZG35FI/BJ8IoY8U6otFA3tuPGlGpsEbMS Oj4m5fYzLAfHAjnyZUkjbcYi2HQzU1qQjtIT5CAJcueYYSHupYPH7Qpq6j0Ck+wK0ZTs uARwWNa8bWyBx14jRRhUKRdWFpKewuQ/gGC/XHOfMsuZ+VN5lzwhKX9XJbHOTq7RnEeT DhWA== 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=vM9nZ3gJiV7hTbkjYFbEQ16RfB59QeQJcseUz6iFMgc6PLaz0ia6ebVZuVp21IZlDN 6ScinypscjcO5YvlSu6uHa7x51NN2EY5+jcc/aWwFuEeIADJsnUL/penRwd9ypXCYUNI QwJrIXrvNnwgzoGhaQl5OFyHmuEh59otKMwIsfhI8nBwVesRPREIqQb9Iyn48XjeTuBL x8y0fMD8GrI6WPU4GPx0DbOnKdZc3ay4t1bAQnW4AduKp9RLU8CR2WGAm7D94jRss8nF e+OM4I3vA3Uu6Mcjr1sF+N6ThULjJiexRAYLpymdeIiMpWbd9Xn+IA6ARSM+trVF0NDU JIag== X-Forwarded-Encrypted: i=1; AJvYcCUawilEpL9y1y1PRa1B05aJAyi3jFDAIz7u3cp9tvAVd6Mdy4vfrMeLanuFUfP9cgZ1jT1BHOCi5uiBhAA2MYKDVVNm X-Gm-Message-State: AOJu0YxB7MJ9FznEHCpOyyIbp4jKOWhHJLNmMDjNBlM8vv0u3Uoq+v5R 1PdbFS2MpPUaXEpJy0RrGkj0TTD/uImvkIHOxl0efUgTvQmCdSDhvYeeQbz+nQw= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705692 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BEC41AB91B for ; Thu, 20 Jun 2024 15:22:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896948; cv=none; b=jo+s0nNrfrIOoQVpU1bOsq4/fUY+GbTpcg0H1xSOFfpSXe5HRLIPm9fg2w3gQ+dEkEB1UhtjB+xeb50ncO6xneAvjpf9p1bEl6dYKpHGFVsA6RT8JwPUF4PTWZ2U365c13SaknVbSq32k32S6RcU06dKuZgIb7Shs9LljCiW5OQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896948; c=relaxed/simple; bh=a/NUlqCvZJfUnZTc2CYLOBjgrGstoH2HmBX4yVV3hiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=aHiXw5Dqnt+mXqEMepHqDuWUbS5zHIEpweGYGjKYLmA33TDBjcw8a02Zz2PQXZ3vY2V7BLnNzsjbrpjHNZ1uDz6QSZ7sYDVqFRZVMGSfmxLLcD815zhVn0JdTX1iI8ZCyHY0eYJ0/E0d9f3xcoJBRfZnUuZOT28Yd+2ZBHf6/xk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=EB3tMfAJ; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EB3tMfAJ" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso1296770a12.0 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=vger.kernel.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=EB3tMfAJLI2RApPVuTq/Tny/NnOv0UVowyy41N3SpFT/kqEruDSCyr18vUjTwP/Gi2 Tc+jBDrji+iiZiT2FTMR2UdcBuucpw3G0bsgvaTBlxxmpYdSoWwqlDdcohDAtHWB737q CL3CbHlK0vMu7JeBqgF8rhzt/PFQBP4bx1RErhvwbaE6lYWx53YtIA/yZ4ARGd0aHg/L MUVvOi4HFKcmoBCPNzVdYNm8kXs+TOCz8Dmx1b4UX5X8VBFtF+62mqYWv15subGyH0Up VT7SiRKHq/qnfFJUtWSe3FUY7nare0mfDuAYreXKP5l1uc6eLKUo97YCWXf8OLKVbuL8 GfvA== 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=K2icvIccyxz4lrCWroapImEaV8bpptcGB57A9HzVY8D2FwttgYhB7BTwO3Rfpry6XJ M8+f97xIf+y7xlj3lAyxhRY0vARs7IQn8KHvwnHKDAnOLk9xq2PSMgnjWbEh3ccjuKoN /JcrSG+Z8Ij0+XMjkod4H38QmNJdvG7YAtTWqhI2Xmoey6SecoQFG8CGBR6MaezHHt/P ZtyjqkJUh8XX4zb/hSGuXMXpVmVISVSJc6L87mL/PmyYM2uxIpjxbd+efueN3V6cn0ea SmN2N24Z1yXfy7P/Ji2mXiJU0xYSxfCVtskXJ4LJXAqySyNf7ZInpRxq+ZNKdin6D2oN CBLQ== X-Forwarded-Encrypted: i=1; AJvYcCXx7YnYnBp5iqJATayHJrbHFFndRJ5JfleBItQJEK3bHxMhzcsQXHirNViiriPG5W5zrqHMDOCzfAqhkXwr5wMN0cxa X-Gm-Message-State: AOJu0YytV6xwfwAwuRiN8yVxDXmanrOrWrLnt/GGbFul+qzm7uDxd8lz Uk/Lfjgg+iu03xWK9ei6Qf9tzg+URG/7+F4qe0558y/w/7vfY00toyc23O2j+OM= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705693 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01D851AB91B for ; Thu, 20 Jun 2024 15:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896951; cv=none; b=CmaniTqjA3UznLB3DEEjo4KK3c2RSFweedbMbECr7f7B7poMQJjQbk8O104LspDsA+yUMBrpNyl0D6YS6HG2mSjGMD7TQ+MqVPLotSR3ojwpSZoVflAXBPr/cCJP9+KkVvGadsmUJibi5Cq4K1lTIH7nQEo7/Q+OO5mJMt8MbNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896951; c=relaxed/simple; bh=x0KN3Mbd8aMVqPHdgl1/SMy2aZnIAphEJs/rdAHKmrw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=hgr/l1YYhA5kGAe+LKu5NvuTOSO+C7Eha7K8g3qqeE4eD37rbei9voC1XIl8uLeMrPggeAI7rGQScIBRYonpFMpikX/ZOfiPUsmXzJg0y2pFaUrbXEQiWIOls26fKsT4mrrKbcGI55rofsq3jk009QU5unAOs7G6vT6q71GVPqo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=d33g02an; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="d33g02an" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-57d1679ee83so1031878a12.2 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=vger.kernel.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=d33g02anEkaGb2oAj6f5puwMLJH+XqUU0wBW1ly6KJFMd1O4o+NT8QfXqiUM+7ZcwC tgcfuNC6JK5D21ZwoQyYXiiXSthUBanSXu4KJ1Sd/pt0vZgA+Zh5kt5g4LY4t8SrGu1H 06TduZTuAATsmdQLJG/7mmNxTRKomwezxm+jKaRKGaJtGsjbshvrd4Lk0DElgCQ3dORo KhIskuV+gT/K34rTZ4pQklWk0E+iafXoOgTuNSpYBip5ZO8hjuNV7D6tpASOBcuq355v YvEXJWbzggs8RjpzEsG8zAnUVxiS8U2j6lB7jXGSQrMj1EFicj4Xruz182OZpt4HVjaC /Vmg== 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=apegAAU5TgvNKJegHUllAycTt8oAf/04zcVuD7cN7AKz1W+g28HNgCjmcXe5TTJL4N P9ZWGFI5j7/I5+JYTZOBofffmK8YOox/9P5K5FExUVBCHqAV2igsHXBSqmRaViQbl2yU llIPz9YiZbsFXJwJjMS+NKWRhQMBdqY/G+dIeSMXlsU1H22WYUbT+4yP6iGDKxD9e5nn 0wFnsay+b7/kt2gJaLwglGGHHnBfYoVjTHLrAKqjaHSnC6SnATRak2boiE/M9Ukd9vmG VZj0/H0R0j9ZerTfGywwGDRpdrcG0HFk70/X4r82nopd/fHMT4f6gbwnfZJMi6ofQGeN hOpQ== X-Forwarded-Encrypted: i=1; AJvYcCXgdoQ0Kxf0uZdhkF5yMG0tKR/ZcoZmAGsWWZnJGMOm/XMmY9MuAgpo6IiRov13eqXM+lIBjD/zxDrHGIjzUzFgdnVm X-Gm-Message-State: AOJu0Yxwz5QbYAiTOl5lPtbsxrfHMIaTrj56bt4Y7YUtxdk2J7rQP6jh jaaBLzkPSSqhxFyduGsByFSK/temnt0jhTyiB7mv8UGGehcHNxGJjaxt2dNdhbs= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705695 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF7F1AD486 for ; Thu, 20 Jun 2024 15:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896953; cv=none; b=X/tO4mvYgFVygK+fUP7U3jyzTJ6z8ZC1dAKAa5Eyt8ycVptBb1pGp3QJKbr2vJ5CJChfxBYtzD9lvNS2F72PHKgcEZZ2M1hKDavqs+T6AF87/dVURFNtdqLNiln5hAykvxMbAf8/RJTeigEXLj18W/CNgUIIjDpbBAnGSqwWgZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896953; c=relaxed/simple; bh=LWQ0eRFkADYmGUcTVY4hJ+pbgRc491C2SQ/i8aBPBiI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=HTA7cTtXvyldAwnQtdBMh5M9TkSjUBseGc4fnfGzjerPo7eWMZCylDRmwz8z0po16snjg1yfUsUM7PN6rO0BGCyXLZKYi/qzQAvgLV7L1dw4T7rmbPrDaonbE/buQ6MkOjjFQWP40m7bPIWt+Gn0HfNfeAIDtRVBt5ZnbGSYezk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ox8J7eZV; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ox8J7eZV" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-57cbc2a2496so1252259a12.0 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=vger.kernel.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=ox8J7eZVQV3HzTHLVqJ+Szj+UNbNFdmbpJQ/3+pHyS/YMB8KqvIF33NalLunh2XB7r Jzv2iWbe6H5UOe23ZQXEOu5MNzSFd1bUyN18sU+6JE3UwxUi9fhJ/CM0T6AjAFcKTqOy dsfbg6hqjtseln0nOGDOVp0CBJq498IFAWBnES9MytL6W6NyFteN3RlnsILQcixSxbGZ 9bP/tApd+IUC2vIcKRrZc11J63JUX0BP/X8OkK5QrUmEYOQUFZattWbxFfBpXHjSThbM U87dWnhA97AE5W9CVNgosZHXckCZuyKJJkIVWzpLhdtZAyD8JVs/Irz3Q2YCcgotNcdn MqCg== 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=Q82d9Uqs3+/lW9+KvHbh9WSfaln5UEP8u+wxdR/wpyXxXKPPw862Z/4TDrQL1KPu1H 2kqHIxcqcBfgoGVof1C4/2Hmke6sS6kUt7gaPZDRvtODGPPjg5fzFGlU9Xe1NfoYKweQ V2jXQiupH0suFHiXruh6CdzefkY9iHbD1ckeagQkn1+q5Cy0jJnyQE5ZfR0lpdEkDNn/ mtQahEGxEkPT56CKLPkIM0Uv9TYVZWTHVBq/8V8j6H4uW4DqxnXk7hkH7ZwW3ZA0XF+C blF5EWfpLKc3UMojvYKyOm7IVr1Ath7Rt6EcVQwLhyYaXFBbOI59fA+eUBr402MzjVoe pjRg== X-Forwarded-Encrypted: i=1; AJvYcCUnWI/W7ekVf2Z9ulSQYyZgfAQXDBAg6E+05e575vMauEi2xRscpJQk1uh2MKX3w8ZBV1xwn+ncLuftja6/ga+s/SaW X-Gm-Message-State: AOJu0YwKpFLF+cudSsSjjOyLXm8+8UYuc6tDJhhOeVACIvZLHBosuoJK +S740zfcUz1n8K/Mkk+gP/PTT1uiyQmfbpNwelzYfxI2IYUFwt78N+s2Zuctvpo= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705699 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 468B61B013E for ; Thu, 20 Jun 2024 15:22:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896958; cv=none; b=lhamiyyW7CeJo+PwTJa97zqiLxdNRFCKuSeDeAyAGZiae2HPU7GhoPjWpC+qU3dSJQQrwUlbMKHdFMeZAhx29kYRON8FWMugYyOrQKKzkkCkdd+GhDxPmwRTzpe4KJxvFwFNw/WdyV8fT35lJJG6fXI+FTmj6vj+yBrHrk3cB/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896958; c=relaxed/simple; bh=zMyxd/0cgt94CkKT8dAJw6AXCgBcWkEglxBAz0hwelI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=jGlsQ/wiymPTCR7DKBeSQ7OUa0M/ymS5ufGWb5XCW8AaGEKOqUrNFERaTJO1Rcfq72XxUw2zEW+TCKVaUVBhHESvvOo3Sn5SlnBXF8oLfjFfNvmZj2bZJniGAISEmF1Ye0ktSKeuU9pyEgkdPaz6sBDqWxVUToUZl034gVJ1N1o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hTtzqOSt; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hTtzqOSt" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-57d280e2d5dso368055a12.1 for ; Thu, 20 Jun 2024 08:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896954; x=1719501754; darn=vger.kernel.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=hTtzqOSttZx2T7mAYeXMArY0fHEYVKxwRSauXhgWSbMDeVeWDheIUNgLfbw4SBjAs2 xxdnApddVLwyOhu00zD9JpqlcvdKXnBrXJ2oRHE/vqXxVzS09Vw/+RwUeglf/8xgrdad p7UcO1RkhfNJaxIdGueGArfxFgyQc/4wzqSfpCI5Y+jmGgt7LGieNvg1tFAZUvQsYWSU RPNTG1O7YAPVROBAnDfO9+xFx+fHsmm2Fjjp98uyCK92fjQ0NQ2pWBhGdOL7Jtq/ggV2 5a26cZJHBFGM7QSYFSaEPD3dlJbl3BwxpRQsVbRk9Nn0NIQp9a+jdR0741JnyaJUFPq6 OrTw== 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=b856O4mjC8Bzw1k3IdGnAziJXVGl7OSjVR/ClCDXH10zXSEjg8DU0qjpVVsvt7YuRT ip8m2RzC28H8SpZ9etCuj5/WF18ECgh79VZe2xRYz9HGqwq56WsHgd+/Q6q7Pfb6/NJz UK1zGDbYQPxvwOAGuK3BFoShSJ8GrtM+AgMbtWkfH0R5SA+UMPIqYkHDkU5MnNPAp0vo tKfkpwlEqWNg1y/0dLmGAWm8LwEZKZhhDCv6253cPglME0GfLO1Kq0gLh74QLiG3wEpl H5gMnq4x71YkdY6h/5VaGmYLaisat/Y16jN7RIUcq7XDDi4oXO2Wl4a0XhmazaaGpU0A /ufQ== X-Forwarded-Encrypted: i=1; AJvYcCUyaE8n/1VitVoTd2+UsnvG4kILpsLYyOxZvtJhaC+PBSf9hH6CJSZdjeLVjAXmcMUUzOkjvCnhCyxyOXg7cKlHcdMf X-Gm-Message-State: AOJu0YzZsLxbfCRTtDV8irkSqfUO3eT7eXMCmIZzTa2oDuoR7Yn+9LgL B59jWnq7nJjTXCLj8/kQVrJ1r7EKzx7vqg5LY04GMNFnNx55JPQpqoGWjP7yR2Y= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705696 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C6AA1AF6BF for ; Thu, 20 Jun 2024 15:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896954; cv=none; b=pa4F4Nqom4ZrGFn3pMs08GD2JLgzOu3GrY5FXRD/3Do6zxtPtb5MU9IunHqCfMtPyZgeh2HWBC5hSyDEtcrQ3GdHvYMPXZIbwYwVuyiLD+8g5qxxaZDt8FZbLlBXAXnppWKu4SAJGHq+ZVNCuGvgZpGNRvWnTXKhspKdYjW4R5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896954; c=relaxed/simple; bh=pBZQmPLUYgPnwPvlGfOu/fmGzScvPOJIZeOOrlx1/wU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=cynRXj7iHp4s8WZno/bQdVLZo7bzp30UOkhvy4GySRAqHJL3PULy8tFG+4eYax4HhVYDokotvxcOKD4dUUHo9Wtnr1jufYgJP+uqIyi7EBpl7khV7Ab6PWMRlOqoGqvDBo6Z9bY22+0BKhB/hAbAJytWe8LOzEglUsAN+7Xo4ws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=QXnMZlDL; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QXnMZlDL" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a6e43dad8ecso175842266b.1 for ; Thu, 20 Jun 2024 08:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718896951; x=1719501751; darn=vger.kernel.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=QXnMZlDL3yGFl1kn0HJevB7RFjzL+rts2BEGlE2KJa4twqpKxGnI5iRDKl/+PRCrfC 0iM7D3Czof9CTguCBmJAH8kxitsAluoc3RmrXwdeMPoDoGzIP+NbJe2yDyDsXAjFSr1O rTZt3g6ofH/mTjH+3M8akf5WbOqWS+oKIhH5rGBxCKawKgmzOOBajzJ22GiEQmt7ssbA wHHEVxapBn31TLYblitbwWHTp2SihIRK1Iq/gcn0tc+MyYBclrt8QEVsTzJCjpGHcwG9 sc+xujhIUr+gSCkEU7SnEnb8m+nGOKVkNF1VvVNnKS6PgYILGGKPbOD9cCs5KXd5mLQA ROQw== 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=SD7PPWPqgxiLJL0yURjzxPkqFOKi83rnyDuFU8m50EzYz7M9SrjCdQhQROaKojtI19 asdzudzeSmFwkTZZ/qf9oIth4S1IpucVF2zY1BAO6GZhl+7TGIfrs5ZSFiaKXVqJ2Sif OeLwbXJ7dnQ4CjpjeIVgFTqC4kNgtmDZcuxurCwyvITadx8u9M1yRnjTNC6ix+uuEY6I vJDCBXAq839Y8Hx1Sx5J4xdOpZp+uhsfLS9WzLfSG3pPzGRBYSZSUScj+wdj37DC9YQN IuXtBkgNoEqVhZbY84Yk6dve1C3w2R0gQmzui1HF06QfZlrDZsoZRLK0Egv3evfL/7f9 p+IA== X-Forwarded-Encrypted: i=1; AJvYcCV0dqBrsROHrXdcHB3U36MK3sR6gSEBT+B9KQGK7uRdEZoBjk0586lOjeMHusMy1f6H6HP53fdz3SSg39krEVoQWGN+ X-Gm-Message-State: AOJu0Ywm3ucWNpLiY/wgKTUF8UGugaDJ6u/eDVfKRLpbRfo3Di8Hs7ss oCZk6fy78MRRhddb76pxtdRFi4UMpsw70gEgdMI4wL5pM9s4c8aMpTpH7Oaafjs= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705697 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98AF81B0109 for ; Thu, 20 Jun 2024 15:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896955; cv=none; b=IQK+mC7Po1NfWYzGX7mt7O0yw41dHWhnYHcgH55dvaEuD8OPjABDWac1HGmJ2NYBE5DTUaCPDdr+2uQrFOM8VUtZv26nCiz7mr+Sh+Z8WT2w6Ab+cJf0HRQCOA/cnDZl2Z06WF3F2hO+z6r1/WD0lQ+apbqtB+KDa5ik2z+jve4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896955; c=relaxed/simple; bh=jmtIKePhQcjj1EOi2/U3yq7fxT7nUM+IOtIIQSVIq5o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=QR5WxvT2djEx61/tZlwN7EnJU3OnaugtdpJWPbpi3KSNyJzAQLHBnyNRF8X4eaxzzsqiwfhSRoAp7dTZ4rVPUsRe2keopK46USD4yU3IFxkG8ZVbD1lLe2mHg+W+QobZ53Gd1pSfn2nLAzuVW4P2IHW8SqCq0HTWS2TD13mYA6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hjL7CM1x; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hjL7CM1x" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-52c525257feso1144337e87.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=1718896952; x=1719501752; darn=vger.kernel.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=hjL7CM1xS2IEyVB0PRyCYjmg6WmCaWbDOYVC56v6AHDiOIswtRyWvmFucGSNlqv04S 8nnnA2rEEub7O4VREozGljsjc/CAkoZtwgtmhruerdeM+gt6D+NqOAynqHEq5KFzLujc +wFa19cPiboRbFY2TdJqJPJ8Vg3HW66hBL2QdSG8SeI1qsWAXylTJX4Xjj0IE+QI7vHy JySlB+s2jPwBooGrOpP4j2qgdQ8WO0ZTZ+lmuf6SRZ5kgTQ7rjLZV9kE06ZKNxlEUW1h 1r/GBIgMvLisNR5ZFlaWeULommLXHbwY2vSmzZnDPd5hvMEqJg3n2aibccoRyVR/BHwJ BtIA== 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=wlDFokleRwG+J+bH5FvDJcKpvvIj09o0Iawp5pg/8EUkpBP7CX/OGia8PqW2Dbvvdh lwYi/Ty5HXaMXCEVy5Tx4LspYa3FBgaKIH5/UiW8MS2mS1vwyYp7Wr4yINHiFNJdO8UF mVtfLz5cW58IOTlTOkvvoN+CMt3F0NfwhRHUXSMjx+bArSb4A+W43GlfeqG0oMim9VD4 w7lbso/bvQvalwGphQQwGkmZIqnJJ/ys5jcIegRnA1uNa+LOj/Up4iPbmfXZ/7Aouuf1 vzGTbfJueKVHjqWqFfjLXwrVIr/zLpO39kB9FBJG3egST7hVCWRzPbZVCo8NdPyDvifd x8qA== X-Forwarded-Encrypted: i=1; AJvYcCV+PRZdLIeDksKdJDV8oA31B29nfbbGwiOMq74Z+Bbjkl+euV9mAH/+X4ba1ye3DlA9V51cvIsek/ornUQFj37Nbdme X-Gm-Message-State: AOJu0Yy4/FkLNV0cOPSPCas1m7+3WOwn6KZFDKkmACXDxB+NWnFCznKB JOhIltRyjEXC6Wi2pqEk7YMcYYnBrOuvaGhNr09Zg8dLODlNbfuWS8Cij3+oK2I= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705698 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A7861AED45 for ; Thu, 20 Jun 2024 15:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896957; cv=none; b=J+AGTE7YcO7AwWDEUqiEB+m6SY+1F+oKi4rdBmS865za8zECSqq3XDqwaFDeAbpa5852VNmQCDe6mlqs7VNBR4RPNJwO/OM2Ck5qjp+lX9e9aoKjdqaCsvsRUiKYZDQTwkLkFqalDePR4qSsQUTux01fiJvlpjNnF0RQ56lUavM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896957; c=relaxed/simple; bh=ewzmX50QquN9YGXnBE44Fb5gfuDMtN+sabHiA0pcCuU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=DYxEIoxHZgjCZEdSq3ybHS35Zh2qvBPkbIFGEMh2iK6kf8+c5mVXTZHsWuX/fbLwYCxrr731jMdXuCoAsqOSaBWudy34n5HFiVxI22O9BSf3y420ncEf4iRyC/UZIOlWlDumcHh41QwyNgIUmHer9pcqhOYDwLPyKpxcVnsCi+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=I63hvIfS; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="I63hvIfS" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a6f1da33826so130637866b.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=vger.kernel.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=I63hvIfSadA1LevOuxrZlJhIzcvyQ5+XbkeDQBxSwwDP8LgRuB9qUnC2MSHQ1u9OVw Ka5zc8QkxW2lZyn5baP357HX3qRNbGKcZoUFhCo+BAwxZI5lTY09C3pD2dkggrW16u/G Jtwf6PyZ603jKphLGvZBS7nx0noQNjvsy+NN5SoxD+jto/PF1ZTSCcMj/HZHbiYRLPql 0UbHd2f3jgljNXfsscVLy6kVKhDJ0HxqGYE9zqT4TtMm0DWgoKhXOABe/mZ9ruaTXR/7 3+fvqq8RY8bPsMUQiMXyv2V8bN7+U8rHFFQnt4Y8NBsZ4HKHlaSLpXnLNo405aPZeViT nQBA== 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=awfkUxavo70FPFLL3myicjubWAcsabT1aqKTbOGYPAhs6zE6mS6AFUaz6ghLYvF0QM BA9VCGYGWjVMRZUnfJORnuCLzZns+1cQR1aHRr8F4O/jQRCpLvmpQ3eWQJHHpIAe6BkB zUsTEWWLghNWg36mFe8NqgZdhpintqsJrfy+KTw0MC2E+lBK4umZvS5yJKCOSzzw0x+u C7oUpP4UHuSO1TOJXgOftRWHs0fcyQ/4tNC+SkKVcTKbluXjG8TyShI0J5FcfmTAgf1h uuc0xJMbcE6P8mJE8ARLLtnSQ+s7Ix6XVnX1O4xkMryyWvmhKEkur4L5xJbChPHC3GFD 5VKA== X-Forwarded-Encrypted: i=1; AJvYcCXMxo6dtFLR7rQ46sx4UEl1iQo7Tw41Wx3/hRBVymrru3dJIGVwS99OTxiWGZGEmOmSVtOHVwgCf0vIIi/AF+2UXnRH X-Gm-Message-State: AOJu0YxFNsKjlsCE1nwU2TRSvh6G9F7O2TKJamDpSCoxHSB409hDsmmD Jh/pY+xAOC7z0ECVi7fYY5NPX/UG3wXCgKkCoYJwZljw0EjtVMtAjHxEdAC06Pc= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705700 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CB8D1B1411 for ; Thu, 20 Jun 2024 15:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896960; cv=none; b=iAZBTi0wKZbLG7EcBX2D+HOFZYkDgsi+1wtkhfSDqwLWJwPSVGpbqTczsMEUrgok2JICyOy+tqefOttzwtJr06oOztR/yrIdEgdQEcvIv4zEgjliYT0ZGQdL2C9t9uKAYGZkvH4cZ5SpzJACiKsgLRcTbv97MstGyVxuOf78VYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896960; c=relaxed/simple; bh=AcidVmYUI6No+qBcD3+XqElOHS06xcWQhMyfFyFmudQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=kUv7c/fC2gijh2gp8R8oMuCHfZFxM0zk6rS+P8ussRCtVzAv5tHZK66EMd0o+41s7cZBYdhemQmWpd6QHSSRJn9HNIwQXv9Mp5BsoiNjXzh4Tj+OA6MHwzcVIoCCeoF7cazhluP0/AiRY3+kpZ3N+xgFtf/2D3tAB3NJY67P9tw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=JTWzeQQI; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JTWzeQQI" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a6fb341a7f2so130465066b.1 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=vger.kernel.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=JTWzeQQI/8STMTMQYkYVK+U6yceH2bJw99CoxjJPvcrDv1aKjrYnIG3ZeL/y4Ldutn uu0Omj6Q654XkGPJSy7Oxo4bGr8E2/PxbtkEDMb4uY5jIoFMgUy9UxP88Z9tzRP4fI9o fPe4bXV17UnxTBYI9noC3EPj7tTv2BOZAdJRSddqtZ5mkJY/WxJZlHT26957ggMQP/n8 7kjtkujT6XejuoXYOKTcYDP0d7WJ92CvIdnjvxQ7+vE6HWMgMC++vhD1aB2vRrjjH1/6 OUOFwpxsVRtvZsYfMjKdaCMdzTERHU9MFNpvhWsacC4F/NYiS/UxgtDA38p0Qlt5/9Sy P4iw== 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=gLH3bkRdCEcCqwwVOWPOH0y8/dvJUln/EcTUUDUTO+DR5QpzTxCfHWMWjCRZiH8YJI 5wrVmVcBxAMcwXAZidfHxvjgwxzFJEijvmYBOn3U7tqL6qZES5iaXv8l0dcmnbCbZXkP IWM6u0+Q5ryxOcdMGNUenwMBJXXqiV1NUTfEp2zVKqu+WQpuxlTLLsb8eCwZmG8tJLlO B/hABQJQeHCsVjPiiuqah3vyzVDjvqU65GsfocDsK8sHmqc4GjubdykOsz/DAZz8SOFs EdRLoJOq4TAvVx/g2QEnydytOPkhuyPuAUAGlx5pXWKjEkDMtuD/0L11NvfFWMhl0P0N kJYg== X-Forwarded-Encrypted: i=1; AJvYcCUQrPYnaZS7XlQUu8orSLEWrlCOVrlGCdpAuOeUEGgFy9p6A7HM7tQ0dvL3XHsXlI1R0TdxbhSw7TD7keW5gHBtSw8E X-Gm-Message-State: AOJu0YyldoPwvtxeFIz+SAzyCUtd/ef5E2MoG+DRWEPbxpAY8CFJhx3+ YWBX5JKM/PMfrFoVzoZtzHy08kFFIjaVao/29tFQjzrUjCtUoAXrV/h0Q8bQQQs= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 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: 13705701 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 265281B141B for ; Thu, 20 Jun 2024 15:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896961; cv=none; b=dLlslYMTy2r8q0JyObURWnDWaHhV64BLLdWOfHORNixi/bu4Izfs0phQgulDO6oWIx85orHnknidJ3c99pKyj5xDmyH1XtiHoYO6RsRYxE7fIXOom5PfBpp2u0ZsbpOg1Vt9iwEyp+t4zXCc7BYpw5RAj72wJr9L+pYC3GlwV6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896961; c=relaxed/simple; bh=bnbZUiGWMO3J8cFkRW4SklmEhRjzMiu8ev+b7OOO7DY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=O8F3Pfm5koGzG2OtCa/BIDTj6/jM1WsqzPOVkB+382S9/jO+SIK9h103jVVmRBdrfEqLy0Dd7iAnloXqV/SySDutkx1SZqi64bVebQFfiEYcS9l++Gx6D44yc2AKm7KDaBbb6KtGfHLgRd/KGx0wBzRP96H4bVk7o3lLP6jyvSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hDC5VVkb; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hDC5VVkb" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-52c9034860dso1263990e87.2 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=vger.kernel.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=hDC5VVkbmeZ9FnuZp8cvuq8yMLPZ36rpKTzhzoUg6mZ3He4d+7+tQRPPobAr2+uuuy pT29PqWuzNOWtJAWhfAx15+7Ai0QVL3Sy6hc2OqNqiueil1zvTJx6CMxj504TPl8kjp9 hbDSyJsWVFXJmOrCCsx1oQF4hvb3cZ+ClcC7oSqSy4nMkvcay/iSNReYUlrtUhTSJMiD NH8sKJvv7a6FoPJ++yc3PXa0nLf/bR+3G6I5VotAPkwSHw37+uUCJWHGlNzjwv3WDa37 0zs2Wop4izIWaeJvyFjKf6cy9VNM8Ndm4FnOVKx9fURdZocUEbdCbC1D9NdOUSM42mpE qggQ== 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=IMYrrMwLakwTMOjWRbD3W9Cak+OD6U/id05ocJX0KmfJqG0DvZEZQ70S6i1VWmdneU PY0BZN53mCXl/4MlQLGhQVXHYedeF50knkhTU2CYX4EhQzRKaypKKfxll5Pr3mOdlF/0 9BAdfJr6AEYF6MZ+adJJtspcwX6YSdJ/BmTIOAM8QPiKxeCAPtMTaU2tu/DQ2IK/jLPS ZwA5Y8vm76Hl8WjR3tiVzaL6QIKPJKfsRj4pt4vR2Xf2G5X1zsdL9j5wjVREkpMFX2H6 nK65xKNtruZPMxZeS6QoPAplqJ6v1DsyQi639v/4P2QCqP7mBFI9RJQUgK8RWSGp2ysy o1ig== X-Forwarded-Encrypted: i=1; AJvYcCWuma226MZDXzxNhMz+Ggd42c/5F279nTTC5uc9sTdOcanM+nZwTwsyo8cz9OhTWZiziaytrNy2u7XwMVM8okqh2zYm X-Gm-Message-State: AOJu0YxX7L7N3eeKEypxCdQeCLNDfeaS5EsvSzEMJ12ofGv9/gpottAo CXEzUxGBqL/TMxrUDCuhrkwOxnY8RkWYugB7xYJjQd/Y6z0ZDNwsQZ/fJatTGag= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705703 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A81DE1B1411 for ; Thu, 20 Jun 2024 15:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896963; cv=none; b=GBuKxPnhMCNVivgJeuRTefThCqcHvsPx0QcFnHkIXAaV/XEyk5qjQHmdSDvqCg9Qhp6OQ6PjdwHkDQP/ljO/jM1XCz4ELbA0amL6clmtoypEtPgtIzdM4UhhvfhWUXXlSS+9gFrsx3GcoR7bHQjsScNVZsLyoS5FJXEjqHI/B9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896963; c=relaxed/simple; bh=dWZToNlnKejocuVrTQZhH42DGhR+YF4KIP5K3Qp2PQc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=dgTtLyl4W/nXv7maqnXRZ/nc3+ausJzwgsilv9tIddPXcbUnSoJC+P4aOzeU/AdRY+W1Rd3rA2V+sGhfC03OsiyLDosJGEHV7hrY1Mq2HEwYQe2tzUySyJ4w/joiOgKWLQcqgkEBjvCKgi7AdgGZA6wvHlHbTJyenyeuGjaDuAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=V1FhL5fo; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="V1FhL5fo" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a689ad8d1f6so121676566b.2 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=vger.kernel.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=V1FhL5foLnWiauwzaqqMS0rfV0ks+896xaY3msK5H60eVYmHDcYGTHB/D2u+cwOm5X +0bz0Odq/BzMZuQH0mSXS5aBjKlUE1yH/0jPGw2SrfdzoppGd+FIojLepK22cmFb6D8W xy3+QmgRa0YQYAhu0276fcwa0vo9q81aCAQ/qsIzz4tLoq6fjk3uCCb2yEUXdMQ+yX6c HJ0SyRlHOgyzCOL5thVieJ5KPA18KGmyl2h+YA1F+IbWN8tu4Es57k2DITOT6iI83kGR qI71iUj1DoZrFgdIXQctGKJn5miARBhbBspupJrKlGsA1CSlP94J1WqZ96FlJi0dA+36 TmvA== 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=GtNCAxFSsk0eV6ugF+kAdTK0NhEAV2i3yboR67AJUU0vSWC6/Wj64woXTyAaXOKFLP ftKTrI6DzCSuhd/CgrfV/WNF/GAN3U2JxDtDn4jb7uGsW1/SGt5XPissqbMGw4F4xhn5 MEQ1+jMDGTEr66SU/vmvHuTPxk8Q4DgyBdS8g6vqupHz5P3SF5hSgFPzHJ0hMN8XJ6ri 1kpW9gq2gUDsEMM+6teQRm7lSfIDCsERKcSn3f0z4Pt3cpGcfPZWr/NHyWqD+QGQa5ky ZfpIR9AxA4cwmRvRtzsL2UlkhHipk9w1t6jQPOGHa/hSNz3xkKM3LzVpNlteKeWnKu7q RKfw== X-Forwarded-Encrypted: i=1; AJvYcCVfpHhBRp5DjAwBzSO+pA7HywDbYnilBN6E7/fDcmuYdv4v1FIwL98LZv/iqLn+vptVPqrEAFzy61YTNf7uI/sWqruk X-Gm-Message-State: AOJu0Ywj4QxhQMBSf/KD5wDuqaQMO6aiBTY2T8PDtsBcCW2BngqUldko 7M4xiokgHQ2HQhMe9m005rU8AT7cpOvCb6z0FLDrhkcRBHYAScjXUUdtJz95J98= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13705702 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 651991B142D for ; Thu, 20 Jun 2024 15:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896963; cv=none; b=GrNTMnXeY0PMx8fM+ikwauHboAL+FIuWNjQcYQWhcZcI2w73zDVAO3nrNsNQnMfJoOfzf2eXkJfx8ISvCKkNjhNSuHLwlmvIPFgeXi35bh1YjtIZ2yaGegjbD9iI9b+wF2phPIjv++3olV3xyO6uSg/63mRAPXbwfSERkoHzpYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718896963; c=relaxed/simple; bh=07cMNi2bfvRha6cTPTGq7oWGEYrUwQEOTDm5bXh8XU4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uwf/QndxlYb04VTHU2AKgp+85h3rBRGYGTk9M6tNM38OaT3ftXeuQbr3L/9IcSw1MSLlniGcfHbedeSfSP0ngtnBO9G3gbMG/hwUx5rSXlcjhkfFtcvh9b7ys9JETmnmcRAHhfpiqp+i0eDp9Xpdb8/gpfBjeyDuButqzR4SbJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=EaDFYD8n; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EaDFYD8n" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57d05e0017aso1274448a12.1 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=vger.kernel.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=EaDFYD8npmyIfq3xcFCWhycZr0di44VrgGFTi1B7Iz8Kmwf/YLeuTck1bHSbaZX7Vx l/86rI/tZiCFxGDdjv+Kf6xkZ/IndBFKDflUkinBfGktnqdvVacab9fNwV9hq5pxmRMK rC0uGgK9iggij+md16EMIR/nobMZrEaPEqaLSJjD2uxi+2nVJuAUn6TfTejbH+3e8o9T yd0d2ysppta6XzX5BXkC6sLxUfBAV6eO3u7YaavfcnBc25iSEkUMdJ9Jcx+VR2QX992G Lf/O8KHlwig9RYMBYJLXHocwEqY/ntzzWQ8tQKoGT02ZYqB0wjngR4vWam55BrBYfRv1 DsJA== 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=Gw7PD3hkkhCsyn2LJyNnwg4f/jT7b6j48PPC0OSHcDon55Hx0LMWHJ1Z/Y2MzkW1WE wwWwIfZoLziDg3Wkrh8r97j+YwYXvF7rAMJUSinAXtQWcHPXM1HKWnjs2K2hrjCaZRgA X5VrlD1MSTjySgzsrjpFjHW0Loeo2EJitWXUGaiiw7zzwDP8/4uWHOLr8q0Gu2GxdIzk f96kkJAMHgjFingHdq0aU8JVLGzITXoGjYG2o/9kvbanrAnaImxZ4KLzuHqP6IoD/W+G QAdMWK/zLqyBaD7hfXum0NIkg6Gylg2xMT0f/4kYzw5FqDXI1q+tEiHrknnqb+b5jYpk 0I8Q== X-Forwarded-Encrypted: i=1; AJvYcCX4Jz+IDcN4n3IdC3g9m9vIJuYjjtNcI/Hc9sXLvtc3F3zriloVQYOJkKw8iLatX3vOXx2roi/OBNJVgaRxLiCpBdA6 X-Gm-Message-State: AOJu0YwnbAEdBAj0gBFVPNNdlN5N6+xw9FqFaIajj6xOewzWqsxet3dH HVwyKabkEtEpwGaOC7cMaegy/OmK7SPTz84qQaUMBniBOtuSDQZykHUKcxkF384= 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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,