From nobody Wed Apr 24 23:25:27 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=1663776883; cv=none; d=zohomail.com; s=zohoarc; b=JSxFpr71NyLFF7dRB24ElF5aoN5zWqKLG1ajeo3URd9svOgiaoJCW3qbhMfuF5FIui00l3TVHIWYyeKd2fYVYzYyA0LPFsh2IAZ0AmlKbJYXjYagoOytUfEVQBDWOEorO1h+LXHK3JfAE++3CSI9P/x7D9xRNjJa8h/7Op5cVyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663776883; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kZCyr3Lyk7RSQMb91zeKViaNh3D4Z14FgGZeAQDXqfA=; b=AD12sdBPlC3XCKF4HvJCZvtI39zQric9npvpXetL/1S8SuTqiz1O/kVOwzPFoTYDxmanCsCQyvFdqqTjFZBWmSyPY+OcQ7n0sLpGZUCUPJb0fT8PpNA4qBaA9CheCPysTnSABrfONRjOErDBaOB6Icn5s8YdEuWVyTbpvlZSlw0= 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 16637768838287.245263777282275; Wed, 21 Sep 2022 09:14:43 -0700 (PDT) Received: from localhost ([::1]:60108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2Mz-0004v9-T1 for importer@patchew.org; Wed, 21 Sep 2022 12:14:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gf-0003CN-4M for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:09 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:38556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gc-0000bz-Td for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:08 -0400 Received: by mail-wm1-x336.google.com with SMTP id h130-20020a1c2188000000b003b4cadadce7so8115336wmh.3 for ; Wed, 21 Sep 2022 09:08:05 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id w12-20020a05600c474c00b003a5f3f5883dsm3367007wmo.17.2022.09.21.09.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:02 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 421BA1FFB8; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=kZCyr3Lyk7RSQMb91zeKViaNh3D4Z14FgGZeAQDXqfA=; b=nFovbVLeQ0CpUgz3+0ZZmlctw68fEUENHUHoV2c7/XVCS9EX2Y2mnkoYN650CgtPuM 3aeYxDlaBZFEMkRfdRerP7avReFugQ1mE9J5+xhimBAEJvFRH6na6gGVSqhSoq5sdl11 L1/tVid2jDEuhiMGq3Gj1l6vqitPxOEcJCOiJE1zG4u3e2SdU5GnHYH+sV6+rRmXQ9f1 Tj04x0fTHhS8foMhDri8ioEkQHh6L0CQfM1RpatGX9plCKDEc5jrdDMc1Rt7LwpfbxB4 l/XpXCW0//k6/Q0PavPmZRbLaoFbtcfGKXPgvYhORYMm62JQ5MqX/RMzxePgrNXiRAvu 8Gpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=kZCyr3Lyk7RSQMb91zeKViaNh3D4Z14FgGZeAQDXqfA=; b=XLwZpqus2aRfJDRzTRO/Ahj6g1yNk3fYZaKnL6LXvPV5QivAKNWARNdFXUIFAw3GQX 5gOnzXVbft0Gnoxz9kXAq5ik22xTadLZK70Tx99yj50mZM4p24JWdXF2n+Y+rNgJhx9W 0khWP6lDaNWHt3PV0vG8stuyi1zHm3sCNGtG6nZC3syj20BS+rN9BBA7Mimjj3X/CZk4 Dya+v37g7hQY4kRa24k7MCQjRZUjdWnxiKQr1ANAkti2bC8M2Hq++19DGn+s4CjtbV9b sVB54n70Y1dypAfKIx09pzIfxpjRghkyFKMJEunuCDrPN05kXMYLizLN4WEGVoA2GKoB pzIQ== X-Gm-Message-State: ACrzQf0WOV8uptzqv4ZDvfFe7b6RvNCeO2qZsVx6C3+v7E/HpduoeBLp uGOSAeyA+8U1wTqcRMk1C2c7YA== X-Google-Smtp-Source: AMsMyM4vzZ+SfF47/uFBVqJdWUEiBqsQ3CeiMdgq92cF7ku4aW6ZWioVNtxWWwl7F2ZXJLk/jhHUyA== X-Received: by 2002:a7b:c8d5:0:b0:3b4:76bc:5dae with SMTP id f21-20020a7bc8d5000000b003b476bc5daemr6514563wml.122.1663776483266; Wed, 21 Sep 2022 09:08:03 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Kevin Wolf , Hanna Reitz , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-block@nongnu.org (open list:Block layer core), qemu-ppc@nongnu.org (open list:New World (mac99)) Subject: [PATCH v1 01/10] monitor: expose monitor_puts to rest of code Date: Wed, 21 Sep 2022 17:07:52 +0100 Message-Id: <20220921160801.1490125-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663776885661100001 This helps us construct strings elsewhere before echoing to the monitor. It avoids having to jump through hoops like: monitor_printf(mon, "%s", s->str); It will be useful in following patches but for now convert all existing plain "%s" printfs to use the _puts api. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Kevin Wolf Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v2 - s/monitor_printf(mon, "%s"/monitor_puts(mon, / --- docs/devel/writing-monitor-commands.rst | 2 +- include/monitor/monitor.h | 1 + monitor/monitor-internal.h | 1 - block/monitor/block-hmp-cmds.c | 10 +++++----- hw/misc/mos6522.c | 2 +- monitor/hmp-cmds.c | 8 ++++---- monitor/hmp.c | 2 +- target/i386/helper.c | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-m= onitor-commands.rst index 4aa2bb904d..2fefedcd98 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -716,7 +716,7 @@ message. Here's the implementation of the "info roms" H= MP command:: if (hmp_handle_error(mon, err)) { return; } - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } =20 Also, you have to add the function's prototype to the hmp.h file. diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index a4b40e8391..737e750670 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -31,6 +31,7 @@ void monitor_resume(Monitor *mon); int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); =20 +int monitor_puts(Monitor *mon, const char *str); int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3); diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index caa2e90ef2..a2cdbbf646 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -174,7 +174,6 @@ extern int mon_refcount; =20 extern HMPCommand hmp_cmds[]; =20 -int monitor_puts(Monitor *mon, const char *str); void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush, bool use_io_thread); void monitor_data_destroy(Monitor *mon); diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index bfb3c043a0..939a520d17 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -638,16 +638,16 @@ static void print_block_info(Monitor *mon, BlockInfo = *info, assert(!info || !info->has_inserted || info->inserted =3D=3D inserted); =20 if (info && *info->device) { - monitor_printf(mon, "%s", info->device); + monitor_puts(mon, info->device); if (inserted && inserted->has_node_name) { monitor_printf(mon, " (%s)", inserted->node_name); } } else { assert(info || inserted); - monitor_printf(mon, "%s", - inserted && inserted->has_node_name ? inserted->nod= e_name - : info && info->has_qdev ? info->qdev - : ""); + monitor_puts(mon, + inserted && inserted->has_node_name ? inserted->node_= name + : info && info->has_qdev ? info->qdev + : ""); } =20 if (inserted) { diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c index f9e646350e..fe38c44426 100644 --- a/hw/misc/mos6522.c +++ b/hw/misc/mos6522.c @@ -595,7 +595,7 @@ void hmp_info_via(Monitor *mon, const QDict *qdict) if (hmp_handle_error(mon, err)) { return; } - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } =20 static const MemoryRegionOps mos6522_ops =3D { diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index c6cd6f91dd..f90eea8d01 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -730,7 +730,7 @@ static void hmp_info_pci_device(Monitor *mon, const Pci= DeviceInfo *dev) monitor_printf(mon, " "); =20 if (dev->class_info->has_desc) { - monitor_printf(mon, "%s", dev->class_info->desc); + monitor_puts(mon, dev->class_info->desc); } else { monitor_printf(mon, "Class %04" PRId64, dev->class_info->q_class); } @@ -2258,12 +2258,12 @@ static void print_stats_schema_value(Monitor *mon, = StatsSchemaValue *value) if (unit && value->base =3D=3D 10 && value->exponent >=3D -18 && value->exponent <=3D 18 && value->exponent % 3 =3D=3D 0) { - monitor_printf(mon, "%s", si_prefix(value->exponent)); + monitor_puts(mon, si_prefix(value->exponent)); } else if (unit && value->base =3D=3D 2 && value->exponent >=3D 0 && value->exponent <=3D 60 && value->exponent % 10 =3D=3D 0) { =20 - monitor_printf(mon, "%s", iec_binary_prefix(value->exponent)); + monitor_puts(mon, iec_binary_prefix(value->exponent)); } else if (value->exponent) { /* Use exponential notation and write the unit's English name */ monitor_printf(mon, "* %d^%d%s", @@ -2273,7 +2273,7 @@ static void print_stats_schema_value(Monitor *mon, St= atsSchemaValue *value) } =20 if (value->has_unit) { - monitor_printf(mon, "%s", unit ? unit : StatsUnit_str(value->unit)= ); + monitor_puts(mon, unit ? unit : StatsUnit_str(value->unit)); } =20 /* Print bucket size for linear histograms */ diff --git a/monitor/hmp.c b/monitor/hmp.c index a3375d0341..43fd69f984 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1094,7 +1094,7 @@ static void hmp_info_human_readable_text(Monitor *mon, return; } =20 - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } =20 static void handle_hmp_command_exec(Monitor *mon, diff --git a/target/i386/helper.c b/target/i386/helper.c index fa409e9c44..b954ccda50 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -415,7 +415,7 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_= data data) if (need_reset) { emit_guest_memory_failure(MEMORY_FAILURE_ACTION_RESET, ar, recursive); - monitor_printf(params->mon, "%s", msg); + monitor_puts(params->mon, msg); qemu_log_mask(CPU_LOG_RESET, "%s\n", msg); qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); return; --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663777665; cv=none; d=zohomail.com; s=zohoarc; b=f2KqFwlFYOS+WQAgt6qLzP5wSnw7N+7ZmFuO4G3y6Jlo2a9A8z+G/EqvC8vpbnVCO3biR/8DtU6ODRKhPm9GSFbl8LTcD62xlWnuFKqtxlJcH7Apl9Ep/245CoFAoseVN6+X7b9LJVkQxEaG/gxnbo7UxlAOSb9/RzEuWcbN0f4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663777665; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uLb+n5aqjLubd88rD9ajb7yNM+TT8WZpmI3dXPveZoM=; b=hGNTPmJrrnMplxYGOPk8aMScGy5YZ1HY8OAj04xKIzgPr7X/JXiFF1tG63RPPOLKZgr7qvQNLImzAICue0ATaVuWwrnlIef0Tl3m0Ce3kMH64IkRXwnXd7Ju6dAAkl9xR+ykWneGhep/v19JJyhWsdkaHwY8BxzIPRKYgDoO8lE= 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 1663777665861207.4248088500591; Wed, 21 Sep 2022 09:27:45 -0700 (PDT) Received: from localhost ([::1]:58732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2Zb-0001KL-NJ for importer@patchew.org; Wed, 21 Sep 2022 12:27:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gp-0003TG-0n for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:20 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:43721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gk-0000eD-K0 for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:18 -0400 Received: by mail-wr1-x42b.google.com with SMTP id t7so10621980wrm.10 for ; Wed, 21 Sep 2022 09:08:14 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id bj1-20020a0560001e0100b0022b0214cfa6sm3716222wrb.45.2022.09.21.09.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:03 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5842E1FFBA; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=uLb+n5aqjLubd88rD9ajb7yNM+TT8WZpmI3dXPveZoM=; b=INOypRfRLiTojSFOGytSUFur61A0S8m5Z+PxDd36JjHbRHR2wJZAhBwYm6xfVODfd6 fKFWan8RTcrFzNN+Us7qy/OdFD7jD0RCrZAyTMTnxrJmQSl4JlF8vC/BQSKQziN0kpJL zz9xOp0c5buIq6+ppstWkpNDLoUX4JGJ3faCtesSEgzTLlZfXSvHnylUQs05XuZI5ugV UAoPBqTir9OiYkMJ5GTKiu4qM9jkNj8s6wRNL6wpObSxKRxiIjVdf07JKMhCwqki3wk0 T2HeKhaJ8SLRVEX1sJtnp0cUQ4AevrnsBqZ2F5hhOUjRKKflixRYvspyBhRdAFhzpxaB gQmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=uLb+n5aqjLubd88rD9ajb7yNM+TT8WZpmI3dXPveZoM=; b=pQ0r1rScXGXGj5/61/bIhJq9SV61nFHLOfipidC27rMqhwAyElFk78utxSTru9hAsc eseQoBTKIFNWASLDFN2ihZihcQLnKX+J5+vLGb+8udDsPp0ECjplb/EU9hTesAieLChJ V/E6mfuplEv7m2I6xHmFy0qydUtjSyzVDAmEGDhX+LptwxqsDRsbgDwHh0EJHRX/AW5n 8faE6SS6MfPG3oFNMWbzOQ1GrWQEj3zV1dlE1DOMvpqECvCoOnqKoR+O3N5DlBh60M3N fqW/TNejkXk/tXtqn3eqVszoZyJXqf4fGYzls48Sn9FfdELS8/Q/DLu25/s7Uy7ZuqxR /yTA== X-Gm-Message-State: ACrzQf1YLBqBfj/QMLqFiN/4XAxl73pvsjkIKboJyy+WUAdMN/Xw3W4b awnsCOJdeMt99tgQnxfi7HPOLg== X-Google-Smtp-Source: AMsMyM7voFfqxh2rMirm21Qu4P95LJFWf3qJZL3cP7HwcLulmiZBUV7/SgS0dqwHRE4OIFzPxVX81Q== X-Received: by 2002:a5d:4e88:0:b0:228:c8ed:2af8 with SMTP id e8-20020a5d4e88000000b00228c8ed2af8mr17988175wru.412.1663776493176; Wed, 21 Sep 2022 09:08:13 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [PATCH v1 02/10] disas: generalise plugin_printf and use for monitor_disas Date: Wed, 21 Sep 2022 17:07:53 +0100 Message-Id: <20220921160801.1490125-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663777667569100001 Rather than assembling our output piecemeal lets use the same approach as the plugin disas interface to build the disassembly string before printing it. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- disas.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/disas.c b/disas.c index e31438f349..f07b6e760b 100644 --- a/disas.c +++ b/disas.c @@ -239,7 +239,7 @@ void target_disas(FILE *out, CPUState *cpu, target_ulon= g code, } } =20 -static int plugin_printf(FILE *stream, const char *fmt, ...) +static int gstring_printf(FILE *stream, const char *fmt, ...) { /* We abuse the FILE parameter to pass a GString. */ GString *s =3D (GString *)stream; @@ -270,7 +270,7 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t= size) GString *ds =3D g_string_new(NULL); =20 initialize_debug_target(&s, cpu); - s.info.fprintf_func =3D plugin_printf; + s.info.fprintf_func =3D gstring_printf; s.info.stream =3D (FILE *)ds; /* abuse this slot */ s.info.buffer_vma =3D addr; s.info.buffer_length =3D size; @@ -358,15 +358,19 @@ void monitor_disas(Monitor *mon, CPUState *cpu, { int count, i; CPUDebug s; + g_autoptr(GString) ds =3D g_string_new(""); =20 initialize_debug_target(&s, cpu); - s.info.fprintf_func =3D qemu_fprintf; + s.info.fprintf_func =3D gstring_printf; + s.info.stream =3D (FILE *)ds; /* abuse this slot */ + if (is_physical) { s.info.read_memory_func =3D physical_read_memory; } s.info.buffer_vma =3D pc; =20 if (s.info.cap_arch >=3D 0 && cap_disas_monitor(&s.info, pc, nb_insn))= { + monitor_puts(mon, ds->str); return; } =20 @@ -376,13 +380,16 @@ void monitor_disas(Monitor *mon, CPUState *cpu, return; } =20 - for(i =3D 0; i < nb_insn; i++) { - monitor_printf(mon, "0x" TARGET_FMT_lx ": ", pc); + for (i =3D 0; i < nb_insn; i++) { + g_string_append_printf(ds, "0x" TARGET_FMT_lx ": ", pc); count =3D s.info.print_insn(pc, &s.info); - monitor_printf(mon, "\n"); - if (count < 0) - break; + g_string_append_c(ds, '\n'); + if (count < 0) { + break; + } pc +=3D count; } + + monitor_puts(mon, ds->str); } #endif --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663777134; cv=none; d=zohomail.com; s=zohoarc; b=YGCV9It+SVof8p/u6PWGFD75lmgjH3BIgNdBZKiQgDn5Bwo5p0biofKvSpyV59xMACH8+dU429AOZANiVa36zLQmmGryEn7qisursSFxPc9fcha5rcYyPmFSYVTTe5d9yfR192kaca9SHdpyVLD9rbbgxqchDS6bKAOBJEHGBeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663777134; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AqWJ7kyP/wVtcUkYapts2DpsBXihq1Vm9sATGZkmD9k=; b=nI4l9LYR5M0Tr6WRbZF5bDk310hJoRGgEFxMqUkaVjxHSmTfcD2B+XVCg8MEtoZwgUiuwVXEy9P+s/YYrlN+9b0rzucot99tZdhPRViHPbLIXskH21oU/NoFcwjLPkXExQqjujJVrAN1mvRfZ5e9r7fJHmiFFgQy8EeBR0CgvCQ= 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 1663777134696713.9016290133586; Wed, 21 Sep 2022 09:18:54 -0700 (PDT) Received: from localhost ([::1]:57214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2R3-0002If-2Q for importer@patchew.org; Wed, 21 Sep 2022 12:18:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gl-0003O6-5X for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:15 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:37735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gj-0000e3-Ed for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:14 -0400 Received: by mail-wr1-x429.google.com with SMTP id bq9so10700834wrb.4 for ; Wed, 21 Sep 2022 09:08:13 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id l30-20020a05600c1d1e00b003a601a1c2f7sm3779689wms.19.2022.09.21.09.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:03 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 707521FFBB; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=AqWJ7kyP/wVtcUkYapts2DpsBXihq1Vm9sATGZkmD9k=; b=prG89gNntB0BCQYooZY3fTpl6Lb5ZwuDlbjaHQbcLF8oef/rpFwfp723aI++JfSjXt sQVrygEW6/CCVrtMPTHLH2YmZ+L/toW0EiSmH20mpYfQNCoge9F0k/ZZSEUu5OkcddaC x/bY1jIKum2yHjch69cCMfPuWIgDZ0SnB3H0SoNZoh8rEtgNW3RFU7gOJnyM9TxR0FVK Oj162hIPUF3497VDa1dA+mt8UODFktJRdFAdTO5kA2uVqRCT6LDDOHhKrXzzJ6XvBpv/ 0OXbfZjZA4Ja38VxzbWLSulAncO3wHCkSW30FkxUxMsX+1ODYksKZlyw9qr4K1ShR34d NsGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=AqWJ7kyP/wVtcUkYapts2DpsBXihq1Vm9sATGZkmD9k=; b=ZfNsX1URGGj5JUmpM4sXvs4036YsgOSiUpjpn2abSPj5MwpXGK/9mFBSu7BKxLRbo8 jXhL1JwhLDp69BaCFpop5zigD6jqWTeoH9engD6e99xa1q7iS3CICa4Xh/BSaUAMhxIs PC3a9NOe1dAuxNA3X51CVpDev7f/aVwdX7oKXfeUo+IlIfSiZPx8bxgYJd4ANXpgH8S8 Qs7cUwbDsjtAJ4hqZA7qJLVADvzYXIQTb8VP5MxPvvOqkAe2no4CVI7RilJIsFMNwVAt EBbsSi5P4xH/cqZmXVSXMmW3VYia131rbpd4MsPnPPI2pXgR181yaBqtDdDgILYqJjkl 07ew== X-Gm-Message-State: ACrzQf1af6+SoolNDt8LYWOZRLDYcaYltT4OAgjPlK1PDivAK0LCJF+q yBEPEYpSZZizw2utyRLZk8yf4Q== X-Google-Smtp-Source: AMsMyM41/V2WGeNTq4r6adjDZh9YvEvcN/JSX/CX7+lQ3esg8Mm+UShj0qT0DYj2IwB310x3YxVUCw== X-Received: by 2002:a5d:6ace:0:b0:22a:f444:2ad3 with SMTP id u14-20020a5d6ace000000b0022af4442ad3mr12755536wrw.21.1663776491974; Wed, 21 Sep 2022 09:08:11 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [PATCH v1 03/10] disas: use result of ->read_memory_func Date: Wed, 21 Sep 2022 17:07:54 +0100 Message-Id: <20220921160801.1490125-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663777137165100001 This gets especially confusing if you start plugging in host addresses from a trace and you wonder why the output keeps changing. Report when read_memory_func fails instead of blindly disassembling the buffer contents. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- disas.c | 20 ++++++------- disas/capstone.c | 73 ++++++++++++++++++++++++++++-------------------- 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/disas.c b/disas.c index f07b6e760b..94d3b45042 100644 --- a/disas.c +++ b/disas.c @@ -83,18 +83,18 @@ static int print_insn_objdump(bfd_vma pc, disassemble_i= nfo *info, const char *prefix) { int i, n =3D info->buffer_length; - uint8_t *buf =3D g_malloc(n); - - info->read_memory_func(pc, buf, n, info); - - for (i =3D 0; i < n; ++i) { - if (i % 32 =3D=3D 0) { - info->fprintf_func(info->stream, "\n%s: ", prefix); + g_autofree uint8_t *buf =3D g_malloc(n); + + if (info->read_memory_func(pc, buf, n, info) =3D=3D 0) { + for (i =3D 0; i < n; ++i) { + if (i % 32 =3D=3D 0) { + info->fprintf_func(info->stream, "\n%s: ", prefix); + } + info->fprintf_func(info->stream, "%02x", buf[i]); } - info->fprintf_func(info->stream, "%02x", buf[i]); + } else { + info->fprintf_func(info->stream, "unable to read memory"); } - - g_free(buf); return n; } =20 diff --git a/disas/capstone.c b/disas/capstone.c index 20bc8f9669..fe3efb0d3c 100644 --- a/disas/capstone.c +++ b/disas/capstone.c @@ -191,37 +191,43 @@ bool cap_disas_target(disassemble_info *info, uint64_= t pc, size_t size) size_t tsize =3D MIN(sizeof(cap_buf) - csize, size); const uint8_t *cbuf =3D cap_buf; =20 - info->read_memory_func(pc + csize, cap_buf + csize, tsize, info); - csize +=3D tsize; - size -=3D tsize; + if (info->read_memory_func(pc + csize, cap_buf + csize, tsize, inf= o) =3D=3D 0) { + csize +=3D tsize; + size -=3D tsize; =20 - while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { - cap_dump_insn(info, insn); - } + while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + cap_dump_insn(info, insn); + } + + /* If the target memory is not consumed, go back for more... */ + if (size !=3D 0) { + /* + * ... taking care to move any remaining fractional insn + * to the beginning of the buffer. + */ + if (csize !=3D 0) { + memmove(cap_buf, cbuf, csize); + } + continue; + } =20 - /* If the target memory is not consumed, go back for more... */ - if (size !=3D 0) { /* - * ... taking care to move any remaining fractional insn - * to the beginning of the buffer. + * Since the target memory is consumed, we should not have + * a remaining fractional insn. */ if (csize !=3D 0) { - memmove(cap_buf, cbuf, csize); + info->fprintf_func(info->stream, + "Disassembler disagrees with translator= " + "over instruction decoding\n" + "Please report this to qemu-devel@nongn= u.org\n"); } - continue; - } + break; =20 - /* - * Since the target memory is consumed, we should not have - * a remaining fractional insn. - */ - if (csize !=3D 0) { + } else { info->fprintf_func(info->stream, - "Disassembler disagrees with translator " - "over instruction decoding\n" - "Please report this to qemu-devel@nongnu.org\n"); + "0x%08" PRIx64 ": unable to read memory\n",= pc); + break; } - break; } =20 cs_close(&handle); @@ -286,16 +292,23 @@ bool cap_disas_monitor(disassemble_info *info, uint64= _t pc, int count) =20 /* Make certain that we can make progress. */ assert(tsize !=3D 0); - info->read_memory_func(pc + csize, cap_buf + csize, tsize, info); - csize +=3D tsize; - - if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { - cap_dump_insn(info, insn); - if (--count <=3D 0) { - break; + if (info->read_memory_func(pc + csize, cap_buf + csize, + tsize, info) =3D=3D 0) + { + csize +=3D tsize; + + if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + cap_dump_insn(info, insn); + if (--count <=3D 0) { + break; + } } + memmove(cap_buf, cbuf, csize); + } else { + info->fprintf_func(info->stream, + "0x%08" PRIx64 ": unable to read memory\n",= pc); + break; } - memmove(cap_buf, cbuf, csize); } =20 cs_close(&handle); --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663777148; cv=none; d=zohomail.com; s=zohoarc; b=UyzdMz/6j9kaI1DFuR+9Sj3kKCXHfd/sCiRlHDjccGe/apPQKeLPx9hn2Z71EtpaiKSJbT36Aur3+HGlJz6wv12/QDUj0r9T5RfzhW1v2FUwGp+PHKgoKHaYX3IoPpRW8pffZHh9E4k6Lsqdc4Su7ht08YwDfk+nU0PvHp/leH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663777148; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8Ro+xFgh/QdLoZQgvYQ8rQUQbQuFqJuKD5ycvRlp+PA=; b=XoBsEbryUhxyToSzB9fWEwThwiMAbZ7b4BWF0cR8sIbU0RGUPwpKxd9IZ/pSrS1Bwlw6i1mVHO6pX3c7EnPy+pmF7eC702Xnk+tyj019o9RKepLSKV8wwc1tu1TMKvBNoMdq2klSR5IIVQDnN1UrOmB72YOQmwBBo3fphTB++kc= 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 1663777148725533.6553003889464; Wed, 21 Sep 2022 09:19:08 -0700 (PDT) Received: from localhost ([::1]:39900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2RG-0002SZ-Kf for importer@patchew.org; Wed, 21 Sep 2022 12:19:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gh-0003FZ-3Y for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:11 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:42676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Ge-0000cG-UG for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:10 -0400 Received: by mail-wr1-x429.google.com with SMTP id n12so10643051wrx.9 for ; Wed, 21 Sep 2022 09:08:08 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id f4-20020a1cc904000000b003a5c7a942edsm3224652wmb.28.2022.09.21.09.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:03 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 886251FFBC; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=8Ro+xFgh/QdLoZQgvYQ8rQUQbQuFqJuKD5ycvRlp+PA=; b=yDRFOGZIwS5TBvjprxxXPeD/fM1U32vJwucS9FveGYT0CdQTBOyivLde2QxrvyAXt2 1Vn4/s/QysuxWhsINXAqZhpyZShvpp4Y2GhDnqDCt0X9P42dlqs0xr3JoU+sG+IdfsxP gWWmOMkWMJiUKsfClVw3y7KkBcIgoLCyZfx6pJpdRkDzFdaiuH7Sfdj2pwUCYLUPrRkm GYrBTwQQrgDHM14JlAaxpdXO5y2yj5LTKDDv425siJ5bfi7p/t/TgWcTYye2C+juJ2l6 9wX9M+l2rwrEZBsnVzrvU37tL5DWQNyOT32YFRbssHqMM4/6gMvpPZ/kVun8CcoP4X/W 7iKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=8Ro+xFgh/QdLoZQgvYQ8rQUQbQuFqJuKD5ycvRlp+PA=; b=iKKshSF4GgWww/SZPLXKi4Y5RZbTw8mI/wlJtyDqeOkJ830zr/efHH9eLMIZMyovIN ibEr9EFTt8ldbWmSx102EYHBjtrWWcZGIRpA3DaS5qP8w/BXf/lhG8WZ1/0sOr9qbh+v nE0F8VuESM7xuPrO8BxxaYnLgarU1pi7Zf9MvLzdC/FzYPsYxcSeGJ59mvFH6mN35csS xq3dbOOglgnM6o4iDQWHblZUj1RRjTG/D8czZ2zg9II6QYYW7cIceO9rmRhwFqHsYhhP DXi0o96/8dCjj816Ege0QHnbXNeQlvLe/EIZ4CvMBXqSa0deKM4r52L/AchSQ+yohB85 UF6A== X-Gm-Message-State: ACrzQf1fWIwOn/sFiSoLGiH2r2Ty/CBzVz8cgqi4YGvvo6iqbh92Bzhp 9BP2BNxwHOPPClJTGPMpba5S3g== X-Google-Smtp-Source: AMsMyM6boG4cIRgF1survFRTZd4Caniql31PKXBe2OhUl5E/ob4SMPewUZERo9uf3bJ0Wqt+zOXsXw== X-Received: by 2002:a5d:47aa:0:b0:226:dbf6:680c with SMTP id 10-20020a5d47aa000000b00226dbf6680cmr17803276wrb.581.1663776487085; Wed, 21 Sep 2022 09:08:07 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH v1 04/10] tests/tcg: add memory-sve test for aarch64 Date: Wed, 21 Sep 2022 17:07:55 +0100 Message-Id: <20220921160801.1490125-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663777151328100001 This will be helpful in debugging problems with tracking SVE memory accesses via the TCG plugins system. Signed-off-by: Alex Benn=C3=A9e Cc: Robert Henry Cc: Aaron Lindsay Reviewed-by: Richard Henderson --- tests/tcg/aarch64/Makefile.softmmu-target | 7 +++++++ tests/tcg/aarch64/system/boot.S | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/= Makefile.softmmu-target index f6fcd4829e..26701b718c 100644 --- a/tests/tcg/aarch64/Makefile.softmmu-target +++ b/tests/tcg/aarch64/Makefile.softmmu-target @@ -31,6 +31,13 @@ LDFLAGS+=3D-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS)= -lgcc =20 memory: CFLAGS+=3D-DCHECK_UNALIGNED=3D1 =20 +memory-sve: memory.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +memory-sve: CFLAGS+=3D-DCHECK_UNALIGNED=3D1 -march=3Darmv8.1-a+sve -O3 -fn= o-tree-loop-distribute-patterns + +TESTS+=3Dmemory-sve + # Running QEMU_BASE_MACHINE=3D-M virt -cpu max -display none QEMU_OPTS+=3D$(QEMU_BASE_MACHINE) -semihosting-config enable=3Don,target= =3Dnative,chardev=3Doutput -kernel diff --git a/tests/tcg/aarch64/system/boot.S b/tests/tcg/aarch64/system/boo= t.S index e190b1efa6..f136363d2a 100644 --- a/tests/tcg/aarch64/system/boot.S +++ b/tests/tcg/aarch64/system/boot.S @@ -179,12 +179,13 @@ __start: isb =20 /* - * Enable FP registers. The standard C pre-amble will be + * Enable FP/SVE registers. The standard C pre-amble will be * saving these and A-profile compilers will use AdvSIMD * registers unless we tell it not to. */ mrs x0, cpacr_el1 orr x0, x0, #(3 << 20) + orr x0, x0, #(3 << 16) msr cpacr_el1, x0 =20 /* Setup some stack space and enter the test code. --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663777678; cv=none; d=zohomail.com; s=zohoarc; b=O8GtwRnFHvG2JTk2IvuspNJd6kKRKKI7Ae9Ehsdsf8/HoOE5v1ZoRAWnu20AhMQK9jU2/b2o5+bqOGx82+b6THIA0DKxaroITNJGQm/w7qwvm7y7flohOyE9sFQgRghwdXfjRypY7c/N1QpAO6rt0vYd2qDt1CxBOQJe689cqyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663777678; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RolUEI1sAdkeZqLhK3SHKMIX8JiB7vTNvSZnkZrUXOI=; b=DQjXdrcF6TistmPiyJTts5onbiZghL3cDn2BXZrOFyOmKP88gmXBOEMirG/GtR/Qg0KTggWkiQEG4dzGUWlgZ0IbGqrFPzpVsu403Ta9X8nJXBX8ESIozdejVpQAHRFjygoWGXjuUz3FJy8VfBnrYYusMZtPzNgm+jTCNfYQtkU= 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 1663777678435593.1342485629609; Wed, 21 Sep 2022 09:27:58 -0700 (PDT) Received: from localhost ([::1]:48282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2Zp-0001ed-7B for importer@patchew.org; Wed, 21 Sep 2022 12:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gq-0003Tr-KJ for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:20 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:38615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gn-0000cF-Aw for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:19 -0400 Received: by mail-wr1-x42b.google.com with SMTP id n15so3755551wrq.5 for ; Wed, 21 Sep 2022 09:08:16 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id v16-20020a5d6790000000b00228dd80d78asm2936092wru.86.2022.09.21.09.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A1E2E1FFBD; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=RolUEI1sAdkeZqLhK3SHKMIX8JiB7vTNvSZnkZrUXOI=; b=qqPuTY1HONNMEFZcSifLXE1XlciQMrd/NBjtbKwNHlgcppwqj+dAyZlTjQocwY/YDn jwV9hR3/7R4NQEi9243TxuXAsD9RssRDbFDUjp5BXa+ECOv00ARL5TO90pw+H/QFmY1X gLLMPZ+vQYJzf4c6FUJnJF7OTCg+2oNU54WoO9mI6gxdmTo5pDgJwYgHp+pfH8gCkphc nSn7E5IYcxA2B14xlKOXEdohVV2oSlkWdS7zEX7L0tKgxsBo2vW+Mpm9PC9haGlcJHER dEf7eRIwlpbRonNxERl3+MluhjrbJJvviToCYTDG5VwfXt2byr0stv3eOJm2aEDNbt4d 1ncg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=RolUEI1sAdkeZqLhK3SHKMIX8JiB7vTNvSZnkZrUXOI=; b=xLGEIL2edv38QXHy0hFcHF14wH1M7Ltu7yLKExPDiUVLjb2HNZHJUaB8CKQLkfIJK1 L5ra1erPagGAutojL21f1LRQOLtIEnhvO2Ffepr3ySMBTlyzhQ5ULdKxTXmVJwNl6w8q dxIGDH68Ty+2L/6qgMlOvlXUDYZnPQ235iNzDU4r9tr0YX9gfqTlkrYthVTumY7po66X LhWFyhPOQGs/bClY1QKkNSAZDCZEM21lgzyiSNwsAVtL7gsnMGZm5Dv0Ems3nI282F6d Nj13iggef9F10w2cxXhoDTPvq4WSaoQh5mYHu5FmIh4R3BWvdbHcGSePZ/tn/BPx0G3Y pcFw== X-Gm-Message-State: ACrzQf0PuOb7qMZieMq9TTtckygdc6+IPr7HlX9EFrDIZuX7DHGuUaqv MRkJviZROeqzV48klLabN/XSSA== X-Google-Smtp-Source: AMsMyM60dfHJXhQ8o4ZjVF9TEZN9i9EUSqyk/TcmsNevj+8jMg8dMzQKw9Jn9k7D/Y1NjgJSOwOjNA== X-Received: by 2002:a5d:6d0e:0:b0:22a:7bb2:14ae with SMTP id e14-20020a5d6d0e000000b0022a7bb214aemr18660208wrq.379.1663776496241; Wed, 21 Sep 2022 09:08:16 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v1 05/10] plugins: extend execlog to filter matches Date: Wed, 21 Sep 2022 17:07:56 +0100 Message-Id: <20220921160801.1490125-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663777679775100003 Sometimes the whole execlog is just two much so add the ability to filter by instruction opcode or address. [AJB: this shows for example .qemu-system-aarch64 -display none -serial mon:stdio \ -M virt -cpu max \ -semihosting-config enable=3Don \ -kernel ./tests/tcg/aarch64-softmmu/memory-sve \ -plugin ./contrib/plugins/libexeclog.so,ifilter=3Dst1w,afilter=3D0x40001= 808 -d plugin -D plugin.out the st1w SVE instruction is not instrumenting its stores.] Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Alexandre Iooss Cc: Robert Henry Cc: Aaron Lindsay --- docs/devel/tcg-plugins.rst | 9 +++- contrib/plugins/execlog.c | 96 ++++++++++++++++++++++++++++++++------ 2 files changed, 90 insertions(+), 15 deletions(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index a7cc44aa20..a503d44cee 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -346,7 +346,7 @@ The execlog tool traces executed instructions with memo= ry access. It can be used for debugging and security analysis purposes. Please be aware that this will generate a lot of output. =20 -The plugin takes no argument:: +The plugin needs default argument:: =20 qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so -d plugin @@ -364,6 +364,13 @@ which will output an execution trace following this st= ructure:: 0, 0xd34, 0xf9c8f000, "bl #0x10c8" 0, 0x10c8, 0xfff96c43, "ldr r3, [r0, #0x44]", load, 0x200000e4, RAM =20 +the output can be filtered to only track certain instructions or +addresses using the `ifilter` or `afilter` options. You can stack the +arguments if required:: + + qemu-system-arm $(QEMU_ARGS) \ + -plugin ./contrib/plugins/libexeclog.so,ifilter=3Dst1w,afilter=3D0x400= 01808 -d plugin + - contrib/plugins/cache.c =20 Cache modelling plugin that measures the performance of a given L1 cache diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index a5275dcc15..e659ac9cbb 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -20,6 +20,9 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGI= N_VERSION; /* Store last executed instruction on each vCPU as a GString */ GArray *last_exec; =20 +static GPtrArray *imatches; +static GArray *amatches; + /** * Add memory read or write information to current instruction log */ @@ -85,12 +88,13 @@ static void vcpu_insn_exec(unsigned int cpu_index, void= *udata) static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { struct qemu_plugin_insn *insn; - uint64_t insn_vaddr; - uint32_t insn_opcode; - char *insn_disas; + bool skip =3D (imatches || amatches) ? true : false; =20 size_t n =3D qemu_plugin_tb_n_insns(tb); for (size_t i =3D 0; i < n; i++) { + char *insn_disas; + uint64_t insn_vaddr; + /* * `insn` is shared between translations in QEMU, copy needed data= here. * `output` is never freed as it might be used multiple times duri= ng @@ -99,20 +103,52 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) * a limitation for CISC architectures. */ insn =3D qemu_plugin_tb_get_insn(tb, i); - insn_vaddr =3D qemu_plugin_insn_vaddr(insn); - insn_opcode =3D *((uint32_t *)qemu_plugin_insn_data(insn)); insn_disas =3D qemu_plugin_insn_disas(insn); - char *output =3D g_strdup_printf("0x%"PRIx64", 0x%"PRIx32", \"%s\"= ", - insn_vaddr, insn_opcode, insn_disas= ); + insn_vaddr =3D qemu_plugin_insn_vaddr(insn); + + /* + * If we are filtering we better check out if we have any + * hits. The skip "latches" so we can track memory accesses + * after the instruction we care about. + */ + if (skip && imatches) { + int j; + for (j =3D 0; j < imatches->len && skip; j++) { + char *m =3D g_ptr_array_index(imatches, j); + if (g_str_has_prefix(insn_disas, m)) { + skip =3D false; + } + } + } + + if (skip && amatches) { + int j; + for (j =3D 0; j < amatches->len && skip; j++) { + uint64_t v =3D g_array_index(amatches, uint64_t, j); + if (v =3D=3D insn_vaddr) { + skip =3D false; + } + } + } =20 - /* Register callback on memory read or write */ - qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, - QEMU_PLUGIN_CB_NO_REGS, - QEMU_PLUGIN_MEM_RW, NULL); + if (skip) { + g_free(insn_disas); + } else { + uint32_t insn_opcode; + insn_opcode =3D *((uint32_t *)qemu_plugin_insn_data(insn)); + char *output =3D g_strdup_printf("0x%"PRIx64", 0x%"PRIx32", \"= %s\"", + insn_vaddr, insn_opcode, insn_d= isas); + + /* Register callback on memory read or write */ + qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, + QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_MEM_RW, NULL); + + /* Register callback on instruction */ + qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, + QEMU_PLUGIN_CB_NO_REGS,= output); + } =20 - /* Register callback on instruction */ - qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, - QEMU_PLUGIN_CB_NO_REGS, out= put); } } =20 @@ -132,6 +168,25 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } } =20 +/* Add a match to the array of matches */ +static void parse_insn_match(char *match) +{ + if (!imatches) { + imatches =3D g_ptr_array_new(); + } + g_ptr_array_add(imatches, match); +} + +static void parse_vaddr_match(char *match) +{ + uint64_t v =3D g_ascii_strtoull(match, NULL, 16); + + if (!amatches) { + amatches =3D g_array_new(false, true, sizeof(uint64_t)); + } + g_array_append_val(amatches, v); +} + /** * Install the plugin */ @@ -145,6 +200,19 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, */ last_exec =3D g_array_new(FALSE, FALSE, sizeof(GString *)); =20 + for (int i =3D 0; i < argc; i++) { + char *opt =3D argv[i]; + g_autofree char **tokens =3D g_strsplit(opt, "=3D", 2); + if (g_strcmp0(tokens[0], "ifilter") =3D=3D 0) { + parse_insn_match(tokens[1]); + } else if (g_strcmp0(tokens[0], "afilter") =3D=3D 0) { + parse_vaddr_match(tokens[1]); + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + /* Register translation block and exit callbacks */ qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663777773; cv=none; d=zohomail.com; s=zohoarc; b=YUmX8TqLv7yw1IDOFRHjamkQr/tLi2H80d30cFUUZQFEhEpHf3VQ1VZ1wf9xJqs94fcVDBpwhtrral7JKBS4XlxLFm0J6hswAaAqKOWDnY/9xcPxYiqgfgDfy4/1zE+8sUuzokWZXl/H6/Zwv+WQD6HJtrXywx4j8SX8uaHTeC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663777773; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8wlJEOjCIqrgKcd8hYGZEfi/YjXbLCd9HqD3SSKCejY=; b=e2fQzmwLs1Q9OG0AKZWSrPYjBdbo3dDExMA71YYyuRxmlOz1KrWX1SsWNKQ1ocGNnAzUcYnq/Kz5y5aPSRBt7U05/ka2GdcMAKlCqlL7UYbGdE17h72IbW3pxXhdFv/ShuyEvpzt03N2vnDs4/Rws5OCui5Z1LgHXOhcS2pZpEI= 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 1663777773561872.3734970106473; Wed, 21 Sep 2022 09:29:33 -0700 (PDT) Received: from localhost ([::1]:33636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2bM-000464-EC for importer@patchew.org; Wed, 21 Sep 2022 12:29:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gp-0003To-LI for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:20 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:38556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gm-0000bz-Ih for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:19 -0400 Received: by mail-wm1-x336.google.com with SMTP id h130-20020a1c2188000000b003b4cadadce7so8115821wmh.3 for ; Wed, 21 Sep 2022 09:08:16 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id iv14-20020a05600c548e00b003b435c41103sm4800673wmb.0.2022.09.21.09.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B7F221FFBE; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=8wlJEOjCIqrgKcd8hYGZEfi/YjXbLCd9HqD3SSKCejY=; b=nKSVH8n+7fIS3nSDQq/+9YSUxw/54UBP8h4BuTs6AG8M1y0aXsVm1dArRdtwS1fo7u rXPu6O38uN0hlb1LRd8J9Q6aXMhU9Ka1d+DJhI8ykyXoyz4zntoAXXfEbZEguqeQ1vSc CykwOdaK99lDsk+FSq6to6/dogKFNCrs7TFTuAcCP/uMamlWRgcngwb/l3MCNulq0H6m 4Ma1n5RriNgWVqPkUkUmGTTIHY4cQILpUC6CZ3uD21gDN1CDyLrSbJHAFM1Clk6HYJI9 THPD6lT3XKy85lrUq+lsiOUD2+BYnIT/11LiOB5fBE77u8fIDwF6XwF8zcFd8IXQ5e8I rTUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=8wlJEOjCIqrgKcd8hYGZEfi/YjXbLCd9HqD3SSKCejY=; b=a0X5U5qHMYDsNFmqdz81ess82nEHGYV5zUsJE8cpxFNGEEnuM0pkUBizu5fwnS7r7i xT+ZFRXd/Z63LlU3NBOn/4iOYrMb8q1uExG/qWFs7jUu6oBpuOp/bpUWKhigJKZAwTFe 4P/mZh4JHKWWxfhWXfJY2HSMAWxC0I/h+UxLzcJUhixwMzThbscydxrGATfaJlQ0ZJD4 Kh6uLe+IkMOsYVQNsw4lVMQeeOv9Vot25sRMpHYbM17dnMZlkw1fZobNHzmkqbFGmIWb +OoH20eo+MuU+UgjWZfUzmQij4WeZt2nbhaediLfR6yERG+1KmKJyNZqZo9h/BnnROG0 haxA== X-Gm-Message-State: ACrzQf2QwGeaW3KEqfOkzP4qIpiFK2c3oawJjjEWPSad1TO2TkrkBBaW l0MY55X9D0LG6fPQ48RGYm1bEw== X-Google-Smtp-Source: AMsMyM7KuU6xe7NQDV5szGuiS31kW6dXUoLdm/yheN9AkDu6oqCFrCQ0hZzDXnCfzeNWmENNvsV+MA== X-Received: by 2002:a05:600c:4e0a:b0:3b4:91fe:80e3 with SMTP id b10-20020a05600c4e0a00b003b491fe80e3mr6449775wmq.91.1663776495707; Wed, 21 Sep 2022 09:08:15 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, Richard Henderson , Damien Hedde , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v1 06/10] plugins: Assert mmu_idx in range before use in qemu_plugin_get_hwaddr Date: Wed, 21 Sep 2022 17:07:57 +0100 Message-Id: <20220921160801.1490125-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663777774450100001 From: Richard Henderson Coverity reports out-of-bound accesses here. This should be a false positive due to how the index is decoded from MemOpIdx. Fixes: Coverity CID 1487201 Signed-off-by: Richard Henderson Reviewed-by: Damien Hedde Message-Id: <20220401190233.329360-1-richard.henderson@linaro.org> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- plugins/api.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/api.c b/plugins/api.c index 7bf71b189d..2078b16edb 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -289,6 +289,8 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_= plugin_meminfo_t info, enum qemu_plugin_mem_rw rw =3D get_plugin_meminfo_rw(info); hwaddr_info.is_store =3D (rw & QEMU_PLUGIN_MEM_W) !=3D 0; =20 + assert(mmu_idx < NB_MMU_MODES); + if (!tlb_plugin_lookup(cpu, vaddr, mmu_idx, hwaddr_info.is_store, &hwaddr_info)) { error_report("invalid use of qemu_plugin_get_hwaddr"); --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663777840; cv=none; d=zohomail.com; s=zohoarc; b=PgSLBlzdbzg4VOSL0DRPz2DoNeKTVNMvhcRaHNVRVMxOAfIolb8fh/euyA9isQkuEuHUPOao9Mxg0jznwgEGL37vZnXVPzuiTmLIP0ihCEI+syXeXeD5J3zXrU9AkmBjzZMI5PYyPFoSUor0KTAJuakZb1l329yg6DDY6m1J5C0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663777840; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OfFvYONTn8YFltPiyuXy+wM30XdQW8jQu5P1PJa3mLM=; b=MdBoxLjV4Td5+28CjTScL/XyRYnRGv7WNL1HVQjaEb8zH5vGaU+gIi8Ukd0FYxXWMAbxOHyaNEenhi6fPPWC4c58xK2J15zHwnOWjnjhq82LrZx0HCqQTCCMymMgDab4X1IRHxJIchnLChzOGdvnOL/7buAk3Al+QlcDyNyVfzg= 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 1663777840539639.9798380531179; Wed, 21 Sep 2022 09:30:40 -0700 (PDT) Received: from localhost ([::1]:37554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2cR-0004Uc-E0 for importer@patchew.org; Wed, 21 Sep 2022 12:30:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gr-0003U8-2N for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:23 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:46908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gp-0000c9-0l for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:20 -0400 Received: by mail-wr1-x42f.google.com with SMTP id g3so10617389wrq.13 for ; Wed, 21 Sep 2022 09:08:18 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id f4-20020a1cc904000000b003a5c7a942edsm3224847wmb.28.2022.09.21.09.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CD9321FFBF; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OfFvYONTn8YFltPiyuXy+wM30XdQW8jQu5P1PJa3mLM=; b=C0L2FrhWZ6mFlKL4eo4kX3F/iuqpx0X/BfSKyXRAStIb/aituXdAN4C4vbOYUfxMfA A41duVDmOfaghLZq1/p1qcWc/4hVQNJSn/c2FiUwqpv38Qa+sC3e6h4lhCqgKgVHLpJg x2y5025B5lSGWMN2MCDNr23lMIQUay7QuBgNjQpM7bC38jxWVqFjE9freKXMg48k5n+h pf2wFAmgQWU1+YlThBmr+qPjpjqjP0KIGt2X8UNqu5TYiIc0GBI6d9dzRpQ0h9GFE2vS HBChE3X17eVdZb/6wllceq39qQTZEFxlf9c5rOSm0DJCMx5cIb+Vojffjx8sVI3YTd+v HR/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=OfFvYONTn8YFltPiyuXy+wM30XdQW8jQu5P1PJa3mLM=; b=FkokS09aUyjfZxx0alnG/w5NonR1XUiHSWKH2UIUkIgdoG+wDbDkrgqskn8I2S2U58 mm6L7dE7VepPNRyOROvi66+qwV1c4LxSqZc9Pmj8aotGPKHAHSSoMO/xMdBGKJlg1rnK X7ZLIYsQEoTF616hEn6DU/jc91ltz82X+3sR0OBN+jBiR+5wX3XsXFZTeGFSxptcQjfc Pu67Sa3L3MhDTpR10UJjaDbNvyUc5JHxOPfnLdzWnLtqH3zrH+IJBGDuYYECGYCk2PBr U60b7RqFIXkOgAM6LImM4q17lMkN2bvalwvV5xpClElKc70h8vEozvGdsGlso1TqxZ/W XhLg== X-Gm-Message-State: ACrzQf3R27NENs3FN3iWrBGMlOq8ZeOs6Kmy1JFaBNyouKnlUB5gniry N5Im2IVRikOQU6HKxcABXyjfOA== X-Google-Smtp-Source: AMsMyM69LVtlV+rVmjcYIsrOhVJf7tyK4IT1Uj1dr5DD7wDmB1BElFuhC+fzUX/aa2l4ojbPoMw+mw== X-Received: by 2002:adf:eb84:0:b0:22a:917e:1c20 with SMTP id t4-20020adfeb84000000b0022a917e1c20mr17526363wrn.223.1663776498092; Wed, 21 Sep 2022 09:08:18 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v1 07/10] docs/devel: clean-up qemu invocations in tcg-plugins Date: Wed, 21 Sep 2022 17:07:58 +0100 Message-Id: <20220921160801.1490125-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663777842850100001 We currently have the final binaries in the root of the build dir so the build prefix is superfluous. Additionally add a shell prompt to be more in line with the rest of the code. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/tcg-plugins.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index a503d44cee..a6fdde01f8 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -172,7 +172,7 @@ slightly faster (but not thread safe) counters. =20 Example:: =20 - ./aarch64-linux-user/qemu-aarch64 \ + $ qemu-aarch64 \ -plugin contrib/plugins/libhotblocks.so -d plugin \ ./tests/tcg/aarch64-linux-user/sha1 SHA1=3D15dd99a1991e0b3826fede3deffc1feba42278e6 @@ -186,7 +186,7 @@ Example:: =20 Similar to hotblocks but this time tracks memory accesses:: =20 - ./aarch64-linux-user/qemu-aarch64 \ + $ qemu-aarch64 \ -plugin contrib/plugins/libhotpages.so -d plugin \ ./tests/tcg/aarch64-linux-user/sha1 SHA1=3D15dd99a1991e0b3826fede3deffc1feba42278e6 @@ -220,7 +220,7 @@ counted. You can give a value to the ``count`` argument= for a class of instructions to break it down fully, so for example to see all the system registers accesses:: =20 - ./aarch64-softmmu/qemu-system-aarch64 $(QEMU_ARGS) \ + $ qemu-system-aarch64 $(QEMU_ARGS) \ -append "root=3D/dev/sda2 systemd.unit=3Dbenchmark.service" \ -smp 4 -plugin ./contrib/plugins/libhowvec.so,count=3Dsreg -d plugin =20 @@ -288,10 +288,10 @@ for the plugin is a path for the socket the two insta= nces will communicate over:: =20 =20 - ./sparc-softmmu/qemu-system-sparc -monitor none -parallel none \ + $ qemu-system-sparc -monitor none -parallel none \ -net none -M SS-20 -m 256 -kernel day11/zImage.elf \ -plugin ./contrib/plugins/liblockstep.so,sockpath=3Dlockstep-sparc.soc= k \ - -d plugin,nochain + -d plugin,nochain =20 which will eventually report:: =20 @@ -348,7 +348,7 @@ Please be aware that this will generate a lot of output. =20 The plugin needs default argument:: =20 - qemu-system-arm $(QEMU_ARGS) \ + $ qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so -d plugin =20 which will output an execution trace following this structure:: @@ -365,10 +365,10 @@ which will output an execution trace following this s= tructure:: 0, 0x10c8, 0xfff96c43, "ldr r3, [r0, #0x44]", load, 0x200000e4, RAM =20 the output can be filtered to only track certain instructions or -addresses using the `ifilter` or `afilter` options. You can stack the +addresses using the ``ifilter`` or ``afilter`` options. You can stack the arguments if required:: =20 - qemu-system-arm $(QEMU_ARGS) \ + $ qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so,ifilter=3Dst1w,afilter=3D0x400= 01808 -d plugin =20 - contrib/plugins/cache.c @@ -377,7 +377,7 @@ Cache modelling plugin that measures the performance of= a given L1 cache configuration, and optionally a unified L2 per-core cache when a given wor= king set is run:: =20 - qemu-x86_64 -plugin ./contrib/plugins/libcache.so \ + $ qemu-x86_64 -plugin ./contrib/plugins/libcache.so \ -d plugin -D cache.log ./tests/tcg/x86_64-linux-user/float_convs =20 will report the following:: --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663777497; cv=none; d=zohomail.com; s=zohoarc; b=KPXy/6XbZNtSyyv6y0BlCw27jjWcKmQMn8YXFUb+aem36DzhWhfdOS84S3KSohUFmF9YX6sek7KpTWwwaAlre/1UUnIVQpAi1OIQ393IDbUhCr8ND4OZz7IEu8X4BO0dPQ2/keB0H3BK7ImR8Ind6v3sut+hz3HGMELM7mYDKxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663777497; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iHHyl8AojnEq14+3x1kjoY7otQgZX0hgTY1qjaFy320=; b=ajbBElS0hhGFlW9ue7L3BmYTqA0k6G5kWdKUiL0f7nun3lezqSws1u6EoXF8ri9SVlndn52mOKpjbCmA5JgxElv1HCL0hJ861W4JiF7QfU6py0Xrb4PDCKRtiFLrL54u3menUWXBE8JXDnfyykSfD3kR8A4Xcik8nb4Rg3sGrKs= 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 166377749773361.46476327423841; Wed, 21 Sep 2022 09:24:57 -0700 (PDT) Received: from localhost ([::1]:32778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2Wu-0007Ah-EU for importer@patchew.org; Wed, 21 Sep 2022 12:24:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gq-0003Ts-L1 for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:20 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:37735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Go-0000e3-NT for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:20 -0400 Received: by mail-wr1-x429.google.com with SMTP id bq9so10701321wrb.4 for ; Wed, 21 Sep 2022 09:08:18 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id j3-20020a05600c300300b003b4868eb6bbsm3675523wmh.23.2022.09.21.09.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E3B041FFC0; Wed, 21 Sep 2022 17:08:01 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=iHHyl8AojnEq14+3x1kjoY7otQgZX0hgTY1qjaFy320=; b=DgjEppD2lwo1KBT/JmrbtWMHe24x3FEtWiueAYDoEq3edddOgwN+lsD7HdBvFnKUiw dFtkt1TSBzLcHff6bd1ub8OUfL2gptjE+tXJUrX+D4F/tmOjO4NxDl4BFKNTEqCiF+uU a5QEXSWKFjjl26XSEyDF4iNtJqVOQ1vC5O8q+LufzUCjDMO6/rpB8PPXrB/h9hTRLdtS vU+P5XI2ZAgBVi5TbbYifBVxl5DUpdIf3ESx+F1gxiCjZbDhqFs9WLBModyrFJ88MppS YnzVmAZsCnny4OdNv6aTt6OomgacMZBHkCzQrwL7f1VvVCcMQ5PtWBdyWhlOXoF1V1mU 5FkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=iHHyl8AojnEq14+3x1kjoY7otQgZX0hgTY1qjaFy320=; b=VA8PkrffaN5tht2fjmAEEyF/osug5f/tPvpmQD0rYT39wDRuz2Zm84nCUJIB0GyJZY K+ipJKAO1QnVw4CWKA8mIvUJ6YlcM8ZMGzLdGqAHEkrwtSvqVvCZoGuYprPc/4zEML2c E5+5AvUVV1JcR//tjU0LkdZF+2q/EivfiBfBTPOhGrXyrl64DnHM8emsnWvGSEQHPhS5 csA9sv5by4mmGWcOjUdTMctvJskQQ47WMYr8/i6OR/pSrjmztuevVvLGznRZ3UDmA5Oy aWoguiSKz7r2Zb+nP6ORxElmMJk1VBbKFkyl7li1bQhOZaTFQkCrlpPBILPmvASBwqJC hGDQ== X-Gm-Message-State: ACrzQf1lHeRL+gxdGK+KH/bVwh521SsJZ1x9lWRhkquAXJI9oo1OgmQF sFbspbqAcRRHNnq8Q3P0Nz/08A== X-Google-Smtp-Source: AMsMyM44+Xh/j6yRqnSUs28g0/T3j6kN/0MgJlWh/GTgpEwQyUVPfzJq2QvuhxIMLT3mlSgju58mDA== X-Received: by 2002:a05:6000:14c:b0:22a:c14a:29f8 with SMTP id r12-20020a056000014c00b0022ac14a29f8mr17631312wrx.588.1663776497802; Wed, 21 Sep 2022 09:08:17 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v1 08/10] docs/devel: move API to end of tcg-plugins.rst Date: Wed, 21 Sep 2022 17:07:59 +0100 Message-Id: <20220921160801.1490125-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663777500218100001 The API documentation is quite dry and doesn't flow nicely with the rest of the document. Move it to its own section at the bottom along with a little leader text to remind people to update it. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/tcg-plugins.rst | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index a6fdde01f8..8b40b2a606 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -110,11 +110,6 @@ details are opaque to plugins. The plugin is able to q= uery select details of instructions and system configuration only through the exported *qemu_plugin* functions. =20 -API -~~~ - -.. kernel-doc:: include/qemu/qemu-plugin.h - Internals --------- =20 @@ -448,3 +443,13 @@ The plugin has a number of arguments, all of them are = optional: associativity of the L2 cache, respectively. Setting any of the L2 configuration arguments implies ``l2=3Don``. (default: N =3D 2097152 (2MB), B =3D 64, A =3D 16) + +API +--- + +The following API is generated from the inline documentation in +``include/qemu/qemu-plugin.h``. Please ensure any updates to the API +include the full kernel-doc annotations. + +.. kernel-doc:: include/qemu/qemu-plugin.h + --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663778695; cv=none; d=zohomail.com; s=zohoarc; b=RV3HFjLFh2yAT2Zyn6gEvMmHzWdfcjrHwUQYU6o82jp1hVHxpOrAN4P1qYgwDCujp75qo49TEyJq82MiMb30wcKQe/xBuerxcyVcyhsz3SOfNWECFHh2po/upuX3jcEYkHZxfcOS28kR5PoK08ZrB1L0HM0QKQU6Ovm3/xBeR7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663778695; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zs6if3JsrgpCg8dSorFuiYuQlfRV6HSFVzcfBOEUknM=; b=kDMFxVxRe8zZJ36w2sBF5jW3urJlNtph+wtUXmwRGR7dNzAYlk3mmJMr0JkkhwLkmGumFq5MATwWTMiD/hpjObeEAjAPtVyA5qx9f1HvJbeQugY+Kgez3JEwZbJSi4MlT2DHU1ej0gaT76gOsO3vzhYxgCkXs3LXOD2X8DmihlM= 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 1663778695355995.1102020986925; Wed, 21 Sep 2022 09:44:55 -0700 (PDT) Received: from localhost ([::1]:35264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2qD-0007iO-Pj for importer@patchew.org; Wed, 21 Sep 2022 12:44:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2ND-000740-Hw for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:14:55 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:44828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2NB-0001Va-OZ for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:14:55 -0400 Received: by mail-wr1-x429.google.com with SMTP id c11so10667356wrp.11 for ; Wed, 21 Sep 2022 09:14:53 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id q63-20020a1c4342000000b003b4bd18a23bsm3218113wma.12.2022.09.21.09.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:14:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 04F121FFC1; Wed, 21 Sep 2022 17:08:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=zs6if3JsrgpCg8dSorFuiYuQlfRV6HSFVzcfBOEUknM=; b=tBSaZXCHyL0X04o1b89r/sLIPcBvPkr2w01jT2oe9V7TTqQy9BHGCmNmtdgSs0AXsC T9bINdrmnGZ+mkMzznBZnAIgdxeeI2iqWvJTNIRpQltLMnSkn+6zK6610r5wvPlaypVM sQro1bKETDsae2m8+Fyu5x+siStPyYF+0G1fK6JCV4/9vlmQoo5aukU8uCu7CaWg5lNH LBz3X+O3zVHMMM31zPqskcXRtXt/o6Q/iY+pSxjiA7HOujQ0fwZQTHKsvOMIpK8I3vw1 NZ/FCuWxjKyvvgUw0+GifXs3kl0STEn6v5nb8nKxBEUY6gW6XdJ1t7u9SHcA45JCDzSm 8Ugw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=zs6if3JsrgpCg8dSorFuiYuQlfRV6HSFVzcfBOEUknM=; b=fL/fNjNE9XsltlUlySzWwWL8dCH1g9iP7wQaFab5vTdI2nhFdtj2os5kp55jOLbnG4 lB2SpAWQbStBEbfCGks/dqmK7Ry/GjsbqgzWNR1XZoLsNX+QybhVObWjx2yvb/ysyN7L 4BoSE8qsc83V3WFDeBy15gYW5ZMql5NHbaN2X7Gqi1YU5F/Ezv8wBamcIx7oKck8VjyZ AIo/Q6Y2+ffwu53eCoKcO6Bo95mAMzDPdcp4cFbitTZUThUMLzSKuzvbicaJIj4lO3Fw YBJFxec33t+AfEVA2fOctnRaH4IPBjiSfA9Geu0UJq+OEIi88NR/IJ9NAROMKmgW9z99 3btA== X-Gm-Message-State: ACrzQf2/UWRHx7bMLcgRdwtQBvmWvSL/VobO+/AQQL0z6CQXJcxUF/as 9OIiM9u4+0EfxJKTdXX8heYJXQ== X-Google-Smtp-Source: AMsMyM7PhvOqlA7muc8FKwfRm0KNnnmscgHRXtZBD5GBCG42+BbrfQiWPBVJfJ5yZA0N8M7AbYg0Tw== X-Received: by 2002:a5d:59a9:0:b0:22b:e6a:4796 with SMTP id p9-20020a5d59a9000000b0022b0e6a4796mr6907197wrr.47.1663776892207; Wed, 21 Sep 2022 09:14:52 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v1 09/10] contrib/plugins: reset skip when matching in execlog Date: Wed, 21 Sep 2022 17:08:00 +0100 Message-Id: <20220921160801.1490125-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663778696919100001 The purpose of the matches was to only track the execution of instructions we care about. Without resetting skip to the value at the start of the block we end up dumping all instructions after the match with the consequent load on the instrumentation. Signed-off-by: Alex Benn=C3=A9e Cc: Alexandre Iooss Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- contrib/plugins/execlog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index e659ac9cbb..b5360f2c8e 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -147,6 +147,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) /* Register callback on instruction */ qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS,= output); + + /* reset skip */ + skip =3D (imatches || amatches) ? true : false; } =20 } --=20 2.34.1 From nobody Wed Apr 24 23:25:27 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=1663778231; cv=none; d=zohomail.com; s=zohoarc; b=j0p3FXogMCHP9hm38oXYJ3rBteBhXVtUg7t9oQEC9ZjySiel/4X6HE5qcUdaXDbsS3Ur5Mh3mEE/0J2MM8UUQrk/OT5Y/JgcrvLE5MA8JZZNiXU50Vke13ZOIs5nZMotXIfkkOKYMRm1M4VOFqgfYK2P3rkfuNjZF1aPpxnQTXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663778231; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GoEs9/h2LLepKNbeRIHGFuvJURS7q8MKK6QKHpul0xk=; b=Cz5whV3TkzqUo9BKUmWnsf0XgN4vaF3kgySRnUp39/YfzzsJu++MPXQ6hbwchAEU4ZwvAx16FsA2y2nrnpfAh86qhHotZ/2AK8A+pivCHa91u4vu8cM0DzWL+faGsgTGopgudHBHMMmFRKPGJ+REPoZDh0kT5DI7XbnaGcxrqNw= 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 1663778231180193.3143132070894; Wed, 21 Sep 2022 09:37:11 -0700 (PDT) Received: from localhost ([::1]:36994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2ij-0007ln-Gx for importer@patchew.org; Wed, 21 Sep 2022 12:37:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2ND-000758-O2 for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:14:55 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:33458) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2NB-0001VY-Ob for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:14:55 -0400 Received: by mail-wm1-x333.google.com with SMTP id ay7-20020a05600c1e0700b003b49861bf48so2720735wmb.0 for ; Wed, 21 Sep 2022 09:14:53 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id bu23-20020a056000079700b0022a3a887ceasm2889808wrb.49.2022.09.21.09.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:14:51 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1B8EF1FFC2; Wed, 21 Sep 2022 17:08:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=GoEs9/h2LLepKNbeRIHGFuvJURS7q8MKK6QKHpul0xk=; b=JyKI51tvaaRmGJEvtwLZkNMg1pNweSuN79tWCjShG5iLTQEZRlc3Nzz6/1ehh16kmw ri3VdHTqBd/yRwL1JlMKwS8WfJsMHAgOGmM9n7kzZ1SGSw8bfMgZuZo7kSYeY9tplrdu XhhyUqxJRI2tcmniWNmeJXTCF2P7C1fL3YEnnPXpiBR3/fJe3JaX2GZx9/DxW/2iP8JU m84gDp99s54rFN7PpyFREuzbzop9lCset84v2X1Rwvyw+7HaMhxbV+Z32IvD8Ch3Y0BV rRypTxRN1i+4pyoSnwZZI3ktd4MMoNH7qDg+yNYPHOR4dcYg3ULSlfz+4Me9R4HIpdqu Yzgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=GoEs9/h2LLepKNbeRIHGFuvJURS7q8MKK6QKHpul0xk=; b=D9z9jp+5PtEOqfR6BjUxs7s8Ms0R7KbMC0uBAjCvN2qTAcKD7q230AtX2TqlWgRK9Q i+71m9T9F/iresKdnsc85mJTCa6UZH6Y2mFiF+2b4LvuMM9NJ6C2U5gbmURPSM94T8Us A49o709Mhb5AKiLX0QRZRSURPSvNoBA70cucgFyrjycdBN5N4uFv4LEglApf14miRy2/ 64oCLffCKmI3gy8mMmUdsMlZTE3nKqD5jDiTuwoWe4e02+qPo3pXN5c4MUUjdrLERzUQ zlli75fwhHpcgDdLPcm8bhbo/C2OG+tvFOMXsFqkqs1rQyFPvApnXsOFlN6zSOpA0yGY hb6w== X-Gm-Message-State: ACrzQf3x8VjmvvHNJQKfeFqc9RpKVISKlJz97cpSk5yZfxkZ2YaIimzK VswuMmQTDkVUUx1C30ijT1KQdg== X-Google-Smtp-Source: AMsMyM6kYJVDJTUx48OQtp4d3cM83SM9P21pcTTKIyEAOGspuz70GJJkne483hjjuvE9efftWuW18A== X-Received: by 2002:a05:600c:4ec7:b0:3a8:4622:ad27 with SMTP id g7-20020a05600c4ec700b003a84622ad27mr6786719wmq.88.1663776891802; Wed, 21 Sep 2022 09:14:51 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v1 10/10] docs/devel: document the test plugins Date: Wed, 21 Sep 2022 17:08:01 +0100 Message-Id: <20220921160801.1490125-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-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::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1663778233383100001 Although the test plugins are fairly basic they are still useful for some things so we should document their existence. Signed-off-by: Alex Benn=C3=A9e --- docs/devel/tcg-plugins.rst | 137 +++++++++++++++++++++++++++++++++++-- 1 file changed, 133 insertions(+), 4 deletions(-) diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 8b40b2a606..9740a70406 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -145,12 +145,141 @@ Example Plugins =20 There are a number of plugins included with QEMU and you are encouraged to contribute your own plugins plugins upstream. There is a -``contrib/plugins`` directory where they can go. +``contrib/plugins`` directory where they can go. There are also some +basic plugins that are used to test and exercise the API during the +``make check-tcg`` target in ``tests\plugins``. =20 -- tests/plugins +- tests/plugins/empty.c =20 -These are some basic plugins that are used to test and exercise the -API during the ``make check-tcg`` target. +Purely a test plugin for measuring the overhead of the plugins system +itself. Does no instrumentation. + +- tests/plugins/bb.c + +A very basic plugin which will measure execution in course terms as +each basic block is executed. By default the results are shown once +execution finishes:: + + $ qemu-aarch64 -plugin tests/plugin/libbb.so \ + -d plugin ./tests/tcg/aarch64-linux-user/sha1 + SHA1=3D15dd99a1991e0b3826fede3deffc1feba42278e6 + bb's: 2277338, insns: 158483046 + +Behaviour can be tweaked with the following arguments: + + * inline=3Dtrue|false + + Use faster inline addition of a single counter. Not per-cpu and not + thread safe. + + * idle=3Dtrue|false + + Dump the current execution stats whenever the guest vCPU idles + +- tests/plugins/insn.c + +This is a basic instruction level instrumentation which can count the +number of instructions executed on each core/thread:: + + $ qemu-aarch64 -plugin tests/plugin/libinsn.so \ + -d plugin ./tests/tcg/aarch64-linux-user/threadcount + Created 10 threads + Done + cpu 0 insns: 46765 + cpu 1 insns: 3694 + cpu 2 insns: 3694 + cpu 3 insns: 2994 + cpu 4 insns: 1497 + cpu 5 insns: 1497 + cpu 6 insns: 1497 + cpu 7 insns: 1497 + total insns: 63135 + +Behaviour can be tweaked with the following arguments: + + * inline=3Dtrue|false + + Use faster inline addition of a single counter. Not per-cpu and not + thread safe. + + * sizes=3Dtrue|false + + Give a summary of the instruction sizes for the execution + + * match=3D + + Only instrument instructions matching the string prefix. Will show + some basic stats including how many instructions have executed since + the last execution. For example:: + + $ qemu-aarch64 -plugin tests/plugin/libinsn.so,match=3Dbl \ + -d plugin ./tests/tcg/aarch64-linux-user/sha512-vector + ... + 0x40069c, 'bl #0x4002b0', 10 hits, 1093 match hits, =CE=94+1257 since l= ast match, 98 avg insns/match + 0x4006ac, 'bl #0x403690', 10 hits, 1094 match hits, =CE=94+47 since las= t match, 98 avg insns/match=20 + 0x4037fc, 'bl #0x4002b0', 18 hits, 1095 match hits, =CE=94+22 since las= t match, 98 avg insns/match=20 + 0x400720, 'bl #0x403690', 10 hits, 1096 match hits, =CE=94+58 since las= t match, 98 avg insns/match=20 + 0x4037fc, 'bl #0x4002b0', 19 hits, 1097 match hits, =CE=94+22 since las= t match, 98 avg insns/match=20 + 0x400730, 'bl #0x403690', 10 hits, 1098 match hits, =CE=94+33 since las= t match, 98 avg insns/match=20 + 0x4037ac, 'bl #0x4002b0', 12 hits, 1099 match hits, =CE=94+20 since las= t match, 98 avg insns/match=20 + ... + +For more detailed execution tracing see the ``execlog`` plugin for +other options. + +- tests/plugins/mem.c + +Basic instruction level memory instrumentation:: + + $ qemu-aarch64 -plugin tests/plugin/libmem.so,inline=3Dtrue \ + -d plugin ./tests/tcg/aarch64-linux-user/sha1 + SHA1=3D15dd99a1991e0b3826fede3deffc1feba42278e6 + inline mem accesses: 79525013 + +Behaviour can be tweaked with the following arguments: + + * inline=3Dtrue|false + + Use faster inline addition of a single counter. Not per-cpu and not + thread safe. + + * callback=3Dtrue|false + + Use callbacks on each memory instrumentation. + + * hwaddr=3Dtrue|false + + Count IO accesses (only for system emulation) + +- tests/plugins/syscall.c + +A basic syscall tracing plugin. This only works for user-mode. By +default it will give a summary of syscall stats at the end of the +run:: + + $ qemu-aarch64 -plugin tests/plugin/libsyscall \ + -d plugin ./tests/tcg/aarch64-linux-user/threadcount + Created 10 threads + Done + syscall no. calls errors + 226 12 0 + 99 11 11 + 115 11 0 + 222 11 0 + 93 10 0 + 220 10 0 + 233 10 0 + 215 8 0 + 214 4 0 + 134 2 0 + 64 2 0 + 96 1 0 + 94 1 0 + 80 1 0 + 261 1 0 + 78 1 0 + 160 1 0 + 135 1 0 =20 - contrib/plugins/hotblocks.c =20 --=20 2.34.1