{"id":1882153,"url":"http://patchwork.ozlabs.org/api/patches/1882153/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20240103173349.398526-44-alex.bennee@linaro.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20240103173349.398526-44-alex.bennee@linaro.org>","list_archive_url":null,"date":"2024-01-03T17:33:49","name":"[v2,43/43] docs/devel: document some plugin assumptions","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"fbdb2362517f38016a6a709ffb19e23ab9683119","submitter":{"id":39532,"url":"http://patchwork.ozlabs.org/api/people/39532/?format=json","name":"Alex Bennée","email":"alex.bennee@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20240103173349.398526-44-alex.bennee@linaro.org/mbox/","series":[{"id":388742,"url":"http://patchwork.ozlabs.org/api/series/388742/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=388742","date":"2024-01-03T17:33:08","name":"testing and plugin updates for 9.0 (pre-PR)","version":2,"mbox":"http://patchwork.ozlabs.org/series/388742/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1882153/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1882153/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=M/XA8ZIV;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4T4y0z2zJnz1ydb\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  4 Jan 2024 04:50:11 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1rL5Mj-0000h8-CD; Wed, 03 Jan 2024 12:49:17 -0500","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <alex.bennee@linaro.org>)\n id 1rL5Md-0000KM-QB\n for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:49:11 -0500","from mail-wr1-x430.google.com ([2a00:1450:4864:20::430])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <alex.bennee@linaro.org>)\n id 1rL5Ma-0000IZ-6l\n for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:49:11 -0500","by mail-wr1-x430.google.com with SMTP id\n ffacd0b85a97d-3373a30af67so3036290f8f.0\n for <qemu-devel@nongnu.org>; Wed, 03 Jan 2024 09:49:07 -0800 (PST)","from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id\n b15-20020a5d4b8f000000b00336a0c083easm26789106wrt.53.2024.01.03.09.49.05\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 03 Jan 2024 09:49:05 -0800 (PST)","from draig.lan (localhost [IPv6:::1])\n by draig.lan (Postfix) with ESMTP id B41EC5F9D8;\n Wed,  3 Jan 2024 17:33:53 +0000 (GMT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1704304146; x=1704908946; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=6SqdFcQlAJfCo/zD79U6TVq3bxpUqFYpwmC4QorajEA=;\n b=M/XA8ZIVIl14/b5CEJdCIXEuiu9WWFr7yyJ7VejV+OwPyHgrqOPwxA1yHj5LZFP8U9\n vanrbIrQhs1v43XvkERSpOMFFP/aCctmfSMSnrPdyTqhhiHFbNq3vw3o4zxFUW9CN3R/\n XAuYWA8WzGjxFXoPKX4AvhkuD74AvrxSiNAxUeDIdTFErja0S2wMNCgg2IaQpibz7F04\n quB1X5cQh0j0xk1P9kuito8bXIMTMByW16s+lXoE589hixjIY2489RaDg8n+gA6zOonj\n BAA07XX+RWqoUgyLleuSO+N8bJcx7R5iG9HLe885GxoxCDfvho/k0LphcmvleZxyTx5h\n gwxg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1704304146; x=1704908946;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=6SqdFcQlAJfCo/zD79U6TVq3bxpUqFYpwmC4QorajEA=;\n b=MrvhE3XXhwbGakqMVTdfJDTIYiOA+HBXb1IOQdBQrszS6GT1POr4ZqAn+I5I33Dtac\n sC6Q/CgZ3ULGpUHLNAcGedvin1MJzryqDIsFTebaW500pb+1ABSXgMrnofLMToWSTgXF\n uawK6sv7oB/TmxrPqSgAlHbpljqItk0+VZktvPWVhPijaVZTVdEGhpuRDQh+UE/iww5p\n OW1zubaXEqhs1FkZguRdSviYYtKySc6+goiDmxEMeKhMmy0WLIsR6F5J7vIoCQovOOkH\n Vk9bgsA4CTRqHssHg/AoA8c4y5IeftH6r6eA+nAwM95wa3jBnJPsjlvj6MCEJrnh0Eas\n Fynw==","X-Gm-Message-State":"AOJu0Ywg97ACiTpCJeOHNwrqYgxkJNNEieuGBa8UA+Pc79Jke2suJxZ+\n 7N02nmz4pnltK59dzpFCrxo6hZLtKVeLQg==","X-Google-Smtp-Source":"\n AGHT+IEJ8pbxuaW2ajiIhIsjZLjKvMEndaRM5euTVk/mz6c4/+Ko8TKlGfHnO3Mdder+FMkZ6TvagA==","X-Received":"by 2002:a5d:47ac:0:b0:337:4a09:b7d8 with SMTP id\n 12-20020a5d47ac000000b003374a09b7d8mr916886wrb.211.1704304146266;\n Wed, 03 Jan 2024 09:49:06 -0800 (PST)","From":"=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>","To":"qemu-devel@nongnu.org","Cc":"qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,\n Richard Henderson <richard.henderson@linaro.org>,\n Song Gao <gaosong@loongson.cn>,\n =?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n David Hildenbrand <david@redhat.com>, Aurelien Jarno <aurelien@aurel32.net>,\n Yoshinori Sato <ysato@users.sourceforge.jp>,\n Yanan Wang <wangyanan55@huawei.com>, Bin Meng <bin.meng@windriver.com>,\n Laurent Vivier <lvivier@redhat.com>, Michael Rolnik <mrolnik@gmail.com>,\n Alexandre Iooss <erdnaxe@crans.org>, David Woodhouse <dwmw2@infradead.org>,\n Laurent Vivier <laurent@vivier.eu>, Paolo Bonzini <pbonzini@redhat.com>,\n Brian Cain <bcain@quicinc.com>,\n Daniel Henrique Barboza <danielhb413@gmail.com>,\n Beraldo Leal <bleal@redhat.com>, Paul Durrant <paul@xen.org>,\n Mahmoud Mandour <ma.mandourr@gmail.com>, Thomas Huth <thuth@redhat.com>,\n Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Cleber Rosa <crosa@redhat.com>,\n kvm@vger.kernel.org, Peter Maydell <peter.maydell@linaro.org>,\n Wainer dos Santos Moschetta <wainersm@redhat.com>, =?utf-8?q?Alex_Benn?=\n\t=?utf-8?q?=C3=A9e?= <alex.bennee@linaro.org>, qemu-arm@nongnu.org,\n Weiwei Li <liwei1518@gmail.com>,\n =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>,\n John Snow <jsnow@redhat.com>,\n Daniel Henrique Barboza <dbarboza@ventanamicro.com>,\n Nicholas Piggin <npiggin@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>,\n Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,\n Ilya Leoshkevich <iii@linux.ibm.com>,\n =?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@kaod.org>,\n \"Edgar E. Iglesias\" <edgar.iglesias@gmail.com>,\n Eduardo Habkost <eduardo@habkost.net>,\n Pierrick Bouvier <pierrick.bouvier@linaro.org>, qemu-riscv@nongnu.org,\n Alistair Francis <alistair.francis@wdc.com>","Subject":"[PATCH v2 43/43] docs/devel: document some plugin assumptions","Date":"Wed,  3 Jan 2024 17:33:49 +0000","Message-Id":"<20240103173349.398526-44-alex.bennee@linaro.org>","X-Mailer":"git-send-email 2.39.2","In-Reply-To":"<20240103173349.398526-1-alex.bennee@linaro.org>","References":"<20240103173349.398526-1-alex.bennee@linaro.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2a00:1450:4864:20::430;\n envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,\n T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"While we attempt to hide implementation details from the plugin we\nshouldn't be totally obtuse. Let the user know what they can and can't\nexpect with the various instrumentation options.\n\nSigned-off-by: Alex Bennée <alex.bennee@linaro.org>\n---\n docs/devel/tcg-plugins.rst | 49 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)","diff":"diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst\nindex 535a74684c5..9cc09d8c3da 100644\n--- a/docs/devel/tcg-plugins.rst\n+++ b/docs/devel/tcg-plugins.rst\n@@ -112,6 +112,55 @@ details are opaque to plugins. The plugin is able to query select\n details of instructions and system configuration only through the\n exported *qemu_plugin* functions.\n \n+However the following assumptions can be made:\n+\n+Translation Blocks\n+++++++++++++++++++\n+\n+All code will go through a translation phase although not all\n+translations will be necessarily be executed. You need to instrument\n+actual executions to track what is happening.\n+\n+It is quite normal to see the same address translated multiple times.\n+If you want to track the code in system emulation you should examine\n+the underlying physical address (``qemu_plugin_insn_haddr``) to take\n+into account the effects of virtual memory although if the system does\n+paging this will change too.\n+\n+Not all instructions in a block will always execute so if its\n+important to track individual instruction execution you need to\n+instrument them directly. However asynchronous interrupts will not\n+change control flow mid-block.\n+\n+Instructions\n+++++++++++++\n+\n+Instruction instrumentation runs before the instruction executes. You\n+can be can be sure the instruction will be dispatched, but you can't\n+be sure it will complete. Generally this will be because of a\n+synchronous exception (e.g. SIGILL) triggered by the instruction\n+attempting to execute. If you want to be sure you will need to\n+instrument the next instruction as well. See the ``execlog.c`` plugin\n+for examples of how to track this and finalise details after execution.\n+\n+Memory Accesses\n++++++++++++++++\n+\n+Memory callbacks are called after a successful load or store.\n+Unsuccessful operations (i.e. faults) will not be visible to memory\n+instrumentation although the execution side effects can be observed\n+(e.g. entering a exception handler).\n+\n+System Idle and Resume States\n++++++++++++++++++++++++++++++\n+\n+The ``qemu_plugin_register_vcpu_idle_cb`` and\n+``qemu_plugin_register_vcpu_resume_cb`` functions can be used to track\n+when CPUs go into and return from sleep states when waiting for\n+external I/O. Be aware though that these may occur less frequently\n+than in real HW due to the inefficiencies of emulation giving less\n+chance for the CPU to idle.\n+\n Internals\n ---------\n \n","prefixes":["v2","43/43"]}