From patchwork Thu May 2 21:15:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 794140 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp456671wrr; Thu, 2 May 2024 14:17:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVfN71IFStQnLxe6cYH/lyT8snyUg0KSI9WZJzQfrtf1V+zUqQoOCJeoPP8nG6V6OrNIk5uxncuM7P3U16ceGxg X-Google-Smtp-Source: AGHT+IG1UyqGcEqdLnlxOApM/ITjKyvLIBChim18nxOhccW9i7+DtcLU2UISiurQgB88ea+ELXvm X-Received: by 2002:a05:6214:c88:b0:696:8f17:2ccb with SMTP id r8-20020a0562140c8800b006968f172ccbmr949219qvr.17.1714684662315; Thu, 02 May 2024 14:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714684662; cv=none; d=google.com; s=arc-20160816; b=RVJD6cMGbdT/HMLWhuY5H/iIaJfz5hyTpgNgSN1mVA0cjNSiEJt9sa3p1TFftp+4DS M1aDUZgY3VPTkoHpGSK7FzXMQw5T0e3/Ufc4Ln5RN6GYWNnIo+MWkbdyg56/zH4/Al89 3VnJLC2pXNwPFHJIeEPTxER8/zllqp79oid4hVeWEZecJXy66+V+ul4mL5H0SzXsh//J eFiE7rkSdPhI4idN/dTtYJUMF4Yf7Pj0/JPXl5OiMRF1aYRV0Jy1hyp+Jzv2Rn/7e/ip yJYexc0PmqttCCgbrBnOrdluqDKrt6I4BoPx5MriN+VFGw4oCs4NnbeKMU+82uYLwVeC SmiQ== 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=AwiuoqvuZesoeTfyTbR5jyoxVWb/NhK8asPTRiYJ8l0=; fh=9xGhv+1UliIX34j+rhFuVtnm9fBdMYzeJdXCJAB33Zg=; b=jcv32sLhD7HQGcEJKgnAzX3vEw/T5lKJ/8Kf4oYcFjHPzNnrj0630tI85Yv1zXEieh uVNAsEBgELNaBJXLSr+7ZfzrR3G74Cxr8ZqNFXS86eXtuscoua5T/gxg6ka2u+tq+bh5 pfIKcJcNjezMaAcPEOHKuhSTALl9JBOwIugLfZsLAyJpThj4autLI256e4214AC4QZQT BZM2dp44MUusjqgraOcz8l9tmEyARKnOt4U99WIFdBkSKm08/AOYTXqadt2bFZyEU1Q9 XdPbiiYywO1wag4UzR2nd7W6S9GdH7NfqwWN2CvAk8EHMgZMziR2VSH1KJLlLnp1PyHG y2lA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOIg6JYE; 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 d5-20020a05621421c500b006a0ccc49ca3si1840214qvh.97.2024.05.02.14.17.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 14:17:42 -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=QOIg6JYE; 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 1s2dmM-0008N5-UL; Thu, 02 May 2024 17:15:46 -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 1s2dmK-0008LW-MN for qemu-devel@nongnu.org; Thu, 02 May 2024 17:15:44 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2dmI-0002ok-Oj for qemu-devel@nongnu.org; Thu, 02 May 2024 17:15:44 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6ee13f19e7eso7775792b3a.1 for ; Thu, 02 May 2024 14:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714684541; x=1715289341; 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=AwiuoqvuZesoeTfyTbR5jyoxVWb/NhK8asPTRiYJ8l0=; b=QOIg6JYEpzyMOxC20dbh4IJQKZAlM9bPGWhVnIMVzGXQUQiVzmaGcoKSFMHFyfARtp 91hSgqLzE1ZtH/NB83UbA9Qde8RTdlQicvhRfdtBwvvH4fEXoKNuZRB0h+FLbC1dCLpj kXhULakyqWddi5sTiLgH5kw69PZgHRM47cqP7nfeL4thSV1Kd+81f4JyuaGYgAKe2eo9 UEVLzXhhTe3uo6Lsnm8AGxB74psQ6msKnEb1jrpCn7vwmCcPPq4ug0t3U6mEA1jt+Kgn N3qSm9oq3zaUAd92G6P/L00ZeHzz00HUeb6SR0BX70esOU1ze7E1geMVmuTcuSEzSe0Q a0Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714684541; x=1715289341; 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=AwiuoqvuZesoeTfyTbR5jyoxVWb/NhK8asPTRiYJ8l0=; b=IVVMVtaJLOCCDXPaTsXMv8jtXMin9DquGMU5V4E/kc07UEZgN9bipxuwXEy+W6yegp U0XwMQEC5DM+qACU+vkJE/mFTUETA8A1036riPSNGg26dhwILofQGOYIe0OqSb5UGpOT Rffa4XJl1fzhSyI4SuAsnla+NQpW2oNkpubLkQnNYF+DuyLvgx1l+PIlhpEzbgNnul5j suyqapDW2Ek04uIMRH5bcBdASRa+Y/LdiPgja91cElJ5tNUeYulFent0PKDPfUzObM2N zc44R4qIkGw5mXU1tDlPz+tSrVhzU3BRz5eX2Us9J79nQlkyDGpV8n3kSCw4zQZ4kgXU 4RUA== X-Gm-Message-State: AOJu0YyfSx37HX+pm4ox62dp+CL8DIwWVajaf9p1B/yEFh8nyHS2EgSE h93xEEZ0HHfDwJ2cYVMZYKJcYtBmO1AbQqLxot9q1Xg88A/RYyZoSQfFx2XfAN7Hxl7u4clF6dS I/U4= X-Received: by 2002:aa7:88d2:0:b0:6ec:fdfe:9bde with SMTP id k18-20020aa788d2000000b006ecfdfe9bdemr783078pff.25.1714684540948; Thu, 02 May 2024 14:15:40 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::ecd0]) by smtp.gmail.com with ESMTPSA id d14-20020a63f24e000000b0060063c4be3bsm1700915pgk.14.2024.05.02.14.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 14:15:40 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Alexandre Iooss , Richard Henderson , Paolo Bonzini , Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v6 4/9] tests/plugin/inline: add test for STORE_U64 inline op Date: Thu, 2 May 2024 14:15:17 -0700 Message-Id: <20240502211522.346467-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240502211522.346467-1-pierrick.bouvier@linaro.org> References: <20240502211522.346467-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x42a.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 --- 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..103c3a22f6e 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);