From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224357; cv=none; d=zohomail.com; s=zohoarc; b=bySabculsPiJoQuZcCqMaJyWgj6M60buEq8NTNZoD/dlCWJlBqNWMsc/LyixABWaKObydxsBrPe4a4IJJTzefDBMloGY6jLP+TmhMOcLWVkgB1X7k+zvumyrSElS8rlwCGcapBF5zGykrZqxqn/oQDPk8NDgU69N313aDmkZHyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224357; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YP0Mfaa8TidAoBaCJkmfwZz45gYzsO0OgSu5WsDjDig=; b=L1GhJjVovnyFDIj/hSwrsf7a1d7l3XGe3ySegevTHhb55rXj1Twqj8LQEfrpaHTWyChoIC+NRvmpZQnpOTL3u6cbSvwVDV5zgrAi4pJajTl0eTpv3SBCrFpitDLZ/Se3SyAkzC6Os4NhptKihz2YIGXMyVGIriagIPZuj9CS2iE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224357761785.6480509760493; Mon, 24 Jun 2024 03:19:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgma-0006l4-2F; Mon, 24 Jun 2024 06:18:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmX-0006kU-OT for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:41 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmW-0007eJ-3p for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:41 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-57d280e2d5dso3868654a12.1 for ; Mon, 24 Jun 2024 03:18:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d3042fd17sm4556554a12.47.2024.06.24.03.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:37 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5FF055F956; Mon, 24 Jun 2024 11:18:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224318; x=1719829118; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YP0Mfaa8TidAoBaCJkmfwZz45gYzsO0OgSu5WsDjDig=; b=MiREaZaFoc2AVznp0DA9m82WvUVOW33SuQoV3qXafPTenH6aoCwyiYwZcAJh8QLYBs n1gZpNheTI0vZLWRrYiyEOGHHIPCgAkKMl+j5Gd3F1bmJAdt3YbeU1h3o1KpHJ4uKBi1 m9qUQAqQ5Im3YUpL4AdLS9ogLJISGA45VxQmEQ5FPMD/1ARiC3h9HFGircJdiUo/FP61 fA6m9ncR0XOtff9n32wx93NGb3xuqypIu32NVfHaVnohSQFSuC4541Ri+9573o6cEM3D JrSZWOVVMCjbWMzv23jFlBJl3RPYWJiacPnupdenyU7pRWKdlh2qy47wp4UULoHcgDq7 biHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224318; x=1719829118; 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=YP0Mfaa8TidAoBaCJkmfwZz45gYzsO0OgSu5WsDjDig=; b=SsWOR3Pxf8SnhFM2T2SFPqDFhZ22HkcoHqAcDsrTwcnE+P2Py2pISgdUnHGxRT0SyL U1ok3rJJg4YCxL1b51yCwf+afeXSiNn+4sptMzrtgOByX5dcC6LPAgzhTR4MTM9Adxff IvWZZbg5Pruz2tsUayuhz4z27FQUSmnzBIW4xozsyO6Q7WLzl7Hcqv+ItsJtB5awanBj yyuAoo9lo60Ky/4b/KlWGhfBWd3d6XbXu/F/MU7oP804QaO6216VREKAYjMiAyuah94G rRXbCKaqgIeQ2wEwd3yIhgB6Pe27Fa+bzBgPXk4a3ZFHAU5U9o4h3eNOaFhoUcPthqxj xUhQ== X-Gm-Message-State: AOJu0YxBCj983BdOC/lwqgJc0llBud9//FIoKYL3vbsf9ioFAqYgeZYq 9sgNrxCl63uVi1m0KPhkcrwIl4usDFFj+EbZMXcNSe5jnrU5f/PiQLhkBqQzeQU= X-Google-Smtp-Source: AGHT+IF4essl0D3NCh21YCVBk4QmnMUZNsoHttfpzdI8If1i1Ku3Wd/clzMBdtd3brt/2etryP4u4w== X-Received: by 2002:a50:ab01:0:b0:57d:5388:bdd3 with SMTP id 4fb4d7f45d1cf-57d5388bdedmr1803171a12.10.1719224317986; Mon, 24 Jun 2024 03:18:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 01/12] include/exec: add missing include guard comment Date: Mon, 24 Jun 2024 11:18:25 +0100 Message-Id: <20240624101836.193761-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224358437100003 Reviewed-by: Pierrick Bouvier Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-Id: <20240620152220.2192768-2-alex.bennee@linaro.org> 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[]; =20 -#endif +#endif /* GDBSTUB_H */ --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224375; cv=none; d=zohomail.com; s=zohoarc; b=YF6AQkxy4olFuEF6pFAVx5GxPMCrvlay0Nt2lAS3mbSP7iKK7X32M9JO6zQpP3LJ+YupGRue8XeAE/gXnC/Wtw0LNaa/DsHGaxvdFr0FbWl417ZDYEifFH4XZrpRJa708ETXy9vIkUijUpNjqUFlOgAUk6u3Svn51RsGyA9i+yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224375; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YNgw6jE6+Mh361eYuvFy3mgdndxGrJV55+5IHn+HTVw=; b=ZouZZ3NmZsfHxO6wb7mfNznd27jcb0dvMAIimEzRQHFEkmS+j7RkX9NlXfBgcY/glEWJS7ozXjHlgnf7ZO42aZFtfzhE5qbaoZFgIZPp6f6VioOmvAoHmf4Ii4DHUX28z85o19iZvY+vEckTzutnS3gv0uinEb21eGLdqgx0cbE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224375589810.4485398767589; Mon, 24 Jun 2024 03:19:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgme-0006nB-PR; Mon, 24 Jun 2024 06:18:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmc-0006l9-E6 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:46 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmW-0007eU-FS for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:46 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-57d044aa5beso4565754a12.2 for ; Mon, 24 Jun 2024 03:18:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d30563440sm4509938a12.84.2024.06.24.03.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:37 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 840DD5FA0D; Mon, 24 Jun 2024 11:18:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224319; x=1719829119; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YNgw6jE6+Mh361eYuvFy3mgdndxGrJV55+5IHn+HTVw=; b=hX2+LeUYjg4qRFPw1UC35uPuwEYTppX+E3r8KNJ8nhfH+e6jTApl8tM93VMeRo74it /Dhf+nrxQYeQk+o+i2IuUTcbLFSIijwyKrwE6pko/dlqOihkVtZixXGuVys0uvZ8Ac4z hsst67OEEtSky6gxSG6JaHvDlxEboa5JOFT8HJ7hydPWfSmxcsmsi0M3w0W4u/lfAXx7 iLa8KnbtCSgbUV1RahDzbBBYJq4K0RQVUBWIY7Bj2za4ONEZG+CrMwqI5KS96Dtjnec9 +JtdjS5OBNAEjA1ielc4kS9rvFEBRg/gdrbJzt+Gk91Ppy8Yj/z/wcULMgPjhJ6OC/FA fn4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224319; x=1719829119; 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=YNgw6jE6+Mh361eYuvFy3mgdndxGrJV55+5IHn+HTVw=; b=hcD3TEBtTeOawtfziJU0Ffb9VK7cclXIwnj+Sfuv3LzZzkEV3NVjcnV/cifkJeYAfq qxcBHoGGDaNpyEVwqv5djUWT6MvZzGJKBxqk+JsQmuszfO9HgsnipfSccdr80xaDh/1j TxrPQfvhFYs195ZaN5iT0Ie+7oLjTUTB8lP16mmMNhMlBKBA/vPhaPP3jKtBWve6T5C7 iR06AFwzpxa40QTmT0EwjCeTTgjrIO8AxKvZHN5Bs7Vkf1+MI+HTF7MSmvVkjoglMBk8 sk4OA+G8GaVvkNxFB76ABWWvCII6+ufBJNiHfdw1pQbnOYVZF3Jy+0ajPM8Pkd8EHhi8 Stzw== X-Gm-Message-State: AOJu0Yy1lOTCfz9SvfNeCcB6ij3echHqFicQgOa6kYaer3h/0ThQwvjX x8hssZ9+CZ5/37jz0mUKRKjyMGZLreeYIL5Ow8KPEPYUSc8cTVyom5xwJuMXuKI= X-Google-Smtp-Source: AGHT+IFtBtI8kXui4zGfQhOuThPJ8k4YDr7dZReao4k4WveA0Eah33vTmROC7oKSSZwE2aEx907Pzg== X-Received: by 2002:a50:d79b:0:b0:57c:dbf6:931f with SMTP id 4fb4d7f45d1cf-57d4bd56bc0mr2499112a12.5.1719224318334; Mon, 24 Jun 2024 03:18:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier , Richard Henderson , Cameron Esfahani , Roman Bolshakov , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Dr. David Alan Gilbert" , Alexander Graf , Peter Maydell , Marcelo Tosatti , Nicholas Piggin , Daniel Henrique Barboza , Halil Pasic , Christian Borntraeger , Thomas Huth , David Hildenbrand , Ilya Leoshkevich , kvm@vger.kernel.org (open list:Overall KVM CPUs), qemu-arm@nongnu.org (open list:ARM TCG CPUs), qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs), qemu-s390x@nongnu.org (open list:S390 KVM CPUs) Subject: [PULL 02/12] gdbstub: move enums into separate header Date: Mon, 24 Jun 2024 11:18:26 +0100 Message-Id: <20240624101836.193761-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x534.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224376562100003 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(). Reviewed-by: Pierrick Bouvier Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-Id: <20240620152220.2192768-3-alex.bennee@linaro.org> 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 =20 -#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" =20 #include "hw/core/cpu.h" =20 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 @@ =20 #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" =20 -#include "exec/gdbstub.h" +#include "gdbstub/enums.h" =20 #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" =20 /* 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" =20 -#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" --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224400; cv=none; d=zohomail.com; s=zohoarc; b=Rw1/Vjf0pWoEXchSAGYSEbauZNeyrpjasruZTM7HAqlOU7wiNUh+c2+CcLwaHzrEvE+2S0DJ8DYfY99EnStjfSfmDVB+OA1pWV9BE1TsJ+vHlF4zVx1CMOmeEpR2Q2bYffS7hO0GYz76kpr0JKcm6DbXwzeXvcB1fc0b2SyEHAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224400; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ePkIYhsbktpF3GtdyBZ/LusJJnuJUmhkpUEHT+S8oig=; b=iJx89IEagTiPrkbnLMb5Clbt0nxeIuJ4DNl4PWUKltRkTuixo9qy3+lH6titQRg+JCYhAXLAEFU1ULXC+LyvCCmjYIWbpuWHWBTmFCRL4kxyQA9kHGAApERYlWUZ/9XJvWPByEW7WjJMahoiUiXrRUyDuADWThYqaos7iWJaVJg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224400711889.3846657246647; Mon, 24 Jun 2024 03:20:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmg-0006oN-60; Mon, 24 Jun 2024 06:18:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmd-0006mT-QI for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:47 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmY-0007ed-MN for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:47 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-57d0f929f79so3586197a12.2 for ; Mon, 24 Jun 2024 03:18:40 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a725b092fc4sm53108866b.35.2024.06.24.03.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:37 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9AE395FA16; Mon, 24 Jun 2024 11:18:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224319; x=1719829119; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ePkIYhsbktpF3GtdyBZ/LusJJnuJUmhkpUEHT+S8oig=; b=Z+5XkD//EQxpM8WsA8LQ4Blzu1du2VFdCxRdbl4R/rqgN+2C3U8pDMqiO5Jo9k3ikV 0vooL+W9vuJ6Am5P1vxrM6pg1E8zQyX1HaCyJXN4tLp6E9AvOxt+EsNM19clU82R8rSv MKgDlLlFkj5IojL0nLjJEM8AEbOefdIsAHPCH6N+Mmz3ULaTT6l2Vv768X/ItMJBM3Ga aAWTodcytRtSSFs2t5neonl9mcKW+L/teO5IV45UA+AX85tl0hMAmQosiJUpr07STfc3 qgZB3U4d16eqLxo4OsTX1n2wL3MwVZyPIaS6w3yhLl+Kj6E7ZCRkXOzPc0gvHd7QfCWb fnSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224319; x=1719829119; 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=ePkIYhsbktpF3GtdyBZ/LusJJnuJUmhkpUEHT+S8oig=; b=hUzlEP+o+7r6xHsqcHXnT5LrDjLIYALtUxRKEDSTRWB1IQzyPSIEOjPRbmkl87svJO bEih46LxLOIPSmcuj8fxqFTPRCapDruSovfz3EcQb9FtevIcLPzrU+yRod+FRWHo5PZa KgG7Rw8/BzsPgTOXXL0vtpuBqq4CL13KQQkkTy5Jo+WsW0lGCPj54Lhg+XvA1r1tnbjf O2J3cTmCsb4x0TS05BDEu+i4rPzuze/QYvFs31MsAvT7/T+VVln7cfVKUaHOnqBzb/vj iFp0a+xlUcBDX1FIsaGSBFKoCzuaYBBFXTxnpmw27H6tkW8eYC9iTaBz0W/asQ7FYOPx Jr/A== X-Gm-Message-State: AOJu0YxqlxQdQjdIOXIV2LHH2NJ+C8GyU1CBOdc67mxmDiygWuQ1ArIL 7SPExgySczII1+WKsD7HRwyvEjZR5S+QZGX7W+dkLrSCLvEaXwn+k8y+2fzlRI0= X-Google-Smtp-Source: AGHT+IFzzeAFBHPFAtDV5Zt5xhcNoBENB2qO1dBQe8+FvKsnsYzi6Ci2uVRv+cHGW+5UYWtKpiCzwA== X-Received: by 2002:a17:906:fc1b:b0:a6f:4be5:a65a with SMTP id a640c23a62f3a-a7245b73ffemr244048966b.45.1719224318719; Mon, 24 Jun 2024 03:18:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 03/12] plugins: Ensure register handles are not NULL Date: Mon, 24 Jun 2024 11:18:27 +0100 Message-Id: <20240624101836.193761-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224402844100007 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: <20240229-null-v1-1-e716501d981e@daynix.com> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-Id: <20240620152220.2192768-4-alex.bennee@linaro.org> 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) } =20 /* Create a record for the plugin */ - desc.handle =3D GINT_TO_POINTER(grd->gdb_reg); + desc.handle =3D GINT_TO_POINTER(grd->gdb_reg + 1); desc.name =3D g_intern_string(grd->name); desc.feature =3D 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_regist= er *reg, GByteArray *buf) { g_assert(current_cpu); =20 - return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg)); + return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg) - 1); } =20 struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_s= ize) --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224388; cv=none; d=zohomail.com; s=zohoarc; b=fp9WlaMTcRQu/dYF9sfEaWYPrXkEbGjO0G6/Fq5rMbsufodfOxIB7G3epATfNy7E8Yg59Ho5wf903MCKfUE2HhHWd9DctQ6pYfNPAS0pxTsNXsyfIersi4ac68faVKOyppgTs0jOUjXugI0kf8KgLlJiS0ZcIpFygxqrtLZsiJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224388; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vyNzW8swQuYkPObetY8GGPVB+trDsJ78ejFduvHLra4=; b=hieBOZAkkX5P4IVFfwECn2HFdc1EkFEDQVuTVB3O4W5Bp5i5O0jFyHWEgq+eThehZ35VQSWwc6ztr96UoQf4Y8pjm2TY869bvPyAxZQ30xcA2AEfAFH04Su2XBZmiGsRIdsqjEKJ4UNpwcK3+y3CtWW6do0p+1mLF7XqKobGMd8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171922438811316.80793269252979; Mon, 24 Jun 2024 03:19:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmi-0006pm-JK; Mon, 24 Jun 2024 06:18:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgme-0006me-82 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:48 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmY-0007gd-OC for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:47 -0400 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52cd80e55efso4511194e87.0 for ; Mon, 24 Jun 2024 03:18:42 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a725cc93794sm43811966b.170.2024.06.24.03.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:38 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B44215FA1A; Mon, 24 Jun 2024 11:18:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224321; x=1719829121; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vyNzW8swQuYkPObetY8GGPVB+trDsJ78ejFduvHLra4=; b=bOuEoPltXk/BDmqTxr7flLBzYPuQ+NCNT2fCXnKO4YgnExDn8aoXDyyMlhxX+k9IQd Dvhwkxvy+Bd3ST6t1sZqlTRlXXeFxjrfLAma6vWOZzg4ydgbjBNBTmiLnXDIIPlyiXkv ZlvFjNmRQgIEnYSR3VU8c/dM3k2MQWtQbP8yZvy1nY+AvixtErJYNwVbGoAI8emem8GD vvORLek/85RPBNFh4qdbfWePxXo062WqZGYBKqNGQ0OdJwDenQ9chYwk5zpYpTpONI+B EDvREHPMXpEucJX5ljb4GaVfMltDRq6LZoXoxUnwygiQyRwHutHDIMMhZpfmOo6h0NlH +2xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224321; x=1719829121; 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=vyNzW8swQuYkPObetY8GGPVB+trDsJ78ejFduvHLra4=; b=SfiAjZNCv/qdxrWn+AXlirP5kizRDcJ942CZUI9HCA/sTDTQ4wY6UPvVrK8pqz7OF0 2nualAGqMOoiqYPlZuSFErtE3Qg4HZluzxtRWiT9ihQw9uNxnHttD17mLb+m2p7s7FIo IlJ3/NHMtsr54nfMPLtQiK+jtCSiz+ybzKktvOMLgVPOMUfQfEgIv6HkmZvNecQ7Rm55 EOotK5+pPH7xZj8vfwzzFMbnvLQW5SXJjojSYO8hYURVr4A2tpQ9AAXrfRxFt6safFiY Kwc0jyHEkTe4FrDATg+po/mALezlHWsVUMsgURkdr1vUzg/GwsJBy8K+sl7X3pHeGJ3G YM7w== X-Gm-Message-State: AOJu0YzNJ7VDeMiwWHrFFd64axsiI2ewT15TVZZRu9/aZhwBxOLgVqaS 3YTnI5w+AOiI3WakY3rdLcmqIguAnOiT4tsFKWXB6wO7pEpIgD7hSg6qsDGFruQ= X-Google-Smtp-Source: AGHT+IHjz9zr9W74cajV4yjLpkcfdyQPIoXQ5l1gQ5D0Z7n/aKRu0zHLgtVWrwkhY8lkBgzn4zpf4g== X-Received: by 2002:a05:6512:2813:b0:52c:cd77:fe03 with SMTP id 2adb3069b0e04-52ce182bc85mr3431908e87.14.1719224320701; Mon, 24 Jun 2024 03:18:40 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Richard Henderson , Paolo Bonzini Subject: [PULL 04/12] sysemu: add set_virtual_time to accel ops Date: Mon, 24 Jun 2024 11:18:28 +0100 Message-Id: <20240624101836.193761-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224388622100001 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=C3=A9 Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson Message-Id: <20240530220610.1245424-2-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240620152220.2192768-5-alex.bennee@linaro.org> 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) =20 -/* 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 { =20 void (*handle_interrupt)(CPUState *cpu, int mask); =20 + /** + * @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); =20 /* 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); =20 void qemu_timer_notify_cb(void *opaque, QEMUClockType type); =20 -/* 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); =20 #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(); } =20 +/* + * 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 c= ycle 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() --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224400; cv=none; d=zohomail.com; s=zohoarc; b=RtiMQrPMaDIHCbHceEcGNEBqldtPg8qyhGQK7RMJH6do9pQZKhdxWnLbGZGGJQihiCdXK2uCEqgmPlow/FyzhqPU68l+TTlcIihhHWwEMil4/PtQFV41o1JbWsYUFPvEGkJkqVvTbQQbvajlCZRnbRmCDUa5BUZtMBZ4xOP28qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224400; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DnPYMS9aYu3Dj6IJQtGryC0W7EDGLSoROmhQZYsJ9o8=; b=MTK3lvXfbYqVtOMKLlYG+53+OlfPe7an16gEHgjgvpAZd03qJylm4dERg/O4+YkXtHWi8hPWTJonCQ8YRlpPEtg8B0Tv7dddlVZz0MWr48Fu9kdX/f4gD2qF6ZzV/E0/WuPrmxtPWo/GL2QCOq7/oCmBAOSwuohJlX/0pAWV/58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224400817509.4070526436511; Mon, 24 Jun 2024 03:20:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmf-0006oK-VK; Mon, 24 Jun 2024 06:18:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgme-0006mc-4E for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:48 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmY-0007gi-Mr for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:47 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a6fe61793e2so92326166b.0 for ; Mon, 24 Jun 2024 03:18:42 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d303da378sm4442631a12.18.2024.06.24.03.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:38 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CBC6C5FA1B; Mon, 24 Jun 2024 11:18:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224321; x=1719829121; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DnPYMS9aYu3Dj6IJQtGryC0W7EDGLSoROmhQZYsJ9o8=; b=SkgGU456E/eRQZtALQKNApf6IQXAJEzetyKxLSdL0OxPh9ITqvCih2DW+mCjwLOPRh tRsFof4yWrj214CYktrFMHrE+eBxqpa/CF6yqecSvYsKi7U+yWbNCvN810pkZ/IcgvRh osshWM7tVa8jxn1IWZSNouZTMJJH5acRoeIUKCGcvDyO9K3rRVWu7/m8SMO5kPSaXcSf /+59GeuhAacrZKyYdyGnM+g7nFJfsP87NEbk3Yl9UpsTp9S+kJRg4LqQ/71qMskB9tS4 zeddr9vM2P2Y8dKB4vd9LUFT/FTHaXpo1tPY5UD8dx7xNegJwSLPdhcRTHqy0/MvYhih oKSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224321; x=1719829121; 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=DnPYMS9aYu3Dj6IJQtGryC0W7EDGLSoROmhQZYsJ9o8=; b=HB9UPveOPwVyvhSL9ricmCRow5jqQBCXuqmVOEKv/J8FB+m/SVe4LJzfmA31JS7V/z TFDp0nM0jihcxZwQXctwq0VD9QubHz1U754Q+Vo+mVxwm02fN6IC2353UDV5RJP551wr oQ6VLbSVz7RCAo7l+MUotmMQGrJMVet+zqn7EiBp+CY9N6vPJ65vVXgxxlmWaG+f+Cc0 qg1OjHFKFDi+lNt/zMeYcG3apKI7zWsRPM7yMSIqFToyzYlInL+IgH0N/EStvXQG6clr foHqmm2iTpHbBYOqmOUy4i6NymDlbiLQw6XIUmhEVUpT3+fSzA2HFPU82UP8eEjNvweE 2NCw== X-Gm-Message-State: AOJu0YyjRtNIqcxIawOrEuOnHy1k5eGqYYJ2VODGajrUPBDwJUMGjro5 6947F6B+f7SHKmm4F42HBfnDMkXFEFdbTJbWnllwrj/ekopJFfyhWRduEaYSW0o= X-Google-Smtp-Source: AGHT+IGwR4NEtHCek9W3waMcRLouJdItHMJoas8iVZ3gRebQxMeepupzKLm8cZoLyvO41bsz0ny7lQ== X-Received: by 2002:a50:ab5b:0:b0:57d:2659:9143 with SMTP id 4fb4d7f45d1cf-57d4bde078cmr2805979a12.37.1719224321011; Mon, 24 Jun 2024 03:18:41 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Pierrick Bouvier , Laurent Vivier , Paolo Bonzini Subject: [PULL 05/12] qtest: use cpu interface in qtest_clock_warp Date: Mon, 24 Jun 2024 11:18:29 +0100 Message-Id: <20240624101836.193761-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224402681100005 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=C3=A9e Acked-by: Thomas Huth Signed-off-by: Pierrick Bouvier Message-Id: <20240530220610.1245424-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240620152220.2192768-6-alex.bennee@linaro.org> 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 *, c= onst char *), void qtest_server_inproc_recv(void *opaque, const char *buf); =20 int64_t qtest_get_virtual_clock(void); +void qtest_set_virtual_clock(int64_t count); #endif =20 #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, v= oid *data) =20 ops->create_vcpu_thread =3D dummy_start_vcpu_thread; ops->get_virtual_clock =3D qtest_get_virtual_clock; + ops->set_virtual_clock =3D qtest_set_virtual_clock; }; =20 static const TypeInfo qtest_accel_ops_type =3D { 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); } =20 -static void qtest_set_virtual_clock(int64_t count) +void qtest_set_virtual_clock(int64_t count) { qatomic_set_i64(&qtest_clock_counter, count); } =20 static void qtest_clock_warp(int64_t dest) { - int64_t clock =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + int64_t clock =3D cpus_get_virtual_clock(); AioContext *aio_context; assert(qtest_enabled()); aio_context =3D qemu_get_aio_context(); @@ -348,7 +348,7 @@ static void qtest_clock_warp(int64_t dest) QEMU_TIMER_ATTR_ALL); int64_t warp =3D qemu_soonest_timeout(dest - clock, deadline); =20 - qtest_set_virtual_clock(qtest_get_virtual_clock() + warp); + cpus_set_virtual_clock(cpus_get_virtual_clock() + warp); =20 qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL); timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]); --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224440; cv=none; d=zohomail.com; s=zohoarc; b=IJXj+vnZ47sib2ZtDnnJVlO4xtuyq1vKcOTHTo4KioZkOEBthffRzN1DG/zIFMlYp750sSad94yVu7BPPvxoR3driw6mYYNVtQH6qo7ZdM7CpdUxcSbsgb3lPJTpEvLJwaffLMtlJI9Zp9nGGNMgsM01BlbrIlL/WfqONilIXsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224440; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZgJtc3lx/g2nwJr+x/MfCvRRoPneDciPWhATdKfcPaw=; b=eoGh+49ZxOTMA3/QQbDky4ybFxPVE15Q8DC4wkYw6oe3hZ6NVNDFNONdc7gtsActOS/0KyLOrHSbdauwz5ENPx2SDJoD3rLcIeQXwU5eVEupkwD8ogahbd+FsGbWAAUjivtPM3l1tXsbX4cHCQ2iQHOWwcaP2iUg4C3grT7KHlc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224440808290.08615191759975; Mon, 24 Jun 2024 03:20:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmj-0006pq-7r; Mon, 24 Jun 2024 06:18:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmf-0006nU-Bk for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:49 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgma-0007gn-9X for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:49 -0400 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ec50a5e230so26750021fa.0 for ; Mon, 24 Jun 2024 03:18:42 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d3042d8b1sm4542750a12.45.2024.06.24.03.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:38 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E3F485FA28; Mon, 24 Jun 2024 11:18:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224321; x=1719829121; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZgJtc3lx/g2nwJr+x/MfCvRRoPneDciPWhATdKfcPaw=; b=hbGu1h3w7vCxvSdAXv28enYgsBs5s1JP09QVqCYbcZhNoxeui6JDl42CWbIF34q5/A XsLK0puK1qbT52QcV+Ope9bXb3wWBQB9E5Vzn5QzukF6zO4NLRj/ffgS+beQCMTGwCCB zldGtRsESLO98t32s+g28okLvjFRSkQYPzkp7iTMje7WOzZ4Ec8h/vpY1YrraIDEuGiH 2VyBEII4vOe6robLQLwQOGXxc9C2VXTsvc8panlr7tgXv4pIq1fwHXfujRYKm7SBg826 gpAe0VTHzgUdPETDbby4BYF3sZ0qcyS5rhEPZmioWUz9bOW9WPSjA+SgHF2oi0DTVkRr ZTWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224321; x=1719829121; 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=ZgJtc3lx/g2nwJr+x/MfCvRRoPneDciPWhATdKfcPaw=; b=LWfKiwVb2grFbrLOtYYTFGbWz2g0Txm/Bc3vwueF9SjYSB9OltGos7TwZGhSvIiWEX dtQz7UNIlodPQwxDfROziZOR5p7/IbpkhnIDeVJi5lBAUrhP+iiID7ZyiQ2oTG1Zj/CV R0/X5lFOK/3J1h7Pg/csOu7kSsnBOFZml78LmbU5ekZrueoStbXu/8g3/kiylb8Ij1ta JQQ+/XIQTJyAcyAJEEUck7POhg/2WxX7aB7HataPaz+8M5OnT0CM+s1UKcaU2FSS0SkE CjqkJFLegvUKjorm15qRVq4iocy1LdW5DZeKLXu5HdE+rPtUMRnOHrtgAnc8fqJz0E4Y lRjQ== X-Gm-Message-State: AOJu0Yx2HLT0VGfWsxCpQPie1W6/aVh+vOnkq0rC/Tww1ibwTcJDrGyY 4mGcx2VAVdLdAk4GoOeCWlvb1DkZse7DpKcZ+riAbkflYZs75IiA6XhAyclERg8= X-Google-Smtp-Source: AGHT+IHybceIGVKtpYJjyJ9oz5M7WZSet3tCE54JANEzeZb/pIt33N/iEI3HyzYK69dPSofw5r8rUw== X-Received: by 2002:a2e:b0f5:0:b0:2ec:4086:ea6d with SMTP id 38308e7fff4ca-2ec5b2695d9mr26484241fa.4.1719224321326; Mon, 24 Jun 2024 03:18:41 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 06/12] sysemu: generalise qtest_warp_clock as qemu_clock_advance_virtual_time Date: Mon, 24 Jun 2024 11:18:30 +0100 Message-Id: <20240624101836.193761-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x232.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224442968100003 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=C3=A9e Message-Id: <20240620152220.2192768-7-alex.bennee@linaro.org> 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); =20 +/** + * 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); =20 /* * 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); } =20 -static void qtest_clock_warp(int64_t dest) -{ - int64_t clock =3D cpus_get_virtual_clock(); - AioContext *aio_context; - assert(qtest_enabled()); - aio_context =3D qemu_get_aio_context(); - while (clock < dest) { - int64_t deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, - QEMU_TIMER_ATTR_ALL); - int64_t warp =3D 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 =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - } - qemu_clock_notify(QEMU_CLOCK_VIRTUAL); -} - static bool (*process_command_cb)(CharBackend *chr, gchar **words); =20 void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words)) @@ -751,7 +731,8 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) ns =3D 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, gch= ar **words) g_assert(words[1]); ret =3D qemu_strtoi64(words[1], NULL, 0, &ns); g_assert(ret =3D=3D 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) } } =20 +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) =20 return progress; } + +int64_t qemu_clock_advance_virtual_time(int64_t dest) +{ + int64_t clock =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + AioContext *aio_context; + aio_context =3D qemu_get_aio_context(); + while (clock < dest) { + int64_t deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); + int64_t warp =3D 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 =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + } + qemu_clock_notify(QEMU_CLOCK_VIRTUAL); + + return clock; +} --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224357; cv=none; d=zohomail.com; s=zohoarc; b=jufa2+Qhn3Zzl8Ija91c0r2qgveJTbI3vEtxeNvPFq1m+9LjMHTBA6Mv4B7pr46eg+sa0P9tNFqx4HCGq2BHlbtsh/7oR+Yt0HDF+A4mUhItUw8ihT8RMe6tEtKsuk/Zls1G1IX9i7aXm8GnECEQI28q42nYLA/7eYYjEg6gGKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224357; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ob6CSHHY9QNLxHtzyLGqMdnNXrmVZ+yffKASjxK2raE=; b=K/2GEo7KYkDP5NmQ6a+1ue7Esl3wH6RTsl3b31JhImDkXRsRYqUI+ME1VzL4HxzN1BQ71UBry1WyC9+EIcYekI2kt+UyyLlTA0L7tcdlMD+k4OQJblJtETA7MMeC/1HLMp0Rm1cU2KkBzW45mF4LXwrDczjm4n7mnk+2stFPt5E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224357945952.6017306914792; Mon, 24 Jun 2024 03:19:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmg-0006oP-Tx; Mon, 24 Jun 2024 06:18:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmf-0006nV-Dx for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:49 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgma-0007h1-Q2 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:49 -0400 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-52cd80e55efso4511238e87.0 for ; Mon, 24 Jun 2024 03:18:44 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fe779bc80sm271867366b.174.2024.06.24.03.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:40 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 097D85FA29; Mon, 24 Jun 2024 11:18:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224323; x=1719829123; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ob6CSHHY9QNLxHtzyLGqMdnNXrmVZ+yffKASjxK2raE=; b=Rw2d9G7IRRr8L/W4poDLO1yig4CE+Q11uujTiznMRWF3WiMsdCVGF9+Ru+dEnzHHpx Wbb4Xm2FvzCfXgpsHWe+gc4dXKHnnmTKnE8sqs3zzRMuVxyl7dttWLlqQMJL/GwCsQ82 b6N4cVmU1hDQKt8J98Fus2Eu/DZbSuBeblvcqD6R3E2itMc4qL8lukOGEbex4n5/SOK4 8GX6gJo8wJ+hfJej3idLBisfxCB9zao2coWpdomI3f2UVKrbsdaX8QZuylU5JDBogGYa pgLtJw0mHxL5YBe1SbZxUiwXylaAiG0a/US6Jxf/x2JW6cxWSzfRcTrlKliNeBz0SlF4 UWmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224323; x=1719829123; 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=ob6CSHHY9QNLxHtzyLGqMdnNXrmVZ+yffKASjxK2raE=; b=OHACda3E58oPF4zmfmK3UDuKThXOSm0Lc1T8WEfqeveZlc1CqbXvCiJGLwPcOf6VSZ rQbY0J3PpDWQSG3c0yLtHLIXWbf29FZGzj3m48HhsgFQv+KJ3YN5kIeWoPjuja3L/vXr eCKQxhR4X9yBmWvSFEvHb/U5fkJRKiplGWQacxCec2etcKllBsfQZlzu7oXmVT59/tdc 8rtQOfmcTaj3dOggfknbpos5Mo26q5JR6XNaPr2iA9CVeBgGwudV/JRvpD7pPy4tIBRG Wx9jrM+FHyuRFOyp8V0ma0sJv9i/MDUInyuajSINt2R2ieTyHp1K8KFo1UEpR3ql1ctc ZGqA== X-Gm-Message-State: AOJu0Yy4IwIAXMrHwmA7hJDAsMxAaGDf0Jfm/vM+FbuI65IC8CpH0niX 9rDi3qtOK+r1fYjt03D8mNIzEFZ0ylr2tJWhQJUD7EQEZxHGwiWqqnGADUbnb4IsfBZcbhYCKj3 X X-Google-Smtp-Source: AGHT+IHYQ9qCLgr2TBPN3m5DwnDKZMFmvjBYLPIZnkcaU9/Fb6Yij+5WgLmObvaoVxK7LvLabgty8g== X-Received: by 2002:a05:6512:539:b0:52c:ab21:7c05 with SMTP id 2adb3069b0e04-52ce185d03emr2736074e87.67.1719224322852; Mon, 24 Jun 2024 03:18:42 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 07/12] qtest: move qtest_{get, set}_virtual_clock to accel/qtest/qtest.c Date: Mon, 24 Jun 2024 11:18:31 +0100 Message-Id: <20240624101836.193761-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224358445100004 From: Pierrick Bouvier Signed-off-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240530220610.1245424-5-pierrick.bouvier@linaro.org> Message-Id: <20240620152220.2192768-8-alex.bennee@linaro.org> 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 ch= ar *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 =20 #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" =20 +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) } } =20 -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); =20 void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words)) --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224416; cv=none; d=zohomail.com; s=zohoarc; b=ka7Z4t5ugcdPT0OELtY/hqlkgO/6CeWF30BeGcnR06QyPp+rimm7WG+aTrGAvbg8yFkCdisVah3Sy3Y/3N9rppugAzsXn5hU3ukH/r+qgCheaenNW4TpinUOCJaWZaWoq+HNtFGfAioEf8pV0a4f3LFsfFF69uYaoCtPh1xLXQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224416; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=14X8Z5in8w/+qtjupg5LlJdeob+7lldC0gA0O0WPJcM=; b=kKSbiPK5ZmBqlqzhv+qccBCs77NReFCI33LdNM9XQeXOvSzmW7u0a34vzjXxv8QFTRVClDc9MVgp0IPA4OA9VoD8+d9HbecQ1DvxGw2kL1I+hurlABpP7xTmS1K2losXGtfx65IEKDXQMfVsmMgHagvuhZAzhI3xHLlTGeVNEFs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224416700950.600939037951; Mon, 24 Jun 2024 03:20:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmg-0006oS-VV; Mon, 24 Jun 2024 06:18:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmf-0006ny-Ms for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:49 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgma-0007h7-T0 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:49 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a72517e6225so105985666b.0 for ; Mon, 24 Jun 2024 03:18:44 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fe81449a4sm263361266b.72.2024.06.24.03.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:40 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2361A5FA2A; Mon, 24 Jun 2024 11:18:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224323; x=1719829123; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=14X8Z5in8w/+qtjupg5LlJdeob+7lldC0gA0O0WPJcM=; b=YflQOG2zDMvd5SmwDM311boRCpgJM33X1B8dYsLk0VIQEVxa2hDcPhezXG0Prde634 g8TxQwpIZURzAQrDR7vgYLKtxMMcbKWJ80DXB7Wgs1cAUox3WMf2Keo4FJwr5Tctt2Jn dF5K/M9tcASadcjZcKPdZ9Xp61R+WTQbbPqWo4bRLeTaJ4+ClRQASzoOkeFx9VL7a6jk 2PG6/6MS+BZggq+MP5HOzefccvybXI3PmbMI/cupO7eVOsOWln4oz5VdM5+sfwgq2yqw 8n/fFbFQWfTxhtwmSJXC2O91i/2wzb+OWL7Gv+b6tWTiyH3zB383G5BGqq53HzOmaAuy fyww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224323; x=1719829123; 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=14X8Z5in8w/+qtjupg5LlJdeob+7lldC0gA0O0WPJcM=; b=q/FDvF/tmsoFKpO2YU1Xs8FVUs7Dda8MysVhZ5L2Q1r9LEq3scmO4xiU7/oiF/yMSn RnZP4WUuKF4RhUJaH8kOe7OYt27AFyhdjxklvDFBgs62HBThKEguol7olnm3YMXqoH+x M3kIKU0xpqi0J3LXYE0qf9kDXuMft10pgPEnQg7Xx8l+gjSCd7/j1Sh6kFxW2S1U7BK/ ytsBXoHZ2wiCVyS8qglUzhME6aGxSqQFRql5RcvDKA/oOnLmWSPn8jwp0Rqt9ayypyNU 2aFfd/GMsYNakN5crFjkRV9wgk/vtlSzCLMvyZUKPRFp0PnUah7ElD4nl5AVEZiTAmx8 Vxgw== X-Gm-Message-State: AOJu0Yx8rT+ymHBcMc5KoTWxq4pLk31odS7ikalCdeyq6memT/lK7Sxy gcWhqp+j98EqtBWSvsin1360Qq820uY+8IjGWFOWuCoUFeidDZ+352zMxwGzj3U= X-Google-Smtp-Source: AGHT+IGVO5Y/HcdTHQZaaQAt1MAV4iUiwO7x4lDbbA68PQqVAMTVJfKADt52/9q2HTfGNGvPN6IU9g== X-Received: by 2002:a17:907:a806:b0:a6f:ba92:53ca with SMTP id a640c23a62f3a-a715f390c1bmr357848966b.21.1719224323238; Mon, 24 Jun 2024 03:18:43 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 08/12] plugins: add time control API Date: Mon, 24 Jun 2024 11:18:32 +0100 Message-Id: <20240624101836.193761-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224418681100003 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] Message-Id: <20240530220610.1245424-6-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240620152220.2192768-9-alex.bennee@linaro.org> 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); =20 +/** + * 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_in= dex, 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 =3D true; + return &has_control; + } + return NULL; +} + +#ifdef CONFIG_SOFTMMU +static void advance_virtual_time__async(CPUState *cpu, run_on_cpu_data dat= a) +{ + int64_t new_time =3D 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 =3D=3D &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; }; --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224425; cv=none; d=zohomail.com; s=zohoarc; b=aycDHcRr12fumMjc6NnaVtythfAlPZ2MeCNSS+k7umgSvSALv7ODfthwP6gAxw41B0juRX47ZSjJMEqmAIEQ40KVxiL4Kj+gkCBvmGGWGO8t4VvCWMBrlvctWZEjf6j05IPGw5XNGwn8TfYiAtwikkjkHuzNg5DEmixahZPRSQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224425; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vOqcccRFtqwnOnQskJAEv5Hp+aQLehrHF9Mo27OLiHs=; b=TTm2zM7OhVJo2qObTXgVPF1wTy/eHWA2dIO6ZC/MwUKZa3Z5++xxTFWkNcm9jTQlvIrSERi7abHGe8GN5cEVf2rC2MD5Eo462r9mBmDyEKKqBw3VG/Na6m4CVlPo+TlcJm7O25kKBbXXfCWzt43Mr9qguw3WXLRZ24KRZNeiLfo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224425168995.090542401107; Mon, 24 Jun 2024 03:20:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgml-0006rA-27; Mon, 24 Jun 2024 06:18:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmh-0006oi-4L for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:51 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmd-0007hT-Tp for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:50 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a725d756d41so58075366b.0 for ; Mon, 24 Jun 2024 03:18:47 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72479f360bsm184669166b.173.2024.06.24.03.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:41 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 385B75FA2B; Mon, 24 Jun 2024 11:18:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224325; x=1719829125; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vOqcccRFtqwnOnQskJAEv5Hp+aQLehrHF9Mo27OLiHs=; b=eRNL3Z/2b7At9tCV5e0URQpy82BZ82qmdObN4IXf/wQhyF5EK4KCh0ukzwXA9I4FDo T+8yU04JkxqZGwTpbMEXTM+NBcrKZnK3P5gzp6qn7mXuitQr01Eyq7Eubika60bWFd4i Exh8i7PkdT1PwOw9i3gadwMUAsfQ8AkrPy3vsnTJVyD2aK4GS+okv4QMj88vxiWmHz6V aGyJKDsjkaFpkemCXhQcd/jM/wO7opK+ws6ra9D5NQr+0kaOuT42VKXTUGtZ/Bp5SdDU Ww8RTc9+kg2nCVkSFF0JxhzoB2+K3OVBojIYyJPxcsQR1NFspL47Em4glRuWYsQ3hs4V tELQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224325; x=1719829125; 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=vOqcccRFtqwnOnQskJAEv5Hp+aQLehrHF9Mo27OLiHs=; b=D8T/8J1fJwbLdnadLx6bcXgcD2TQxcWSfdOV9HmhrzAaVkJVt0HoLGjeSSMMEv/k3I +SJxPlf41rZ09WKPRAZIc/xxJu45EmtRPH8a2b7AuEUjXYGeKq7FEsUG9AM4qJ6uPAKG 6RqulYKoE5KgRN8OWmJtkOkVerTv69sq5kfasUcFNfuIZPkOky/KtZ3jE9j2pbMAmIx1 U9esAlpOrJZ4GCsCMd/+t6TDSfmK/YPagQic2A62ptLEhooxVhfzSCZMS26F/2UqGM7m kYJaWYPWFKSfZCxuJjwvRHPwxRsy4twjcHMpVZ7mxhZwSiPeYnNc5CSsZm4q5o305ZY2 BaLw== X-Gm-Message-State: AOJu0YxewoX9iCzxAbszcckxR9stqF+nO5taSKWXHnckYcli+Y50qj1e wat0voq7ad26mek/KMH4ydX7SwvHI/0c8WP4WzvW1M6l6lcI3XRZ7cDVEftCXyKDYFaSzEBdpL4 7 X-Google-Smtp-Source: AGHT+IGVV8EfcoWO/NT56w8v6aH5qpXhL92REndMYGyZvQDCrOk0fo/iVRh7SCRq4Lr1Ip6W9oKGgg== X-Received: by 2002:a17:906:f34e:b0:a6f:b91c:5197 with SMTP id a640c23a62f3a-a700e73164bmr337627366b.36.1719224325233; Mon, 24 Jun 2024 03:18:45 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Dr . David Alan Gilbert" , Thomas Huth , Richard Henderson , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Subject: [PULL 09/12] plugins: add migration blocker Date: Mon, 24 Jun 2024 11:18:33 +0100 Message-Id: <20240624101836.193761-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224426703100003 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. Suggested-by: Dr. David Alan Gilbert Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240620152220.2192768-10-alex.bennee@linaro.org> diff --git a/plugins/api.c b/plugins/api.c index 4431a0ea7e..2ff13d09de 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,19 @@ uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry) * Time control */ static bool has_control; +#ifdef CONFIG_SOFTMMU +static Error *migration_blocker; +#endif =20 const void *qemu_plugin_request_time_control(void) { if (!has_control) { has_control =3D 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; --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224356; cv=none; d=zohomail.com; s=zohoarc; b=dNr1N/vimyR5QNEcEBSPZuH8yrxXK6XlC+cKrniNtpy2hSgHZa9/e+aiptHaBd9EfP1HhRwozB2Ie2GlJJ8vXhHJJhTDuV1I3xAhpeLep8/4T2WxmcsIsTCodggI9KkJ4+XIJWfQAKI+NOlnVJPM2+3Q+EhB1do0Fx3+tq32FlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224356; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qjVpqIsr2KpoX8UmLmTVI1cUhWtUJxDYaiW1+kp25gQ=; b=lJJCGLjQw/HcXeyZ01SfEYVDpeFXIxnYB4UROgRA2tYZ1rxXb+L7Mrrv1uPu4rczGxZEOsBfcuwWlC/KwuZkdcbZn96RPTuSSF6t/BDCs7p1NplA3f4kyG5vPQ6YTXA5YE//NGHb26oNv/pf4b7ANegUbw7B8XZ2m7Sayedne3A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224356932513.3183018787057; Mon, 24 Jun 2024 03:19:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmk-0006r6-Vd; Mon, 24 Jun 2024 06:18:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmj-0006qJ-LF for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:53 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmd-0007hh-Cr for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:53 -0400 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-57cf8880f95so4674460a12.3 for ; Mon, 24 Jun 2024 03:18:46 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d303da25fsm4539897a12.5.2024.06.24.03.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:41 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5096D5FA2C; Mon, 24 Jun 2024 11:18:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224326; x=1719829126; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qjVpqIsr2KpoX8UmLmTVI1cUhWtUJxDYaiW1+kp25gQ=; b=vh3ccqDMtFdQZi8XkjR/ckM6yFK0UavkPktIyo0nZnb5KuB/Brw4OLUo0T5OVDvhax kshdAG7IyIDTycMpIToYQnQcdaK7UXIDQo4UZ57Sth0HGsNzhr7ZD3Fvu3t5+dvGPUwk 1mlkhTQ7UMtW6ItEArCDhFAyQ5am4geG+kK/FvkMGM9peJQU1ECcFYTY6ZSfnLeLecZx ffuFfA793nufOv5p3U15ukbJ6qq1u7ONNcxc+Aph2dBnxWP5bxh7m7RrUPTRAM/UiHgH u6n2QM0G7sBcOAnkmuYg7PWn5/jBvR65BoKT14uJvYQLnlyqunonnJoXeAisj68pQXjI mT9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224326; x=1719829126; 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=qjVpqIsr2KpoX8UmLmTVI1cUhWtUJxDYaiW1+kp25gQ=; b=ofHHY2D8NibO0l/sV7HliFaQkdEGJuhxbXMxOJS41fMJIXBZKeGYYpho98DLUR4g+f u0bEzw2RRYkNE4PtU8BDOrNIl421I7krh/ZA4MzwZitYoyNcY4ilvlVBh8qZb5jsdhyD 2ee7/RvuelIMZ5WpkBbI9Zmxrjc0W6zuZop0Uv924qXyDrqYQWT7DBori+nY+m7w5t9W liqENgbMcF5WWvzLhCF57GkXWlI8+8/LMXFt59rWzTaHyTCnXVQP9OWTOlTtxX0ZeM3T iDSeU+1i009mYJxYM9U5P5/vlo6FbaXd4UPjD2aITR3schsl87W4WpTiU1RKB7l3o4pm NDpA== X-Gm-Message-State: AOJu0Yy1VyiMAQrTlyjRipUe+iP3uNhrLrS54t3FTiuL4fUFgGabk9jY aYHy4YQxyTKd2tNJdkvwws1UMb4Kgaem9FeMab8WfpCD5/UfAuL+2scpPrG8Qdk= X-Google-Smtp-Source: AGHT+IFb/dvIQ5GlRzE+g8IdJCLffOe3aUE7j3u/i2+9N1+3aiVUaNWwiQm5//ekNxmY29/wy4qDTA== X-Received: by 2002:a50:99d4:0:b0:57d:34e2:f554 with SMTP id 4fb4d7f45d1cf-57d4bd61381mr3563554a12.11.1719224325574; Mon, 24 Jun 2024 03:18:45 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 10/12] contrib/plugins: add Instructions Per Second (IPS) example for cost modeling Date: Mon, 24 Jun 2024 11:18:34 +0100 Message-Id: <20240624101836.193761-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224358475100007 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=3D$(./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=3D= $(($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 "c= onsole=3DttyS0" -plugin ./build/contrib/plugins/libips.so,ips=3D$((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 Message-Id: <20240530220610.1245424-7-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240620152220.2192768-11-alex.bennee@linaro.org> 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 =3D 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 =3D 1000 * 1000 * 1000; /* ips per cor= e, 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 =3D 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 =3D (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 =3D now_ns() - vcpu->last_quantum_time; + uint64_t max_insn =3D num_insn_during(elapsed_ns); + + if (vcpu->quantum_insn >=3D max_insn) { + /* this vcpu ran faster than expected, so it has to sleep */ + uint64_t insn_advance =3D vcpu->quantum_insn - max_insn; + uint64_t time_advance_ns =3D time_for_insn(insn_advance); + int64_t sleep_us =3D time_advance_ns / 1000; + g_usleep(sleep_us); + } + + vcpu->total_insn +=3D vcpu->quantum_insn; + vcpu->quantum_insn =3D 0; + vcpu->last_quantum_time =3D now_ns(); + + /* based on total number of instructions, what should be the new time?= */ + int64_t new_virtual_time =3D 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 =3D new_virtual_time; + } + + g_mutex_unlock(&global_state_lock); +} + +static void vcpu_init(qemu_plugin_id_t id, unsigned int cpu_index) +{ + vCPUTime *vcpu =3D qemu_plugin_scoreboard_find(vcpus, cpu_index); + vcpu->total_insn =3D 0; + vcpu->quantum_insn =3D 0; + vcpu->last_quantum_time =3D now_ns(); +} + +static void vcpu_exit(qemu_plugin_id_t id, unsigned int cpu_index) +{ + vCPUTime *vcpu =3D qemu_plugin_scoreboard_find(vcpus, cpu_index); + update_system_time(vcpu); +} + +static void every_quantum_insn(unsigned int cpu_index, void *udata) +{ + vCPUTime *vcpu =3D qemu_plugin_scoreboard_find(vcpus, cpu_index); + g_assert(vcpu->quantum_insn >=3D 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 =3D qemu_plugin_tb_n_insns(tb); + qemu_plugin_u64 quantum_insn =3D + 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 ar= gc, + char **argv) +{ + for (int i =3D 0; i < argc; i++) { + char *opt =3D argv[i]; + g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); + if (g_strcmp0(tokens[0], "ips") =3D=3D 0) { + max_insn_per_second =3D 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 =3D qemu_plugin_scoreboard_new(sizeof(vCPUTime)); + max_insn_per_quantum =3D max_insn_per_second / NUM_TIME_UPDATE_PER_SEC; + + time_handle =3D 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 +=3D hwprofile NAMES +=3D cache NAMES +=3D drcov +NAMES +=3D ips =20 ifeq ($(CONFIG_WIN32),y) SO_SUFFIX :=3D .dll --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224451; cv=none; d=zohomail.com; s=zohoarc; b=nu0l4bM7b1guoaAWlgQyjtnSnp0zA6GwGrNq2sZJFelxNPgQ5lfR7qjNrsxb98MEcJRK0Y+n9Bu0PEwMydJDEzgulqOTJ4CC+b2wXtVKyVtjsFvYuQaqa5K8drwJnrHJdykbgc12O1CY2sodwrSzpnDeaq2s7X8Qxzso++sgOAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224451; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GAfr/ztELiK85W31P9IhL6FxEJ0DWBMMSKgHmbUooPs=; b=TBzw16MYfmRpo57Y5pMJUxa180OoJLm3BKk02wMEg5mNHE+l+QuZHuwnANbIc2m4o2g1ov+5F/etA/zrejo8gigIyZysn+yUy+3HuRdiQecSQXuif+oCmI25Uv79UvfdHBTJ8td79Wxprsx6uiw04jkmDI9JOglWIXMbEOhBHqk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224451198691.4940577283851; Mon, 24 Jun 2024 03:20:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmj-0006ps-Af; Mon, 24 Jun 2024 06:18:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmg-0006oT-U2 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:50 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgmb-0007hE-4i for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:50 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-57d15b85a34so4241182a12.3 for ; Mon, 24 Jun 2024 03:18:44 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d3053510asm4546151a12.74.2024.06.24.03.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:41 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 66EB55FA2D; Mon, 24 Jun 2024 11:18:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224324; x=1719829124; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GAfr/ztELiK85W31P9IhL6FxEJ0DWBMMSKgHmbUooPs=; b=KOfxYaAFT1UKAmg4PtNEYKJLeVpQId1II0wF4//OI2nQz9HG8eWEGR7ditNAUJ4WM0 DRhGp5X0AHgbTeOxND8vJsyTCytj8S/9EtxULxP2+dCs+EI8RjeOxMxek8w0N/od+wHB XCd+sNWIwK4STat6GugT7z6Pj+B9wzFqKR9v+Eclpazj2BJ/cxDYgER7vci/hcl3Kg3T ZsbpbFKdXH7hIBbkPo/kF2U1Su4l2lBuQ9AU4b+o88kUAjz6LcEk+D8Zn5YNTWWokuqT sC4ovrGDbUCiLtKDYq+28LZtDXKib92HTf9sgLOWYyv7CwO8+vt6Z2TeyQB51Xk5HnSX sb/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224324; x=1719829124; 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=GAfr/ztELiK85W31P9IhL6FxEJ0DWBMMSKgHmbUooPs=; b=qIGOUKb3/ugrb+ynJDU05ikpCnqn9jCV8ymSDUor7Heru5IY42p81OGVhUfpMN6/8A oUU6+ORx3ZwKvGuFDweg+qWRXdpkDspH5LLbirUprjIeUMV+qB7DSbTP2as/U2JEF7Yl pMTPJFwdyw+IyK6wNFtHEYvH9qehve3SinGWka82noDQWegknUiBs6zuNfjba0KOyIgN XPgE+AIFu+lEhDLgwv8Qxv9JaI8b0vUDvP99mSteVcCAGR4rRmgspFjjNqUXxnlLG74h T4+9eXOxNR9kGtxXIh8hjZ87JTREKQKPArwU0nAG3kONClVWQW4dDP7lu4/Gxga+GBqg hXoQ== X-Gm-Message-State: AOJu0Yyk4yTMe+ZZCg/J+M6p/eOIPa1GryE0SabXooBbZ15k8vSz5CYw OzeJvUN1VPv1ypvlyoMaJw+z7RKUiMf4Mc2A8FLJO+6eY1dIaBfjHf3C1eyJo6o= X-Google-Smtp-Source: AGHT+IHywj9LUyqeOsx78e4BQlmYW5gn9KolicYOr/jxUBNZHGqIPULzIO3kQe4lYDSbzE50McHCwA== X-Received: by 2002:a50:c31e:0:b0:57d:1756:6bb1 with SMTP id 4fb4d7f45d1cf-57d457f622amr3054576a12.31.1719224323540; Mon, 24 Jun 2024 03:18:43 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 11/12] plugins: fix inject_mem_cb rw masking Date: Mon, 24 Jun 2024 11:18:35 +0100 Message-Id: <20240624101836.193761-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224452828100003 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=C3=A9e Message-Id: <20240620152220.2192768-12-alex.bennee@linaro.org> 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 va= ddr, =20 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 va= ddr, 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; --=20 2.39.2 From nobody Sun Nov 24 22:31:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719224392; cv=none; d=zohomail.com; s=zohoarc; b=HVgSWWF9pzLBqT5WcO5WpuHTIosfiaNhVm9ERRBLyUzlyTtVurVFZwQxUUwkAa1nm2A04SasMmWqxTyPmSqrtstMruq0IDPA7sgfpW1SQ1OCrkPxbfMVALZ+N7k73u+Oo0XU9Ah3wBxb/MVUci6JvEnt/X5i9kGcaljnpjxeNvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719224392; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=csz4agAZp6lldiHiVd/L/1KnBx9/0btPjs2vbkrKDHw=; b=JrVPpNFZgas583BcpLOEWX9q4hwKjNEsEc7FrkA5c9zcxgFA12FqWUGZjpI3Es8dTrYVvkL3aniYL85RjeNGcXBvM+HucO4G5NHAd0i1rL3NWKsQo5hIU9vApoDyXJp/M30/OXX7WKwP9Wcab15caQqvYG5kY8uvH4Kdpo3ggiw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719224392894266.29249182288675; Mon, 24 Jun 2024 03:19:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLgmi-0006pp-NT; Mon, 24 Jun 2024 06:18:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLgmh-0006ov-JX for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:51 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLgme-0007hs-Mt for qemu-devel@nongnu.org; Mon, 24 Jun 2024 06:18:51 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a724b4f1218so133438366b.2 for ; Mon, 24 Jun 2024 03:18:48 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf428c24sm400211666b.17.2024.06.24.03.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 03:18:41 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7ED865FA2E; Mon, 24 Jun 2024 11:18:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719224326; x=1719829126; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=csz4agAZp6lldiHiVd/L/1KnBx9/0btPjs2vbkrKDHw=; b=ehrNIR6s2ugtuKX1oJKaSxMT6df7vcm/OIwEV1MmbzUDFepB1Fk3vhfNeF9p/41yt7 GjKWgxjYnyKB8xrM0rC3wY8kaqN4HeYXw1R7rEIdBU7FykjAfp10TZwH1YtxEnPQPdj3 z1vJP5RGAAIrUJE8fQz+kIRtv1KK9LkFa2Uue7pv4Jbq/UsFskd8dt1jtznnfXbGOTkS A+fE8R9nrpC6Drf/lsI83KUf6ytZf+r8a3MEQk3VyQbRcCEOfGXJiGvvkE4QrUlYsnCD P+K9Oh3V31bHkT5SDVv3hJ5/Rz9poM1EQ3up8EDE9+66gkcjVbTHcM8ZDHgoUrIQrw4d c3/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719224326; x=1719829126; 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=csz4agAZp6lldiHiVd/L/1KnBx9/0btPjs2vbkrKDHw=; b=Io4JWUhpLC0S7fPNhq2sCklsekqjmLhiZKz7e3xxOEXDh8Km7bPkKSOOSa6g6U4/vC ZeL3Egv1SlEcYVpueXptnvdsL86ddgqH6lMqaoqKT6TZbZkWFl48nIj0rl9KlGwAuU5k rUI4EjA5y6onAIJP1tA+11fmPcK8QNne2ddz12Lm9gyiP4PebTbzFAAHufDnpJaKzfmL 2OOP6CKVkW/VJM69D8YBAmmiSG6Lrn684YZcZWq0pbk8ZYwqXEy/kUvor/KlfqPiMw3o KgXhDexZc42um8lkqJ1aJnbUB8/X0RPdq2GYt02BTbJFLm/wyE9XMdjCz6/jqsJryqkw J2+Q== X-Gm-Message-State: AOJu0YwEJGnKp5HqF2eG01sE0cGx68Yo8fOedjrnXFHtDJ30/SY7scMm FoMtCdUovZr/RpB/GCGhu+UOTwcQYG6MKFV3LTwlJxsyaCw+7S91IthQcaKS7rUHgiVq/MjH2Cw S X-Google-Smtp-Source: AGHT+IG5BSidx52uhSWpp/mh6pNM+q21O4sxjvtkcz4NhOy76Clte55RiYYAyLy5AoXyXPbRdt1JjQ== X-Received: by 2002:a17:907:8b8c:b0:a72:4b31:13aa with SMTP id a640c23a62f3a-a724b311555mr241195866b.55.1719224325881; Mon, 24 Jun 2024 03:18:45 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Max Chou , Richard Henderson , Frank Chang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini Subject: [PULL 12/12] accel/tcg: Avoid unnecessary call overhead from qemu_plugin_vcpu_mem_cb Date: Mon, 24 Jun 2024 11:18:36 +0100 Message-Id: <20240624101836.193761-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624101836.193761-1-alex.bennee@linaro.org> References: <20240624101836.193761-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719224394613100003 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=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240620152220.2192768-13-alex.bennee@linaro.org> 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, I= nt128 val, MemOpIdx oi) =20 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); + } } =20 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, =20 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); + } } =20 void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val, --=20 2.39.2