From patchwork Wed Jun 26 23:37:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807527 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546078wrn; Wed, 26 Jun 2024 16:39:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX6xpP/pd6pVwMcgZMYojIdrux03KqvKpH9iV2gmmWvoCIxKDpxYheHJRPOr8kL9gDH9rLZHT9QIRH6T5ZMiEbv X-Google-Smtp-Source: AGHT+IFrUo+5JYhPfQQnt8jn5ZSft5o/qpCmkROLxdjvVQzigj8yCeheWC5HW2DUwsDFiU4A6p7c X-Received: by 2002:a05:6214:21af:b0:6b5:2bfa:edd5 with SMTP id 6a1803df08f44-6b56341eb3fmr152252596d6.17.1719445193581; Wed, 26 Jun 2024 16:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445193; cv=none; d=google.com; s=arc-20160816; b=PjVz0ciPe+G/+yEO4btq6+VjZrrxbBMEEPOpVgtdIip8GpRqv3UdLuaXFoAahu2JMY 5w55haARu7dw5QenpqI/Y7ZcAhc0RdEI+CWoM3XPFOTUtw4Uo/X+2r13InTHJjNDUmqI 2BYjxGfFIaEFXD3L4HW/OfYIbiDzsdg+dJmVZOvsDg3FJWofO4Rqa4ACIK1cKs/u0kB5 Jz/6BzYfMStU29hQSO9/Mdqj3LhVZeyArcZ0fNPhf//M+Pm72P4Oo2+1423D6vnMZrvM 1LjZA0Uc6r6eAdQZp3dDBYx/t1NMzuSfIWKlhfdrLUm6ZpK3wqbvbgUBytyg7ZdHlHct DLZw== 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=f3YG3piskD3FnrYHWUhj9K/baIAzLlF794+NnT4pc1snWs0qUINfb+aLqAIoH4JViU vKgC0sPnjW0y5CBfszyTIBXsQLH5L/uZIla3VVryGGGW9xDyu0BirxIw+BGUmjdfj+vk +FVDFMZobc8cZn5f3uBMb0/+tuPoJVEhDs9fh+cVLvcU1TNEm+9wdqNwq+f6FnDGYpKx o0eDWMau73Pusj1M9KXvlzYdmYELi9IYGjkb6AIbYr8AXtKBImGFIvbmmITXgdCHCRzD Wh/OoDtixve+gXpzGrnoYdQqvaZPLbNfAxDiteDd5OUkw2fVnL790eS1JOmHrtZhjIoB 8flw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rg0Ph9Vn; 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 6a1803df08f44-6b592901ec8si1051626d6.533.2024.06.26.16.39.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:39:53 -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=rg0Ph9Vn; 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 1sMcDr-0007W6-TC; Wed, 26 Jun 2024 19:38:45 -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 1sMcDK-0007Rr-6Q for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:12 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDI-0007Ft-Fq for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:09 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1faad2f1967so120105ad.0 for ; Wed, 26 Jun 2024 16:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445086; x=1720049886; 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; b=rg0Ph9VnKXP78yvmrSJR3pcdE5y+2Hrr8Y/nCjNrLYsF0Td/grm3VPFNUGOQI1mtHo Y6AbcxYn0AhrVMwrJcFXHmot2M8klm5xuDcXU7QW9jkXoy3gVTUcTOm3LgMdaAyT54Ib M/GGi9vqYJcVKqxNgKgGi+FPMtWkbPjVbhB/uvLx3N/FvqJRMYCVzhyCCWvjvI18GHnl gdZ0dLufOI4P8HblsLsXVWCK9lx2ud5oi6yHmk+/yTtbmS0+GESOVffbNM6zl8cfogfk lVb8sNKgJ/OvOYF5wd1IZBuJ0xqFOT2ni5WxV7tC2ZSbka6OwuhyG3Za9jwwWN0ipw65 Xtpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445086; x=1720049886; 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; b=Kv0l00BS58E2h10snFROjMAdDZ7JOqtwTj+lo/ojsTvycDaTg0otqiq5HLaSEn3I+n k5i2ggJQNyHg+av/X7bRufmx3hJXAAkF/VVTaisfR+3MpPT0Rx7YuEyrJBnXMI7SvHs2 tSqvWoFSomGxoZIMIXIY+WBTm2LzcAuhIY65F325JWSoy+LyhtCTaJV1ruGsh0ohfrLG ZA7FHEZkRuNlJKEsY2g7dvGeznvJmPEry6dcxPGNy03fvg3b3aNd9qOWJldo+tL54zzE 3eUJf4W06drlpHvyDXp5XF4+2NLWTEZIX1VXXan8Un5Op1TocaBGvnA1R/yw+8hVkL0R mCsg== X-Gm-Message-State: AOJu0YyWug3g8yLSmtnlmzTJJkdkGxk/4FzKiESOEroGLNVd0hxZX4IR vusmG6CS5IpXlqnGvpuQgjycNUCCSQ8NpZ0/SmGJi0ZjMgIwGCu6F1mW/zwi52WmlRISnCGZSA4 QLPM= X-Received: by 2002:a17:903:2444:b0:1f9:b698:3221 with SMTP id d9443c01a7336-1faac2ba21amr3421045ad.21.1719445086682; Wed, 26 Jun 2024 16:38:06 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac8df624sm563055ad.29.2024.06.26.16.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:05 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= Subject: [PATCH v2 3/7] plugins: extend API to get latest memory value accessed Date: Wed, 26 Jun 2024 16:37:53 -0700 Message-Id: <20240626233757.375083-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x632.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 Two functions are added to plugins API: - qemu_plugin_mem_get_value_upper_bits - qemu_plugin_mem_get_value_lower_bits This value can be accessed only during a memory callback. Signed-off-by: Pierrick Bouvier --- include/qemu/qemu-plugin.h | 20 ++++++++++++++++++++ plugins/api.c | 21 +++++++++++++++++++++ plugins/qemu-plugins.symbols | 2 ++ 3 files changed, 43 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c71c705b699..5945f256949 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -551,6 +551,26 @@ bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); QEMU_PLUGIN_API bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); +/** + * qemu_plugin_mem_get_value_lower_bits() - return 64 lower bits of latest + * accessed memory value + * @info: opaque memory transaction handle + * + * Returns: lower bits for value accessed + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_mem_get_value_lower_bits(qemu_plugin_meminfo_t info); + +/** + * qemu_plugin_mem_get_value_upper_bits() - return 64 upper bits of latest + * accessed memory value + * @info: opaque memory transaction handle + * + * Returns: upper bits for value accessed + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_mem_get_value_upper_bits(qemu_plugin_meminfo_t info); + /** * qemu_plugin_get_hwaddr() - return handle for memory operation * @info: opaque memory info structure diff --git a/plugins/api.c b/plugins/api.c index 2ff13d09de6..89e9f6ba5b4 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -351,6 +351,27 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) return get_plugin_meminfo_rw(info) & QEMU_PLUGIN_MEM_W; } +uint64_t qemu_plugin_mem_get_value_upper_bits(qemu_plugin_meminfo_t info) +{ + return current_cpu->plugin_state->mem_value_upper_bits; +} + +uint64_t qemu_plugin_mem_get_value_lower_bits(qemu_plugin_meminfo_t info) +{ + uint64_t value = current_cpu->plugin_state->mem_value_lower_bits; + /* tcg values are sign extended, so we must clip them */ + switch (qemu_plugin_mem_size_shift(info)) { + case 0: + return value & 0xff; + case 1: + return value & 0xffff; + case 2: + return value & 0xffffffff; + default: + return value; + } +} + /* * Virtual Memory queries */ diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index ca773d8d9fe..9f2646fc812 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -13,6 +13,8 @@ qemu_plugin_insn_size; qemu_plugin_insn_symbol; qemu_plugin_insn_vaddr; + qemu_plugin_mem_get_value_upper_bits; + qemu_plugin_mem_get_value_lower_bits; qemu_plugin_mem_is_big_endian; qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_store;