From nobody Mon Nov 25 02:05:44 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=1719443651; cv=none; d=zohomail.com; s=zohoarc; b=ZUnszsmf9Gr7mc1IjAy5HnWVlz+ddx4a/9j5bMZr8sLzEAV7jyAWkIUvB+PPpsj2NUrR3MrEi+VqOCLeW9tUEZlhB369sfEh7+lLjpPqKrO6/1Ma9gDNnB6DSWgb2sZtNLQlcVASv1lzaA4K3ZRUXTYCQEMZ8/Sk/GgqsKZ1p4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719443651; 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; b=S9hQC0WB3A5brBc6L2dThSJkn9zvfUTv2RON57xO470XbZTS/ZBbzP6k+Zu65RF2iZp7gxPR5kLSI4IAR8MBrnLHTFkbnE9Zf/k0j86fXiUiPVHYKr7NW4sqSHP46nUdhxr7s5L4/xqGSVQZ7o21a/sk1fH+HRzVpqtW4scF5zY= 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 1719443651284371.455337880231; Wed, 26 Jun 2024 16:14:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMbp7-000391-1x; Wed, 26 Jun 2024 19:13:09 -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 1sMbp5-00038h-AH for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:07 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMbp3-0000Ok-KM for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:13:07 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1f64ecb1766so55240225ad.1 for ; Wed, 26 Jun 2024 16:13:05 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac82cd3bsm478215ad.0.2024.06.26.16.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719443583; x=1720048383; 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=wT9xxqW3L6yVoUEKBBB+r6331cprohHKpgpb18yAFgQ7FkVORpiEyCHxkwCHJY5Qwm 8w3q4b+v+/PM84RBIl/uWYGnziJgyeNOtvIqjbRDd1jRpAVUf1Q+r7Wb15nujkFwfF78 lmlmsawR/yY9tdJy8NeDFsagD62j1yUxnq+pLf0BMCR2xEezjHGvTYucaWtqvMqPRy2d q/x+Uo1FlJZP0j9hFWmos/yEkImlZuGBq6u3iqNiFv9e3V7nnHnCghR7tSrhOyA+tAGY NCdpleltjbE2Ke/XhyBAJCfvlpCnruE5FnwJsW0GUoQcRxG3NqfR53ugXxccxwiTkudo fkQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719443583; x=1720048383; 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=uypQj2ceUsknLTBe7FaG6NZf3ujwpnOq4cZ1NhqjmrJ+NDrYZLWPRTdUw5hV3Dpwie 7hPCiNHRu3/4v7wftXyieyNtfDSSBO57jsGlGl1MJBxlC+L2gRL0HoF4LkPrcvoacPHY FF64kjLVCZsnCYUb1VTk2r42G5r35CpZGmWiQSZX7isdmC3QE1HPBsiAAImC+fuvCm1m 9aUlpU8oGKGC+T1s9OY1xsz6mNw7RbsU2fL5bJGc6j72sTqpukAe8IycZGDc2xWvJIqt N8G+xAPy4Eu33fZrT9SHnJiEagLxVak7boxrINtS5iQYx4cjp9zBCxcd0NTt+BnMLhM1 Wfmw== X-Gm-Message-State: AOJu0YyApzMNm6JtyeVUi1i4kZloIxhz8kimy6ROg2zMghrUIvz/+hz5 duwLX4FqJxRIXm0ctXzLyP8LrTungv3Neda5mO08yh2EGrrmDGgv3rDqNHn7FBEuIi9QMmjKbx9 c1gI= X-Google-Smtp-Source: AGHT+IFkyezoVgHJssBrFpgZLrvyBCnk+IWmjPP4ptSouzisQS8jNPUVW6z7pvSSHjx2ZZk1iI/l2w== X-Received: by 2002:a17:902:c944:b0:1f7:ff:b477 with SMTP id d9443c01a7336-1fa1d67101cmr144414285ad.55.1719443583249; Wed, 26 Jun 2024 16:13:03 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , Alexandre Iooss , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH 3/7] plugins: extend API to get latest memory value accessed Date: Wed, 26 Jun 2024 16:12:51 -0700 Message-Id: <20240626231255.339353-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626231255.339353-1-pierrick.bouvier@linaro.org> References: <20240626231255.339353-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=2607:f8b0:4864:20::635; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x635.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719443653369100007 Content-Type: text/plain; charset="utf-8" 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); =20 +/** + * 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 in= fo) return get_plugin_meminfo_rw(info) & QEMU_PLUGIN_MEM_W; } =20 +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 =3D 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; --=20 2.39.2