From patchwork Wed May 15 20:23:29 2024 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: 796996 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp3164039wra; Wed, 15 May 2024 13:24:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhJoDxAJGNwWrBIEmTo87D1ms23FW3pqy0NDsUelGWmhZRNBnEnJUTocyvflov0ClIrOnVuNAk1v0rLXjON3rU X-Google-Smtp-Source: AGHT+IEewETRekKGxJr7Sn7Rv1hm14L1Z4WWoDh4hGJ05hBYbwKGHjbTN19ZAh34ElMgYz1Peq3f X-Received: by 2002:a81:6cd0:0:b0:627:5e68:69e3 with SMTP id 00721157ae682-62760bb9639mr14939987b3.33.1715804671921; Wed, 15 May 2024 13:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715804671; cv=none; d=google.com; s=arc-20160816; b=ifCatm07jMLGMjWWUvWv9SG8QqNTFtUu/WJnNkOsVS3EBbZQEn0xDE803tm0769WVU QTOj1MzXIpSv4M9QxyWmT/bwBCk5wteKEor201+L8UOoOdEIhkIUOf4bDAlvuyuD4ibj vq9MINQjBh50oPXh5bbKexJMJzR5XWNBcnVIlmqehfsqdQr4LuyrQ8RqGp8gXygFhChY n2ltCxjqTwtuqgC/ObdFehUJh5HEf5me6Ss7Tx8uf57t74y937yfuKKHMIKZ/4CqzTcG 3a6jbaQoVfhH3fz2t3WHCO20FbeJNmyQ5DOrrMoQlCRjpqx7A7e4b4QJ783EBwCl3chr CFyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=O7I9WCElbdcMf/kuEixqssrEdQnRAPE04lpGLv5s6u0=; fh=ahP8Qp0dn4zGVUGmV4kNOqRf/7GS2jpWEgP4Mrekis4=; b=XHbx2/ToOM8a2mP0kxX8X9QLfGNbJNe+WFpigL7194LqIn/GSz7sUZytVw+dxrzyd8 oIBchksOZEkWe9Azy7c1sHv9ZQq9KCh1ULU0jZPBDGjshEh5dbQ3UX6BF747eKRYk+PU zblVJ6IAftSscS0gz78zfUXBTS8YBXnso/kknbpikKsn/LQZcbEh0SEIN8RHefdA4VNz ja0cDnCRrMywpnqluomBSpvu/5bmgQkhc37UnMS+OeV7Xl5l+0bptx3a7mb+UIin+TST MnRd6gFLGbBtrOtRbfl2HUEqkRUOm+hrfRBHL/vfBcmpGjWebjFhZ3MX7KLDmwuTb+6l zy0w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n1vamhfP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-43df56aac7fsi147284021cf.503.2024.05.15.13.24.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 May 2024 13:24:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n1vamhfP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7LAF-00019r-Es; Wed, 15 May 2024 16:23:51 -0400 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 1s7LA7-00012t-Vr for qemu-devel@nongnu.org; Wed, 15 May 2024 16:23:44 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s7LA4-0004FA-Qa for qemu-devel@nongnu.org; Wed, 15 May 2024 16:23:43 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-572ba002a6bso2393002a12.1 for ; Wed, 15 May 2024 13:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715804619; x=1716409419; 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=O7I9WCElbdcMf/kuEixqssrEdQnRAPE04lpGLv5s6u0=; b=n1vamhfP+topOgp5OwFoJEUUJSDv43mK4JXsB7G53PmGWArKxbXdihN0A0WworM2KF U6jOc3YtULDqJjGUSpQHv7b4ZUUrzc7+kLYF9nKTmc9xxHQcvEr7WH530fc4bXmPJLNw byzDyC4VAHkZI6Lvhi/k0S6YWqoUiX+6qvpUCL2yC/1xZ+FApYFqkvpYkpTcuK6pg/4g lJKPYy2gWqsS6KpcoQYxHYXA+k6NudPxY6oF2aYHZyw4UU0ZgAWqBiKZWW521dEcKDEU unWLCbWDQk9WwaK+oiJ05EksZ51QWaxt94NwTqxigSAx54Br62T5l8pMJ/hb7kND1k0d vzDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715804619; x=1716409419; 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=O7I9WCElbdcMf/kuEixqssrEdQnRAPE04lpGLv5s6u0=; b=ZZfV5VvD99X/tJK8fOtOj4XwQR2XF2jXudORuGo1fNxzjGa42o4d5EN9YtRvnvMy3b hC3RZgqKKKHF1A4+5CQsxXnBBCGOGLRYRgzW5zmtlTcvkBF6VBXIZY2GlfCgAlQNhz+g y03wTAyugKQlE7c4/5ZzC68vNBwAfMMTyfKd9JA6YKPFYGRw2kSZcwcyfsVAoAlmqG6v Nlb+d3CtoKvJAwq5xY4qpacwfJeMCu0LRt7xcnHPvC7PVKotiNemb+eiZjMirQ0M/7PZ c+uUv1JKFXDbuksEIB448wUhv1SVmspPZybifCOwsja6km2xgIPEeDYzFCkKGC/KAQJW qdrg== X-Gm-Message-State: AOJu0Ywchn1z7oYqCLQ4mgLHGLcQTDlg669ZIY10/+lieGXUe3MdD/Ff 7LCod72Lm306JbGFvOY1ozM2+98UDmlIyu3IjXiXvdIwZRMECTF7U8qXhrKhSL8= X-Received: by 2002:a50:d516:0:b0:56f:e75b:83aa with SMTP id 4fb4d7f45d1cf-5734d5c17b7mr12452661a12.6.1715804619048; Wed, 15 May 2024 13:23:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5733bed2059sm9608919a12.56.2024.05.15.13.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 13:23:37 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 363015FA28; Wed, 15 May 2024 21:23:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , "Michael S . Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 06/11] tests/plugin/inline: add test for STORE_U64 inline op Date: Wed, 15 May 2024 21:23:29 +0100 Message-Id: <20240515202334.710324-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240515202334.710324-1-alex.bennee@linaro.org> References: <20240515202334.710324-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x533.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: <20240502211522.346467-5-pierrick.bouvier@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Alex Bennée Message-Id: <20240514174253.694591-7-alex.bennee@linaro.org> diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c index 0163e9b51c..103c3a22f6 100644 --- a/tests/plugin/inline.c +++ b/tests/plugin/inline.c @@ -22,6 +22,12 @@ typedef struct { uint64_t count_mem_inline; } CPUCount; +typedef struct { + uint64_t data_insn; + uint64_t data_tb; + uint64_t data_mem; +} CPUData; + static struct qemu_plugin_scoreboard *counts; static qemu_plugin_u64 count_tb; static qemu_plugin_u64 count_tb_inline; @@ -29,6 +35,10 @@ static qemu_plugin_u64 count_insn; static qemu_plugin_u64 count_insn_inline; static qemu_plugin_u64 count_mem; static qemu_plugin_u64 count_mem_inline; +static struct qemu_plugin_scoreboard *data; +static qemu_plugin_u64 data_insn; +static qemu_plugin_u64 data_tb; +static qemu_plugin_u64 data_mem; static uint64_t global_count_tb; static uint64_t global_count_insn; @@ -109,11 +119,13 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata) stats_mem(); qemu_plugin_scoreboard_free(counts); + qemu_plugin_scoreboard_free(data); } static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { qemu_plugin_u64_add(count_tb, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_tb, cpu_index) == (uintptr_t) udata); g_mutex_lock(&tb_lock); max_cpu_index = MAX(max_cpu_index, cpu_index); global_count_tb++; @@ -123,6 +135,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata) static void vcpu_insn_exec(unsigned int cpu_index, void *udata) { qemu_plugin_u64_add(count_insn, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_insn, cpu_index) == (uintptr_t) udata); g_mutex_lock(&insn_lock); global_count_insn++; g_mutex_unlock(&insn_lock); @@ -131,9 +144,10 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) static void vcpu_mem_access(unsigned int cpu_index, qemu_plugin_meminfo_t info, uint64_t vaddr, - void *userdata) + void *udata) { qemu_plugin_u64_add(count_mem, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_mem, cpu_index) == (uintptr_t) udata); g_mutex_lock(&mem_lock); global_count_mem++; g_mutex_unlock(&mem_lock); @@ -141,20 +155,34 @@ static void vcpu_mem_access(unsigned int cpu_index, static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { + void *tb_store = tb; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_STORE_U64, data_tb, (uintptr_t) tb_store); qemu_plugin_register_vcpu_tb_exec_cb( - tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, tb_store); qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); for (int idx = 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx); + void *insn_store = insn; + void *mem_store = (char *)insn_store + 0xff; + + qemu_plugin_register_vcpu_insn_exec_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, 0); + insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, insn_store); qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1); + + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_STORE_U64, + data_mem, (uintptr_t) mem_store); qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access, QEMU_PLUGIN_CB_NO_REGS, - QEMU_PLUGIN_MEM_RW, 0); + QEMU_PLUGIN_MEM_RW, mem_store); qemu_plugin_register_vcpu_mem_inline_per_vcpu( insn, QEMU_PLUGIN_MEM_RW, QEMU_PLUGIN_INLINE_ADD_U64, @@ -179,6 +207,11 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, counts, CPUCount, count_insn_inline); count_mem_inline = qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, count_mem_inline); + data = qemu_plugin_scoreboard_new(sizeof(CPUData)); + data_insn = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_insn); + data_tb = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_tb); + data_mem = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_mem); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);