From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
qemu-ppc@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
devel@lists.libvirt.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH-for-9.0 1/2] target/monitor: Introduce 'info mmu' command
Date: Wed, 20 Mar 2024 17:40:54 +0100 [thread overview]
Message-ID: <20240320164055.60319-2-philmd@linaro.org> (raw)
In-Reply-To: <20240320164055.60319-1-philmd@linaro.org>
Introduce the 'info mmu' command. For now it only
forward to the 'info tlb' and 'info mem' commands,
which will be deprecated.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/monitor/hmp-target.h | 1 +
monitor/hmp-cmds-target.c | 37 ++++++++++++++++++++++++++++++++++++
hmp-commands-info.hx | 14 ++++++++++++++
3 files changed, 52 insertions(+)
diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h
index d78e979f05..2af84b1915 100644
--- a/include/monitor/hmp-target.h
+++ b/include/monitor/hmp-target.h
@@ -44,6 +44,7 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval);
CPUArchState *mon_get_cpu_env(Monitor *mon);
CPUState *mon_get_cpu(Monitor *mon);
+void hmp_info_mmu(Monitor *mon, const QDict *qdict);
void hmp_info_mem(Monitor *mon, const QDict *qdict);
void hmp_info_tlb(Monitor *mon, const QDict *qdict);
void hmp_mce(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds-target.c b/monitor/hmp-cmds-target.c
index 9338ae8440..71bce4870a 100644
--- a/monitor/hmp-cmds-target.c
+++ b/monitor/hmp-cmds-target.c
@@ -31,6 +31,7 @@
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
#include "sysemu/hw_accel.h"
+#include "sysemu/tcg.h"
/* Set the current CPU defined by the user. Callers must hold BQL. */
int monitor_set_cpu(Monitor *mon, int cpu_index)
@@ -379,3 +380,39 @@ void hmp_gpa2hpa(Monitor *mon, const QDict *qdict)
memory_region_unref(mr);
}
#endif
+
+__attribute__((weak))
+void hmp_info_mem(Monitor *mon, const QDict *qdict)
+{
+ monitor_puts(mon,
+ "No per-CPU mapping information available on this target\n");
+}
+
+__attribute__((weak))
+void hmp_info_tlb(Monitor *mon, const QDict *qdict)
+{
+ monitor_puts(mon,
+ "No per-CPU TLB information available on this target\n");
+}
+
+void hmp_info_mmu(Monitor *mon, const QDict *qdict)
+{
+ bool tlb = qdict_get_try_bool(qdict, "tlb", false);
+ bool mem = qdict_get_try_bool(qdict, "mem", false);
+
+ if (!tcg_enabled()) {
+ monitor_puts(mon, "This command is specific to TCG accelerator\n");
+ return;
+ }
+
+ if (!tlb && !mem) {
+ tlb = mem = true;
+ }
+
+ if (mem) {
+ hmp_info_mem(mon, qdict);
+ }
+ if (tlb) {
+ hmp_info_tlb(mon, qdict);
+ }
+}
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index ad1b1306e3..e31f2467fb 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -208,6 +208,20 @@ SRST
Show PCI information.
ERST
+ {
+ .name = "mmu",
+ .args_type = "tlb:-t,mem:-m",
+ .params = "[-t][-m]",
+ .help = "show virtual to physical memory "
+ "(-t: TLB; -m: active mapping)",
+ .cmd = hmp_info_mmu,
+ },
+
+SRST
+ ``info mmu``
+ Show virtual to physical memory mappings.
+ERST
+
#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K)
{
--
2.41.0
next prev parent reply other threads:[~2024-03-20 16:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 16:40 [PATCH-for-9.0 0/2] target/monitor: Deprecate 'info tlb/mem' in favor of 'info mmu' Philippe Mathieu-Daudé
2024-03-20 16:40 ` Philippe Mathieu-Daudé [this message]
2024-03-20 16:40 ` [PATCH-for-9.0 2/2] target/monitor: Deprecate 'info tlb' and 'info mem' commands Philippe Mathieu-Daudé
2024-03-20 16:53 ` [PATCH-for-9.0 0/2] target/monitor: Deprecate 'info tlb/mem' in favor of 'info mmu' Peter Maydell
2024-03-20 17:06 ` Philippe Mathieu-Daudé
2024-03-20 17:17 ` Peter Maydell
2024-03-20 21:59 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240320164055.60319-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=dave@treblig.org \
--cc=devel@lists.libvirt.org \
--cc=manos.pitsidianakis@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).