From patchwork Tue Jan 14 11:38:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 857221 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1871891wrc; Tue, 14 Jan 2025 03:39:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWQ9zoDHEw/gpojgu2zthIjDk3m6Y7PbawnjjJcMvlTFwYIas9P09IDynIthT6YuOnECpLyCQ==@linaro.org X-Google-Smtp-Source: AGHT+IHYxFN/MzBS4S0Usfhk4+VNxlYaQsz1J0G6I+Inh5nnrrNFjwVmn+WIGpvZqJFYzB2SoQP4 X-Received: by 2002:a05:620a:2a15:b0:7b6:6634:5a42 with SMTP id af79cd13be357-7bcd973e684mr3797463285a.23.1736854759154; Tue, 14 Jan 2025 03:39:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736854759; cv=none; d=google.com; s=arc-20240605; b=ehrnxdaalcYFLwxxqltjjqwnB05iuGRPgbpGkqWf6GsZ+ayI4r7zpLUfY5XEAVeYmD U2BTGAfkpAMdm4/1hRyDAOnzQRR1jxVB5pWikIhP0QVljr6La61Jx/ifeUydYVG6nJeo uXJ9abtei15ro1SexvELgNx/tu6c5i4oHrSSPpa+ETvd4FG9655RrGDFkbMfVwIlFbvT WnEAwqKz5ofrYDBmwCQoJFi8KWtRlkXpzVMSaljd9gfafTpVNCjmqa9Y78PQmZtEKpUT FCNTUBzPiit6+USEMdEDdcofHSC4fHzZuwU6QNuFaabBISpdq5ZQK9+WLdg19CR/gzie acDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1tw2ZvpgzU+NWUchIsRD68y5QyIwwYntbgovoaeHxtY=; fh=kybcMgHu6G3G1kz+Iwx2Y7lVQ4lMSqWHrwHMI/PcVVA=; b=Z3yoTjLK2nVMtO+Y1Hf+o3UehcaFQ0YHFg3cWpyxvRVyc3XkG1VLYbkW5smAwb9uRW no/tAnx+XD541J1HgBlv3pTWtF+WSsbksUzXUYWPsGPUg+ooVZmocfyXsMEYP6zHPp3E 26CUUd/Kd5xBjgz7yRRoYQfcjjJQIWfKUn+KOoCvycfqd+HmFy5ZSrJ3tNYWSUm0FpUe TJWEO48IJBKG68VrU6TBujk0UlFv9D5xranWp+zQVQmX/tFfcYy9OaScfTxA31NoFo6q wb5/j+m+iRAiwE05xBjSenz23hhje4ccxj8k+DSbC1FSv7OyZwKUcEnBxS9hPmSkdCRQ DJFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bLxZWzE4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7bce322a59esi1375511585a.32.2025.01.14.03.39.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jan 2025 03:39:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bLxZWzE4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tXfG0-0005Fu-Hw; Tue, 14 Jan 2025 06:38: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 1tXfFk-00057s-QY for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:39 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tXfFi-0005RG-1f for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:36 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5d3d2a30afcso8965857a12.3 for ; Tue, 14 Jan 2025 03:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736854712; x=1737459512; 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=1tw2ZvpgzU+NWUchIsRD68y5QyIwwYntbgovoaeHxtY=; b=bLxZWzE4VnYikUOh4+mFixrEzmJ3y3HvjNYGuY24XYuTKAgNufCDLtmiiPnvBB6DjQ 8fqG89Xtj7koZ9MmryDrn3PzvXr09WNNhTSsIPZis8r76Fg/Gul8hMQYirxPjb5k0TMc MIGc4N8h7lymABzvoGLaIk+msEXiywK/Mz6FpHo4dtaLj3XRyJiPzVtQjPW/DI/duxDP u993zTfthjINTWtYQDqoUiiY9kRM+4SjxsHIss6p54/OhaYX5FFtZyCsLvn6Nxpnd/o+ +k8f1iXhlAgGJ6iK2UpYEiaQttMd8gWZ0WVA+lxk6/Nb2smCIkfjVPNltbXVxEWZV+2l n7fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736854712; x=1737459512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1tw2ZvpgzU+NWUchIsRD68y5QyIwwYntbgovoaeHxtY=; b=H68Gvw/okiuTFzXXOPZgr4IT4oPOmkqx5mJ6MvsAve1LyOjJnO7OHUdIDvOyCQ9IYT bTQFxRXCAjtsr5c0fNLeNO81SM+VTTLe7jc76z/Zi7qSFIAnTJjwx5I34ES4EbYQqhNW TE0a2TDmwnFLpQg+w44EuKql+8G0WihGu7iWhlGxLlTMjOCPjgNQ1dG0udvZyJ9ybicE fAbhGAK03srXvf55fqpQKsmPwn+wJJISpetAjkZC6jFPbtri/Oa/PqFYo4FuGViMwG+X 620XSEDZ8r1rJVsywIgJ5HFXagSGW0dcwKG4omF33ghcEl8sRMGtmGVdwlnumHrn+VLi CoEA== X-Gm-Message-State: AOJu0Yxdsx1XXTUDV4C7NsKZfSPeezme7BrLunfYn5QbnP7zI37Bhddt GE9BSPitSvlASLgHeHMJngodapwWt0NoqCsSi3DbNT2fJdW9R0/hOFA/7zMwarM= X-Gm-Gg: ASbGncsEpDXxelYMaa8PoyDIsj2PxPz2/ih0oXAOx8l9iJxRJcdB8Kluf9np6qZPlB+ Q+hvLzkkUiq+39weeDjXuhgpmGN2vgfYaovqNTMmfNbDru0Ovz1PiG/v4EGgUN7/pjH6lGe+Ol2 3D3Y2oCtfjOdy1CjkOz2usYDMgLGtx9zmZPtGhmtfRWx7FzGwZmaDdZgDhuo70nRTQTihvYq8Jj bJA/kijTV/8t1rvYRmFjWRdD+s3Eyh0wP6G0eFXc24nf5oKxdqNIwE= X-Received: by 2002:a17:907:3f95:b0:aae:b259:ef6a with SMTP id a640c23a62f3a-ab2aad3a453mr2389981466b.0.1736854712532; Tue, 14 Jan 2025 03:38:32 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c905ecb7sm618679266b.26.2025.01.14.03.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 03:38:28 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 739925FA08; Tue, 14 Jan 2025 11:38:23 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Weil , Pierrick Bouvier , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PATCH v2 18/37] contrib/plugins/cflow: fix 32-bit build Date: Tue, 14 Jan 2025 11:38:02 +0000 Message-Id: <20250114113821.768750-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250114113821.768750-1-alex.bennee@linaro.org> References: <20250114113821.768750-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20241217224306.2900490-9-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- contrib/plugins/cflow.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/contrib/plugins/cflow.c b/contrib/plugins/cflow.c index b39974d1cf..930ecb46fc 100644 --- a/contrib/plugins/cflow.c +++ b/contrib/plugins/cflow.c @@ -76,6 +76,8 @@ typedef struct { /* We use this to track the current execution state */ typedef struct { + /* address of current translated block */ + uint64_t tb_pc; /* address of end of block */ uint64_t end_block; /* next pc after end of block */ @@ -85,6 +87,7 @@ typedef struct { } VCPUScoreBoard; /* descriptors for accessing the above scoreboard */ +static qemu_plugin_u64 tb_pc; static qemu_plugin_u64 end_block; static qemu_plugin_u64 pc_after_block; static qemu_plugin_u64 last_pc; @@ -189,10 +192,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) static void plugin_init(void) { g_mutex_init(&node_lock); - nodes = g_hash_table_new(NULL, g_direct_equal); + nodes = g_hash_table_new(g_int64_hash, g_int64_equal); state = qemu_plugin_scoreboard_new(sizeof(VCPUScoreBoard)); /* score board declarations */ + tb_pc = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, tb_pc); end_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, end_block); pc_after_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, @@ -215,10 +219,10 @@ static NodeData *fetch_node(uint64_t addr, bool create_if_not_found) NodeData *node = NULL; g_mutex_lock(&node_lock); - node = (NodeData *) g_hash_table_lookup(nodes, (gconstpointer) addr); + node = (NodeData *) g_hash_table_lookup(nodes, &addr); if (!node && create_if_not_found) { node = create_node(addr); - g_hash_table_insert(nodes, (gpointer) addr, (gpointer) node); + g_hash_table_insert(nodes, &node->addr, node); } g_mutex_unlock(&node_lock); return node; @@ -234,7 +238,7 @@ static void vcpu_tb_branched_exec(unsigned int cpu_index, void *udata) uint64_t lpc = qemu_plugin_u64_get(last_pc, cpu_index); uint64_t ebpc = qemu_plugin_u64_get(end_block, cpu_index); uint64_t npc = qemu_plugin_u64_get(pc_after_block, cpu_index); - uint64_t pc = GPOINTER_TO_UINT(udata); + uint64_t pc = qemu_plugin_u64_get(tb_pc, cpu_index); /* return early for address 0 */ if (!lpc) { @@ -305,10 +309,11 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) * handle both early block exits and normal branches in the * callback if we hit it. */ - gpointer udata = GUINT_TO_POINTER(pc); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_STORE_U64, tb_pc, pc); qemu_plugin_register_vcpu_tb_exec_cond_cb( tb, vcpu_tb_branched_exec, QEMU_PLUGIN_CB_NO_REGS, - QEMU_PLUGIN_COND_NE, pc_after_block, pc, udata); + QEMU_PLUGIN_COND_NE, pc_after_block, pc, NULL); /* * Now we can set start/end for this block so the next block can