target/xtensa/cpu.h | 2 +- target/xtensa/mmu_helper.c | 44 ++++++++++++++++++-------------------- target/xtensa/monitor.c | 2 +- 3 files changed, 23 insertions(+), 25 deletions(-)
Currently 'info tlb' dumps the MMU information on stdout.
Propagate the @Monitor argument and replace qemu_printf()
by monitor_printf() to dump information over the monitor
(which is not always stdout).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/xtensa/cpu.h | 2 +-
target/xtensa/mmu_helper.c | 44 ++++++++++++++++++--------------------
target/xtensa/monitor.c | 2 +-
3 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 22192924841..2e56e337022 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -694,7 +694,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
uint32_t vaddr, int is_write, int mmu_idx,
uint32_t *paddr, uint32_t *page_size, unsigned *access);
void reset_mmu(CPUXtensaState *env);
-void dump_mmu(CPUXtensaState *env);
+void xtensa_monitor_dump_mmu(Monitor *mon, CPUXtensaState *env);
static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env)
{
diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
index 71330fc84b9..766fe60e2eb 100644
--- a/target/xtensa/mmu_helper.c
+++ b/target/xtensa/mmu_helper.c
@@ -27,7 +27,6 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
-#include "qemu/qemu-print.h"
#include "qemu/units.h"
#include "cpu.h"
#include "exec/helper-proto.h"
@@ -38,6 +37,7 @@
#include "exec/page-protection.h"
#include "exec/target_page.h"
#include "system/memory.h"
+#include "monitor/monitor.h"
#define XTENSA_MPU_SEGMENT_MASK 0x0000001f
#define XTENSA_MPU_ACC_RIGHTS_MASK 0x00000f00
@@ -1082,7 +1082,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
}
}
-static void dump_tlb(CPUXtensaState *env, bool dtlb)
+static void dump_tlb(Monitor *mon, CPUXtensaState *env, bool dtlb)
{
unsigned wi, ei;
const xtensa_tlb *conf =
@@ -1091,6 +1091,7 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb)
xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ?
mmu_attr_to_access : region_attr_to_access;
+ monitor_printf(mon, "\n%cTLB:\n", dtlb ? 'D' : 'I');
for (wi = 0; wi < conf->nways; ++wi) {
uint32_t sz = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1;
const char *sz_text;
@@ -1121,11 +1122,11 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb)
if (print_header) {
print_header = false;
- qemu_printf("Way %u (%d %s)\n", wi, sz, sz_text);
- qemu_printf("\tVaddr Paddr ASID Attr RWX Cache\n"
+ monitor_printf(mon, "Way %u (%d %s)\n", wi, sz, sz_text);
+ monitor_puts(mon, "\tVaddr Paddr ASID Attr RWX Cache\n"
"\t---------- ---------- ---- ---- --- -------\n");
}
- qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %s\n",
+ monitor_printf(mon, "\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %s\n",
entry->vaddr,
entry->paddr,
entry->asid,
@@ -1140,12 +1141,12 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb)
}
}
-static void dump_mpu(CPUXtensaState *env,
+static void dump_mpu(Monitor *mon, CPUXtensaState *env,
const xtensa_mpu_entry *entry, unsigned n)
{
unsigned i;
- qemu_printf("\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n"
+ monitor_printf(mon, "\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n"
"\t%s ---------- ---------- ----- ----- ------------- ---------\n",
env ? "En" : " ",
env ? "--" : " ");
@@ -1157,7 +1158,7 @@ static void dump_mpu(CPUXtensaState *env,
unsigned type = mpu_attr_to_type(attr);
char cpu_cache = (type & XTENSA_MPU_TYPE_CPU_CACHE) ? '-' : ' ';
- qemu_printf("\t %c 0x%08x 0x%08x %c%c%c %c%c%c ",
+ monitor_printf(mon, "\t %c 0x%08x 0x%08x %c%c%c %c%c%c ",
env ?
((env->sregs[MPUENB] & (1u << i)) ? '+' : '-') : ' ',
entry[i].vaddr, attr,
@@ -1170,19 +1171,19 @@ static void dump_mpu(CPUXtensaState *env,
switch (type & XTENSA_MPU_SYSTEM_TYPE_MASK) {
case XTENSA_MPU_SYSTEM_TYPE_DEVICE:
- qemu_printf("Device %cB %3s\n",
+ monitor_printf(mon, "Device %cB %3s\n",
(type & XTENSA_MPU_TYPE_B) ? ' ' : 'n',
(type & XTENSA_MPU_TYPE_INT) ? "int" : "");
break;
case XTENSA_MPU_SYSTEM_TYPE_NC:
- qemu_printf("Sys NC %cB %c%c%c\n",
+ monitor_printf(mon, "Sys NC %cB %c%c%c\n",
(type & XTENSA_MPU_TYPE_B) ? ' ' : 'n',
(type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache,
(type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache,
(type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache);
break;
case XTENSA_MPU_SYSTEM_TYPE_C:
- qemu_printf("Sys C %c%c%c %c%c%c\n",
+ monitor_printf(mon, "Sys C %c%c%c %c%c%c\n",
(type & XTENSA_MPU_TYPE_SYS_R) ? 'R' : '-',
(type & XTENSA_MPU_TYPE_SYS_W) ? 'W' : '-',
(type & XTENSA_MPU_TYPE_SYS_C) ? 'C' : '-',
@@ -1191,29 +1192,26 @@ static void dump_mpu(CPUXtensaState *env,
(type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache);
break;
default:
- qemu_printf("Unknown\n");
+ monitor_puts(mon, "Unknown\n");
break;
}
}
}
-void dump_mmu(CPUXtensaState *env)
+void xtensa_monitor_dump_mmu(Monitor *mon, CPUXtensaState *env)
{
if (xtensa_option_bits_enabled(env->config,
XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) |
XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION) |
XTENSA_OPTION_BIT(XTENSA_OPTION_MMU))) {
-
- qemu_printf("ITLB:\n");
- dump_tlb(env, false);
- qemu_printf("\nDTLB:\n");
- dump_tlb(env, true);
+ dump_tlb(mon, env, false);
+ dump_tlb(mon, env, true);
} else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) {
- qemu_printf("Foreground map:\n");
- dump_mpu(env, env->mpu_fg, env->config->n_mpu_fg_segments);
- qemu_printf("\nBackground map:\n");
- dump_mpu(NULL, env->config->mpu_bg, env->config->n_mpu_bg_segments);
+ monitor_puts(mon, "Foreground map:\n");
+ dump_mpu(mon, env, env->mpu_fg, env->config->n_mpu_fg_segments);
+ monitor_puts(mon, "\nBackground map:\n");
+ dump_mpu(mon, NULL, env->config->mpu_bg, env->config->n_mpu_bg_segments);
} else {
- qemu_printf("No TLB for this CPU core\n");
+ monitor_puts(mon, "No TLB for this CPU core\n");
}
}
diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c
index fbf60d55530..2eb7997a011 100644
--- a/target/xtensa/monitor.c
+++ b/target/xtensa/monitor.c
@@ -35,5 +35,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "No CPU available\n");
return;
}
- dump_mmu(env1);
+ xtensa_monitor_dump_mmu(mon, env1);
}
--
2.53.0
Philippe Mathieu-Daudé <philmd@linaro.org> writes: > Currently 'info tlb' dumps the MMU information on stdout. > Propagate the @Monitor argument and replace qemu_printf() > by monitor_printf() to dump information over the monitor > (which is not always stdout). > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> I'd call this a bug fix. Can you come up with a Fixes: tag? Only if it's not too much trouble.
On Fri, 20 Mar 2026 at 13:51, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Currently 'info tlb' dumps the MMU information on stdout.
> Propagate the @Monitor argument and replace qemu_printf()
> by monitor_printf() to dump information over the monitor
> (which is not always stdout).
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/xtensa/cpu.h | 2 +-
> target/xtensa/mmu_helper.c | 44 ++++++++++++++++++--------------------
> target/xtensa/monitor.c | 2 +-
> 3 files changed, 23 insertions(+), 25 deletions(-)
>
> diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
> index 22192924841..2e56e337022 100644
> --- a/target/xtensa/cpu.h
> +++ b/target/xtensa/cpu.h
> @@ -694,7 +694,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
> uint32_t vaddr, int is_write, int mmu_idx,
> uint32_t *paddr, uint32_t *page_size, unsigned *access);
> void reset_mmu(CPUXtensaState *env);
> -void dump_mmu(CPUXtensaState *env);
> +void xtensa_monitor_dump_mmu(Monitor *mon, CPUXtensaState *env);
>
> static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env)
> {
> diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
> index 71330fc84b9..766fe60e2eb 100644
> --- a/target/xtensa/mmu_helper.c
> +++ b/target/xtensa/mmu_helper.c
> @@ -27,7 +27,6 @@
>
> #include "qemu/osdep.h"
> #include "qemu/log.h"
> -#include "qemu/qemu-print.h"
> #include "qemu/units.h"
> #include "cpu.h"
> #include "exec/helper-proto.h"
> @@ -38,6 +37,7 @@
> #include "exec/page-protection.h"
> #include "exec/target_page.h"
> #include "system/memory.h"
> +#include "monitor/monitor.h"
>
> #define XTENSA_MPU_SEGMENT_MASK 0x0000001f
> #define XTENSA_MPU_ACC_RIGHTS_MASK 0x00000f00
> @@ -1082,7 +1082,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
> }
> }
>
> -static void dump_tlb(CPUXtensaState *env, bool dtlb)
> +static void dump_tlb(Monitor *mon, CPUXtensaState *env, bool dtlb)
> {
> unsigned wi, ei;
> const xtensa_tlb *conf =
> @@ -1091,6 +1091,7 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb)
> xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ?
> mmu_attr_to_access : region_attr_to_access;
>
> + monitor_printf(mon, "\n%cTLB:\n", dtlb ? 'D' : 'I');
Shouldn't the change to this function be purely
s/qemu_printf/monitor_printf(mon, / ?
> for (wi = 0; wi < conf->nways; ++wi) {
> uint32_t sz = ~xtensa_tlb_get_addr_mask(env, dtlb, wi) + 1;
> const char *sz_text;
thanks
-- PMM
On 20/3/26 14:56, Peter Maydell wrote:
> On Fri, 20 Mar 2026 at 13:51, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Currently 'info tlb' dumps the MMU information on stdout.
>> Propagate the @Monitor argument and replace qemu_printf()
>> by monitor_printf() to dump information over the monitor
>> (which is not always stdout).
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> target/xtensa/cpu.h | 2 +-
>> target/xtensa/mmu_helper.c | 44 ++++++++++++++++++--------------------
>> target/xtensa/monitor.c | 2 +-
>> 3 files changed, 23 insertions(+), 25 deletions(-)
>> -static void dump_tlb(CPUXtensaState *env, bool dtlb)
>> +static void dump_tlb(Monitor *mon, CPUXtensaState *env, bool dtlb)
>> {
>> unsigned wi, ei;
>> const xtensa_tlb *conf =
>> @@ -1091,6 +1091,7 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb)
>> xtensa_option_enabled(env->config, XTENSA_OPTION_MMU) ?
>> mmu_attr_to_access : region_attr_to_access;
>>
>> + monitor_printf(mon, "\n%cTLB:\n", dtlb ? 'D' : 'I');
>
> Shouldn't the change to this function be purely
> s/qemu_printf/monitor_printf(mon, / ?
OK, will split as v2 (but still use puts replacement when no formatting)
© 2016 - 2026 Red Hat, Inc.