From nobody Tue Nov 26 08:47: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=1709186101; cv=none; d=zohomail.com; s=zohoarc; b=WIQOuOEiV06kaWQ7da6aFcfBMf4uFRN588HRCRN0mv2HzdDCSq0X2LC51jJaOHKk8GHF7/jNmdDFz/gtlFrJZLsAM4B3rJolpyt/MMWQW+nXE95VFHclHFAllTxh7e0AT4AP3esMHgmszUp91RHBmbsbgdcsjb68Xya/HuBwzq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709186101; h=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=i526I2NdBPegbWf9Dxe02iA+9L1d9LPYMCNUBY0HJ0Y=; b=NLhSa4yNeJ0kIKPQIoRPzFaHbu8L2USSMUwg2JLR73Y2FFWvWtVVt1tbTOfIpLMbX0+LetDj1Rj7BPEAOY9CLsLRQB6f9Z+zm7S2LbLkqcAN8wCijav9hPYwzkJohtId8zvdcH5qzupB/rjFng1nAwtNP8K4TfPbBcEpmA5CTpQ= 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 170918610148388.06473035129409; Wed, 28 Feb 2024 21:55:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfZND-0004k3-Eh; Thu, 29 Feb 2024 00:54:27 -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 1rfZN9-0004j0-66 for qemu-devel@nongnu.org; Thu, 29 Feb 2024 00:54:24 -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 1rfZN7-00078u-88 for qemu-devel@nongnu.org; Thu, 29 Feb 2024 00:54:22 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-412b40e023dso3793985e9.1 for ; Wed, 28 Feb 2024 21:54:20 -0800 (PST) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id ck12-20020a5d5e8c000000b0033d2541b3e1sm721589wrb.72.2024.02.28.21.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 21:54:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709186059; x=1709790859; 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=i526I2NdBPegbWf9Dxe02iA+9L1d9LPYMCNUBY0HJ0Y=; b=IUDhuBEHmlN6tC0/Tf+VcQkYGTCt5GCWRSPZMDtZQH+6b0ed8HunmGmavVtQ9lSz63 UZs5r924XfBvm+ijVz4oXodmOMNFIQbNTzYX40xhSm7MgqF9g970UyQId0BAL06bT5b8 OBOpOHkciBg8aOGGPr5JFhNvgImqQCgtKr4sIfHc8ZcKcM15lwbpazk9LwDz4zpSwyKX M4IQS54tioobauA52Ury0kMJMeB1AU4mb0axOKqT43SR1/K2YD6y1mN7nG0Z5TLdV8je 5CW1ja1bh67a6LCaCzLe1WWWv3DDOmym1rpAS4yI+fiimjOOlVkeQ5DHgoL62WerSSgB 4SJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709186059; x=1709790859; 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=i526I2NdBPegbWf9Dxe02iA+9L1d9LPYMCNUBY0HJ0Y=; b=WuETdwGEGRCAQrPtIMQEpufJ4LMXCfjARQ6sBTLTMnSoiuPS9A/jiC5olIXiSZZtKr a9k2Ahljfof3yyXIp6i7wG0PsWtozPylDwH9NjZkCHMcxlGYiWinVBfUGUU+Hlr1pLPr pILFbrLsRTOCLh9D7wfOJjttYKcJJU3YkytZyg+RwrWjguJXR4Znf0xe9OD2F7rzJBv1 VeNbaPPaMGh/fPloMAk3vOkL7FrCUmtVExF7qKEcv5Bj7SbLOTW6J7+0OaNfdv22SULK XF5CzgBse2tLLnhL44JArm2UDkvzar/KCyKxl9njxx09Z08+ZfUoz8HS0oVihTnhYebt /BbQ== X-Gm-Message-State: AOJu0YwGiE4bk5t5Ld7d8QKchudGYI5CkV6698fY9jd5Dt9qL3MOsLXb zHUMGB1RjsWVqO5UsPvfdwB+8CGNLbm7AkE/+zD+BkGUObUSAyF/f/PhkvL8z2ZhlaMdo80od+p Ij8U= X-Google-Smtp-Source: AGHT+IGVreuRxPHL0uydbUaQewVvKFRersB7LodV852Xvlxq9kEEZcRTIKc842PLk2gEGwF7I4qtvQ== X-Received: by 2002:adf:e5d1:0:b0:33d:620b:49 with SMTP id a17-20020adfe5d1000000b0033d620b0049mr756524wrn.32.1709186059394; Wed, 28 Feb 2024 21:54:19 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier , Richard Henderson Subject: [PATCH 3/5] tests/plugin/inline: add test for STORE_U64 inline op Date: Thu, 29 Feb 2024 09:53:57 +0400 Message-ID: <20240229055359.972151-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229055359.972151-1-pierrick.bouvier@linaro.org> References: <20240229055359.972151-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 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::335; envelope-from=pierrick.bouvier@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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1709186103207100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier --- tests/plugin/inline.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c index 0163e9b51c5..30acc7a1838 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_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); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_STORE_U64, data_tb, (uintptr_t) tb_store); =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_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_STORE_U64, data_insn, + (uintptr_t) 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_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_STORE_U64, + data_mem, (uintptr_t) 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.43.0