From patchwork Wed Sep 21 16:07:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607955 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2479387pvb; Wed, 21 Sep 2022 09:13:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jmhlX9XgiLteBDjKh1tbLBH322nTsEx1OMJ2I9NvIjAPTwXdAhnZMtO5sFy8Dt3Xrcbam X-Received: by 2002:a05:622a:4d2:b0:35c:ffc8:93a5 with SMTP id q18-20020a05622a04d200b0035cffc893a5mr5982694qtx.426.1663776791521; Wed, 21 Sep 2022 09:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663776791; cv=none; d=google.com; s=arc-20160816; b=cA0+/HGBakkdF5TdlG5F4eupTH+O+lEpe7dcydJsdwmigvVV0wBjbwDzDERSRoZtDO SroIBu1agiBqhgH5fsg5+aoSB4bSyyqbaYaPSnmpIG0xI7bQ7uSoG5H1PUQ4eW3odrha kngmnQ+TYkyshpYiNf4nTRLXdw4P9ScO6XWTim3YNouUEbsD8QmkWIm1iKfw7Kb2gBvr yyQzvuXDMec1a8HQtl3xBFffP0tM9YBzWwzsq6e8yMeDr6fvwoo5HAUggqILCUToUybr /tf5KofpILH9ddkUKrzV+uzs2ySahCPK0kDErqSpgS13RYSiFPEKEq/3Yw/3fkkSfyon 4Ugg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kZCyr3Lyk7RSQMb91zeKViaNh3D4Z14FgGZeAQDXqfA=; b=TA8Yj6CZvSyA14aXYOCoSRvt8qr7ymU4fyatZFIWtTeSbeuUbjC0Guc3GQ5JHRrfOf YSEt2jP3Mk2Gkpx1GjLDM3yuglnB3doJHbEs3k/c3jgIbY7hiBe0FVvTDHb9iZMHXk1/ Kxbz8DMvdzcPOUQCzfXIFRnDRc4CpIx8ozPeXJPoL3dbOgc7GpL0dycxJuNUXiQxIMsZ ZCdKmmlMcY3SCyADJw4IgZZrpdYztK376lTozGleJLjRd5Xc0Tkafat3A3ZqUakkAJ8I Girl4JE6EZ8/OU+qs7AyorAUIWHRVGHUL+pJNHYJ87AAXL+CqmA3f+l0IKnHhxJ7dPvy x9LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nFovbVLe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gm7-20020a056214268700b0047962d5ee41si2057673qvb.20.2022.09.21.09.13.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:13:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nFovbVLe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2LX-00022X-0w for patch@linaro.org; Wed, 21 Sep 2022 12:13:11 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster Reviewed-by: Kevin Wolf --- 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-monitor-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" HMP command:: if (hmp_handle_error(mon, err)) { return; } - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } 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); +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; extern HMPCommand hmp_cmds[]; -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 == inserted); 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->node_name - : info && info->has_qdev ? info->qdev - : ""); + monitor_puts(mon, + inserted && inserted->has_node_name ? inserted->node_name + : info && info->has_qdev ? info->qdev + : ""); } 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); } static const MemoryRegionOps mos6522_ops = { 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 PciDeviceInfo *dev) monitor_printf(mon, " "); 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 == 10 && value->exponent >= -18 && value->exponent <= 18 && value->exponent % 3 == 0) { - monitor_printf(mon, "%s", si_prefix(value->exponent)); + monitor_puts(mon, si_prefix(value->exponent)); } else if (unit && value->base == 2 && value->exponent >= 0 && value->exponent <= 60 && value->exponent % 10 == 0) { - 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, StatsSchemaValue *value) } if (value->has_unit) { - monitor_printf(mon, "%s", unit ? unit : StatsUnit_str(value->unit)); + monitor_puts(mon, unit ? unit : StatsUnit_str(value->unit)); } /* 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; } - monitor_printf(mon, "%s", info->human_readable_text); + monitor_puts(mon, info->human_readable_text); } 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; From patchwork Wed Sep 21 16:07:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607959 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2487540pvb; Wed, 21 Sep 2022 09:27:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EnAWg3XeOXPWZVTi+I2wUP+658JH9YYgPWZOaSLCOHMuc3RsiMhrocbjpzJArXXT5lC4e X-Received: by 2002:a05:6214:daf:b0:49f:5ce8:e628 with SMTP id h15-20020a0562140daf00b0049f5ce8e628mr23850168qvh.115.1663777642320; Wed, 21 Sep 2022 09:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777642; cv=none; d=google.com; s=arc-20160816; b=IDifIfydeJzAeMqf9RywJ+NUrEZTDS3iSzSe0a93xfeUxE7gdi+ATton59Sc2DSuYV NXlLP5oUS1sN6gaAqplNJ/HZ+hBTuX4Rg5hUnrSgA2sJCDLqmMKWXyZNzD29F/Mw2uyP nU0L8ABv7jRcUHZT5RV03Fgzg6dqV3KBA9GczFpGYfKOhKEN8L2AGo9PRCAgHWClZeyG p6avXE+FbfCwPBtHO+Cn1Vtk0OHu4xk7F3DUYcoIgsm4fHcoo8Wz/NQc8AEikAD9cg2h siGMpfayqBlYr8OEYLH9I0U66meARHh7zKixMYj8KRYH53T3dRnCoTXA1bOckaVtmG8k nOsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uLb+n5aqjLubd88rD9ajb7yNM+TT8WZpmI3dXPveZoM=; b=XLJvRSOhLEKdguUd7ZOJ22WiMvUauawLcOCpDzMGoH60k1FtOXwu+QrHJ0fMoi+sGO Tw4RBYLR7CGR1zhriAMqvhr1ieclDAoG3dRzStRmPo1uL09IUzo83GhNrM74YlmEKVU1 Bzxphr8v5V7Sfk+Zom4WkaaYSDGJHTOtgeJYSUHx49KhE9Gym7Jeymg22RwYX36WNctw IY8z3LvWEOAt2rluQHv6vqTZgk4uFp5SkQWfVSM0Bu9djF/2wGR32Mmn/wnK4GCQ4gqR IHnHCcBsSbm6g7JSdHAt6O2z4KEClpd9dGBqM3e8Ut1vKpE2hDZAdHVsIdQaVK/KBjyP ADAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=INOypRfR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q10-20020ac8734a000000b00342f2052170si1450621qtp.661.2022.09.21.09.27.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:27:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=INOypRfR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2ZF-0008Nx-T2 for patch@linaro.org; Wed, 21 Sep 2022 12:27:21 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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_ulong code, } } -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 = (GString *)stream; @@ -270,7 +270,7 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size) GString *ds = g_string_new(NULL); initialize_debug_target(&s, cpu); - s.info.fprintf_func = plugin_printf; + s.info.fprintf_func = gstring_printf; s.info.stream = (FILE *)ds; /* abuse this slot */ s.info.buffer_vma = addr; s.info.buffer_length = size; @@ -358,15 +358,19 @@ void monitor_disas(Monitor *mon, CPUState *cpu, { int count, i; CPUDebug s; + g_autoptr(GString) ds = g_string_new(""); initialize_debug_target(&s, cpu); - s.info.fprintf_func = qemu_fprintf; + s.info.fprintf_func = gstring_printf; + s.info.stream = (FILE *)ds; /* abuse this slot */ + if (is_physical) { s.info.read_memory_func = physical_read_memory; } s.info.buffer_vma = pc; if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) { + monitor_puts(mon, ds->str); return; } @@ -376,13 +380,16 @@ void monitor_disas(Monitor *mon, CPUState *cpu, return; } - for(i = 0; i < nb_insn; i++) { - monitor_printf(mon, "0x" TARGET_FMT_lx ": ", pc); + for (i = 0; i < nb_insn; i++) { + g_string_append_printf(ds, "0x" TARGET_FMT_lx ": ", pc); count = 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 += count; } + + monitor_puts(mon, ds->str); } #endif From patchwork Wed Sep 21 16:07:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607956 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2482104pvb; Wed, 21 Sep 2022 09:17:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xU7rfX8pO4h7iceM52QKWLJEjUEw7g+kpZcuTpGKX9wdya5vwmJQ5jjBTfQbDVgx9dptA X-Received: by 2002:a05:620a:4089:b0:6ce:2d15:5487 with SMTP id f9-20020a05620a408900b006ce2d155487mr20185531qko.464.1663777058270; Wed, 21 Sep 2022 09:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777058; cv=none; d=google.com; s=arc-20160816; b=xMB5ieVaNxlK4cg9uK1y6zTWvyP8z/Gtf/g5ySJKFHJpJxu3fQgU2O4Lb3LfFFOOaZ bC9qRJxteebdaYgTDLmmXu5Hm5tMj4aVDbwnn8dRKzpzffFNvjPeXRSogxyoiRuOHAeC XjqRQY+ZEivGLNM8aOgv1NdteuC6dL1ZNgS9RwQXsXSGtmgLajDA8I7acinMJh04muJ5 LKWxvOl0+Y73ATA6wE/+FHZgEMwbjaLiR3Zp/kokpis3VmKdgGBhEefoWW7V9/1I2vsj DQOcVIUpgeGFmCLzR2Wr1TJ4c1TshLktJ5w7HuMTs/D9CgfZSI2JecXbvbKDBCRdHjMD l7Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AqWJ7kyP/wVtcUkYapts2DpsBXihq1Vm9sATGZkmD9k=; b=xYuOuo1KNgx535EV4ltk79dQDoCApwXg7xuIDw1lTglBSOIAKJGr+6x/2iT3c0kOad RthMBhapkcxSgdeCTvLkyiGdv0uQtbJ9zEghGnB41YMmjEDOsE08jMjGprsjYrAavnia zJwCjXb3yFKjnHDVFjHM+rhR8B4hUp83bHkYEQF3DPc4+BoTtwmXqalVPkkuwN+CCRZj QLU6CJu87Z3mfcWOUVnamCX95ash1tulvkyHvQ3J6v3M+QVmWLl9U5yWD4GYv/VAeyKw VUBq3QJYNKFXtTl9CeURczOhdedmRwJ6mvR85wFmwHqZ768WAEiF3Vl3Fv0ovOb43pdd 9McA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=prG89gNn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jp9-20020ad45f89000000b004ad7ae9a5a7si39981qvb.371.2022.09.21.09.17.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:17:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=prG89gNn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2Pp-0007st-My for patch@linaro.org; Wed, 21 Sep 2022 12:17:37 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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_info *info, const char *prefix) { int i, n = info->buffer_length; - uint8_t *buf = g_malloc(n); - - info->read_memory_func(pc, buf, n, info); - - for (i = 0; i < n; ++i) { - if (i % 32 == 0) { - info->fprintf_func(info->stream, "\n%s: ", prefix); + g_autofree uint8_t *buf = g_malloc(n); + + if (info->read_memory_func(pc, buf, n, info) == 0) { + for (i = 0; i < n; ++i) { + if (i % 32 == 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; } 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 = MIN(sizeof(cap_buf) - csize, size); const uint8_t *cbuf = cap_buf; - info->read_memory_func(pc + csize, cap_buf + csize, tsize, info); - csize += tsize; - size -= tsize; + if (info->read_memory_func(pc + csize, cap_buf + csize, tsize, info) == 0) { + csize += tsize; + size -= tsize; - 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 != 0) { + /* + * ... taking care to move any remaining fractional insn + * to the beginning of the buffer. + */ + if (csize != 0) { + memmove(cap_buf, cbuf, csize); + } + continue; + } - /* If the target memory is not consumed, go back for more... */ - if (size != 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 != 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@nongnu.org\n"); } - continue; - } + break; - /* - * Since the target memory is consumed, we should not have - * a remaining fractional insn. - */ - if (csize != 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; } cs_close(&handle); @@ -286,16 +292,23 @@ bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) /* Make certain that we can make progress. */ assert(tsize != 0); - info->read_memory_func(pc + csize, cap_buf + csize, tsize, info); - csize += tsize; - - if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { - cap_dump_insn(info, insn); - if (--count <= 0) { - break; + if (info->read_memory_func(pc + csize, cap_buf + csize, + tsize, info) == 0) + { + csize += tsize; + + if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + cap_dump_insn(info, insn); + if (--count <= 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); } cs_close(&handle); From patchwork Wed Sep 21 16:07:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607957 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2482234pvb; Wed, 21 Sep 2022 09:17:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AyB2BMvMP0teir6blC+K0i+A0DMb48mYfRMHmOzXfkhkOU5eu4JGRrZ5O+hFLGanilP0+ X-Received: by 2002:ac8:5793:0:b0:35b:bbc9:c638 with SMTP id v19-20020ac85793000000b0035bbbc9c638mr25000222qta.403.1663777071520; Wed, 21 Sep 2022 09:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777071; cv=none; d=google.com; s=arc-20160816; b=ngvDPc8PYptWMZWdvgSyirrppobIxKDuDN0SokLiuW87aRrvXq5mkJUPfyTdl2rJt4 KZC5heyIwVGp6sZwYa9vdevQ7ptbP2sqNlLXqfcrUWGX7ZSV5qd5lYG9gVFpc7CLvXth FjJY+dTu2MOO9uYWlSUR6EjzwFHBQVZT7YPWVqN7sZXMFjJ1ILAPp9r0TmKpuJRFsUZN A/lzppt4qNVvJpmtx7e5tU4VYByLRZAcNLeGTh7oLYc9zDix+n+nlTe5xxHGaL1VcGFh WBg6UqjJ+Fik0ki6JesGPGKMwsfxELX0uPqhZn6uX40QsDBed5ugELLep2pke//jBPRl 8KLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8Ro+xFgh/QdLoZQgvYQ8rQUQbQuFqJuKD5ycvRlp+PA=; b=ycwtalc8kqYt+GQpaOElRYzz5sHmW1VRuhGN4Qt2h/mHFqHJ8wsztawnhJlydV6zF2 PH28X2MQth2H+k3L+t3wKSnqY8a40CiSSFBiofLdNGTSEJI+pgi7CNjOaPu5OBO5tEVM k5xGzQM1t21YM58cAOIgGw/3XFD6GeYp+QWXEbaqsDfFqtZ3DAUa0jDOP7J2vBXOU0FB /wdmB+rXn3ykBFg45LfYVthaiMsflG/8xMQL1QCzPSGEuIIYKLZzWlYxd+5/g731JzZv oA6aSz2DHu93z1RJlYA/8riuqMyixvM/mOtEQSfqXXVjpiHDkDCX61jIyNe7SXHiRn1G gTpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yDRFOGZI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v3-20020a05620a0f0300b006cebcfbc520si2268893qkl.412.2022.09.21.09.17.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yDRFOGZI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2Q1-00085e-Vi for patch@linaro.org; Wed, 21 Sep 2022 12:17:51 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will be helpful in debugging problems with tracking SVE memory accesses via the TCG plugins system. Signed-off-by: Alex Bennée 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+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc memory: CFLAGS+=-DCHECK_UNALIGNED=1 +memory-sve: memory.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +memory-sve: CFLAGS+=-DCHECK_UNALIGNED=1 -march=armv8.1-a+sve -O3 -fno-tree-loop-distribute-patterns + +TESTS+=memory-sve + # Running QEMU_BASE_MACHINE=-M virt -cpu max -display none QEMU_OPTS+=$(QEMU_BASE_MACHINE) -semihosting-config enable=on,target=native,chardev=output -kernel diff --git a/tests/tcg/aarch64/system/boot.S b/tests/tcg/aarch64/system/boot.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 /* - * 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 /* Setup some stack space and enter the test code. From patchwork Wed Sep 21 16:07:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607960 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2487620pvb; Wed, 21 Sep 2022 09:27:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6RSiV6Fnvkjdy5L+0NGES3TVGY3IIcUIv9DABG9jcSvlklNO4LKYOv64V158/QjAaP/4PY X-Received: by 2002:a05:6214:29e4:b0:4ad:53c5:7559 with SMTP id jv4-20020a05621429e400b004ad53c57559mr10088648qvb.86.1663777650965; Wed, 21 Sep 2022 09:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777650; cv=none; d=google.com; s=arc-20160816; b=RLu7+HO5wHObF/eM4aT+ZVhuWCMmwFSITsQxUxvCz3mFJeHwIiwJTDFjaYmDKUT9lu Z/uUWGWC3e9ZcqnZTplC+ThvOGzQx4pavgY+AJtMMwKRrSHXxiYRWOjJmW5nxbx8AXw/ a+77ZDCEqZt7HUNSc+nFcZwdD1deRAG11aRstOXgIS8FmDg8PGJj+hpkHKvkitpaA1/A rA71moOELUGPyDDSfzaB6qIYh4XQfCwH2NajvyFzjldJwbDUMfiVi0ncTU4sZZ0VbK/b U+H0C5CoKvoFKCUz0nLoNKifu5Huz8wbaI+MisI+xFbOo7OS8fSefL3zxZFcWz3vvP2F HQRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RolUEI1sAdkeZqLhK3SHKMIX8JiB7vTNvSZnkZrUXOI=; b=XHB7T1djSIL025Y6DW3xL94P3xtwk5aouoEqylqrrSX/Tyc11LfCfRU/iXjo8CP14+ UsXpgfu4sNDNQvn4rrV2ZW5MCrWL3/bPFNJaYrhsbM2zmcYQiDBF9li6R7lWFPDNxv+H A+KRCxFOTKKuSVCk8WI6yRLw9TUKx48WChb8tCRaw0lf+2IAqJf+2tp0bGyteaYlfOig E9rgsQI2gKZ4uPAqtRyV+oIpAMqZPA4wbHnPgf/InS9lI6RAWIPCqCtnsFHr7Agnlrd0 XbQ1iG25YoxwCsoZY1wAb7z3PLbZw8wDVpLOIZWRccS7YYNHevdEUrjaLkWBWtQt+STL y1yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qqPuTY1H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e4-20020ac84e44000000b0035cbe580c98si2035265qtw.101.2022.09.21.09.27.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qqPuTY1H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2ZO-0000JW-Fx for patch@linaro.org; Wed, 21 Sep 2022 12:27:30 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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=on \ -kernel ./tests/tcg/aarch64-softmmu/memory-sve \ -plugin ./contrib/plugins/libexeclog.so,ifilter=st1w,afilter=0x40001808 -d plugin -D plugin.out the st1w SVE instruction is not instrumenting its stores.] Signed-off-by: Alex Bennée 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 memory access. It can be used for debugging and security analysis purposes. Please be aware that this will generate a lot of output. -The plugin takes no argument:: +The plugin needs default argument:: qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so -d plugin @@ -364,6 +364,13 @@ which will output an execution trace following this structure:: 0, 0xd34, 0xf9c8f000, "bl #0x10c8" 0, 0x10c8, 0xfff96c43, "ldr r3, [r0, #0x44]", load, 0x200000e4, RAM +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=st1w,afilter=0x40001808 -d plugin + - contrib/plugins/cache.c 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 = QEMU_PLUGIN_VERSION; /* Store last executed instruction on each vCPU as a GString */ GArray *last_exec; +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 = (imatches || amatches) ? true : false; size_t n = qemu_plugin_tb_n_insns(tb); for (size_t i = 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 during @@ -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 = qemu_plugin_tb_get_insn(tb, i); - insn_vaddr = qemu_plugin_insn_vaddr(insn); - insn_opcode = *((uint32_t *)qemu_plugin_insn_data(insn)); insn_disas = qemu_plugin_insn_disas(insn); - char *output = g_strdup_printf("0x%"PRIx64", 0x%"PRIx32", \"%s\"", - insn_vaddr, insn_opcode, insn_disas); + insn_vaddr = 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 = 0; j < imatches->len && skip; j++) { + char *m = g_ptr_array_index(imatches, j); + if (g_str_has_prefix(insn_disas, m)) { + skip = false; + } + } + } + + if (skip && amatches) { + int j; + for (j = 0; j < amatches->len && skip; j++) { + uint64_t v = g_array_index(amatches, uint64_t, j); + if (v == insn_vaddr) { + skip = false; + } + } + } - /* 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 = *((uint32_t *)qemu_plugin_insn_data(insn)); + char *output = g_strdup_printf("0x%"PRIx64", 0x%"PRIx32", \"%s\"", + insn_vaddr, insn_opcode, insn_disas); + + /* 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); + } - /* Register callback on instruction */ - qemu_plugin_register_vcpu_insn_exec_cb(insn, vcpu_insn_exec, - QEMU_PLUGIN_CB_NO_REGS, output); } } @@ -132,6 +168,25 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } } +/* Add a match to the array of matches */ +static void parse_insn_match(char *match) +{ + if (!imatches) { + imatches = g_ptr_array_new(); + } + g_ptr_array_add(imatches, match); +} + +static void parse_vaddr_match(char *match) +{ + uint64_t v = g_ascii_strtoull(match, NULL, 16); + + if (!amatches) { + amatches = 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 = g_array_new(FALSE, FALSE, sizeof(GString *)); + for (int i = 0; i < argc; i++) { + char *opt = argv[i]; + g_autofree char **tokens = g_strsplit(opt, "=", 2); + if (g_strcmp0(tokens[0], "ifilter") == 0) { + parse_insn_match(tokens[1]); + } else if (g_strcmp0(tokens[0], "afilter") == 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); From patchwork Wed Sep 21 16:07:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607961 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2488435pvb; Wed, 21 Sep 2022 09:29:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6H2D6TgubysUQBXqPBcxoJ8wQiTE1OImk33qw1nBYa+ls7f5p0m7i0H3kXbXxBztDP8Xhs X-Received: by 2002:a05:620a:2989:b0:6ce:1913:83ce with SMTP id r9-20020a05620a298900b006ce191383cemr20493232qkp.49.1663777752687; Wed, 21 Sep 2022 09:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777752; cv=none; d=google.com; s=arc-20160816; b=fWbV8k46Ge7S7sjn3S///j0CQ90UTpqZi9XrYWWwpUBQIq/o5ujRXv95V3hSi06fe0 r0ims6bvTFuuDj+cnIt8tWGdEFiwwR+ShlT9zrg1sCEshhNj2BgoT2aau4EpB0EC8Lpi jMl0bTeswInWAj+LNhp7lS5omBY27Pl8MAS+LpC+Hu2dI00bCkUQNLwlv/Yyfe4l/MwM t9z9utL7U10XGdtV+C3RFkVwGhrrblqwXquiAFPpCscOJ/jUUwwl7hp0zVqQbdqxgwSR ScXjCl+cN0RWxbptCai678afy/4Xm8IvJ+cllaVEGTS37Bk0hhf9eaNx0zsCos5LUKu4 JWyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8wlJEOjCIqrgKcd8hYGZEfi/YjXbLCd9HqD3SSKCejY=; b=ePnVhtr01f5taGqFg3BqduoQL8TIRxjx00Llnue1mJSSz6XsQwwDwfrEwB212XdE9l 1+FqTMHruGrqL+qjrI6HbLo184t2GaiBXYiHatb+/jOPblxQk/1T9JVFI3/p9SIGVV4o bL/R4ZhYkm7mDXWS98CWhR31JvNRe5MlKKD7FkEISYeIFWcxpWAcwqgjg5rz+9+w5DGi 858hJZsD0ahonEftdl3i0kXCwmsbxw77hYipqPUTZ8HS62ZvfIPG7jULcCIwR/SMLEoN ljTPvT65mlbpntvR2rV8TzW4hes4gB8usuTU/fKT2ITs3aLKoSW3fVpxGZJ3NjvAVAv3 hJBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nKSVH8n+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 2-20020ac85742000000b0035ced04659asi1955733qtx.718.2022.09.21.09.29.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:29:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nKSVH8n+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2b2-0002lC-7n for patch@linaro.org; Wed, 21 Sep 2022 12:29:12 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Philippe Mathieu-Daudé --- 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 = get_plugin_meminfo_rw(info); hwaddr_info.is_store = (rw & QEMU_PLUGIN_MEM_W) != 0; + 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"); From patchwork Wed Sep 21 16:07:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607962 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2488528pvb; Wed, 21 Sep 2022 09:29:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44U9tOpcFKxFF6cArNua47sVO0zkMlBMx4lWP8olj7o4aSnpwgqB690tpSA2xjolqf50GT X-Received: by 2002:a0c:eb8c:0:b0:4a4:4f21:4a92 with SMTP id x12-20020a0ceb8c000000b004a44f214a92mr24006154qvo.35.1663777765355; Wed, 21 Sep 2022 09:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777765; cv=none; d=google.com; s=arc-20160816; b=BrTyKiIUwKLI8YU4O0fYFJ1tUruKz9jl/7TcBHkmhMgH6kgQdxFIykC/YKXH5ojSL8 dJ+RQyIYJjH1ar2eUk6wu8qlDNkCo6CL/29QYZ12mMgJoiefm60qgO0HmuXLR9LjuXYT WXtVZ/kFqKImzCxy1UCCRrQeUQY4gTIO4lP2q3pSz2kF+p2vKvUxnlxaAmT4jLN64I61 Gvv6IcpHFJeS70hssjyvvBYxPlzYK8PlK7MHgXZIF3tm2eWwGvmVaZOhr/UqwV0UIsXX x+3rIFJXVaKq97Oyj/xluIHqLQVk8z2DFw8K+B8xWVYd9DAa0+ENi4OlvQtsr8csNCxD EBlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OfFvYONTn8YFltPiyuXy+wM30XdQW8jQu5P1PJa3mLM=; b=kXRZzpXJDVOMVB+gWJVHVbRw1N7Imsbtv6bREhGnJcDdTDzl4aSXJKIw/0WFsyqfWI ZcqerIqOwaFxe0ATHMXxdXquSsfB4GY5zEotMotLSnIQG9HNRn0oSR7VV6WveGghn81w fn6RQrt24R9UqY8LrjwMonT4ZmWvambk5+niUC6/Q4+hDVuwtD0gzCAegu+SLVUkJyzS Vo+850IEUu7rAW0Rpeezp4P/ETexYDWNETA7W4TShrryniSzaMCYkqrNR5RdLivSvgOy 88nmpFIkIXAQ70w9SO9n3tF9y2rUqK1YQ/Xv4jJsg0Lt3KFvwgOy3vwXAMLtCJHWBmjC RvMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C0L2FrhW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q1-20020ad45741000000b0047493914dfdsi1747788qvx.388.2022.09.21.09.29.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:29:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C0L2FrhW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2bE-0003AB-TM for patch@linaro.org; Wed, 21 Sep 2022 12:29:24 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Philippe Mathieu-Daudé --- 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. Example:: - ./aarch64-linux-user/qemu-aarch64 \ + $ qemu-aarch64 \ -plugin contrib/plugins/libhotblocks.so -d plugin \ ./tests/tcg/aarch64-linux-user/sha1 SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6 @@ -186,7 +186,7 @@ Example:: Similar to hotblocks but this time tracks memory accesses:: - ./aarch64-linux-user/qemu-aarch64 \ + $ qemu-aarch64 \ -plugin contrib/plugins/libhotpages.so -d plugin \ ./tests/tcg/aarch64-linux-user/sha1 SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6 @@ -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:: - ./aarch64-softmmu/qemu-system-aarch64 $(QEMU_ARGS) \ + $ qemu-system-aarch64 $(QEMU_ARGS) \ -append "root=/dev/sda2 systemd.unit=benchmark.service" \ -smp 4 -plugin ./contrib/plugins/libhowvec.so,count=sreg -d plugin @@ -288,10 +288,10 @@ for the plugin is a path for the socket the two instances will communicate over:: - ./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=lockstep-sparc.sock \ - -d plugin,nochain + -d plugin,nochain which will eventually report:: @@ -348,7 +348,7 @@ Please be aware that this will generate a lot of output. The plugin needs default argument:: - qemu-system-arm $(QEMU_ARGS) \ + $ qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so -d plugin which will output an execution trace following this structure:: @@ -365,10 +365,10 @@ which will output an execution trace following this structure:: 0, 0x10c8, 0xfff96c43, "ldr r3, [r0, #0x44]", load, 0x200000e4, RAM 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:: - qemu-system-arm $(QEMU_ARGS) \ + $ qemu-system-arm $(QEMU_ARGS) \ -plugin ./contrib/plugins/libexeclog.so,ifilter=st1w,afilter=0x40001808 -d plugin - 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 working set is run:: - 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 will report the following:: From patchwork Wed Sep 21 16:07:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607958 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2485773pvb; Wed, 21 Sep 2022 09:24:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JJCpULwk86yIsE/hgadak2BgYZ+tUSjI1xyI3ZnB7Fg6aVuxZFYlj7sPimTNO3n0wraKG X-Received: by 2002:a05:620a:13d8:b0:6cd:ef36:4034 with SMTP id g24-20020a05620a13d800b006cdef364034mr21096983qkl.561.1663777443615; Wed, 21 Sep 2022 09:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777443; cv=none; d=google.com; s=arc-20160816; b=w8bCoQroP+tERPZb3bkFYsAlzD6lkTo/nntOscH6TdeTWzhsL3CKJdmdoM8pJPf4H5 qOLT5SSRNOBSv5LEXwyYLYZvf/KTus2/FoCeLPRm2FJ6Ggib73yf/K7HI1spsqyLdnMu KQ9OMflJKnpTAaGqqWmpF2K95G9p/O2yBPqxs8EXfdXW/92W9/F3wiUAj8LrXgyPJp0h Eucco+zOTUQNee3CDB/qhj4eGCR25go9dGuyrP5BBg2JOZAUtRmekIKV4QebN59PDkVM p7D3x8HRHEB5VPVDiQmL1FkoSRixlkS9Znl5PqBg4iGtuiJSU9hrjYJLa9KzviS2SPTX ipOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iHHyl8AojnEq14+3x1kjoY7otQgZX0hgTY1qjaFy320=; b=uvRO9ej4VSJlskrNfhK1k/IflH4TumLNgrPGYZxs1TBioCHjRH5R4DBVbQMDWrQ7TE oOJAgKRudMEookapoGglfBpcGvRhGBeCj4wgPNSo1oTLnn2t3ARI6AqBdaGuT1iRWNn+ g3aDymGkcGDIaawsXmGDWNVOQO3iE/8ZU7c+na7hfNvlEcDs3CRZhS18y3e8DN4LRQly reNII9jileA/anGfrcMZ+hqQUxHv2zEjbs19td5D2/sSN1oZp4t5HaomzWwdtx96itr4 6BSkI3LrwZsiCV+DUg+AMALfrhOcb8PiyelFHh28Pr/1xVDYva374mT/T2TCSgvKB/tp E/Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DgjEppD2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j9-20020a05621419c900b004aaa4435236si1911267qvc.502.2022.09.21.09.24.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DgjEppD2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2W3-0005BF-61 for patch@linaro.org; Wed, 21 Sep 2022 12:24:03 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Reviewed-by: Philippe Mathieu-Daudé --- 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 query select details of instructions and system configuration only through the exported *qemu_plugin* functions. -API -~~~ - -.. kernel-doc:: include/qemu/qemu-plugin.h - Internals --------- @@ -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=on``. (default: N = 2097152 (2MB), B = 64, A = 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 + From patchwork Wed Sep 21 16:08:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607964 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2496607pvb; Wed, 21 Sep 2022 09:43:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CQlSw8FnyY8AdHiVuLzxyvyYiJ5EArSSWzmHz+b41DleYIjRGHc/RDIuk9/8PbTGNzlhb X-Received: by 2002:a05:622a:1109:b0:35b:ae57:5a6c with SMTP id e9-20020a05622a110900b0035bae575a6cmr24139598qty.23.1663778597617; Wed, 21 Sep 2022 09:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663778597; cv=none; d=google.com; s=arc-20160816; b=sF2t1c2zesBLOmUR6ZiMiK7pM1v7LF/BcRnqzJa+xhAu1xt6gtNFv/5i3wYdIIa/ZD /VJVdSBoxhe66RerEkgRQf8R5xCutd3VHzHNsvNuUCONSkSzg9/xKvj/1C/OfqkAYRs5 QKL1aG3bPjK47hLZzh8Zj56ri9foDuRnKsAGY1yeK0yvPADQiNXKVApfzjbW66Sv1kbv 2VxcoNS7xVvXQtM/2gHRNmL8wkF4thBLd7Rxf5ngOlP2dXeGU/frIC6yNKtdHDakp8b0 UZ5j0W8pywVHlU3QHT0gmjwuuIhiJ01zrN/8KZpQn+fW24N1iwyHjjBl/Ya/X25ERY1u 4/Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zs6if3JsrgpCg8dSorFuiYuQlfRV6HSFVzcfBOEUknM=; b=SvoNTqYOQsM2+jA2i9JxxiQUQE/FPAtdozPDuGGgoHaRz1WmSnPXssfPea+t1MXeDU ODHh4vaSutz71ue8hhvivZuyw5u0ZF6hPmSW1ejSTCdzk9uzU7iNzYSQy/t9W/cF2fJg qtHVKC8by5jcAOvBapJ1GtYTpmJ8Isdx1iGYgUyermZRNxTQOm+e5Tus6uT0cOHIA7WH F/Uxi2OK5khIVS0tSD+Rp95BEX7IF+FLV+AW3yz3gFc/GHKRA64pqQcQyFyDywCchf1v gR6cXdg7p7aJa2NY/RojZLszxKF2xvAxepjL/hvfxXbG99LCGIJ+wpFJSRxJVF7ybhk6 FHCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tBSaZXCH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m7-20020a05622a054700b0035d0b7c8d3esi1015917qtx.159.2022.09.21.09.43.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tBSaZXCH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2of-0006I2-51 for patch@linaro.org; Wed, 21 Sep 2022 12:43:17 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Cc: Alexandre Iooss Reviewed-by: Philippe Mathieu-Daudé 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 qemu_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 = (imatches || amatches) ? true : false; } } From patchwork Wed Sep 21 16:08:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607963 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2492515pvb; Wed, 21 Sep 2022 09:35:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Lr5qHShaN3EtHz6S6RXE8slLSUCrntWXhCUjCc7KzaNYOdK8Vem2eqJM8xwVeTUasTr+M X-Received: by 2002:a05:6214:d0e:b0:4ad:5e35:329a with SMTP id 14-20020a0562140d0e00b004ad5e35329amr6752387qvh.28.1663778157000; Wed, 21 Sep 2022 09:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663778156; cv=none; d=google.com; s=arc-20160816; b=zpDydFt5zzW93atIzia/CPye3L6qGWiGs9gviodjLexl5RQj21LcctJmYYBz20Dw/M 4dL/wPVQPk/Q6Ap3KLre/j9GgID3NG2HcJ5q8dNmtiJVs0MtugtXKCCaucIDdEViNb8N Yi2JhT7deqR1lKFpLbychfACL7Xhl2sT1DsuMCADbz+ocZhrIE3+0BzuL5CUWWLqCm0v vFuFH2NBA3TRfB86WbEP1t97c68AVKKeR+8Lfe6ZfZldatO6AAlmTa9tfiyIqKUO7njO 33sFQSeA9nVPwNnjMz3ZWt7Bd+7vBoqbBQSctQmnBJW+TJBNSv/5hubcC+8OJapx5GFG kwCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GoEs9/h2LLepKNbeRIHGFuvJURS7q8MKK6QKHpul0xk=; b=YE/wKoqOjizDPXyBj6wTuNeJDWkf6L8Xhw6jICAqRDPpnna6Ir59vY6NkPUfQzaw7q LP3UQZ9jRvG0hJTS5G2APzd9tEzOSTccYgk3MKH4Dg9/i0NdFcOB0lQxhYpk9tIJ57fp odXtzwR5yAOqDi5LZygjvJ84lX5rziSNd/4z644VDtM7cFm9Zo2kS2BzrE+vhJSPP9hZ zZD2LSwYuyutaN6/5Mv7hcQa92FHwYgWlGGhdbk1/kL0wAd/+gxE7n3hx62+3sUhJBQb nO741cYC8hsYLvbzWO/CqKsjm9haNmix5h6sbSWPE2RiGRF7o1fna+lsXw/OZGuqkluM 12+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JyKI51tv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o3-20020a0562140e4300b004acc579f24dsi1842572qvc.207.2022.09.21.09.35.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JyKI51tv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:54688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2hY-0006BA-Fq for patch@linaro.org; Wed, 21 Sep 2022 12:35:56 -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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- 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 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``. -- tests/plugins +- tests/plugins/empty.c -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=15dd99a1991e0b3826fede3deffc1feba42278e6 + bb's: 2277338, insns: 158483046 + +Behaviour can be tweaked with the following arguments: + + * inline=true|false + + Use faster inline addition of a single counter. Not per-cpu and not + thread safe. + + * idle=true|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=true|false + + Use faster inline addition of a single counter. Not per-cpu and not + thread safe. + + * sizes=true|false + + Give a summary of the instruction sizes for the execution + + * match= + + 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=bl \ + -d plugin ./tests/tcg/aarch64-linux-user/sha512-vector + ... + 0x40069c, 'bl #0x4002b0', 10 hits, 1093 match hits, Δ+1257 since last match, 98 avg insns/match + 0x4006ac, 'bl #0x403690', 10 hits, 1094 match hits, Δ+47 since last match, 98 avg insns/match + 0x4037fc, 'bl #0x4002b0', 18 hits, 1095 match hits, Δ+22 since last match, 98 avg insns/match + 0x400720, 'bl #0x403690', 10 hits, 1096 match hits, Δ+58 since last match, 98 avg insns/match + 0x4037fc, 'bl #0x4002b0', 19 hits, 1097 match hits, Δ+22 since last match, 98 avg insns/match + 0x400730, 'bl #0x403690', 10 hits, 1098 match hits, Δ+33 since last match, 98 avg insns/match + 0x4037ac, 'bl #0x4002b0', 12 hits, 1099 match hits, Δ+20 since last match, 98 avg insns/match + ... + +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=true \ + -d plugin ./tests/tcg/aarch64-linux-user/sha1 + SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6 + inline mem accesses: 79525013 + +Behaviour can be tweaked with the following arguments: + + * inline=true|false + + Use faster inline addition of a single counter. Not per-cpu and not + thread safe. + + * callback=true|false + + Use callbacks on each memory instrumentation. + + * hwaddr=true|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 - contrib/plugins/hotblocks.c