From patchwork Tue Dec 17 22:43:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 851467 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp616750wrq; Tue, 17 Dec 2024 14:44:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWIduGz3Lxw2wzmxcG744wGZkzq/zoq8dEbLQWYzYxb4MfzuAkVYS6bIMZRcwPSgAi12wmwwg==@linaro.org X-Google-Smtp-Source: AGHT+IE1WscFUeIpAtod0c6Nlod83F877C4yZ7FrtpFYh4K4d+bgceVdq1A6RSZrZXGH9kbif3fJ X-Received: by 2002:a05:620a:40ca:b0:7b7:869:2e48 with SMTP id af79cd13be357-7b8637ae7f5mr68843485a.47.1734475489912; Tue, 17 Dec 2024 14:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734475489; cv=none; d=google.com; s=arc-20240605; b=gViNrkaSSTyCqna2m5v7ELnkaxqCMGblEZluNlGuxd3ErQr+zduiHtuK9BADU0KyR9 GB0Cv9R9S4lCFkw1oD5PQHpwJnxmDBEH8MWiRLGPNA6U/Xn5NtsHA1gBspBlTT9ixM4g IfqUvc6eVSUM2TEZAxCBPopCCEyVJ70BlE7muq334ctniLALQ2xpfKF1K6HeX7L5WZgy DNwZwagOE++CoHwGfLnuGASwMM7W9VGVXI7QpkR3AGQilDYcPtNl1+h1jwRIDJT5NwCN x4vx6mlfXFLEa6svcgELs150UgxxR9Zq1LGRqk4jkq8mWzC38luLHviLKOXLSR0EFvMW BRDw== 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=Fpq9JRkJksoEkEWeOYDLbD75PjoHd4ohCmD67AV53u8=; fh=e32mLanPjfs41dQwy8Wt4zFa68BQ2A3naWRPcWqt/Vw=; b=gAPK86hPqBRKh9kRgl3TDUq+cH6l5BwGVeN5DnWc+AxCS0b6QWUTrUUDGbcK552UTs rVQLKfCGQINJN+mnfTdsQgsm49Auwz7pn8YuXO7qpCeXcVQyb+YUkYDyUO5iE2+6nNMP kePCeDqifBEpLvyAgQsIcrJPVxJMCs9PxO7GVRKx84ZV82X7XNsBLUE1iesKZTVZGD24 wCgSu5jHJZU+UMVHNeudqzVd/CMTK5hg+6wTSk3qgTCsnWDX9SRcNueHODYbEf5BazbE Urq4I9KeLEI2HlVAgX53tTEeE6Yko9rSFVevlYWuYDSFVcNGAm9hRxhloRsHx4GCd9SN srvw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Iqk/lGhU"; 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-7b7047e4d7asi1102567385a.148.2024.12.17.14.44.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Dec 2024 14:44:49 -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="Iqk/lGhU"; 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 1tNgHl-0004Ms-Mb; Tue, 17 Dec 2024 17:43:25 -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 1tNgHg-0004Jz-Ub for qemu-devel@nongnu.org; Tue, 17 Dec 2024 17:43:20 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNgHf-0001AW-98 for qemu-devel@nongnu.org; Tue, 17 Dec 2024 17:43:20 -0500 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-728ea1573c0so5112694b3a.0 for ; Tue, 17 Dec 2024 14:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734475398; x=1735080198; 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=Fpq9JRkJksoEkEWeOYDLbD75PjoHd4ohCmD67AV53u8=; b=Iqk/lGhU7rni03XzBqYo/YngFsgOgKjsNKz9sSBzBeDWMEOSWAn3E91gKekUKVcAlg EPmKQpYo57xdsKyfAyzj4JKIqY69FUc1c/4a7rsau+f4hNz3krp0w5C6DlFwFo26qY1K ZkGsUEfnxr9sZ+T9bZsrr9CTZgl0nkUPnpTOAO8nrbUyvjr8l8GZ2QXnpgXoABpMHuDz 99zDtYoXvx5j7fjPmrqP83VamhhWcT+exSJg9fzf8uL0TN1XFvSEZIZNxTKwNwFS2/2w WDuIg0+tON2QLA4cPQmRaw/qRqwTRcEMxc9gNdrcen7qH4Cmbfg2i/g/K9oz9niMJsoW C16A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734475398; x=1735080198; 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=Fpq9JRkJksoEkEWeOYDLbD75PjoHd4ohCmD67AV53u8=; b=uoiLQ4l/wK/+pJcQ6mNfgYkyZKSXhyWZnyhP+oTwIRu28b0BFB9V4J7QJXwEkeYsst ZNDGyOyGzO+ypZH1rj3zljUg5ZA9D2y4ZXRAfihABe/+Cq8zHXI4hpOu+BO6iCJpPvZJ ap3NiOa69SvsPuprgZJ+IGE7ZFN5+M1JrTWZ617OsKAAaYSpU68qgqM4JxKP/njHZLqD +1HLz2JppI0xE+mdk60/60oexs2fcT9w5nmVbcbhVlVMNX83Pa1hwz+T2zI6UezZY71Q 1R6BScwXWKv0aG2ql0rhIUB2waa2hr8TPqn/QCcO5l93hxZfZcEwZDsRfdtow2fRvX5K mXGg== X-Gm-Message-State: AOJu0YxuSiYklh+9050qRx40CVnZeCrJY6a1h+bT0KVxWVihUCIEG7HK 7fC5MiHoNeIRlTrdVIOMSAkUke7c2v4QR60nxBI/aPbNtn8/9rrYnsIweJUCvPNtlKrEHOj6qpW 0guo= X-Gm-Gg: ASbGncss2W2E4NyU8s5truzlOm+0wfBW+/sb7tNuqqPwHlLr8E1evA+u3ONsSJVHO24 wgmuP9dPqhBuzx1sp7zxu85VwrSahqQ1SpXnvYpJpDcoH/k7VGThc2QHhxu5OMJQpPVv+nwZQyH TaoLbDc2oOrTsD+UXQ481es//IaoLwlCRC+eXbp/r6fFMJfx1vD1AO7o7WaBh/0FjKp8K7s0jd8 oYdhT5Wd1YjCYOvQzEw68cRMrjiAewHILdjqrtuJifLIlYw7SSvMxRB X-Received: by 2002:a05:6a00:21c6:b0:728:eb32:356c with SMTP id d2e1a72fcca58-72a8d2611f2mr992157b3a.11.1734475398045; Tue, 17 Dec 2024 14:43:18 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ac53f3sm7463214b3a.27.2024.12.17.14.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 14:43:17 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , richard.henderson@linaro.org, philmd@linaro.org, Alexandre Iooss , Mahmoud Mandour , Thomas Huth , Paolo Bonzini Subject: [PATCH v3 08/11] contrib/plugins/cflow: fix 32-bit build Date: Tue, 17 Dec 2024 14:43:03 -0800 Message-Id: <20241217224306.2900490-9-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241217224306.2900490-1-pierrick.bouvier@linaro.org> References: <20241217224306.2900490-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, 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 Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- 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 b39974d1cf3..930ecb46fcd 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