From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171375; cv=none; d=zohomail.com; s=zohoarc; b=FVtQtuSoEF8lZrdxlJifsjtZx97MiwhaZuCsbrZCrXwtmbY/5D+ieG9MK98GxZCHqqBIQGZmhZq2p/kAH7Yet4z1IORNQ5PS+7XjG0UbDt3GTJhxtGa96ax3IkqYpeNX/AU9KIQCC4i3KcVZM5osgfSBSD7nxuccAdelpGTYHvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171375; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ncJUNebs7ZM73hrk151b27J1wkIMha9Y6kzNKacJdwU=; b=EHGD1qvwBv7lDZdvU/BtENMlF+fGc8/dyFseZq7d6M/zSUXnomqTwiNFW2bh2BIrCYp7r0iUv2g+e1GAzsPay4AprYKrW2BXHltf2m+UKF5gFB6e8GzMLS13wbuc3Kt5OMxBK9q/OThvGkfYdajLaXe4n0e3f4CvdVUJmK82nX4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171375135354.71862923430456; Fri, 19 Dec 2025 11:09:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfqS-0000Zg-V7; Fri, 19 Dec 2025 14:08:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqR-0000Yc-1X for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:55 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqP-0006nB-4S for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:54 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-477a1c28778so23305005e9.3 for ; Fri, 19 Dec 2025 11:08:52 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324eaa2bdfsm6615321f8f.32.2025.12.19.11.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:50 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id EA01C5F87A; Fri, 19 Dec 2025 19:08:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171332; x=1766776132; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ncJUNebs7ZM73hrk151b27J1wkIMha9Y6kzNKacJdwU=; b=q/94JHsRJ+GkMfyohYwwRRoVvhO7IwzheWujSHlnn6C7IVRmWHYjzCRLg4i9kW1O1u S/6m5EOMiWz7Acqhc1tXE3qtwDece5RLIOaqdrpCniEY6m2ogHmTUKxsHgUkUsrpE6ZA thaZVxRUNimUBCa6bbHzxUFWNGwhe5qzbswrtXF3FsH/YXg6fdN8k7uec2JFkQ7A+wYu zIr4UrEVdNzyVthK0nIrei+ItIMUDVqbARcbecS9kk/ATacZKw3FBJwlmut7bEEi0poa AoYjBeFhiqJ594lICwhce0TNXGxz5LAsgFSAFpru7NcwQ9e1C3RY3/uxuUtOefuKV89r NyFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171332; x=1766776132; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ncJUNebs7ZM73hrk151b27J1wkIMha9Y6kzNKacJdwU=; b=fvkrgARbDEFqdcUBmXsBa0OCd5JxFTB+Js+FBZStiunVhwX3dhVuvgiaq254n6wArx zDd+OsMRCWKIQLN1T1pEvCCwYEJ2q5EAYgDhhANhlgE7p8c2zHuQ7XDFtraTcSSA6iI0 OA0ehRaKS8CqC8z69sK+O6+4lMgL76dYZsJYue77ZSty+EGn4sUFc8TRISwfa2gu2xSh v75Og1teOY9YaiTC+nw3rDWMWgtCs2vK3qlC75Cyd+i06D/UMRthqL6rWnxLVScNsVcj HU2Npat27VMh+5erBBMYB+H2EQrEqjp4ipmffH6FwYc0wOk0362tuPxGVqd7bzfMqaTM lEKg== X-Gm-Message-State: AOJu0YylUQfSaHLkfpRQKa75cJopikPnG1jrJnebDFvUCCPcRcwN0sXW TZCrOLx8uB4XQjXal5JUgdNVTpYXwAP4rj7Xdzjayzc6h0u5dnH+L+OoqBDxRir308E= X-Gm-Gg: AY/fxX6apNyVxOPMKsbdt9eRupH3p1JJZDGxZmxLL9aYClvuzb2G9CP6jIFspbBdrk8 iTlYjFfzgugqErAH8DrPwCzA1jmnjj5pIRnL0Nqw6krbCIZdtlMENSWUv7/AG7csKF5gLuArTWk LgKoabU7yirHY8vgf5HRE5NASqkzvf/NRfzYI7Lqt4+O6fmbTb6euPCrtDYyymKyuqRBYl4cl/Z uYUL6zW0DWlP+rsFYa3ta0zAmi6UdW22siezZvjt4yMvp0BYv+/zN3PV//pH7wzxA8p5T7KKb29 yHqPL2LY3wiuJnA8aQ6gIHVLjsBrNtYzdlA4rnCH8mi+r1b9FBIdsiz6RgWrgZrdXZGFo7XwyuE lPeIVtnOhTusoysDuBaDRhGRIpggKfPsGTQwbmarQeXLxPPTzCEvXaM9yW25IgrD8kYk5Nx/gCM wnIMTWRZbALk4= X-Google-Smtp-Source: AGHT+IEDTpOPtHHV4qDExkgs8HlMd1I1k+4FnT1Ic9yNZd92whd1zb5UBPyt+JRb0F5YDM9/M10TLw== X-Received: by 2002:a05:600c:4709:b0:477:9aeb:6a8f with SMTP id 5b1f17b1804b1-47d220b7f4dmr2062125e9.9.1766171331612; Fri, 19 Dec 2025 11:08:51 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alex Bradbury , Manos Pitsidianakis , qemu-stable@nongnu.org Subject: [RFC PATCH 01/12] contrib/plugins/hotblocks: Correctly free sorted counts list Date: Fri, 19 Dec 2025 19:08:38 +0000 Message-ID: <20251219190849.238323-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171378446158500 From: Alex Bradbury g_list_free should be passed the head of the list. Signed-off-by: Alex Bradbury Reviewed-by: Manos Pitsidianakis Reviewed-by: Pierrick Bouvier Message-ID: <0529ab0212aae1e4a5ff3c287045acc0731e5d01.1764716538.git.asb@ig= alia.com> Signed-off-by: Alex Benn=C3=A9e Cc: qemu-stable@nongnu.org --- contrib/plugins/hotblocks.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 98404b68852..d3dd23ed9fa 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -73,15 +73,16 @@ static void exec_count_free(gpointer key, gpointer valu= e, gpointer user_data) static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report =3D g_string_new("collected "); - GList *counts, *it; + GList *counts, *sorted_counts, *it; int i; =20 g_string_append_printf(report, "%d entries in the hash table\n", g_hash_table_size(hotblocks)); counts =3D g_hash_table_get_values(hotblocks); - it =3D g_list_sort_with_data(counts, cmp_exec_count, NULL); + sorted_counts =3D g_list_sort_with_data(counts, cmp_exec_count, NULL); =20 - if (it) { + if (sorted_counts) { + it =3D sorted_counts; g_string_append_printf(report, "pc, tcount, icount, ecount\n"); =20 for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { @@ -94,7 +95,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) qemu_plugin_scoreboard_u64(rec->exec_count))); } =20 - g_list_free(it); + g_list_free(sorted_counts); } =20 qemu_plugin_outs(report->str); --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171375; cv=none; d=zohomail.com; s=zohoarc; b=ZlA4KP/ZJK9FI3VJqed4qLJHVMO5uJpWL/A1sIzECK0vLI6zEM0WgAfisQZ9C8VrC3NzteiZ+rCqhgpJPSb8SKiu31zBQMv2/7fW2sOScepzGScNjoK1Ha1gR6nJqfN29xTUDsc+mu2siIgAuHaHIxhd+RSeup2EfPwLrcJUIHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171375; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7InpFQ7BTqeavUK3Pc8BqtwXriQXDgmpyYwzlrclqtQ=; b=PJNeq/dKhJtCLHs8Fmk3tuVbywGBQh/eve51kvKTPObUrxOsdi/iE2ULBEeUKiImn+jxsnCL5bBtDegvdwfi22HAuUCF1/P1cSMQWX0yzQDjvawTtxInO4ALIjzhviYltw+Fjoo4NIi3d0Ku9DF3fvd/LFruXTZeJ2b9f5QV0QU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171375172585.6298321229006; Fri, 19 Dec 2025 11:09:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfqR-0000Yn-VJ; Fri, 19 Dec 2025 14:08:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqQ-0000YP-OE for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:54 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqP-0006n5-3o for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:54 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-47d182a8c6cso6304955e9.1 for ; Fri, 19 Dec 2025 11:08:52 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be273e4d5sm112790995e9.6.2025.12.19.11.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:50 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0CB2E5FC1E; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171331; x=1766776131; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7InpFQ7BTqeavUK3Pc8BqtwXriQXDgmpyYwzlrclqtQ=; b=bFov7Yst/kv7x55AGFTTQYiCsPgRXM+cHtldE1A62sN/zyLKY223/3Sp6tq495gzbE 8cDjIZPx2aFvTn+zQy48c0uaRd1Je3F36W1gSEWuyKG9hPLCvbu630vX66WGTVqPrQsW BrB0sDCyer+ys3wJFRJ8tNNZ18lhHPCCOzcoMYImzQ415JaixcLbcZyWtJydAbw3m2PZ g+cZJqUw7NtE1b+XqzDIQIPHAcu0oVytIrrm+EVPTCkRlrwNPyox5h5ShQQQtuBxtxR9 MEbn3ENwKrn0FiE4CF48U1b2D9lDO3ga+KMvaesebilK92r0r7WDV4B7kqvxN+G58xRB WLcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171331; x=1766776131; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7InpFQ7BTqeavUK3Pc8BqtwXriQXDgmpyYwzlrclqtQ=; b=opo27awkO+SKfQpuLfxLgyA4/G2lTu0JGNWCuhjfc8RtrVCWQXe/1WPPxUlBtxkcU2 ZcSgoviw7Mnqg9fwtsPmkEVwHS5GJ+6A5fUYvPdbeVyVAUfT/ax8RQA86zY2DRV99PSP RU/WuOplFlfluKgab/EqpP6miVUIlCribiapprxN7zMqR22AgyRkyIRZ5hdCWsgbp5WG f+mofIBHTI9hptHXXLK798K3EmsZdNIISuIVNVJyOwPPzhl/ujmtWRxPvHWtDfmSiIxa CwMQ+feI4jw1PbSaO2KBR8V/oGices6z2mfQnObUeyXe8kGrahKUAtILRNM2dlA3TE1i 5vEg== X-Gm-Message-State: AOJu0Yy1Izif1v3dniT+CIJ+54786ftTiFmfm//5W074qCDRYPB3aCR7 XPj0ULonRSAD86HdwPD9XnpKYdq6qAZ/WEEfbjqkI9hle29wEWSrsbbRePhWSM3ssW0= X-Gm-Gg: AY/fxX6UtQ7gttmfFMVFgAPTzxU8b1Mq4lzj7NF4AUDufKorSSU7FgfJ+N1zRnWufnk DrMJvBARGKwJzTut+QAbkTj1Q3p2kum/KmqvYOO+3bV/hpQfcsAmNMK5LSEHrzVDAfo5UjrutDD DrP2g+OPTXWF2Bq/sjjNYZm3o5gpTMSBSyucXcDO9lAWhOhsTPk1zR3jnT9FoKtmbe1Cwtu5DfO 53W/lY6t57W+/Y301Kqfx0mBVyUPyfsDfUBJ4B0u+V1gmrtTGB7mHXof6twq8V+Ydi6csf/npUp FV7+AxI/BTAJ8i4XDUcgb2W+b7Z+DqzC7S6LzszsKr1YF7YY9lPKpMZhziSrhpx+WDXcH/UvfUQ qkQjYyqSBUP43USOeNJkeKno8tG07lXp9mnmv8HzsFGZQIxbWSLAttwcPgf3XwuX4ttxTJC6frz V4PatNxb6BaNU= X-Google-Smtp-Source: AGHT+IGjJ4d/5pjemsnQ0AshvMwPrp7duwimLFoMgWxw1v60VDF7w1sETbryDdVo+y/CrlNQVCnXZA== X-Received: by 2002:a05:600c:6211:b0:45d:e28c:875a with SMTP id 5b1f17b1804b1-47d19598fdemr35889845e9.31.1766171331276; Fri, 19 Dec 2025 11:08:51 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alex Bradbury , qemu-stable@nongnu.org Subject: [RFC PATCH 02/12] contrib/plugins/hotblocks: Fix off by one error in iteration of sorted blocks Date: Fri, 19 Dec 2025 19:08:39 +0000 Message-ID: <20251219190849.238323-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171378442158500 From: Alex Bradbury The logic to iterate over the hottest blocks will never reach the last item in the list, as it checks `it->next !=3D NULL` before entering the loop. It's hard to trigger this off-by-one error with the default limit=3D20, but it is a bug and is problematic if that default is changed to something larger. Signed-off-by: Alex Bradbury Reviewed-by: Pierrick Bouvier Message-ID: <2e1c404fd21d064610391ebb2ffe24d0c536f8dd.1764716538.git.asb@ig= alia.com> Signed-off-by: Alex Benn=C3=A9e Cc: qemu-stable@nongnu.org --- contrib/plugins/hotblocks.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index d3dd23ed9fa..cf4d6b8c363 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -82,10 +82,9 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) sorted_counts =3D g_list_sort_with_data(counts, cmp_exec_count, NULL); =20 if (sorted_counts) { - it =3D sorted_counts; g_string_append_printf(report, "pc, tcount, icount, ecount\n"); =20 - for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { + for (i =3D 0, it =3D sorted_counts; i < limit && it; i++, it =3D i= t->next) { ExecCount *rec =3D (ExecCount *) it->data; g_string_append_printf( report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171400; cv=none; d=zohomail.com; s=zohoarc; b=fWazTb13+Jqbq/M3go1HR9AClj1pA1z+EjE4oqJ4y6Ivnh4eY1adprwOQTKOLJPdLc2M/5BmeJ8tGPNsOArYqvb5W/wfqq/i8tOv2rvejgVKKNtK7D8zjwJ+G+101O1cxWfnzdOywgJKtp4QlXtsUm8O8lHOdGYZPYJ0kh4s8EQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171400; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C22/vs2ZfJSDD5oYLXLbIlcB/xOvGQzCI4efey47eBg=; b=Iaoj0bmq5tqaUyzPf8T44z3xALeG4OZqmuIWP5EE0QVQLpQaCwezW1k8VGizZM51zSXaO74GJlat4DGRlbtT2KnEFXYpJDwM+U+10gRPlkVz5cA3zArB+WBCeMUGK/tOkJoCQd0IjhwxusUeDQwSet6mTXilN6L4ONu56n9kcJ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171400611510.46694403837216; Fri, 19 Dec 2025 11:10:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfqZ-0000cn-JS; Fri, 19 Dec 2025 14:09:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqT-0000Zs-En for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:57 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqP-0006nL-RA for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:57 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-47a80d4a065so10311625e9.2 for ; Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be27b0d5asm111088195e9.13.2025.12.19.11.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:50 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2463A5FCCB; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171332; x=1766776132; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C22/vs2ZfJSDD5oYLXLbIlcB/xOvGQzCI4efey47eBg=; b=Z5g7qCdcGVC3M69Jtop0aljbgmXGI/zbMj9VnadVKdnaFVARr7FPzLFwOrr4knzeH8 Bh/vumKANatVEYRDWYiBz/41o0ZcvZjxQHkLp2AHPhOGX0d5L2ymgCs73aU1krv7VvgI qQKM+uUAqJWzihyHjZgyOLXel1ONKJq+pgrOP/373RQRzyczVDugNZkSOQ49Jcqo8KkD Gw/z22ZPZdxkrHCHYOqOp3t7ZqTWpS+LulRFP7hmB9R6eWmGbxEnw2KGOuAwTQ5CqWXL SMGSAPQZrmJ3AXmzV4wX8UhvxdiZOpR173HQQhzP71HYk2dsiDlgKslvmwKaMuK9MlSO XNtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171332; x=1766776132; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=C22/vs2ZfJSDD5oYLXLbIlcB/xOvGQzCI4efey47eBg=; b=IxZdGK0JMZU4Y5BYI1B7rqRQR5zlwSnUBX3e246UDJRVRrQhxXyZ3susQASrZrdDhG F10i+x65npPiscqcs8NHs22mFG6Vz5PQbwo0ar/okUoms6oqcZKNtB+8N0olKDIhY1uL d/L825xazzNJmQGVtukmFOtFx255BO3O5byqNVFt6CJDxyFY/LhMIp3XNKrcPFpWCvNh F5FKjZEKXJcYkZpblqkrN/OJh8X57KqeUbLiSP289eXBmz5JryOvvUO7D1RoB1HggUqe r3RuBYMTIZQPXCNiGtnUweS5IVFyo1Y2I7CC4ypCN4mmYXMqXR1ItPnFELnsYOTTwzV/ gohA== X-Gm-Message-State: AOJu0YyZKdalO0KmnbV2Rquzw1EWgFNznxIwEtBrcntqdqXNbAUHLphT S4HfdYoNQVZmuOmhuTT4c3YLpnkzT/YMnYb7Xt45AQMY8J+220xSY8EOHRxrU5bI5gA= X-Gm-Gg: AY/fxX6rki+KiAY1grXNSwOrq11u3dUoGqkIIhEMpzGJtGrPhf1yPXJya25fi488oe2 KhVcFOxwc03hAbdNFEOBovFEi47SLUhsXQNfAR5FhGfhqhQhLh8f7lTTvUJ5cDr0F+5tZi8aKje TQUFTb55qp60GXHhslknZmeVlf/0M4O9JKse2+WVShtHrz7nw+4xBBF6p3S+llWftJIhm2cjmJ/ W6ZsCokOg0f7ryTXXP4h53JvH0z1XiBbXmH1WdzwE+aZbgvLTHbjaukjsqdlMuSWIqJi4chlR6b 592WcAmvL/HUagkKsxwg8cK+dqmgHnKJD4xJ7qpP4hqihys3tMflqGNwzY3x31wTrRmxm9Ucb3m baaogC3DwXvukdGjpZZOC2rg+peqe1bvabqT0k7wZQLkdJUfNSlZ0kpa3v3u9io27P7Mq8Vnjoz A8+HXOEuGn9l/DgAXBgDobww== X-Google-Smtp-Source: AGHT+IHGmEV+VQa78mOCnE5VmcRAIGLmwzvCTF2gan22LhZ2i10uvCYF+aQhAqQKrce5z+W5dw/AWg== X-Received: by 2002:a05:600c:8819:b0:471:1765:839c with SMTP id 5b1f17b1804b1-47d1957b7aamr35236735e9.20.1766171332138; Fri, 19 Dec 2025 11:08:52 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alex Bradbury , Manos Pitsidianakis , qemu-stable@nongnu.org Subject: [RFC PATCH 03/12] contrib/plugins/hotblocks: Print uint64_t with PRIu64 rather than PRId64 Date: Fri, 19 Dec 2025 19:08:40 +0000 Message-ID: <20251219190849.238323-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171402622158500 From: Alex Bradbury qemu_plugin_u64_sum returns a uint64_t, so PRIu64 is the correct format specifier. Signed-off-by: Alex Bradbury Reviewed-by: Manos Pitsidianakis Reviewed-by: Pierrick Bouvier Message-ID: <46f83ac83c6cabace91b9be85da2547ff7b08204.1764716538.git.asb@ig= alia.com> Signed-off-by: Alex Benn=C3=A9e Cc: qemu-stable@nongnu.org --- contrib/plugins/hotblocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index cf4d6b8c363..40d8dae1cd3 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -87,7 +87,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) for (i =3D 0, it =3D sorted_counts; i < limit && it; i++, it =3D i= t->next) { ExecCount *rec =3D (ExecCount *) it->data; g_string_append_printf( - report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", + report, "0x%016"PRIx64", %d, %ld, %"PRIu64"\n", rec->start_addr, rec->trans_count, rec->insns, qemu_plugin_u64_sum( --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171377; cv=none; d=zohomail.com; s=zohoarc; b=IePx5dhNCk628LSnwFhy/mi5x1+NUcR1jP1q86YFH2eDJAu8CvIyRLm8nKDY4KvNpffpZdJ/CLtBWgeS8inM7vpj9LhHw6lIC4NCzIDIRCUfjThb6WPedxuWELI7vpW2uBHnl//w77PCfNUpHbOVoUeuO6vaOkQroh3LOB1fV+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171377; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IXQ0JVIP0porfp6WIA5UdBF+RCWCKfVXfAFfgt7VfmE=; b=Jn6Mhhc+YD3Wl5zIQ0MFsQdlfJMrNClw5zDOXFPEi0RL4PNBUOeZwgX4xVBEaFg89B9+mKa9mcN880XKGVA5YYY08Tn1Uu0dtVxilA7n4J7gM576jtsflKVLxrzzqNpccREfCuw6VeYegcjlUUn5LLq5BMcbuOO5HEDv/syuX/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171377259422.91323952373375; Fri, 19 Dec 2025 11:09:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfqp-0000hg-Li; Fri, 19 Dec 2025 14:09:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqU-0000aB-9O for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:59 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqR-0006nz-MY for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:58 -0500 Received: by mail-wm1-x344.google.com with SMTP id 5b1f17b1804b1-47bdbc90dcaso14659985e9.1 for ; Fri, 19 Dec 2025 11:08:55 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be3b3a80dsm42226405e9.7.2025.12.19.11.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3A4805FE66; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171334; x=1766776134; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IXQ0JVIP0porfp6WIA5UdBF+RCWCKfVXfAFfgt7VfmE=; b=v7UefhSY9E48jM0jLjci2eOy3je2CNFw0qkLH0Uqp2xEspeU0ErWis1Svhub2ty8hz FcccUfnw4eUTF+/+KhiOSnOnLmhujkSf+cG2967vtICHjHYqMr/8JDga78sy/HnzYCrF THtTiWZLN4h4P9Qoi3r2tqf0xL3yuGn3qzRF/NB/wBRwr5911cvMDyCt4pBIRmu3WUwb 7ZmdTZ1r4vIcrAgFcAPjzul3EHpW+8VTl0jnVn6vM3hTLQmQzhEDzP0HDV0zVeGXBD/s LIEe9sb8mHg4KQFpfGaG9GlhrV17vevcdV57pCXKIODodR6uj7D3TW1MM7gkV8tfC6Xm V/GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171334; x=1766776134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IXQ0JVIP0porfp6WIA5UdBF+RCWCKfVXfAFfgt7VfmE=; b=QCUOMk30ZGwu6mNDVSpJuCDBlsLFg48AI4asDbfzxnu8A3Uip5Q9v/da/ZRkrjrddL ASEmgzQJ/PaksJZTVd1ILonBOJ9SyFC8L06Y96JPzarBpN2NtlgUi231v4Ji7uYeAPRG H1dV38sk6uGgRHTkgPm49tFrT9fNv7n4VjfWgFP9tVHoLfEjzGjpsd1Xmhm3cmVbi+fR mnA2VN3efgD57CtH6O9agVDgjybBJ4sDIKuknUeuiLRGxY/jZr/VWFgqf6jR98pEt7Se HcSqbdxsJZyUfR8cgD7uWVDqjpacmbmBY2NUnX0LFefXIi6y5fzLrjk8bMxKT8uOhI1G bRHQ== X-Gm-Message-State: AOJu0YwGIAXfgh8SEzuKr6nndSpftv6KtGngu+GEj083vHGSzaA5++9v mnFSeUDU8KG7eLyX7wxI8maaLpQNAe5vfZL/4hOms0dC6LKSinNKj3qV9mluPWGb1t4= X-Gm-Gg: AY/fxX5SAiTfR+MhJFwJxDfqNWbaaWrfpnyXH/UpX56tA4eD1AWA50G5orU59iXdrU9 M8MVk1yY/GGXYswxhNaALNrfSSMYGnh7dZKJ4qPh3F0HKSKGqj7OMtBVpTv2yEgrnHHYnLDeTxm 7ygDddp5MkQe/CWcY/ABVNtZGgKv62ap5NjWvfo2dUKkTKa5FYvxpsi96xB0PbOlMIbg+MXQXuC yJWcQqRrwwtzRZYQdnDGTq0DqyDdI3/xftKbfZBIhbsX9SRh4cLs5sG8REkmfNJSBfiZgI+cVqg wSig6fh3+nNNGVcJKAVbvtyJflA3vyMkwFt0XRcVZKdu/6Q8+nyM1veSqddbYnVaFAWy1vz9lKh 9mIbXnCLNUwtT7KLPLB29oKizumB5B0kD+X3NEtE1MTQ/x+q6bOknyuTAETy1OxYefUxx7KQ42g zepOgNLN+bHH499HJQuKPeNQ== X-Google-Smtp-Source: AGHT+IFdC0OTekt9ybDbjjAAwIH+3y/8vTzQi7VuvlPdeGli9BRRlgtAH6wvFt2VPfAiMl8LcWGr1w== X-Received: by 2002:a05:600c:4595:b0:477:a1a2:d829 with SMTP id 5b1f17b1804b1-47d1953ead3mr33912265e9.13.1766171334131; Fri, 19 Dec 2025 11:08:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alex Bradbury , qemu-stable@nongnu.org Subject: [RFC PATCH 04/12] docs/about/emulation: Add documentation for hotblocks plugin arguments Date: Fri, 19 Dec 2025 19:08:41 +0000 Message-ID: <20251219190849.238323-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x344.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171380140158500 From: Alex Bradbury Currently just 'inline'. Signed-off-by: Alex Bradbury Reviewed-by: Pierrick Bouvier Message-ID: <60f1ad20663f7e5c6cb00dd83fe0f1f5aa6ca4de.1764716538.git.asb@ig= alia.com> Signed-off-by: Alex Benn=C3=A9e Cc: qemu-stable@nongnu.org --- docs/about/emulation.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index 4a7d1f41780..543efc4d7dc 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -463,6 +463,16 @@ Example:: 0x000000004002b0, 1, 4, 66087 ... =20 +Behaviour can be tweaked with the following arguments: + +.. list-table:: Hot Blocks plugin arguments + :widths: 20 80 + :header-rows: 1 + + * - Option + - Description + * - inline=3Dtrue|false + - Use faster inline addition of a single counter. =20 Hot Pages ......... --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171474; cv=none; d=zohomail.com; s=zohoarc; b=mSNNP/Ni99wTeifZ41yR2jHeH2gKBM4CwpTvftVL3zI1DO/BSIifdkL+SPkMK0kGve1yw+o6jj1o5CSGwoPGRNYgBrbJv6MPvl2rPaSSWM6YD7p8VYLx7FnYX2PqNICfhTiImya5Mlst8PWuXAXxx/FbBlIErxedCVkYK6hRzS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171474; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z1Ho9A/XPHpaG24XQJMf5tV6Yy1l2byzrQqypIVDpzA=; b=TpHxTQO3mp+IDJPXWZYhL9zPLF2nhfWoMZY0CKhF0KO8YB/SrJEYz1pj+nDBo5AbSuqCb0Tfj+Yy1FN7/RMXAIDi+fbWYWqHfZVtm6IGiVP3wl8d8VPp/4Sn9rWzS1ktPHkJudIRGTJ0Xt1sJCMA1av91ddb9wmH+XUvJvOe2ms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171474851243.6379336137203; Fri, 19 Dec 2025 11:11:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfrN-0001br-9F; Fri, 19 Dec 2025 14:09:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqX-0000ci-N6 for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:03 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqU-0006pR-Ck for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:00 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-477770019e4so18527585e9.3 for ; Fri, 19 Dec 2025 11:08:57 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be2723d19sm123428605e9.2.2025.12.19.11.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 518AD5FE99; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171337; x=1766776137; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z1Ho9A/XPHpaG24XQJMf5tV6Yy1l2byzrQqypIVDpzA=; b=G+FnhMtzS3RMtfv/TdimH1hYI4sg4UbXLJxoG60Yi7MUk07gXQKu665zMKi9PNFvlf i/VZzOsdz0T3kGa44FD8PTreMz4QCtmljC8nvjpTJWZpmpb6y/hQ70I9+yWtGMtmLheK Pwtsp3lXF4msGxl2GIgTW3qK3a2e/4BLEm5Xznw9BuZ7KD5+bQJradqm+Qd21gHLCJ61 juj2R9nArj91yb0nk9h39cGaDMWHepSrJl+eXpx5oI9/8GncUe648mBlkUkaGAERIIEs c6RaIHjSLqlxGrZPo6DMxtZD4XWXNUMa5SM0NCnYAKGEZqk5/8F0MQhTDRsLTvVpgG05 42pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171337; x=1766776137; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z1Ho9A/XPHpaG24XQJMf5tV6Yy1l2byzrQqypIVDpzA=; b=QH00x8UDbwDstEyHtJuSc7e0jAXIezfzv0akJ9jWczalxD2rgTH35T0RlEHRFEQz4P OsYAg4A2fboevHprPrczbBaQZM2LAoUAfa48OwGYSeEGXCUct8qa11H6tEVSvZTSDHjX LtV+BYhKbkKOJ6LO+49XI6U/LXnd9aS51psVIkMRlO2Jz2P2LkY6FMQmBQTSZSSujIIq WFUWj8Y44m2Clmmd9zhx6JjrjkIaKDbmMEmlKdWAn0z16a+s968vSa+KVM9/tWE6gNBr 644aacV6SCiqXOWX7yeT5r/TgnrRMYdG7/H23EAQ/aaezBirMROPX7q9VYtecng0i8cg rq9w== X-Gm-Message-State: AOJu0YxQjNNFnPw0hYKIagQI8pppb2K5SWDZq/EM8s6nWLIp2ameUm4V rNJrjhbyQftZs7KjbkVuTmTUmxEr/YcKnyrXtVDRS8ZnAUlPwViWc7gvesLlJSy8SAg= X-Gm-Gg: AY/fxX7q6wEet3CitMT1ohy8s6Rr9pptJNcHfPaiN/VoWYaiULtapthWQdakc80ZSoF Wj5wDOE1G63tXDNQS8wuVVESzDuCargf4p8zBXCxrwglDsEPBH/oCOCiI4VCNtvfyf/NGaRflrc tgbBiPzhnEEgaOY8w7k1dzHFNfsEn/zWL4H1++XKnpKgHCsuWxYFX6CKF4Jb57zLsopbG2b7P72 wt7u5ar3cUCLGkuGJBJJ2yknnBAP1nZnGMkuCpL/YwOuM7XbH35mmOQMhVp3relPq+jfJWpuBNE xrX/eFEpilHpxzBUXvmgWesKeQ9+20mexBhzxyITsSfOiYJoyNMgz69vqb8f678pbVI/m2UTn1O nmlIKdSkNvseh4nAkyVcM1ByEmU1qXTeUfz7utCXUulLEsnt+mCBQ4zHH4GcU4WoKn+PMrSbh9c EuUYByg0V62zs= X-Google-Smtp-Source: AGHT+IEiRuseyh0saS2WdyWQSI+3lEZVjidRsb7ooPV+14p4ymxQyBFa4fsZZF3Ealju2FknUZz8Fw== X-Received: by 2002:a05:600c:1d1d:b0:477:9eb8:97d2 with SMTP id 5b1f17b1804b1-47d1953b8acmr38452675e9.8.1766171335660; Fri, 19 Dec 2025 11:08:55 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alex Bradbury Subject: [RFC PATCH 05/12] contrib/plugins/hotblocks: Allow limit to be set as a command line argument Date: Fri, 19 Dec 2025 19:08:42 +0000 Message-ID: <20251219190849.238323-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171476070158500 From: Alex Bradbury Also add documentation for this argument. This allows the default of 20 to be overridden, and is helpful for using the hotblocks plugin for analysis scripts that require collecting data on a larger number of blocks (e.g. setting limit=3D0 to dump information on all blocks). Signed-off-by: Alex Bradbury Reviewed-by: Pierrick Bouvier Message-ID: Signed-off-by: Alex Benn=C3=A9e --- docs/about/emulation.rst | 2 ++ contrib/plugins/hotblocks.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index 543efc4d7dc..e8793b0f9ce 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -473,6 +473,8 @@ Behaviour can be tweaked with the following arguments: - Description * - inline=3Dtrue|false - Use faster inline addition of a single counter. + * - limit=3DN + - The number of blocks to be printed. (Default: N =3D 20, use 0 for no= limit). =20 Hot Pages ......... diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 40d8dae1cd3..8ecf0339974 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -84,7 +84,8 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) if (sorted_counts) { g_string_append_printf(report, "pc, tcount, icount, ecount\n"); =20 - for (i =3D 0, it =3D sorted_counts; i < limit && it; i++, it =3D i= t->next) { + for (i =3D 0, it =3D sorted_counts; (limit =3D=3D 0 || i < limit) = && it; + i++, it =3D it->next) { ExecCount *rec =3D (ExecCount *) it->data; g_string_append_printf( report, "0x%016"PRIx64", %d, %ld, %"PRIu64"\n", @@ -170,6 +171,13 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qem= u_info_t *info, fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); return -1; } + } else if (g_strcmp0(tokens[0], "limit") =3D=3D 0) { + char *endptr =3D NULL; + limit =3D g_ascii_strtoull(tokens[1], &endptr, 10); + if (endptr =3D=3D tokens[1] || *endptr !=3D '\0') { + fprintf(stderr, "unsigned integer parsing failed: %s\n", o= pt); + return -1; + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171431; cv=none; d=zohomail.com; s=zohoarc; b=ar+82vRb/jBMNpjWpawOuu/uW4Lpqj3Bo1H6KIGUGQQZqzbNbq8tqH6S6mwllIn0LLtVQUsCZwSleAyIm2MvUoLvnhZDLw+TCQcF9JpKXYbeP4dO16lKdjn3gNHku87uUkfL2cgAufNLqnySD6jDuQC5dlAiPYjh49Tx5LPcGrw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171431; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LdWAJH6s7XticPUwO+/xRlCKqNuhKhU8yKqVINAJxXA=; b=cxV2K3N46X7h3o7LncqbAEPQW+X6BXj2pWVLedQPHpNNQAhhBYGSH/29P/Ek2AlIqJ1iVJHxaHB6fMAwAUAnP7iDMSvC/sm+SLaBzBdQOmXNw678Z4cn6AXYRvXpuvs5PzxVxbLQIHyIiY0pobLLdVBnv0LwfNP3846fIZXiC0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17661714315701013.8605176769161; Fri, 19 Dec 2025 11:10:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfrJ-00018p-5t; Fri, 19 Dec 2025 14:09:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqZ-0000f0-Sc for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:10 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqX-0006qy-DD for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:03 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4779cb0a33fso21685235e9.0 for ; Fri, 19 Dec 2025 11:08:59 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea1aee5sm6533011f8f.4.2025.12.19.11.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 72AE06003B; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171339; x=1766776139; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LdWAJH6s7XticPUwO+/xRlCKqNuhKhU8yKqVINAJxXA=; b=seU9cUL3KdiqhUJbXeZkV5ubltZE7lgJYvzMHvzTg5+GA4rgAN/Avc3/C8h0Z43dxl 9LhfKlBtDFNxCS7KgNXUvI9VqRwxPzgmJmuhrGo9MpMCk1vq5T+91b2/Bv8zJrTqiLBz YOML5zgPHIGPo9uAVOBGqVdVWXOOSHRggq3HQGBvz6iuR+TX5M2LHZlGKcrLDCMKnFzn W9R1Hy7sk4mPrLaEdJ7RTgkePvY1vK6bvXS3PLZMrZq9u+P/gyUcmlMnqYhTspu14HGr gC/tlsrbLvJSTt3puu9wCt8MjkqpCofOm/BiqStqWz/Ij17m+sKM4mUixd0MuNTZ0MdM 8dWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171339; x=1766776139; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LdWAJH6s7XticPUwO+/xRlCKqNuhKhU8yKqVINAJxXA=; b=BLNCU8UDC9iivatpsgmM7H32CV7hKA8KA8G9V76fv2iJYSeMH1IYy+MdD4De/sBohX 9xugiRQMBCQK7/KsDgKJqxTEj12w9zN7nqOKI4XlWYUpyRmVbYsKmKMb4RT/BCMlaRWB apkI+zToSzva+vemIpqO1EtP5w2A38/g9nY7j/SWfhgb9+TB/A6KtJl6pdAHG7dzFnoI CcmIJLZUlY5qjQcKwPJoJez44PWLDsxLm+KeHyI2D6WaV+OKOfaRN7QgJ3uUZkbmm/9q qVjhaCwK12YN109Krx2ngjd3ooG38BECD4s8jpS7rS6IeuRESn2DWMJNfQlfll7CTqlm 2h4w== X-Gm-Message-State: AOJu0Yz5bHrnWcCgiPImXPnhKZG6eX0oFrwBVf36I0Kvq74GCf9q3fvZ p3IU84xoDX1fSG4TEb/GWiGoyGkQhpAnlsAUlH3a/O9BHKf1NkeyFNUkt0peHAcs8pw= X-Gm-Gg: AY/fxX6K3og6VONXumXkP38oaXhe6HuzEQlP9p8jF92fiTrJ+to4qVDC52W1yuGGOQj XPVmO9fzWtq2r0QJItK2kcrra9ROnTaefNYU4Ie0K5CN5aKjEmUUCMebfQRt6WgyTJd2L5RPjCH WcTF9uVGgYsAQ+OH+Rg+WYjv1OveqO5vjD71SwidERtnygq90Mzsku34e1yRC3Udr5UyLv5Y16L pLhu8EIgjyuhu84slXBMOskOPpu8LDP4KmlyTO/rhYWiLumsqgzIk2JVDebdeqKRDO4gvcQ9lGE o1J9D7Vf6re1I9+HyPUiBxObsmChyigwoVCIRnPxp+Yk8FSQ9o++lkL0n7Edm40zEKhLTILwtnT 8Lem4vJM/rWT3s14DqBjalXCmz/q4d0ahWA9TvOe6cs/pjmZn0GfLO9lT8h0DBne0LE5CGF52FK smZCVWSsNbkVc= X-Google-Smtp-Source: AGHT+IH7AC9vVnND0gYXr5atVBGRs/VhsrnYyCclK/S3/odWqahABKmANWELHXqVL5a40P6VSkjfMQ== X-Received: by 2002:a05:6000:250d:b0:42f:bc61:d1d9 with SMTP id ffacd0b85a97d-4324e4c9dc4mr4863073f8f.20.1766171338219; Fri, 19 Dec 2025 11:08:58 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [RFC PATCH 06/12] plugins: shorten aggressively long name Date: Fri, 19 Dec 2025 19:08:43 +0000 Message-ID: <20251219190849.238323-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171434014158500 The old name comes in at a 51 characters, contains at least one redundant token and exec is arguably implied by inline as all inline operations occur when instructions are executing. By putting the name on a substantial diet we can reduce it by 15% and gain valuable white-space in the process. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Pierrick Bouvier --- include/qemu/qemu-plugin.h | 4 ++-- contrib/plugins/cflow.c | 22 +++++++++++----------- contrib/plugins/howvec.c | 2 +- contrib/plugins/stoptrigger.c | 10 ++++++---- plugins/api.c | 2 +- tests/tcg/plugins/discons.c | 18 +++++++++--------- tests/tcg/plugins/inline.c | 6 +++--- tests/tcg/plugins/insn.c | 5 +++-- 8 files changed, 36 insertions(+), 33 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 60de4fdd3fa..29663591ebf 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -516,7 +516,7 @@ void qemu_plugin_register_vcpu_insn_exec_cond_cb( void *userdata); =20 /** - * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op + * qemu_plugin_register_inline_per_vcpu() - insn exec inline op * @insn: the opaque qemu_plugin_insn handle for an instruction * @op: the type of qemu_plugin_op (e.g. ADD_U64) * @entry: entry to run op @@ -525,7 +525,7 @@ void qemu_plugin_register_vcpu_insn_exec_cond_cb( * Insert an inline op to every time an instruction executes. */ QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( +void qemu_plugin_register_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, qemu_plugin_u64 entry, diff --git a/contrib/plugins/cflow.c b/contrib/plugins/cflow.c index b5e33f25f9b..cef5ae2239f 100644 --- a/contrib/plugins/cflow.c +++ b/contrib/plugins/cflow.c @@ -320,14 +320,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) * check where we are at. Do this on the first instruction and not * the TB so we don't get mixed up with above. */ - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(first_insn, - QEMU_PLUGIN_INLINE_S= TORE_U64, - end_block, qemu_plug= in_insn_vaddr(last_insn)); - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(first_insn, - QEMU_PLUGIN_INLINE_S= TORE_U64, - pc_after_block, - qemu_plugin_insn_vad= dr(last_insn) + - qemu_plugin_insn_siz= e(last_insn)); + qemu_plugin_register_inline_per_vcpu(first_insn, + QEMU_PLUGIN_INLINE_STORE_U64, + end_block, qemu_plugin_insn_vaddr= (last_insn)); + qemu_plugin_register_inline_per_vcpu(first_insn, + QEMU_PLUGIN_INLINE_STORE_U64, + pc_after_block, + qemu_plugin_insn_vaddr(last_insn)= + + qemu_plugin_insn_size(last_insn)); =20 for (int idx =3D 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, idx); @@ -355,9 +355,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) } =20 /* Store the PC of what we are about to execute */ - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, - QEMU_PLUGIN_IN= LINE_STORE_U64, - last_pc, ipc); + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_STORE_U64, + last_pc, ipc); } } =20 diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c index 42bddb6566d..c60737d57f1 100644 --- a/contrib/plugins/howvec.c +++ b/contrib/plugins/howvec.c @@ -321,7 +321,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) =20 if (cnt) { if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + qemu_plugin_register_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_ADD_U64, qemu_plugin_scoreboard_u64(cnt), 1); } else { diff --git a/contrib/plugins/stoptrigger.c b/contrib/plugins/stoptrigger.c index b3a6ed66a7b..68c0ed432af 100644 --- a/contrib/plugins/stoptrigger.c +++ b/contrib/plugins/stoptrigger.c @@ -73,10 +73,12 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) =20 if (exit_on_icount) { /* Increment and check scoreboard for each instruction */ - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( - insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1); - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( - insn, QEMU_PLUGIN_INLINE_STORE_U64, current_pc, insn_vaddr= ); + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_ADD_U6= 4, + insn_count, 1); + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_STORE_= U64, + current_pc, insn_vaddr); qemu_plugin_register_vcpu_insn_exec_cond_cb( insn, exit_icount_reached, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_COND_EQ, insn_count, icount + 1, NULL); diff --git a/plugins/api.c b/plugins/api.c index eac04cc1f6b..267fa2fd503 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -154,7 +154,7 @@ void qemu_plugin_register_vcpu_insn_exec_cond_cb( cond, entry, imm, udata); } =20 -void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( +void qemu_plugin_register_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, qemu_plugin_u64 entry, diff --git a/tests/tcg/plugins/discons.c b/tests/tcg/plugins/discons.c index 2e0e664e823..1348d6e5020 100644 --- a/tests/tcg/plugins/discons.c +++ b/tests/tcg/plugins/discons.c @@ -156,15 +156,15 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) uint64_t next_pc =3D pc + qemu_plugin_insn_size(insn); uint64_t has_next =3D (i + 1) < n_insns; =20 - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, - QEMU_PLUGIN_IN= LINE_STORE_U64, - last_pc, pc); - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, - QEMU_PLUGIN_IN= LINE_STORE_U64, - from_pc, next_= pc); - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, - QEMU_PLUGIN_IN= LINE_STORE_U64, - has_from, has_= next); + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_STORE_U64, + last_pc, pc); + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_STORE_U64, + from_pc, next_pc); + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_STORE_U64, + has_from, has_next); qemu_plugin_register_vcpu_insn_exec_cb(insn, insn_exec, QEMU_PLUGIN_CB_NO_REGS, NUL= L); } diff --git a/tests/tcg/plugins/inline.c b/tests/tcg/plugins/inline.c index 73dde995781..35307501105 100644 --- a/tests/tcg/plugins/inline.c +++ b/tests/tcg/plugins/inline.c @@ -244,15 +244,15 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) void *insn_store =3D insn; void *mem_store =3D (char *)insn_store + 0xff; =20 - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + qemu_plugin_register_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_STORE_U64, data_insn, (uintptr_t) insn_store); qemu_plugin_register_vcpu_insn_exec_cb( insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, insn_store); - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + qemu_plugin_register_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1); =20 - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + qemu_plugin_register_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_cond_track_count, 1); qemu_plugin_register_vcpu_insn_exec_cond_cb( insn, vcpu_insn_cond_exec, QEMU_PLUGIN_CB_NO_REGS, diff --git a/tests/tcg/plugins/insn.c b/tests/tcg/plugins/insn.c index 0c723cb9ed8..b337fda9f13 100644 --- a/tests/tcg/plugins/insn.c +++ b/tests/tcg/plugins/insn.c @@ -147,8 +147,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( - insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1); + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_ADD_U6= 4, + insn_count, 1); } else { qemu_plugin_register_vcpu_insn_exec_cb( insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, NULL); --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171470; cv=none; d=zohomail.com; s=zohoarc; b=kB4F7W4KeQ+ldQgFjFWdwkhoi9OKLzXq0jTgc48Khivp6qk4CiJlAaPdKgOxSptcew9eewrYN0y/8u2n8p3tHNHXv5OPo/H05fApIOH6RwOMzPvm1FJGujNylUm8m5yRqC9YgxpEeY3umgzt9IZVeLofvpYNS+MSroyajTTtlKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171470; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=exhExtIFkfMLYG9IcRv/g6zEaHCsYLLw3EKLbf6kTV8=; b=WDWQJNWNITXfmdfh5IvUPWJJO06x7oZE0NOafIhlvfbVuuKygBlunDt09L6Gu0EfwifwX3kcul2P64efwmDIUOdYtzqP4cyyHbLDdiXWaGlN7+cxjP2gwjDKEEEEs1leBIY9M4d7lQlyRTrntklVIolGIbHcq2A+iB/2ZNruQMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171470724819.1062898975109; Fri, 19 Dec 2025 11:11:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfqr-0000i5-Eo; Fri, 19 Dec 2025 14:09:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqY-0000cp-KU for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:03 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqV-0006qU-9O for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:02 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-477a219dbcaso18783305e9.3 for ; Fri, 19 Dec 2025 11:08:58 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be273e4d5sm112791785e9.6.2025.12.19.11.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 959B5600A1; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171338; x=1766776138; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=exhExtIFkfMLYG9IcRv/g6zEaHCsYLLw3EKLbf6kTV8=; b=L9jS7TA6Olkqqjb4VURbPfJYp7k16GwdX7odVYiejS88xXy2o7AphJsRz+JzOjcldQ 3vczdLvFLGnALH5r4Uchv3+C0AlnrqA68Ph1NwQ38S1Y/w6BMZq3xRuHoGZVJMXX/vhy Of1XQODUe3f8isULCgbSxQa6yUKFBOMQHbqWe2Xmn986hitN4psVrW9q8ZJbzzjJvmDI GCs+Ya5qXYAMXxmtUwXt/8c6Nf0FjxOc2WD8yNXRhxZ0Ei9bsFMzW+PVl9Pi9i3A8j8A KfcGDmfguhY05DPO/OpUP58tdnnk3MCE4Phd0YtULKUxeaIL/jme2vue6rDmI58oRQtB qKjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171338; x=1766776138; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=exhExtIFkfMLYG9IcRv/g6zEaHCsYLLw3EKLbf6kTV8=; b=bkeheMTyMc3X3EP3FWKU1O4TSG4U2X5zvq4IM/LmDVPkEhVlYqhCcDTDuV8roJLfQK 71WdWRI4Il/JLbuQTrFGnLqklIj1KkZPPMPb3X5TcQvizthOMvC6AtxyXzum/UpU6qup Q0FJuZ7lZmoKO9iSq+Xz2CVqLPaokKVHEcqixcxeTkp2bf/6Q+pK/TKX2Cc1MjUwyIRO fZ1JTKM9KPNXQgXvi8UMrydzW/ykHqESLx03vO3OWQ00wZBNHT1j1WNfVI2RHvsCgoHg ctHAccnWVXKkhdlM54A16bWZ8OyJxZrLxJNGqYbGJmJMZA6WlFxuJzRtI1i3UacsSuf1 3c6g== X-Gm-Message-State: AOJu0Yy6M8CRx1JBscwHwo1DLI9wKEtO3yu2FKYeRaNvICccfmbwjDH9 3g5s84Qcmud8GVNlc21l/P5meFU6Rr0onlHbftkHGiff8A5KW599a0znmcodYDjgnAM= X-Gm-Gg: AY/fxX7JIynDxfbIm4/Oa2pz/C2BZk2F44gDP3sWZiG2L0lsV2YkZgix25I41akvmw7 Kb77QXuqL36GYAyiHzjXAYgTNvKwCSZTpFlAHV4TBuh3SARmez+XAHfNa9H1m6IbVrFRJF/DGKP xt2x3+Bot39rZEOqRnGCoayoKDW+039etV+/l8ykXGK9BwsxAioR8jWjG9z8KxiPubRwA/ttond xzQhsdvFaUIHRPYGmP070qJjWjlwdOfoAWq/RiSnaeHyAEaX/6zxKr7vBwCVgOVV8JS8vrRPTBL bRfD2QR/lco1VADT3RuSY8Iqn2yuPTWAjtusoNakZZCuUk4Vab8iVpOIcP8MYy+jxNFzY6a20Oe pnbUw76Zlu7Mg1rkv2EExMGl/R2Qw0GGrUSb/nCX1iGAGmoa7e2J9i2FEqfmyRZQHs0un7D+xCT u8zLoBFKrBg68= X-Google-Smtp-Source: AGHT+IFJALMRzI5PGuNMXQPR8fO9l2JZcG1tkgYlhqKkofOlFKniutHsE5LdORNLcgPau9hBLUaCrw== X-Received: by 2002:a05:600c:1d1d:b0:477:9c73:267f with SMTP id 5b1f17b1804b1-47d195aa4bfmr43379675e9.33.1766171337575; Fri, 19 Dec 2025 11:08:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Ziyang Zhang , Mingyuan Xia Subject: [RFC PATCH 07/12] linux-user: add plugin API to filter syscalls Date: Fri, 19 Dec 2025 19:08:44 +0000 Message-ID: <20251219190849.238323-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171471882158500 From: Ziyang Zhang This commit adds a syscall filter API to the TCG plugin API set. Plugins can register a filter callback to QEMU to decide whether to intercept a syscall, process it and bypass the QEMU syscall handler. Signed-off-by: Ziyang Zhang Co-authored-by: Mingyuan Xia Reviewed-by: Pierrick Bouvier Message-ID: <20251214144620.179282-2-functioner@sjtu.edu.cn> Signed-off-by: Alex Benn=C3=A9e --- include/qemu/plugin-event.h | 1 + include/qemu/plugin.h | 33 +++++++++++++++++++++++--------- include/qemu/qemu-plugin.h | 32 +++++++++++++++++++++++++++++++ include/user/syscall-trace.h | 17 +++++++++++++++++ linux-user/syscall.c | 7 +++++-- plugins/api.c | 7 +++++++ plugins/core.c | 37 ++++++++++++++++++++++++++++++++++++ 7 files changed, 123 insertions(+), 11 deletions(-) diff --git a/include/qemu/plugin-event.h b/include/qemu/plugin-event.h index 1100dae2123..7f3c5927f1f 100644 --- a/include/qemu/plugin-event.h +++ b/include/qemu/plugin-event.h @@ -23,6 +23,7 @@ enum qemu_plugin_event { QEMU_PLUGIN_EV_VCPU_INTERRUPT, QEMU_PLUGIN_EV_VCPU_EXCEPTION, QEMU_PLUGIN_EV_VCPU_HOSTCALL, + QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER, QEMU_PLUGIN_EV_MAX, /* total number of plugin events we support */ }; =20 diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index cea0a68858b..91df1e78d2c 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -55,15 +55,16 @@ void qemu_plugin_opt_parse(const char *optstr, QemuPlug= inList *head); int qemu_plugin_load_list(QemuPluginList *head, Error **errp); =20 union qemu_plugin_cb_sig { - qemu_plugin_simple_cb_t simple; - qemu_plugin_udata_cb_t udata; - qemu_plugin_vcpu_simple_cb_t vcpu_simple; - qemu_plugin_vcpu_udata_cb_t vcpu_udata; - qemu_plugin_vcpu_discon_cb_t vcpu_discon; - qemu_plugin_vcpu_tb_trans_cb_t vcpu_tb_trans; - qemu_plugin_vcpu_mem_cb_t vcpu_mem; - qemu_plugin_vcpu_syscall_cb_t vcpu_syscall; - qemu_plugin_vcpu_syscall_ret_cb_t vcpu_syscall_ret; + qemu_plugin_simple_cb_t simple; + qemu_plugin_udata_cb_t udata; + qemu_plugin_vcpu_simple_cb_t vcpu_simple; + qemu_plugin_vcpu_udata_cb_t vcpu_udata; + qemu_plugin_vcpu_discon_cb_t vcpu_discon; + qemu_plugin_vcpu_tb_trans_cb_t vcpu_tb_trans; + qemu_plugin_vcpu_mem_cb_t vcpu_mem; + qemu_plugin_vcpu_syscall_cb_t vcpu_syscall; + qemu_plugin_vcpu_syscall_ret_cb_t vcpu_syscall_ret; + qemu_plugin_vcpu_syscall_filter_cb_t vcpu_syscall_filter; void *generic; }; =20 @@ -169,6 +170,11 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, u= int64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a= 5, uint64_t a6, uint64_t a7, uint64_t a8); void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret); +bool +qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1, + uint64_t a2, uint64_t a3, uint64_t a4, + uint64_t a5, uint64_t a6, uint64_t a7, + uint64_t a8, uint64_t *ret); =20 void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, uint64_t value_low, @@ -280,6 +286,15 @@ static inline void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) { } =20 +static inline bool +qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1, + uint64_t a2, uint64_t a3, uint64_t a4, + uint64_t a5, uint64_t a6, uint64_t a7, + uint64_t a8, uint64_t *ret) +{ + return false; +} + static inline void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, uint64_t value_low, uint64_t value_high, diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 29663591ebf..e8db7a72545 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -798,6 +798,33 @@ typedef void uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8); =20 +/** + * typedef qemu_plugin_vcpu_syscall_filter_cb_t - vCPU syscall filter call= back + * function type + * @id: plugin id + * @vcpu_index: the executing vCPU + * @num: the syscall number + * @a1: the 1st syscall argument + * @a2: the 2nd syscall argument + * @a3: the 3rd syscall argument + * @a4: the 4th syscall argument + * @a5: the 5th syscall argument + * @a6: the 6th syscall argument + * @a7: the 7th syscall argument + * @a8: the 8th syscall argument + * @sysret: reference of the syscall return value, must set this if filter= ed + * + * Returns true if you want to filter this syscall (i.e. stop it being + * handled further), otherwise returns false. + */ +typedef bool +(*qemu_plugin_vcpu_syscall_filter_cb_t)(qemu_plugin_id_t id, + unsigned int vcpu_index, + int64_t num, uint64_t a1, uint64_t= a2, + uint64_t a3, uint64_t a4, uint64_t= a5, + uint64_t a6, uint64_t a7, uint64_t= a8, + uint64_t *sysret); + QEMU_PLUGIN_API void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_cb_t cb= ); @@ -811,6 +838,11 @@ void qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_syscall_ret_cb_t= cb); =20 +QEMU_PLUGIN_API +void +qemu_plugin_register_vcpu_syscall_filter_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_filte= r_cb_t cb); + =20 /** * qemu_plugin_insn_disas() - return disassembly string for instruction diff --git a/include/user/syscall-trace.h b/include/user/syscall-trace.h index 9bd7ca19c84..4ee6c4e5134 100644 --- a/include/user/syscall-trace.h +++ b/include/user/syscall-trace.h @@ -39,5 +39,22 @@ static inline void record_syscall_return(CPUState *cpu, = int num, abi_long ret) gdb_syscall_return(cpu, num); } =20 +static bool send_through_syscall_filters(CPUState *cpu, int num, + abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6, + abi_long arg7, abi_long arg8, + abi_long *sysret) +{ + uint64_t sysret64 =3D 0; + bool filtered =3D qemu_plugin_vcpu_syscall_filter(cpu, num, arg1, arg2, + arg3, arg4, arg5, arg6, + arg7, arg8, &sysret64); + if (filtered) { + *sysret =3D sysret64; + } + return filtered; +} + =20 #endif /* SYSCALL_TRACE_H */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2060e561a20..9ae3c5bfbd7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -14201,8 +14201,11 @@ abi_long do_syscall(CPUArchState *cpu_env, int num= , abi_long arg1, print_syscall(cpu_env, num, arg1, arg2, arg3, arg4, arg5, arg6); } =20 - ret =3D do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, - arg5, arg6, arg7, arg8); + if (!send_through_syscall_filters(cpu, num, arg1, arg2, arg3, arg4, ar= g5, + arg6, arg7, arg8, &ret)) { + ret =3D do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + } =20 if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { print_syscall_ret(cpu_env, num, ret, arg1, arg2, diff --git a/plugins/api.c b/plugins/api.c index 267fa2fd503..a98c0d3e41a 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -208,6 +208,13 @@ qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_i= d_t id, plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_RET, cb); } =20 +void +qemu_plugin_register_vcpu_syscall_filter_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_filte= r_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER, cb); +} + /* * Plugin Queries * diff --git a/plugins/core.c b/plugins/core.c index b4b783008f7..85fabf9ec81 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -564,6 +564,43 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64= _t num, int64_t ret) } } =20 +/* + * Disable CFI checks. + * The callback function has been loaded from an external library so we do= not + * have type information + */ +QEMU_DISABLE_CFI +bool +qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1, + uint64_t a2, uint64_t a3, uint64_t a4, + uint64_t a5, uint64_t a6, uint64_t a7, + uint64_t a8, uint64_t *sysret) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev =3D QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER; + bool filtered =3D false; + + if (!test_bit(ev, cpu->plugin_state->event_mask)) { + return false; + } + + qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_RW_REGS); + + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_syscall_filter_cb_t func =3D cb->f.vcpu_syscall_f= ilter; + + if (func(cb->ctx->id, cpu->cpu_index, num, a1, a2, a3, a4, + a5, a6, a7, a8, sysret)) { + filtered =3D true; + break; + } + } + + qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS); + + return filtered; +} + void qemu_plugin_vcpu_idle_cb(CPUState *cpu) { /* idle and resume cb may be called before init, ignore in this case */ --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171422; cv=none; d=zohomail.com; s=zohoarc; b=cjUZEFGz7QnC7mEZpunFxzMLhgRF9P8kxP4qQPcMIJdrgDeg7mMOroYh9L3UuHeFdWpZwDpqAYsPflJ62zxui6JvGaXg3SPkY9ALog0p1wWnQvbgq7vTsHT5vW3JALfkFjgpWx9VFslwS0zlvTKG9WVjpFnpZt5Wx6TxW239jWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171422; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LBlglM9JFPWM18boH0BMxZfCeA1juo9itb3ve4H0EqE=; b=ZtNDYQSZXVWcXnMFRXwbz9Bisfh4/KEFiOsyfiJV7SpHybnHINZAlovMuVvH6vMNaWWbtBo35QGQpwSyugynj5f3O2LEnQ1i6jbvbMQ255d/cDWMI6tjuMMEmredPvgdHNJrjdn+F97QcLIDUwXKunaVG49sMKhLL3azvfeel1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171422569464.2197935960918; Fri, 19 Dec 2025 11:10:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfrO-0001hp-2u; Fri, 19 Dec 2025 14:09:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqX-0000cg-Mz for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:03 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqU-0006po-K5 for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:01 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so13771145e9.0 for ; Fri, 19 Dec 2025 11:08:58 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d19346e48sm55343155e9.2.2025.12.19.11.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B0619600FE; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171337; x=1766776137; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LBlglM9JFPWM18boH0BMxZfCeA1juo9itb3ve4H0EqE=; b=Getzhc+vfwMNOdf7+cOOBa2HK6PyGN5FNOsLdHP6pgE75RDSf8BaAcMCtOlFrSoHK6 XoBdq32Yt/hFSEgqmKNCHu5FZJB1VrUxWCjUABcH4YuKpNRQXi+TUpGCEi92osko9f38 Eit3uaK2n/WpZhxbDjQ4fobVez3PbzjtG/NEY2RfbuXvYYSHA7IPWpXvH78BNIH9bOmv gcDGXtyU0b4UULM0AsDMwjSmVZffyVW0NzbnAlskg7m469/3KwMuaPL7E5AgDUTc8bDM hBc29ZuZ/Xxm00I6stgNkJfxmbtmWGjuBJC31zSGfCRdHWSpEVkEVnG8Qtwhf8dS/IvM uVtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171337; x=1766776137; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LBlglM9JFPWM18boH0BMxZfCeA1juo9itb3ve4H0EqE=; b=N7t9EpI9S7jiuRQVzabtzaXIsyy8UMK1RyarEJCIAoWOvwK3RuLwhmF+UuSO7G+HOC 6d1eqW3t0iHOOL6ZDOiHI3ljRmHrI7BC3zMw8YmLJ+ijYi7L3+P0jwFSyKDxfUc9PIPT 3DWGJ2m0zE5o1TPBraWXgSP8yBgerfhJYSxxdHegjNK4hQYpxUudq/tb+e45RuICpY/p 7t+zWcE4OGh1eAwUKzj5IcFbWxyKkPplPN+JMSImzSzA2KOPXk4hJXnJSn747CPgBXoc DZOzBQUctqKuz8GiCvDBr3nqO8EXUlnpFiyHYsOeMJ3goIa15ZKSGR/qAKaot3v/U56r zQAg== X-Gm-Message-State: AOJu0Yxy+TjZnrg1zh2j+nW7sqmG+0kFSR0IXIGZeJ826jU21VBfvc6a +oL6W6CpxfOOXczOBlOGpsSGcdYkWaFtoma3fs28wtOcn6g8XDv6PiRgPcsCTvtsf2U= X-Gm-Gg: AY/fxX5wnM4f8SWw0tg2IZbJVYP1JqIfD54nV7ZJefG3YB0BFYpNJsAJa79nqC3hPP5 ODYITDGn/KV8jaMHrgfFdZukRFHauvu9zMxSBTXfhtszJcWj3n/5uY9yxVUR2F06p1PMwfsh56r mihctf+v1oJv20tcch78lSIWHz9W1OvnHa929VU9grPihflw46ozcTurqneAND142mU0zkb/Dv6 VPEF8CgY+wYk514YTZI6HNXzjZXKcqWHJbkkZyD4yk1xtVupfOUfCX+H0SXumiLkDZ3+esnkmvM KyqEEuT7uFM5fyv2TyW+PGxfSWWPq3NG6RU5+qOjebXbLQWmb9GJ08yRw/wt94ID4rPrswYsl+u SGTkKkZNVNvmaSObmonzuRsVRi/QaQqEsPM2XysaBosZ69xVjB3yokWUok3vcMiLpcXRkRRbs71 H7MOk2FaMaYj0= X-Google-Smtp-Source: AGHT+IHGZUtcKQEtS4/zvWBFpofDj83AL78J2684Q/jk7+NYYE7bRgd9WFFHNkJyGywnxsCEdbN5ig== X-Received: by 2002:a05:600c:c167:b0:477:54f9:6ac2 with SMTP id 5b1f17b1804b1-47d194c1e99mr39312485e9.0.1766171336924; Fri, 19 Dec 2025 11:08:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Ziyang Zhang , Mingyuan Xia Subject: [RFC PATCH 08/12] tcg tests: add a test to verify the syscall filter plugin API Date: Fri, 19 Dec 2025 19:08:45 +0000 Message-ID: <20251219190849.238323-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171423946158500 From: Ziyang Zhang Register a syscall filter callback in tests/tcg/plugins/sycall.c, returns a specific value for a magic system call number, and check it in tests/tcg/multiarch/test-plugin-syscall-filter.c. Signed-off-by: Ziyang Zhang Co-authored-by: Mingyuan Xia Reviewed-by: Pierrick Bouvier Message-ID: <20251214144620.179282-3-functioner@sjtu.edu.cn> Signed-off-by: Alex Benn=C3=A9e --- .../multiarch/test-plugin-syscall-filter.c | 35 +++++++++++++++++++ tests/tcg/plugins/syscall.c | 19 ++++++++++ tests/tcg/multiarch/Makefile.target | 4 ++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/test-plugin-syscall-filter.c diff --git a/tests/tcg/multiarch/test-plugin-syscall-filter.c b/tests/tcg/m= ultiarch/test-plugin-syscall-filter.c new file mode 100644 index 00000000000..caa2063a461 --- /dev/null +++ b/tests/tcg/multiarch/test-plugin-syscall-filter.c @@ -0,0 +1,35 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This test attempts to execute a magic syscall. The syscall test plugin + * should intercept this and return an expected value. + */ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + /* + * We cannot use a very large magic syscall number, because on some IS= As, + * QEMU will treat it as an illegal instruction and trigger a critical + * exception. For instance, on arm32, the syscall number cannot exceed + * ARM_NR_BASE (0xf0000), as can be seen in + * "linux-user/arm/cpu_loop.c:cpu_loop". + * + * Therefore, we pick 2048 because, as of now, no ISA in Linux uses th= is + * number. This is just a test case; replace this number as needed in = the + * future. + * + * The corresponding syscall filter is implemented in + * "tests/tcg/plugins/syscall.c". + */ + long ret =3D syscall(2048, 0x66CCFF); + if (ret !=3D 0xFFCC66) { + fprintf(stderr, "Error: unexpected syscall return value %ld\n", re= t); + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/tests/tcg/plugins/syscall.c b/tests/tcg/plugins/syscall.c index 42801f5c863..e7d4e9b5895 100644 --- a/tests/tcg/plugins/syscall.c +++ b/tests/tcg/plugins/syscall.c @@ -170,6 +170,24 @@ static void vcpu_syscall_ret(qemu_plugin_id_t id, unsi= gned int vcpu_idx, } } =20 +static bool vcpu_syscall_filter(qemu_plugin_id_t id, unsigned int vcpu_ind= ex, + int64_t num, uint64_t a1, uint64_t a2, + uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8, + uint64_t *sysret) +{ + /* Special syscall to test the filter functionality. */ + if (num =3D=3D 2048 && a1 =3D=3D 0x66CCFF) { + *sysret =3D 0xFFCC66; + + if (!statistics) { + qemu_plugin_outs("magic syscall filtered, set magic return\n"); + } + return true; + } + return false; +} + static void print_entry(gpointer val, gpointer user_data) { SyscallStats *entry =3D (SyscallStats *) val; @@ -255,6 +273,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, =20 qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall); qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret); + qemu_plugin_register_vcpu_syscall_filter_cb(id, vcpu_syscall_filter); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; } diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index f5b4d2b8138..4005e3a8a9a 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -202,8 +202,10 @@ run-plugin-test-plugin-mem-access-with-libmem.so: \ CHECK_PLUGIN_OUTPUT_COMMAND=3D \ $(SRC_PATH)/tests/tcg/multiarch/check-plugin-output.sh \ $(QEMU) $< +run-plugin-test-plugin-syscall-filter-with-libsyscall.so: =20 -EXTRA_RUNS_WITH_PLUGIN +=3D run-plugin-test-plugin-mem-access-with-libmem.= so +EXTRA_RUNS_WITH_PLUGIN +=3D run-plugin-test-plugin-mem-access-with-libmem.= so \ + run-plugin-test-plugin-syscall-filter-with-libsyscall.so endif =20 # Update TESTS --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171452; cv=none; d=zohomail.com; s=zohoarc; b=C6jzjy0iexy8jAdlUPPz2rfN7lUqoSYHkBxcxRFBMwThAsb/dXA84iXmDJs6ohksJtTLQrkCpGqPQzGuHYbK3Kgys+BZPmuEEd8bY4CByKLzG2HlfWL4iJeM0DYQg8Ej3z4LpBAwBDLILp613Zm6SYQzvgtlOTv3pJvTABOQVTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171452; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Vw9O7QGKvNUJmURJtZXiXFfCdZcxW9QGykR9gjCW338=; b=CDqS+66UeWrbmWUjAyjuoRKycuuIPBr14kYfqDOCZ4C36bSl0JUklqC8jWa4C0QjK8IoU9+BBeQhawKEw02RVjkTmMI4hKwuo22GSuNYhzpYL2eCioZUgRs40C5Cj3RFcL63yt+sse8SNGCDR2ZB0KaFLKusD/5nKu3R8JOnsVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171452149325.92763345307003; Fri, 19 Dec 2025 11:10:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfrM-0001WP-Fk; Fri, 19 Dec 2025 14:09:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqW-0000aT-6x for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:01 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqT-0006pK-Vl for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:59 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-42fb2314eb0so1646626f8f.2 for ; Fri, 19 Dec 2025 11:08:57 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324eaa64cesm6544516f8f.35.2025.12.19.11.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CC6A16017D; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171336; x=1766776136; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vw9O7QGKvNUJmURJtZXiXFfCdZcxW9QGykR9gjCW338=; b=eRHoRXV4GGK2tCs+S3+hmyGhB8rHzXLi69+Jzqy6JB+39KeS5clZKbeCM7Csh1z57s mI0yr0iKpcsQJGLR112X29WdtaD4BLPVar/z5dJFFEZ+JTIgyuUCbo3Hz0dgAGwG1n6Y Nz7v3FSq3L1U4LMInMHTera1X1cOQJjXrzjXjwoVYotnqtWnKuTUs/klWnGf2TO0Tbdc is5FshGVhdOseqPZihUnyOJ34c07rs0YIqyv/MAq1hUaTtlXK3pegKRyVHvNqsnON0ei e/lvuHc5zIsNLg0spKxsgFxE4njvRjhywqMuhI60oruKDIsviTchBKm7O/boDntPV/nH evfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171336; x=1766776136; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Vw9O7QGKvNUJmURJtZXiXFfCdZcxW9QGykR9gjCW338=; b=e/GoR9l3GKpAd0LjmRcWXSh3znlNfX36epb9t6tvABH6HFLV7ckkH7a+WU5XfICm5T HF838ohXuJoSveZfunOB0lEXcvZUtYR8AggmeJQhx6GNyp1a3C+/usglcN0m4yqvZOpb BszVyZmXJOoRi7R5AWfarYb8mTY2Z/7lCw/5xzkRgdXHaFa7Jx965fuEck+4WQM94ReV THzOYYvXcEZlNiNRsnfnPNC2WhQWOp/LpJ54wLrqSnaKR3AOQkRXdZaL6DBeAHBIUDG1 6YjFcuJyEmAByuc0+aze+7ULyHbPJBdGP7b9oQ8RgKT4AdM1DKEVZU8jQNWwrgc/woRz HFvA== X-Gm-Message-State: AOJu0YyMn1Ndv+Okw7k4aiMaMVjkVditkLV6YfjSRnBOvfdg3zh5rawT nyrFQgzCfdA5JkEdPIJ6iIS1GYZE8EL1zdOANAkOSxY11gpWrZHYar4nGCDIU2NvAco= X-Gm-Gg: AY/fxX4eK6ns3LeOVksJB6yJKrlc2PgBxWAkWQM6FOTehu7pzNWTC1WgoqZs+ZMdNM0 ENmq4IPk0ga0lCCfa5gM+pSTj39JW4hbnfyFHM2s9mALY2iHLkXzLsTzuQPOrXfYFIYGbzG04UR i1w+fJq7eGFAh87M7Y1I8pVikt+iL7pXmJqRrQ3Mi1x58IxCr80E6Ki8XFedZvHnD29kYfzIU5n tW8+suAO8rEIQknJXDFn9gzMSnE0xP0Q++2LZxWaRogg2BQjBOqf4dxDxdYd0Lczk8NECKBkfCp VwIFZqu9XLRSHOo3if8oWsNU4XKp5lscLaZVGq+kRFsQ+BimqUp02ry3fN9mHYsnch+UCdVNA6J SPJNXyQfHmtlIg8/QS6sEFb77bJ5iWdHYXTHtpNd/tuNgdFTUA7bR2GEFZ+IaDtZA0DPaBRvDxS KyPDZwyxKVozQ= X-Google-Smtp-Source: AGHT+IHtTFs6vXCwjjVmQbvO8bYOulTtaBQfMoJqmyIsUtGzdORgJKGX6cvOfTdiHWf3m2HcGiN/dw== X-Received: by 2002:a05:6000:2305:b0:431:9b2:61c8 with SMTP id ffacd0b85a97d-4324e4c3864mr4833959f8f.10.1766171336269; Fri, 19 Dec 2025 11:08:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [RFC PATCH 09/12] plugins: split init_hook into create and reset Date: Fri, 19 Dec 2025 19:08:46 +0000 Message-ID: <20251219190849.238323-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171453833158500 We need to move the plugin vcpu_init callback to the reset phase so all register information is available to plugins. However so as not to complicate the initialisation code we still want the call once to do our housekeeping. Signed-off-by: Alex Benn=C3=A9e --- include/qemu/plugin.h | 19 ++++++++++++++----- include/qemu/qemu-plugin.h | 4 +++- hw/core/cpu-common.c | 21 +++++++++++++++------ plugins/core.c | 31 +++++++++++++++++++++++-------- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 91df1e78d2c..6d38b923c73 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -150,14 +150,23 @@ struct CPUPluginState { }; =20 /** - * qemu_plugin_create_vcpu_state: allocate plugin state + * qemu_plugin_vcpu_create_hook() - called on vcpu creation + * @cpu: vCPU CPUState * - * The returned data must be released with g_free() - * when no longer required. + * We don't expose creation to plugins but we need to do internal + * housekeeping of stuff. Called once per vCPU creation. */ -CPUPluginState *qemu_plugin_create_vcpu_state(void); +void qemu_plugin_vcpu_create_hook(CPUState *cpu); + +/** + * qemu_plugin_vcpu_reset_hook() - called on vcpu reset + * @cpu: vCPU CPUState + * + * Called each time the vcpu is reset. This can happen multiple times + * for a given vCPU. We expose this to plugins as vcpu_init. + */ +void qemu_plugin_vcpu_reset_hook(CPUState *cpu); =20 -void qemu_plugin_vcpu_init_hook(CPUState *cpu); void qemu_plugin_vcpu_exit_hook(CPUState *cpu); void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb); void qemu_plugin_vcpu_idle_cb(CPUState *cpu); diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index e8db7a72545..a75e323f31d 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -238,7 +238,9 @@ void qemu_plugin_reset(qemu_plugin_id_t id, qemu_plugin= _simple_cb_t cb); * @id: plugin ID * @cb: callback function * - * The @cb function is called every time a vCPU is initialized. + * The @cb function is called every time a vCPU is initialised. This + * includes resets. NOTE: not all register information may be + * available the first time this is called. * * See also: qemu_plugin_register_vcpu_exit_cb() */ diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 8c306c89e45..8113d83713f 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -100,8 +100,18 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags) void cpu_reset(CPUState *cpu) { device_cold_reset(DEVICE(cpu)); - trace_cpu_reset(cpu->cpu_index); + +#ifdef CONFIG_TCG + /* + * Because vCPUs get "started" before the machine is ready we often + * can't provide all the information plugins need during + * cpu_common_initfn. However the vCPU will be reset a few times + * before we eventually set things going giving plugins an + * opportunity to update things. + */ + qemu_plugin_vcpu_reset_hook(cpu); +#endif } =20 static void cpu_common_reset_hold(Object *obj, ResetType type) @@ -328,14 +338,13 @@ static void cpu_common_initfn(Object *obj) cpu_exec_initfn(cpu); =20 /* - * Plugin initialization must wait until the cpu start executing - * code, but we must queue this work before the threads are - * created to ensure we don't race. + * Called once at vCPU creation so the plugin subsystem can do its + * housekeeping. See also cpu_reset() and + * qemu_plugin_vcpu_reset_hook() above. */ #ifdef CONFIG_PLUGIN if (tcg_enabled()) { - cpu->plugin_state =3D qemu_plugin_create_vcpu_state(); - qemu_plugin_vcpu_init_hook(cpu); + qemu_plugin_vcpu_create_hook(cpu); } #endif } diff --git a/plugins/core.c b/plugins/core.c index 85fabf9ec81..d303256c851 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -226,7 +226,7 @@ plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu= _plugin_event ev, do_plugin_register_cb(id, ev, func, udata); } =20 -CPUPluginState *qemu_plugin_create_vcpu_state(void) +static CPUPluginState *qemu_plugin_create_vcpu_state(void) { return g_new0(CPUPluginState, 1); } @@ -279,7 +279,25 @@ static void plugin_grow_scoreboards__locked(CPUState *= cpu) end_exclusive(); } =20 -static void qemu_plugin_vcpu_init__async(CPUState *cpu, run_on_cpu_data un= used) +static void qemu_plugin_vcpu_reset__async(CPUState *cpu, run_on_cpu_data u= nused) +{ + assert(cpu->cpu_index !=3D UNASSIGNED_CPU_INDEX); + + qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_RW_REGS); + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); + qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS); +} + +void qemu_plugin_vcpu_reset_hook(CPUState *cpu) +{ + async_run_on_cpu(cpu, qemu_plugin_vcpu_reset__async, RUN_ON_CPU_NULL); +} + +/* + * This is purely internal to plugins as we need to expand scoreboards + * each time a new vCPU is created. + */ +static void qemu_plugin_vcpu_create__async(CPUState *cpu, run_on_cpu_data = unused) { bool success; =20 @@ -292,16 +310,13 @@ static void qemu_plugin_vcpu_init__async(CPUState *cp= u, run_on_cpu_data unused) g_assert(success); plugin_grow_scoreboards__locked(cpu); qemu_rec_mutex_unlock(&plugin.lock); - - qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_RW_REGS); - plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); - qemu_plugin_set_cb_flags(cpu, QEMU_PLUGIN_CB_NO_REGS); } =20 -void qemu_plugin_vcpu_init_hook(CPUState *cpu) +void qemu_plugin_vcpu_create_hook(CPUState *cpu) { + cpu->plugin_state =3D qemu_plugin_create_vcpu_state(); /* Plugin initialization must wait until the cpu start executing code = */ - async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); + async_run_on_cpu(cpu, qemu_plugin_vcpu_create__async, RUN_ON_CPU_NULL); } =20 void qemu_plugin_vcpu_exit_hook(CPUState *cpu) --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171457; cv=none; d=zohomail.com; s=zohoarc; b=T6EPPs+8PsW/IVE1z4+WvpgBT1gvQKi0OnYHw371Qu1yVWvZ2yrkHo437FOEgNJ6Pi59MevfzYqcwiM2W7ipXuBGQVJXTOEsaQy+vv1/MkDQaX7CuXXUrwgNMJHNgGM6Z2+YyRNwK7xAlzVjdJ8pAQo7Bo+mEZoMJuJOJ4JsJ+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171457; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fK0KW0TMYcgxgeLwnEP5U3w++5XTKKD1u9IZq89pD2g=; b=OOlao3vWeImM62XdnBt58pGnpTFZ90N1I6MQVzAk1uyM2eAOQA87ZkwK5S8bLw61ItqatKeKwtGDWMidaEUot2Xl73v2Qspud95/m3pSqHySHqQDzRyR72KZfV8qVjLXoikp/R7ZhEtbVzfzBR2Hl+Fn+Q9rtEGUaR0NP207QBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176617145767029.127548366879978; Fri, 19 Dec 2025 11:10:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfrL-0001Pr-EN; Fri, 19 Dec 2025 14:09:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqV-0000aN-FP for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:59 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqS-0006oL-FA for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:08:59 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-430f5ecaa08so1031765f8f.3 for ; Fri, 19 Dec 2025 11:08:55 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea82e9fsm6786272f8f.26.2025.12.19.11.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E33E7601A9; Fri, 19 Dec 2025 19:08:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171335; x=1766776135; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fK0KW0TMYcgxgeLwnEP5U3w++5XTKKD1u9IZq89pD2g=; b=vqTujmtCfIyBNcQeg7L86RHFmifIo+ZJaMLcFuuGp27h5aApSyquyqUUYzjSpbJ+L/ lwTNkGdUGc2xe43ZsfvzUgPt+Ca98uztNpXg6H5+Qp2G5W/9QH5XJQOQ/jSjH4H8cDAe pxccQh2qm+lL/PYPV1IQXz4Ai2W6PhCpnzqpbxKA2/jT3FbNoRfcyX8rgg65J9pwB5k+ po112F4lbSnKQRv19Sxq5gOC7D79zGhJS0zQhQyCObS6lyKLtPHsiSxH51t7bHjlMlD/ nGavTZGBU123lxY8cuz30KHi8pO8xNJ/CkJbTUXfWFRXdCqWr6/s+YLjGlcu9Yf3KQw+ 3+Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171335; x=1766776135; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fK0KW0TMYcgxgeLwnEP5U3w++5XTKKD1u9IZq89pD2g=; b=cIQn7wVYFFfLpDnA8N57Phxx1GRhdSOBDF+ZbMFDR3le3gjzY/GZqAK0Q++G3EBTL1 uxT28GJ9rABJ4sUcnh/gRFdU1z6meuk5y6gUH8aaP6GtTus72MdwDTaFaopSoX8RBsF1 vM6rZL/3I8ikw0ihB8h+kiRE5YTiXA9/XVjtq2W5r1AW/Y269ytjJZt4rB1ItcpVBvY5 Cq42Df4Ua/r4smWSUzJZlbwPXFqkRL7aBp7eWn6ShGKlT+F+mIFut+4IPF4tVJFvnoaU pBRoeHkwhso1lX2U1u/fG1XevN1UwhU/LZL6Lz6BqG954vbUcviWezANCeRVoEC6/hHA DI8g== X-Gm-Message-State: AOJu0Ywwe62UCwcHp6co5tc+5ZmoNWoNanp/VVajfya+BQxcDEcMd5+a r+WjVRyO1au4hUC5AzZLEAEiy5dJF1H8eaG6+31dsqaYicFu7mQXmkfeGYql9RCxMuU= X-Gm-Gg: AY/fxX7AotFotMeqwrHO8BjIuMWwf2ArUyUh4WGgNNrLmeDiHecuRWUMA5G4dwa48Jl ktazjBQZxc9QUJkPlklMdj+iUx9K5g2fZW0wTD5fBiOyQO8RwyDhUYLP6pEpPIWsFLU58k0Op7F N9CXoAbTT8xLZD1c44Nm+uy3OIR1gV3zs/uXVYXsQFZ4H5AE9DVr1BgEx9oyGFLF6saNfMDX9fO vjc2g6LrdjWSNYh9+cTyWcmqReIuVsqQ5vSI72IjnSBnp0bA668TLTS178cxYWwfW/8VdDFmaTk ZVTJ80z7JHHmSceCbnpaYLq8QXZovPCa6E6VZGfNQOMijy55Ekri6Uwz+05nvFfm5okV5ly7ayO mrj11bnxUfhpxY91RUpTtzcvO6fe2Uj5bkqk91RPxbY10hNfiXbMh/6zUF/hddfyPO+O8z4NcBH +ZaB/QIDxwxEc= X-Google-Smtp-Source: AGHT+IEPonMigDhcyUb/rkjFjALC1EHAb9+cuZxjPKGSGDhXmrLZ4qFLqKwCHLvibLsksBtqozcbXg== X-Received: by 2002:a05:6000:178e:b0:425:769e:515a with SMTP id ffacd0b85a97d-4324e50b8fdmr4442888f8f.42.1766171334811; Fri, 19 Dec 2025 11:08:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [RFC PATCH 10/12] target/arm: defer creation of gdb register until machine created Date: Fri, 19 Dec 2025 19:08:47 +0000 Message-ID: <20251219190849.238323-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171459945158500 When running machine emulation we may create additional cp_regs for things like the GIC interface. To include them for gdbstub and plugins defer the creation until the machine is finalized. Signed-off-by: Alex Benn=C3=A9e --- target/arm/cpu.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 39292fb9bc1..81997bac06a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -41,6 +41,7 @@ #ifdef CONFIG_TCG #include "hw/intc/armv7m_nvic.h" #endif /* CONFIG_TCG */ +#include "system/system.h" #endif /* !CONFIG_USER_ONLY */ #include "system/tcg.h" #include "system/qtest.h" @@ -1535,6 +1536,23 @@ static void arm_cpu_post_init(Object *obj) qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property); } =20 +#ifndef CONFIG_USER_ONLY +static void arm_finalize_gdb_regs(Notifier *notifier, void *unused) +{ + CPUState *cs; + + CPU_FOREACH(cs) { + ARMCPU *cpu =3D ARM_CPU(cs); + arm_cpu_register_gdb_regs_for_features(cpu); + arm_cpu_register_gdb_commands(cpu); + } +} + +static Notifier arm_machine_setup_gdb_notify =3D { + .notify =3D arm_finalize_gdb_regs, +}; +#endif + static void arm_cpu_finalizefn(Object *obj) { ARMCPU *cpu =3D ARM_CPU(obj); @@ -2138,8 +2156,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) #endif =20 register_cp_regs_for_features(cpu); + +#ifdef CONFIG_USER_ONLY + /* + * For system emulation not everything is done yet - see + * arm_machine_setup_gdb_notify + */ arm_cpu_register_gdb_regs_for_features(cpu); arm_cpu_register_gdb_commands(cpu); +#endif =20 arm_init_cpreg_list(cpu); =20 @@ -2392,6 +2417,14 @@ static void arm_cpu_class_init(ObjectClass *oc, cons= t void *data) cc->gdb_write_register =3D arm_cpu_gdb_write_register; #ifndef CONFIG_USER_ONLY cc->sysemu_ops =3D &arm_sysemu_ops; + /* + * For system emulation we defer setting up GDB registers until + * the whole machine in setup. This is because we may still have + * some to define for emulated HW (e.g. the GIC). + */ + qemu_add_machine_init_done_notifier(&arm_machine_setup_gdb_notify); +#else + #endif cc->gdb_arch_name =3D arm_gdb_arch_name; cc->gdb_get_core_xml_file =3D arm_gdb_get_core_xml_file; --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171466; cv=none; d=zohomail.com; s=zohoarc; b=hupo9HmYyGbaIMktQT5C6Xp53iRR8gRa05fQRqCYMjC94U6sXoE5GQ4aLkmDj3wVOdwzQHoM+xQ4wPTu4iURkfShxsl9sstJYN7zT3pNv6bU2xkraR1Kd4xCq5TnljnRHABBQ7WETdb8Cmql5ZLXkYtcU6CQbnLye5FYw9iqTEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171466; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KcQg2SX8Fz5MOpmF02U0B+xAbMjSsIf/owN/YL97tDk=; b=l+TNzILhmyPTLsprnZyz0XHHxsAB+z1K5psRqlYHigP19P5MBCS0H/e2va9okTQ41HXj09N4B/5LghjgPvfFKM5CTTjDYLck9MvHeXZXR5gO0hzMkOpRZeZmfyrqWWLCPS9+niYRB+ZKrPfp2AuOfqzEvQCVI2xDsBXrralsVuk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171466449762.8905531574294; Fri, 19 Dec 2025 11:11:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfrI-0000ye-65; Fri, 19 Dec 2025 14:09:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqb-0000fB-5F for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:12 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqX-0006rX-L2 for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:04 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-42fbbc3df8fso1059233f8f.2 for ; Fri, 19 Dec 2025 11:09:00 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea82fddsm6429044f8f.25.2025.12.19.11.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 09D90601C8; Fri, 19 Dec 2025 19:08:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171340; x=1766776140; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KcQg2SX8Fz5MOpmF02U0B+xAbMjSsIf/owN/YL97tDk=; b=N8Tvs23hq8zh5weHIRhobDMaoLoK4FOSqWcoj+BUXd19/InYjW+Obh4Eg0TYNQrvKv 6TRuIs9CGMrzZB2UQ2xoIuEe3/Ydrb+uYopajcav2Khhd8fa0xrN6UUyphN8/80W9a9x by4BcGYvxQ4HiaC+MXcLYDHoI5732AqjcYCPL8OBvBSjy8h5WGojsPEz//Mtr71qn93Z zIgN4WPvYXNvfCaeKSHBViHZ7wCYPPKqqVJeE/MwDFvnDa0QkGnW14SH2wsHWB/qMJh1 gk2TYfUBIghID0dC48MR1QsRWF8ek/FuEwJoIPmDOpYnegwF++GR/mhNm80omYHKvrf4 N6mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171340; x=1766776140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KcQg2SX8Fz5MOpmF02U0B+xAbMjSsIf/owN/YL97tDk=; b=ml8dYQU8fqq51nUf/CDk6yQG657oxtbG0E0SdrAuTQBW6AzXfFw3T2czs9BEqZ1k54 vvuccrXKKYzzVigcF3W3cuk+La1kL6b1XXAfV488QOPy1lZvbecO2jiXwcxaYYI0o/Cs YTyduIDqu7l8yIlGIW5cD8j4YzKfYDdYVeckW+ryGE6lYoHpJG2A2bBpMxEQ4R3clBiJ 5YDFMyK3Nr58lx+Hq5QyIbCa05WDBzZecdlQxuNXGaFeZxzEH+aJv9GE6e67wWBp5ZjT +xA5VHmqlqooxnTxdLaLfXsTvxAbgtBnR60t4V6tWM+IxdypWxLAPF/YZt9WfGRmorpp EbHA== X-Gm-Message-State: AOJu0YzYtTbr1g7BI+GnpbGgVtZiuca9YpEjEcmN7r7qm2+N3ZRj7gNQ wCK+ya3I6JHW3eXTRwsW5NMKIgUxsLO5ThSeNXh5lLYJSOViYeb0jzNuH+bW9ar6zbA= X-Gm-Gg: AY/fxX7gpoiuFJ32FjLyxwX9hde+ES8fLYyVKWc8H1f4H4OKzb76zOHbsvLhs3GA0SF nfIHvzUNvQRs8vxUTpwt8u4lH18/MCoUlvz3OkTTe7T/c/k6yNh30txoA6J7pk7v84VjtXtfBsK nzshU1zettEL5nODuJHhhM+ufD8wx5eH1GMjIebhxjCzNTeB4wLFxchOOZyHFJIcIOiP8Rwrh7C 8raXkkpZMUam3r7R0fZatojfFQsYHXDWbVbn7GbNgjaD++69jHPvDIyje7K0zMZxcx5Z/SeR8ru 8cwHezR0Uxw8IFTzZkhc8YPHLr0tGIVoPB7k2wky7EiW2EWxk8xcV2+ik7HyYupj+kMQYhg3f77 15n35+AAA6eEcwXdbO62knA+ZYLjuj1aH9dI8XV7jItqcVeMPySIuyrbYNFz9oxa3rtCM/v//ZA D2cEsmF+2WhEI= X-Google-Smtp-Source: AGHT+IH598mxUk0qoBk6qUyJAdxA6HPyr+xHiIoAKNHXWXHsghW99OXPC7uG6O/RuG2BS7iOmnynDA== X-Received: by 2002:a05:6000:604:b0:431:8f8:7f1e with SMTP id ffacd0b85a97d-4324e50e0eamr4047737f8f.48.1766171339497; Fri, 19 Dec 2025 11:08:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [RFC PATCH 11/12] contrib/plugins: add systrace plugin for tracking exceptions and irqs Date: Fri, 19 Dec 2025 19:08:48 +0000 Message-ID: <20251219190849.238323-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171468262158500 I'm hunting for lost IRQs and want to trace what various registers are being set to when IRQs happen. This combines the discontinuity tracking API with register value tracking to do so. It supports: tracksw - to keep track of the last thing that wrote to a register show_frompc - show the line executing before the discontinuity As we might not have disassembly for the nominal last pc for an async IRQ we also track the pc of the last executed instruction in a block and use that as a fallback. Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/systrace.c | 572 ++++++++++++++++++++++++++++++++++++ contrib/plugins/meson.build | 2 +- 2 files changed, 573 insertions(+), 1 deletion(-) create mode 100644 contrib/plugins/systrace.c diff --git a/contrib/plugins/systrace.c b/contrib/plugins/systrace.c new file mode 100644 index 00000000000..6c8f6d91f87 --- /dev/null +++ b/contrib/plugins/systrace.c @@ -0,0 +1,572 @@ +/* + * Copyright (C) 2025, Alex Benn=C3=A9e + * + * System tracing tool. Log changes to system registers and where IRQ + * and exceptions occur in the code. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include +#include +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +/* The base register we are tracking */ +typedef struct { + struct qemu_plugin_register *handle; + const char *name; + int index; + int instrumentation_count; +} BaseRegister; + +/* + * Array of BaseRegister - the position in the array will also + * control the index into the access score board. As the list may grow + * dynamically as additional vCPUs are initialised we need to protect + * the list with a lock. + */ +static GArray *base_registers; +static GMutex base_reg_lock; +static struct qemu_plugin_scoreboard *base_reg_hits; + +#define MAX_TRACKING_REGISTERS 32 + +/* + * Scoreboard for tracking last sysreg write - usually the last one + * touched is the one that triggered something ;-) + */ +static bool track_sysreg_write; +static char *sysreg_ins; +static struct qemu_plugin_scoreboard *last_sysreg_write; + +/* + * Scoreboard for tracking last executed PC. It's possible to be + * missing a translation of from_pc due to the fact we may have + * advanced the PC before attempting the translation. However the last + * insn in a block will generally be the last thing we did. + */ +static struct qemu_plugin_scoreboard *last_exec_pc; + +/* per-vcpu initialisation lock */ +static GMutex vcpu_init_lock; + +/* the passed matching parameters */ +static GPtrArray *rmatches; + +/* The per-cpu register tracking structure */ +typedef struct { + GByteArray *last; + uint64_t last_dump_count; + int index; +} Register; + +/* CPU specific data */ +typedef struct CPU { + /* Track available registers over multiple vcpu_init calls */ + int available_reg_count; + /* Ptr array of Register */ + GPtrArray *registers; +} CPU; + +/* This is defined at start time */ +static GArray *cpus; + +/* Track the disassembly */ +static GHashTable *haddr_disas; +static GMutex disas_lock; + +static bool show_from_pc; + +static CPU *get_cpu(int vcpu_index) +{ + CPU *c =3D &g_array_index(cpus, CPU, vcpu_index); + return c; +} + +/* + * BaseRegister handling + * + * We return copies of the BaseRegister entry so we don't get + * surprised by resizing of the underlying array. + */ + +static BaseRegister get_base_reg(int index) +{ + BaseRegister info, *entry; + + g_mutex_lock(&base_reg_lock); + + entry =3D &g_array_index(base_registers, BaseRegister, index); + info =3D *entry; + + g_mutex_unlock(&base_reg_lock); + + return info; +} + +static BaseRegister find_or_add_base_register(qemu_plugin_reg_descriptor *= rd) +{ + g_autofree gchar *lower =3D g_utf8_strdown(rd->name, -1); + BaseRegister base; + bool found =3D false; + + g_mutex_lock(&base_reg_lock); + + for (int i =3D 0; i < base_registers->len; i++) { + BaseRegister *check =3D &g_array_index(base_registers, BaseRegiste= r, i); + if (check->handle =3D=3D rd->handle) { + base =3D *check; + found =3D true; + break; + } + } + + /* didn't find, then add it */ + if (!found) { + base.handle =3D rd->handle; + base.name =3D g_intern_string(lower); + base.index =3D base_registers->len; + + g_array_append_val(base_registers, base); + } + + g_assert(base_registers->len < MAX_TRACKING_REGISTERS); + + g_mutex_unlock(&base_reg_lock); + + return base; +} + +/* Sets *info on find */ +static bool find_base_reg_by_str(const gchar *insn_arg, BaseRegister *info) +{ + bool reg_hit =3D false; + + g_mutex_lock(&base_reg_lock); + + for (int n =3D 0; n < base_registers->len; n++) { + BaseRegister *base =3D &g_array_index(base_registers, BaseRegister= , n); + if (g_strrstr(insn_arg, base->name)) { + *info =3D *base; + reg_hit =3D true; + break; + } + } + + g_mutex_unlock(&base_reg_lock); + + return reg_hit; +} + +/** + * On translation block new translation + * + * QEMU convert code by translation block (TB). We are only going to + * add hooks to instructions that modify the registers we care about. + * However we do need a record of every instruction we come across so + * we can resolve information for the discontinuities. + */ +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + struct qemu_plugin_insn *insn; + uint64_t vaddr; + + g_mutex_lock(&disas_lock); + + size_t n_insns =3D qemu_plugin_tb_n_insns(tb); + for (size_t i =3D 0; i < n_insns; i++) { + g_autofree char *insn_disas =3D NULL; + const gchar *intern_disas; + + /* + * `insn` is shared between translations in QEMU, copy needed + * data here. + * + * We will generate an interned string from the disassembly + * and save it in out hash table indexed by the vaddr. + * + * This is vulnerable to old pages being swapped out because + * we aren't tracking the underlying physical address. But + * generally we expect this to be sane. + * + * The interned strings are never free'd but hopefully there + * is enough repetition we don't need a string for every + * instruction we execute. + */ + insn =3D qemu_plugin_tb_get_insn(tb, i); + insn_disas =3D qemu_plugin_insn_disas(insn); + intern_disas =3D g_intern_string(insn_disas); + /* haddr =3D qemu_plugin_insn_haddr(insn); */ + vaddr =3D qemu_plugin_insn_vaddr(insn); + + /* replaces any existing interned string */ + g_hash_table_insert(haddr_disas, + GUINT_TO_POINTER(vaddr), + (gpointer) intern_disas); + + /* + * Check the disassembly to see if a register we care about + * will be affected by this instruction. This relies on the + * dissembler doing something sensible for the registers we + * care about. + */ + g_auto(GStrv) args =3D g_strsplit_set(insn_disas, " \t", 2); + + if (args && args[1]) { + BaseRegister info; + + if (find_base_reg_by_str(args[1], &info)) { + qemu_plugin_u64 cnt =3D { + .score =3D base_reg_hits, + .offset =3D (size_t)info.index * sizeof(uint64_t) + }; + qemu_plugin_register_inline_per_vcpu(insn, + QEMU_PLUGIN_INLINE_ADD= _U64, + cnt, 1); + } + } + + /* + * If we are tracking system register writes lets check here. + */ + if (args && track_sysreg_write) { + if (g_strrstr(args[0], sysreg_ins)) { + qemu_plugin_u64 write_pc =3D { + .score =3D last_sysreg_write, + }; + qemu_plugin_register_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_STORE_U64, + write_pc, vaddr); + } + } + } + + /* + * On the last instruction store the PC so we can recover if we + * are missing translations we haven't done yet. + */ + if (n_insns > 0) { + qemu_plugin_u64 last_pc =3D { .score =3D last_exec_pc }; + qemu_plugin_register_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_STORE_U64, + last_pc, vaddr); + } + + g_mutex_unlock(&disas_lock); +} + +static void dump_reg(GString *out, GByteArray *value) { + /* TODO: handle BE properly */ + for (int j =3D value->len - 1; j >=3D 0; j--) { + g_string_append_printf(out, "%02x", value->data[j]); + } +} + +static void check_reg_changes(unsigned int vcpu_index, CPU *cpu, GString *= out) +{ + uint64_t *hits =3D qemu_plugin_scoreboard_find(base_reg_hits, vcpu_ind= ex); + + for (int i =3D 0; i < cpu->registers->len; i++) { + Register *reg =3D g_ptr_array_index(cpu->registers, i); + uint64_t hit_count =3D hits[reg->index]; + if (hit_count > reg->last_dump_count) { + BaseRegister base =3D get_base_reg(reg->index); + g_autoptr(GByteArray) new_val =3D g_byte_array_new(); + int bytes =3D qemu_plugin_read_register(base.handle, new_val); + g_assert(bytes > 0); + g_assert(bytes =3D=3D reg->last->len); + if (memcmp(reg->last->data, new_val->data, reg->last->len) != =3D 0) { + g_string_append_printf(out, " REG: %s is ", base.name); + dump_reg(out, new_val); + g_string_append_printf(out, " (previously "); + dump_reg(out, reg->last); + g_string_append_printf(out, ", %"PRId64" to %"PRId64" hits= )\n", reg->last_dump_count, hit_count); + + /* record the new value */ + g_byte_array_set_size(reg->last, 0); + g_byte_array_append(reg->last, new_val->data, new_val->len= ); + } + reg->last_dump_count =3D hit_count; + } + } +} + + +static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t from_p= c, + uint64_t to_pc) +{ + CPU *cpu =3D get_cpu(vcpu_index); + g_autoptr(GString) report =3D g_string_new(""); + const char *type_string; + uint64_t from_hwaddr; + const char *disas; + + qemu_plugin_translate_vaddr(from_pc, &from_hwaddr); + + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + type_string =3D "irq"; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + type_string =3D "exception"; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + type_string =3D "host call"; + break; + default: + g_assert_not_reached(); + break; + } + + g_string_append_printf(report, + "CPU: %d taking %s from 0x%" PRIx64 " to 0x%" P= RIx64 "\n", + vcpu_index, type_string, from_pc, to_pc); + + g_mutex_lock(&disas_lock); + + if (show_from_pc) { + bool le_fallback =3D false; + uint64_t *le_pc =3D qemu_plugin_scoreboard_find(last_exec_pc, vcpu= _index); + disas =3D g_hash_table_lookup(haddr_disas, GUINT_TO_POINTER(from_p= c)); + if (!disas) { + le_fallback =3D true; + disas =3D g_hash_table_lookup(haddr_disas, GUINT_TO_POINTER(*l= e_pc)); + g_assert(disas); + } + g_string_append_printf(report, " FROM: 0x%" PRIx64 " %s\t(%s)\n", + le_fallback ? *le_pc : from_pc, disas, + le_fallback ? "lepc" : "fpc"); + } + + if (track_sysreg_write) { + uint64_t *last_write =3D qemu_plugin_scoreboard_find(last_sysreg_w= rite, vcpu_index); + disas =3D g_hash_table_lookup(haddr_disas, GUINT_TO_POINTER(*last_= write)); + if (disas) { + g_string_append_printf(report, " LAST SYSREG: 0x%"PRIx64" %s\= n", *last_write, disas); + } + } + + g_mutex_unlock(&disas_lock); + + if (base_reg_hits && cpu->registers) { + check_reg_changes(vcpu_index, cpu, report); + } + + qemu_plugin_outs(report->str); +} + +/** + * On vcpu exit, print the final state of the registers + */ +static void vcpu_exit(qemu_plugin_id_t id, unsigned int cpu_index) +{ + g_autoptr(GString) result =3D g_string_new("Register, Value, Accesses = "); + g_autoptr(GByteArray) value =3D g_byte_array_new(); + + g_string_append_printf(result, "for CPU%d\n", cpu_index); + for (int i =3D 0; i < base_registers->len; i++) { + BaseRegister *base =3D &g_array_index(base_registers, BaseRegister= , i); + qemu_plugin_u64 cnt =3D { + .score =3D base_reg_hits, + .offset =3D (size_t)base->index * sizeof(uint64_t) + }; + uint64_t sum_hits =3D qemu_plugin_u64_get(cnt, cpu_index ); + + if (sum_hits > 0) { + g_string_append_printf(result, "%s, ", base->name); + qemu_plugin_read_register(base->handle, value); + dump_reg(result, value); + g_string_append_printf(result, ", % "PRId64"\n", sum_hits); + } + } + qemu_plugin_outs(result->str); +} + + +/* + * g_pattern_match_string has been deprecated in Glib since 2.70 and + * will complain about it if you try to use it. Fortunately the + * signature of both functions is the same making it easy to work + * around. + */ +static inline +gboolean g_pattern_spec_match_string_qemu(GPatternSpec *pspec, + const gchar *string) +{ +#if GLIB_CHECK_VERSION(2, 70, 0) + return g_pattern_spec_match_string(pspec, string); +#else + return g_pattern_match_string(pspec, string); +#endif +}; +#define g_pattern_spec_match_string(p, s) g_pattern_spec_match_string_qemu= (p, s) + + +static Register *init_vcpu_register(BaseRegister *base) +{ + Register *reg =3D g_new0(Register, 1); + int r; + + reg->index =3D base->index; + reg->last =3D g_byte_array_new(); + + /* read the initial value */ + r =3D qemu_plugin_read_register(base->handle, reg->last); + /* we currently don't handle the bigger ones */ + g_assert(r > 0); + g_assert(r <=3D 8); + return reg; +} + +static void free_vcpu_register(gpointer data) +{ + Register *reg =3D (Register *)data; + g_byte_array_unref(reg->last); + g_free(reg); +} + +static GPtrArray *registers_init(GArray *reg_list, int vcpu_index) +{ + g_autoptr(GPtrArray) registers =3D g_ptr_array_new_with_free_func(free= _vcpu_register); + + if (!rmatches) { + return NULL; + } + + /* + * Go through each register in the complete list and + * see if we want to track it. + */ + for (int r =3D 0; r < reg_list->len; r++) { + qemu_plugin_reg_descriptor *rd =3D &g_array_index( + reg_list, qemu_plugin_reg_descriptor, r); + for (int p =3D 0; p < rmatches->len; p++) { + g_autoptr(GPatternSpec) pat =3D g_pattern_spec_new(rmatches->p= data[p]); + g_autofree gchar *rd_lower =3D g_utf8_strdown(rd->name, -1); + if (g_pattern_spec_match_string(pat, rd->name) || + g_pattern_spec_match_string(pat, rd_lower)) { + BaseRegister base =3D find_or_add_base_register(rd); + Register *reg =3D init_vcpu_register(&base); + g_ptr_array_add(registers, reg); + } + } + } + + return registers->len ? g_steal_pointer(®isters) : NULL; +} + +/* + * Initialise a new vcpu with: + * - initial value of registers + * - scoreboard to track reg hits + * - optional scoreboard to track sysreg writes + */ +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + CPU *c; + g_autoptr(GArray) reg_list =3D qemu_plugin_get_registers(); + + g_mutex_lock(&vcpu_init_lock); + + c =3D get_cpu(vcpu_index); + + /* Are more registers available now? */ + if (c->registers && (reg_list->len > c->available_reg_count)) { + fprintf(stderr, "%s: reset list....\n", __func__); + g_ptr_array_free(c->registers, true); + c->registers =3D NULL; + } + + c->available_reg_count =3D reg_list->len; + + if (!c->registers) { + c->registers =3D registers_init(reg_list, vcpu_index); + fprintf(stderr, "%s:%d reglen %d\n", __func__, vcpu_index, c->regi= sters ? c->registers->len : 0); + } + + if (track_sysreg_write && !last_sysreg_write) { + last_sysreg_write =3D qemu_plugin_scoreboard_new(sizeof(uint64_t)); + } + + if (!last_exec_pc) { + last_exec_pc =3D qemu_plugin_scoreboard_new(sizeof(uint64_t)); + } + + g_mutex_unlock(&vcpu_init_lock); +} + +/* + * We have to wait until vCPUs are started before we can check the + * patterns find anything. + */ +static void add_regpat(char *regpat) +{ + if (!rmatches) { + rmatches =3D g_ptr_array_new(); + } + g_ptr_array_add(rmatches, g_strdup(regpat)); +} + +/** + * Install the plugin + */ +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, int ar= gc, + char **argv) +{ + /* We only work for system emulation */ + if (!info->system_emulation) { + qemu_plugin_outs("The systrace plugin is for system emulation only= ."); + return -1; + } + + /* + * Initialize dynamic array to cache vCPU instruction. We also + * need a hash table to track disassembly. + */ + cpus =3D g_array_sized_new(true, true, sizeof(CPU), info->system.max_v= cpus); + g_array_set_size(cpus, info->system.max_vcpus); + haddr_disas =3D g_hash_table_new(NULL, NULL); + + base_registers =3D g_array_new(true, true, sizeof(BaseRegister)); + base_reg_hits =3D qemu_plugin_scoreboard_new(MAX_TRACKING_REGISTERS * = sizeof(uint64_t)); + + for (int i =3D 0; i < argc; i++) { + char *opt =3D argv[i]; + g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); + if (g_strcmp0(tokens[0], "reg") =3D=3D 0) { + add_regpat(tokens[1]); + } else if (g_strcmp0(tokens[0], "tracksw") =3D=3D 0) { + track_sysreg_write =3D true; + if (tokens[1]) { + sysreg_ins =3D g_strdup(tokens[1]); + } else { + sysreg_ins =3D g_strdup("msr"); + } + } else if (g_strcmp0(tokens[0], "show_frompc") =3D=3D 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &show_from_p= c)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); + return -1; + } + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + /* Register init, translation block and exit callbacks */ + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL, vcpu_d= iscon); + qemu_plugin_register_vcpu_exit_cb(id, vcpu_exit); + + return 0; +} diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index eb944b5159a..3d1365da433 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -1,6 +1,6 @@ contrib_plugins =3D ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotbloc= ks', 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger', - 'traps', 'uftrace'] + 'systrace', 'traps', 'uftrace'] if host_os !=3D 'windows' # lockstep uses socket.h contrib_plugins +=3D 'lockstep' --=20 2.47.3 From nobody Sat Feb 7 05:53:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1766171393; cv=none; d=zohomail.com; s=zohoarc; b=k/ZELyfWkqnVJ9eQvMQxc5Y+XYGTTze6kH52nKLKo8VDgciKk25TEuUmfRjDVQn1dvcqEmpI2vkipd5a7EKQlK7dXl9nGtlpXAGf9eecdnOhX1JllI6hWOwmisT3KdfWpWvjBl7lqUpT1+jir8Kk/TcLyE8p9ISe4U5G4jms1kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766171393; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TNnO369o5RyODW40YP5PUoZ8MigxvrSBu+tgeyebTyU=; b=OZhNU/AeUmQpboYvV11WV0y1XitLTOoPn7pR6JHdAH477MxyfnZ9K/Ehyc4IrVmBcx5535hF8IeUh3WHh5Ti91OzUCs4YqivLjK3YifVVMOVnQRKb1tvudFqHNDO3O3sFfh4l5HUD786k+u8k0DzRpaIKzWpHeHwhBGUEHGZWSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766171393145138.3414384002508; Fri, 19 Dec 2025 11:09:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vWfr1-0000lO-1H; Fri, 19 Dec 2025 14:09:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vWfqZ-0000ct-Bo for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:03 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vWfqX-0006rC-DY for qemu-devel@nongnu.org; Fri, 19 Dec 2025 14:09:03 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-42fbc305552so1602263f8f.0 for ; Fri, 19 Dec 2025 11:09:00 -0800 (PST) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea2278dsm6612935f8f.18.2025.12.19.11.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 11:08:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2298E601D0; Fri, 19 Dec 2025 19:08:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766171339; x=1766776139; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TNnO369o5RyODW40YP5PUoZ8MigxvrSBu+tgeyebTyU=; b=uCi57RPHJaxATgectNUY9mGSninUKVMOW9uk3FYTOxOIPMQMdacNUn3XujAgg4cQwm NjFVuV1/i/LIkmNbZSaU/Wg4RWsRZmF9Ws1BhjcnZBWQnMbBqeOaFuagLaGiYvrV7CC1 kepTCh2TD7xzpsDrq5nxYxL6jHdq8zFVM6a76v1jkJbwuRLTeJaG6bK3IVXBo0dtFsWk DvsNQfDTKANOxZDqIhzPJ/zulogjDb2RRc7KQUJ0hgkYxWsSshm6Ha4MsqLYlATSw1du J0tgYvHJTHt0Hd8LT40Mqp+qI6QaBpCZXXH54bQYUmltHXm3WusOilGE6TuF8nNKrIRg oGWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766171339; x=1766776139; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TNnO369o5RyODW40YP5PUoZ8MigxvrSBu+tgeyebTyU=; b=Cvi0oRrYSfq0NTVpjyHGrPdTfBPNQDtuEWEonwegaW8nCqQCXbFASPUc2UYtRA+CE6 +hKenmwlHthLT/hKRIJnkV9zSbcX9HFaUrogr+NmjQYjCuPmcXNE46k8ud+AYQML/ZZq PQuoNwVY0x3ZAV4TL7EZUivjXQFP8Ymb5QuBUk4vPRrQ2cHVXWZwa2ofrKGRFNf9OO+7 VYBKyx0vT+bh/C+W414a9W5J9oRqvFfGE4P5NgVswXyJsgBOXmTtf4UQ7nmZ8VnUfAMP REh4KQDPxNIzFzcKIqhjNZzDmfhV9wwxXWRjl4jx3w5Z4aTgGDkob4B0k9WifVQc7LCp rOrA== X-Gm-Message-State: AOJu0YyggXWMKVjDXCknfU6Mm8xAalydEfD19uJ1zKe/PflBto/s6uVV evN/2tsPUsM1FHt/wUzrhWJPpR7ZScYQ7Xjot9RUE5HLa3EU9fReYNkpPz0yFx+hB9E= X-Gm-Gg: AY/fxX46EylDrHaYdo0ax575LUGG311AgaVVOgrMj0D1TE2hYPMprgVkTJ0t8q0ImF4 88x/8CqgfUCCDfpZLQ6rkNNIQk9+Um1bEqtR1UDDkxCwSmayDGflagFtmXdH/K+48GvHB5oD70e qfkCQczvmAiHQcl0SdTVX/8d0uVgi8ukIEyNV2o+9BFNmUcyYNulgikqzz6XXm4IYaN4xDIl3Bu EOR5fZx+QgejIXXcHi35zcpgiFbBXpFfc8asODBVV+Z0eGgbcjblNqC+cPnBeAMNmbmXsePh4IX +iftj0mPTuR1u+r5Yk1r3+cWZ4Pp8Z5QbcfzG6Diqjn//mGnVymXwMMA+PXiAWuIcY5DUqtn5/M VDZJa8wLMDNA9FN3jZlUT3Gvurxhfju0xAPJAt2zFnqMCY7+qKvRvfrjD/kEGTiO04xeX+1vXJk BGPKy/8bSqMmc= X-Google-Smtp-Source: AGHT+IE/djsvq7V5yPEwmnhCaYtBAJh0llME81JdJRIYDw/vscbT8puxC23HWIyG+lk4mLByaL1eLw== X-Received: by 2002:a05:6000:178c:b0:430:f41f:bd5a with SMTP id ffacd0b85a97d-4324e709017mr4626110f8f.57.1766171338905; Fri, 19 Dec 2025 11:08:58 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yanan Wang , Paolo Bonzini , Alwalid Salama , qemu-arm@nongnu.org, Zhao Liu , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Marcel Apfelbaum , Peter Maydell , Mahmoud Mandour , Eduardo Habkost , Mark Burton , Laurent Vivier , Pierrick Bouvier , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [RFC PATCH 12/12] target/arm: allow gdb to read ARM_CP_NORAW regs (!upstream) Date: Fri, 19 Dec 2025 19:08:49 +0000 Message-ID: <20251219190849.238323-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251219190849.238323-1-alex.bennee@linaro.org> References: <20251219190849.238323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1766171394059158500 Before this we suppress all ARM_CP_NORAW registers being listed under GDB. This includes useful registers like CurrentEL which gets tagged as ARM_CP_NO_RAW because it is one of the ARM_CP_SPECIAL_MASK registers. These are registers TCG can directly compute because we have the information at compile time but until now with no readfn. Add a .readfn to return the CurrentEL and then loosen the restrictions in arm_register_sysreg_for_feature to allow ARM_CP_NORAW registers to be read if there is a readfn available. Signed-off-by: Alex Benn=C3=A9e Message-ID: <20250507165840.401623-1-alex.bennee@linaro.org> --- vRFC - this is a useful debugging aid but a bit haphazard for up-streaming. See thread comments for details. --- target/arm/gdbstub.c | 6 +++++- target/arm/helper.c | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 8865f27089d..205bab811da 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -292,7 +292,11 @@ static void arm_register_sysreg_for_feature(gpointer k= ey, gpointer value, CPUARMState *env =3D &cpu->env; DynamicGDBFeatureInfo *dyn_feature =3D &cpu->dyn_sysreg_feature; =20 - if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_NO_GDB))) { + if (!(ri->type & ARM_CP_NO_GDB)) { + /* skip ARM_CP_NO_RAW if there are no helper functions */ + if ((ri->type & ARM_CP_NO_RAW) && !ri->readfn) { + return; + } if (arm_feature(env, ARM_FEATURE_AARCH64)) { if (ri->state =3D=3D ARM_CP_STATE_AA64) { arm_gen_one_feature_sysreg(¶m->builder, dyn_feature, diff --git a/target/arm/helper.c b/target/arm/helper.c index 27ebc6f29b8..1fbc45263d5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3529,6 +3529,17 @@ static void ic_ivau_write(CPUARMState *env, const AR= MCPRegInfo *ri, } #endif =20 +/* + * Normally the current_el is known at translation time and we can + * emit the result directly in TCG code. However this helper exists + * only so we can also expose CURRENTEL to gdb. + */ +static uint64_t aa64_currentel_read(CPUARMState *env, const ARMCPRegInfo *= ri) +{ + int el =3D arm_current_el(env); + return el; +} + static const ARMCPRegInfo v8_cp_reginfo[] =3D { /* * Minimal set of EL0-visible registers. This will need to be expanded @@ -3567,7 +3578,9 @@ static const ARMCPRegInfo v8_cp_reginfo[] =3D { }, { .name =3D "CURRENTEL", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .opc2 =3D 2, .crn =3D 4, .crm =3D 2, - .access =3D PL1_R, .type =3D ARM_CP_CURRENTEL }, + .access =3D PL1_R, .type =3D ARM_CP_CURRENTEL, + .readfn =3D aa64_currentel_read + }, /* * Instruction cache ops. All of these except `IC IVAU` NOP because we * don't emulate caches. --=20 2.47.3