From patchwork Wed Jun 26 23:12:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807515 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp539224wrn; Wed, 26 Jun 2024 16:14:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV3NqmDFwo0+aDBOGIsJLiXUU2aAezilpIHOH5/T/U4beIShoEFi97Hj7HH00ZZoGOPM/aNN954uex+Y5Ym1ZVC X-Google-Smtp-Source: AGHT+IGcQshFg/QOEQzDRYUcOb18GBEHH22vClbeHhrZGWQL/TXZFD8pEV/DVjZGUwmof8V/gWVO X-Received: by 2002:a25:ad65:0:b0:dff:2fcc:ea3d with SMTP id 3f1490d57ef6-e030110a9e3mr10862010276.63.1719443650948; Wed, 26 Jun 2024 16:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719443650; cv=none; d=google.com; s=arc-20160816; b=BUiUqjqlsQ3Er4zSAUAbwXSU53EnMblfQFTHzcKBWavN0p971DLD3c68LGRMlscOey /j0TdDIPpNV8+k5XD8k27JjSYBrSkM8Re2S9BR4wy/7bqY49Rk5DRc0fnOVJkB6T2fgK CbAiRtZFO7dre9Txhx/4RY1n+E9gHufzSEnqhTZy4r3mL0d3D7WpHZFwXlvvrQRD9tFw d62WxZIF1IV9pZEteCUlEqpn63t/pblXsoCwdPBLh7ZOnq9w6Rp2rUsNBayP1jXe8zIN G5k5M/yhFu2MwoJnW6JMpJa4TdabgObLH/0VZzzWYSBPHL6SCXgQKdsOtAI8SRCZG7Hg IFow== 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=WQ0fQ4sUzgT0xo1UK8NVSlSI80y+/XkhC1sdM3re38s=; b=OKA6agaBH1efxt+Z8lO4d/ZnbKC7MyONn1M/thk8fcVsw5zXEYPmNKMn1hcwVqKp5I UI2UdmGx5QV6GdHrmdaak6SOiF0lPwXbS7OHYaiXq1B8djbkwG8ZNDsHCDVqEllNF0iE +PDtL+87ADDzvrLn3uF1rGIWSuD4k5sJ0vGByl2FFjVv2WMuRRCcuXJgzUZVIcT91U8u zdbrRq5b9kqEpeAkBmjj6OcS1F8PCYyYRv5qUNDDiRqC522LUMkQmdC9uGxEfpXAcqSW Q9MENC8UEAXYXvQpBfI/DMOcsxhVWxauvPh2ISXhU6zBI9m3xRFLA0EFoSOBSyLnuE+P cOWg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wT9xxqW3; 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 d75a77b69052e-44642199e7asi670101cf.503.2024.06.26.16.14.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:14:10 -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=wT9xxqW3; 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 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) 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-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) 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) 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_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=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 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+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;