[{"id":3243857,"web_url":"http://patchwork.ozlabs.org/comment/3243857/","msgid":"<8ce7c705-8f11-4ed0-ba7c-7965a1dd1fff@linaro.org>","list_archive_url":null,"date":"2024-01-09T14:28:17","subject":"Re: [PATCH v2 43/43] docs/devel: document some plugin assumptions","submitter":{"id":85798,"url":"http://patchwork.ozlabs.org/api/people/85798/","name":"Pierrick Bouvier","email":"pierrick.bouvier@linaro.org"},"content":"Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>\n\nOn 1/3/24 21:33, Alex Bennée wrote:\n> While we attempt to hide implementation details from the plugin we\n> shouldn't be totally obtuse. Let the user know what they can and can't\n> expect with the various instrumentation options.\n> \n> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>\n> ---\n>   docs/devel/tcg-plugins.rst | 49 ++++++++++++++++++++++++++++++++++++++\n>   1 file changed, 49 insertions(+)\n> \n> diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst\n> index 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>","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=G9tfFnVE;\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 4T8YGH1PJfz1yP7\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 10 Jan 2024 01:29: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 1rND5t-00033k-Ch; Tue, 09 Jan 2024 09:28:41 -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 <pierrick.bouvier@linaro.org>)\n id 1rND5r-00032r-Pm\n for qemu-devel@nongnu.org; Tue, 09 Jan 2024 09:28:39 -0500","from mail-wr1-x435.google.com ([2a00:1450:4864:20::435])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <pierrick.bouvier@linaro.org>)\n id 1rND5n-0001PB-GD\n for qemu-devel@nongnu.org; Tue, 09 Jan 2024 09:28:39 -0500","by mail-wr1-x435.google.com with SMTP id\n ffacd0b85a97d-336897b6bd6so3096712f8f.2\n for <qemu-devel@nongnu.org>; Tue, 09 Jan 2024 06:28:31 -0800 (PST)","from [192.168.1.24] ([102.35.208.160])\n by smtp.gmail.com with ESMTPSA id\n j15-20020adfb30f000000b003375c8f796bsm2627787wrd.0.2024.01.09.06.28.20\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Tue, 09 Jan 2024 06:28:29 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1704810510; x=1705415310; darn=nongnu.org;\n h=content-transfer-encoding:in-reply-to:from:references:cc:to\n :content-language:subject:user-agent:mime-version:date:message-id\n :from:to:cc:subject:date:message-id:reply-to;\n bh=Pn5mJSy6+IPUiDDo8gfQUfaMovq3bcwda2oYtY3vgIw=;\n b=G9tfFnVESf2+OLIg6rKIGF81B9NoAYiv16VdxfLurQqQDtYAuH2FCTNJLEYy8yFN/I\n VR5LxsJwMiSztJJDgKpePkkUASc/pBjgft5dClS5NC/VQRur1KeWMYF7xFXX7wLK8WmG\n aJGHQzB70vNlRSu5TUGPsyTqI5U3QpH6RrtSNagVPPsyuU4B5GVEG9TAWNR08xSJbyww\n zzcl94WLRhAp6aXTzLjjMg7OADZHXEfj0blJbO/SgecmgKnQNsbRhrRRhUImZiotFGoH\n tCHsgcERBQywTOrjO0YsbEiumYUY9WTFCB05n/1yOIcbl5XfysJ2cLdR/E30gV6ac406\n R3Fg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1704810510; x=1705415310;\n h=content-transfer-encoding:in-reply-to:from:references:cc:to\n :content-language:subject:user-agent:mime-version:date:message-id\n :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=Pn5mJSy6+IPUiDDo8gfQUfaMovq3bcwda2oYtY3vgIw=;\n b=ozhxNKtCWn40e6bwqiFRMFaXMfhTt2XHMsBFgomWfA1m3m5NuBMAF3OP2w2AgrSZqV\n k0niZeaMj4hBTNRGOHJc+hXqqpLkoLsVcRmAkmaAdASBBDDSr96fC9H6+4Qi/kCZDVb/\n Dz7EridJzgUy391LpJ7qq9WesCC5d5wOyMTuqxPWFHQR378+zze2gWL5NO4hyQlYaesB\n 5qlW/tTsnyDbLMEtLVD9uTojuwhY/Cl9hUieM9s3+4meyf7pN7EyfDnySZI72+tWpk0R\n 8E+mQnt8zcoXl+7RUktuGETzXPdRp5vllET1WZI7x0zaD10oR9c08NnRm8fwOaEI/6K9\n OjEg==","X-Gm-Message-State":"AOJu0YwLGkY68U2WpxhHTLxyHiFf/6JovXQqZurahqgBXmeBKIPAnD6/\n zWrLiqcEZppGc+qxLIpwUgSgJ0Odg+TtsA==","X-Google-Smtp-Source":"\n AGHT+IEMfFwF5fvLeUZ0AaWVyWVBLuAVIpiU1k8nqhqE7npOWTXGjdkDfY+e8W66evzYBoSR2N9pbQ==","X-Received":"by 2002:a5d:51c3:0:b0:336:b52d:30cf with SMTP id\n n3-20020a5d51c3000000b00336b52d30cfmr548248wrv.61.1704810510205;\n Tue, 09 Jan 2024 06:28:30 -0800 (PST)","Message-ID":"<8ce7c705-8f11-4ed0-ba7c-7965a1dd1fff@linaro.org>","Date":"Tue, 9 Jan 2024 18:28:17 +0400","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 43/43] docs/devel: document some plugin assumptions","Content-Language":"en-US","To":"=?utf-8?q?Alex_Benn=C3=A9e?= <alex.bennee@linaro.org>,\n 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>, 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>, qemu-riscv@nongnu.org,\n Alistair Francis <alistair.francis@wdc.com>","References":"<20240103173349.398526-1-alex.bennee@linaro.org>\n <20240103173349.398526-44-alex.bennee@linaro.org>","From":"Pierrick Bouvier <pierrick.bouvier@linaro.org>","In-Reply-To":"<20240103173349.398526-44-alex.bennee@linaro.org>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"base64","Received-SPF":"pass client-ip=2a00:1450:4864:20::435;\n envelope-from=pierrick.bouvier@linaro.org; helo=mail-wr1-x435.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"}}]