From patchwork Tue May 14 17:42:48 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: 796754 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp2612153wra; Tue, 14 May 2024 10:47:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUFJlLZhHxoxSZBqu6u5OA2m/0ReYnDb/4Jv32GyHnToRieXrFImV+bcPS4jSyFjc7accgQDS79tgCZt/nxJju0 X-Google-Smtp-Source: AGHT+IEe2LHfzLyZsgQcrxY+hyO16Kjplbk37hERFk8chdM3aYY78OIYEtXlCwUXUiskzID2r9PR X-Received: by 2002:a05:620a:248c:b0:790:c15b:e192 with SMTP id af79cd13be357-792bbe66992mr2876004985a.32.1715708827591; Tue, 14 May 2024 10:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715708827; cv=none; d=google.com; s=arc-20160816; b=fSvUGS7wKvUAygYwiGDebXqSe5s3aK2qtDMlHu/mhrP49+8R0la+aftBUmsgRqK/36 PzUBpR+AbECjppauLxv9y+ipdOYSKWSl0lRteVecrJ/m2ZBH+5Kz2nzpOrvmlAMfu21c /pbW18qfaGE0zavZHiqL9mxEMihKB2O52jBeoHcMGmnluJyNTITIifMjH1CmglQvRo79 Zu44767WCl/YaE40MpnTetbZQVA/t612amRMrHRy+G3VuYvjAsp7P6GVEWEGXe/L0gDh Z9FBFOuJvwJ+M/Ux5u3AWR04XthQ1Yoab7aCuUe1Op87ATLd1f47onWj7nJSWFvLAzbh kLTQ== 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=FZhvGQJLCzvceDPyZ67XElIegSjy3JPT1fqbqptrVHU=; fh=AUhhMvfuqYV1WD/1Jx7Q0Z0LnvlruScCfdPWYDT2uE8=; b=0rcoP+cUblVQ0G5KNrxaHFKHJIJySRE7vvzVh4WzzVnqkItNI1XASIrfsdbXR9rOEZ xiAzGCRCfK4VDGbflq9pT8ht6Udvl2vWxlQ0uu4nxgOG45xn5yF7ec8apKpBe5mneXFO ug+dEaDVeNeVdvZ7x6CV9WbPm56y6Jd7DZbBu3dx5Optozw9+3DYOxDfXE1LT+VxecDB 1/0uUmdjlMGY3NdNuxV6IZ5bUDQTlvLo6JrhAMR/UJ8ggS/td3g97qoAZ4txBwXGY+tb SgHqfXDRkdulinrDde2DwywQ4yzirvxbsav9yZFxsFEyOfVM7OLT/UKfvoMCj7U7TVVg O8NA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QH6n3tAa; 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 af79cd13be357-792bf38efd8si1176723185a.759.2024.05.14.10.47.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2024 10:47:07 -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=QH6n3tAa; 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 1s6wBr-00050i-La; Tue, 14 May 2024 13:43: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 1s6wBh-0004u4-GO for qemu-devel@nongnu.org; Tue, 14 May 2024 13:43:43 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6wBY-0004u1-1O for qemu-devel@nongnu.org; Tue, 14 May 2024 13:43:40 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-51f71e4970bso7001363e87.2 for ; Tue, 14 May 2024 10:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715708580; x=1716313380; 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=FZhvGQJLCzvceDPyZ67XElIegSjy3JPT1fqbqptrVHU=; b=QH6n3tAa51o7Sa6+MDixlnPUCQsw92AKi0Y26I+lobhnEbBuOj/QGdgmi3JIXwLktN a7IXnErjRfYBKDgKgyox2mNBO0rdJnuUc6Vr7yDAKkKPaRI5LKVl9uM688KMtcrSgfBb ie8KLPtQeNocgAaKqtNZ3LDNkeIAVy1sZOQZSOX54yNQd2ZkjF1WBv9NTJgWye4LQkFK clUf4Jjqip7yJTuLTEH7Wic7rzxa6tHO+Z6lnDJkP+kNcJKxOizgK4l6hjmfk4RUiXBY /zd3p9UwnQFvTpds0rCuznkbCKIno2KKET5OpGFHfkeratxbjAoDGiVoB77kV7zDNUmV 1BzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715708580; x=1716313380; 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=FZhvGQJLCzvceDPyZ67XElIegSjy3JPT1fqbqptrVHU=; b=PABq63bzTkPMwuCG7LlzhajCGF6PlbSobRyEDzYH/08E7eBNv8P9sABShLcHoNmXBC 4PNGuSDlBYn1icyd8Jezt/PTbL3GoQ8guLFK2fX46X2dXxumwKZtLqCwr5FXJUOh+wMW LgetmJB3q7+GoYhnsT5dKuNiSty5HLDbSCxCm6iGzOnNQyUyhEF/JWDyJb/2ab9OLIKd 4kEwLD2AVxhv64Om3eqIhmjLhZWBK51/HZrwCZKWJ+nqiEdz38j4PrCxU4loQFExawwm DNZzfs73bDVo6VGm0n+9Vt18LldYcfmTtenZ5dNis5eZBoj8cysq8rRY1G7xjoz42iNB W+sQ== X-Gm-Message-State: AOJu0Yyhv7RcffTYemm/NW7J7xbshleb09SXtFeHUg6NGEXWe6panEDU DJbSiuJdtWuaOmPRmBIzStutxeawLGU1pd/T1cLBZDiIGvJpAYawwYIMrrS414X8f1ffyy3PyVJ s7Vk= X-Received: by 2002:a05:6512:e81:b0:518:c69b:3a04 with SMTP id 2adb3069b0e04-5220f770e6dmr13898358e87.0.1715708579748; Tue, 14 May 2024 10:42:59 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781cf7bsm741293766b.40.2024.05.14.10.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 10:42:56 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7E0885FA28; Tue, 14 May 2024 18:42:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , qemu-arm@nongnu.org, Richard Henderson , Alexandre Iooss , Pierrick Bouvier , Cornelia Huck , Peter Maydell , "Michael S. Tsirkin" , Mahmoud Mandour Subject: [PATCH 06/11] tests/plugin/inline: add test for STORE_U64 inline op Date: Tue, 14 May 2024 18:42:48 +0100 Message-Id: <20240514174253.694591-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514174253.694591-1-alex.bennee@linaro.org> References: <20240514174253.694591-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x129.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> Signed-off-by: Alex Bennée --- 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 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);