From nobody Mon Nov 25 11:54:51 2024 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=1715804672; cv=none; d=zohomail.com; s=zohoarc; b=XoO3vETiUJyJB/EVjAvCKOY59y7A2kLueKYB3SjMRzFXmSYuMnhr+rIUGGdC7gACXFrNs/1fsSt7N+A53zKe8v0KKXSkXoM22D1wDpmhTiGtup2k/IVdXJY88boOneWgtMxq0dCq0UAvOXMl+AaBL0HVR1E8v5ZRN8Ls/9ii1/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715804672; 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=O7I9WCElbdcMf/kuEixqssrEdQnRAPE04lpGLv5s6u0=; b=ZH0c7DRgEx6kKsBXgOqb972RkQ+quI0OQNi+Dv12MfJ+oGLqAETTxwGalj5GDbhG+Jqwlu8vBaOBTMRbReqFOMh8aFhk5J0tE+8WubdBJabVMV42PnYEdnHRv7AJBBZlq18CPjD65xgENAKOdzLGBlsyWYYQjpzFT8CtOu+2Q5Q= 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 17158046727781012.4024541820493; Wed, 15 May 2024 13:24:32 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AGHT+IGXD/1rMptBtdq1ZTiD/Drd6L1u84wkMR8GaAqRtdEvD4lX508S+92m4OucP7MftA4csU3aFw== 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) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , "Michael S . Tsirkin" , =?UTF-8?q?Alex=20Benn=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 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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1715804674531100002 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=C3=A9e 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; =20 +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; =20 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 *ud= ata) stats_mem(); =20 qemu_plugin_scoreboard_free(counts); + qemu_plugin_scoreboard_free(data); } =20 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) =3D=3D (uintptr_t) ud= ata); g_mutex_lock(&tb_lock); max_cpu_index =3D 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) =3D=3D (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, voi= d *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) =3D=3D (uintptr_t) u= data); 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, =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { + void *tb_store =3D 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); =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); + void *insn_store =3D insn; + void *mem_store =3D (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 qem= u_info_t *info, counts, CPUCount, count_insn_inline); count_mem_inline =3D qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, count_mem_inline); + data =3D qemu_plugin_scoreboard_new(sizeof(CPUData)); + data_insn =3D qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data= _insn); + data_tb =3D qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_t= b); + data_mem =3D 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); =20 --=20 2.39.2