From patchwork Thu Feb 29 05:53:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 776890 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp659127wrn; Wed, 28 Feb 2024 21:55:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWBrJGbifN8foh7z5VjfnFrxTBiDS3v58YkA+oODDOKhYDDtuXtO36ZsuS9CYPQkjrugdFhX5qqhit47s/ymJxZ X-Google-Smtp-Source: AGHT+IHBJSvyQyd38kMh7qbJzXTcLKgbYP+ejW+ZrOCwBgPeOG7R2iZOwS+79D3Y/PydM6knaaWM X-Received: by 2002:a05:620a:2227:b0:787:f9ba:1d5b with SMTP id n7-20020a05620a222700b00787f9ba1d5bmr1079112qkh.19.1709186100777; Wed, 28 Feb 2024 21:55:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709186100; cv=none; d=google.com; s=arc-20160816; b=XQzWmeiCLOb2/WLjAJOmPTOU/rJGPpN6Tr+TIkL6TU9wIfaCjloRTVDsHJFSzDjJ57 0ELj6TrfH8voqNbghILGtG8I5M3xy3XgJRQ9VwpXOqZpevtMqSLPzTYhQoPWCKymJXcD qnNU9xKdYEkK2uSp5ZBTgNeGrmPTHO/D7e9oflPT75hLekY2YSeAos5cTNEtnjIWCvZw H1LdgvWMN+Qh1ZrIWAaotMLxe8fNxiPkNGweEkeHijFxRupxa4uYSvJrl2cillBhrVNN Cozevvy2VZ03uKFAzloDxwnCgW/JJqUAw+TTNRSThMB+wWwG4b77444Cd1tmmg4qiSov xXSg== 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=i526I2NdBPegbWf9Dxe02iA+9L1d9LPYMCNUBY0HJ0Y=; fh=8lOiKNd9h86rc82T3YMc9TRwDu6QzmEoHMzVmFEI/Z4=; b=agHeldAOkzWi/4FuewoQh0bGvA8LxSlQUCR2qI8Q7fLws+fz7tu31jnI9gEJXWZq5h glKlp4h4A+BEG5dk+ZuEvDqVqaDrbOX5B8VBU6hCHv5+Wkv6hO+pHi2Taw3KROA7qAVn EQD42KZAJNbTefs8yzGLJMmO06vPRPYmuF77Hi3p2PSOf6+qluWsXtoK+VFYjy0WMDF1 08hc4OM1MykYdFcD5NWiP6Qwp2Jwm82vcn17t7kshy0dK/lx7T2hiWrlUYgm5PZys7cZ cIM8yH1sTflnSf/1EYMlk+6BG4oYRbKQRgOiuMo91gMa/fLs0p1EgD5FfSFo9bZIx5ky c2eA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IUDhuBEH; 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 w17-20020a05620a445100b00787fed15273si62211qkp.548.2024.02.28.21.55.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2024 21:55:00 -0800 (PST) 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=IUDhuBEH; 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 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) 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-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) 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) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , =?utf-8?q?Alex_Benn=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; +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_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); 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_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 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);