target/monitor: Cleanup around hmp_info_tlb()
cover target/monitor: Cleanup around hmp_info_tlb()
Hi,
In [*] I posted preliminary steps to unify hmp_info_tlb() and hmp_info_mem() after making them per-CPU handler, rather than target-specific method (which break single binary). Since there is no rush and we need to figure the usefulness of 'info tlb/mem' and what we want to do with it, I dropped the series but salvaged these cleanup patches.
Regards,
Phil.
[*] https://lore.kernel.org/qemu-devel/[email protected]/
Philippe Mathieu-Daudé (21):
host/atomic128: Include missing 'qemu/atomic.h' header hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h target/i386: Move APIC related code to cpu-apic.c target/i386: Extract x86_dump_mmu() from hmp_info_tlb() target/m68k: Replace qemu_printf() by monitor_printf() in monitor target/m68k: Have dump_ttr() take a @description argument target/m68k: Move MMU monitor commands from helper.c to monitor.c target/microblaze: Prefix MMU API with 'mb_' target/mips: Prefix MMU API with 'mips_'
target/nios2: Prefix MMU API with 'nios2_'
target/nios2: Move monitor commands to monitor.c target/nios2: Replace qemu_printf() by monitor_printf() in monitor target/ppc: Replace qemu_printf() by monitor_printf() in monitor target/sh4: Extract sh4_dump_mmu() from hmp_info_tlb() target/sparc: Fix string format errors when DEBUG_MMU is defined target/sparc: Replace qemu_printf() by monitor_printf() in monitor target/xtensa: Prefix MMU API with 'xtensa_' target/xtensa: Extract MMU API to new mmu.c/mmu.h files target/xtensa: Simplify dump_mpu() and dump_tlb() target/xtensa: Move monitor commands to monitor.c target/xtensa: Replace qemu_printf() by monitor_printf() in monitor
host/include/generic/host/atomic128-cas.h | 2 + host/include/generic/host/atomic128-ldst.h | 2 + include/hw/core/tcg-cpu-ops.h | 2 - target/i386/cpu.h | 7 + target/m68k/cpu.h | 3 +- target/microblaze/mmu.h | 10 +- target/mips/tcg/tcg-internal.h | 2 +- target/nios2/cpu.h | 2 +- target/nios2/mmu.h | 11 +- target/ppc/cpu.h | 2 +- target/sh4/cpu.h | 2 + target/sparc/cpu.h | 2 +- target/xtensa/cpu.h | 32 +- target/xtensa/mmu.h | 95 ++ target/i386/cpu-apic.c | 112 +++ target/i386/cpu-sysemu.c | 77 -- target/i386/mmu.c | 231 +++++ target/i386/monitor.c | 240 ----- target/m68k/helper.c | 223 ----- target/m68k/monitor.c | 225 ++++- target/microblaze/cpu.c | 2 +- target/microblaze/helper.c | 4 +- target/microblaze/mmu.c | 14 +- target/microblaze/op_helper.c | 4 +- target/mips/cpu.c | 2 +- target/mips/tcg/sysemu/tlb_helper.c | 2 +- target/nios2/cpu.c | 2 +- target/nios2/helper.c | 4 +- target/nios2/mmu.c | 34 +- target/nios2/monitor.c | 27 +- target/ppc/mmu_common.c | 147 +-- target/ppc/ppc-qmp-cmds.c | 2 +- target/sh4/monitor.c | 22 +- target/sparc/ldst_helper.c | 26 +- target/sparc/mmu_helper.c | 102 +- target/sparc/monitor.c | 2 +- target/xtensa/cpu.c | 2 +- target/xtensa/mmu.c | 889 +++++++++++++++++ target/xtensa/mmu_helper.c | 1037 +------------------- target/xtensa/monitor.c | 149 ++- target/i386/meson.build | 2 + target/xtensa/meson.build | 1 + 42 files changed, 1943 insertions(+), 1815 deletions(-) create mode 100644 target/xtensa/mmu.h create mode 100644 target/i386/cpu-apic.c create mode 100644 target/i386/mmu.c create mode 100644 target/xtensa/mmu.c
Signature · 1 line
2.41.0
PATCH 1/21 host/atomic128: Include missing 'qemu/atomic.h' header
qatomic_cmpxchg__nocheck(), qatomic_read__nocheck(), qatomic_set__nocheck() are defined in "qemu/atomic.h". Include it in order to avoid:
In file included from include/exec/helper-proto.h:10:
In file included from include/exec/helper-proto-common.h:10:
In file included from include/qemu/atomic128.h:61:
In file included from host/include/aarch64/host/atomic128-cas.h:16:
host/include/generic/host/atomic128-cas.h:23:11: error: call to undeclared function 'qatomic_cmpxchg__nocheck'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
r.i = qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i);
^--- host/include/generic/host/atomic128-cas.h | 2 ++ host/include/generic/host/atomic128-ldst.h | 2 ++ 2 files changed, 4 insertions(+)
host/include/generic/host/atomic128-cas.h +2 -0
@@ -11,6 +11,8 @@#ifndef HOST_ATOMIC128_CAS_H #define HOST_ATOMIC128_CAS_H +#include "qemu/atomic.h" +#if defined(CONFIG_ATOMIC128 ) static inline Int128 ATTRIBUTE_ATOMIC128_OPTatomic16_cmpxchg (Int128 *ptr,Int128 cmp,Int128 new)
host/include/generic/host/atomic128-ldst.h +2 -0
@@ -11,6 +11,8 @@#ifndef HOST_ATOMIC128_LDST_H #define HOST_ATOMIC128_LDST_H +#include "qemu/atomic.h" +#if defined(CONFIG_ATOMIC128 )# define HAVE_ATOMIC128_RO 1# define HAVE_ATOMIC128_RW 1
Signature · 1 line
2.41.0
Re: [PATCH-for-9.0? 01/21] host/atomic128: Include missing 'qemu/atomic.h' header
Quoted 10 lines · Philippe Mathieu-Daudé
qatomic_cmpxchg__nocheck(),qatomic_read__nocheck(),qatomic_set__nocheck()are defined in "qemu/atomic.h". Include it in order to avoid:In file included from
include/exec/helper-proto.h:10:
In file included frominclude/exec/helper-proto-common.h:10:
In file included frominclude/qemu/atomic128.h:61:
In file included fromhost/include/aarch64/host/atomic128-cas.h:16:
host/include/generic/host/atomic128-cas.h:23:11: error: call to undeclared function 'qatomic_cmpxchg__nocheck'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]r.i = qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i);
Nak. We can rename these host/include/*/host/*atomic* as .h.inc if you need, but the top-level header is include/qemu/atomic128.h.
r~
Re: [PATCH-for-9.0? 01/21] host/atomic128: Include missing 'qemu/atomic.h' header
Quoted 13 lines · Richard Henderson
Quoted 10 lines · Philippe Mathieu-Daudé
qatomic_cmpxchg__nocheck(),qatomic_read__nocheck(),qatomic_set__nocheck()are defined in "qemu/atomic.h". Include it in order to avoid:In file included from
include/exec/helper-proto.h:10:
In file included frominclude/exec/helper-proto-common.h:10:
In file included frominclude/qemu/atomic128.h:61:
In file included fromhost/include/aarch64/host/atomic128-cas.h:16:
host/include/generic/host/atomic128-cas.h:23:11: error: call to undeclared function 'qatomic_cmpxchg__nocheck'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] r.i =qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i);
Quoted 1 line
Nak. We can rename these host/include/*/host/*atomic* as .h.inc if you need, but the top-level header is
include/qemu/atomic128.h.
Patch available here:
https://lore.kernel.org/qemu-devel/[email protected]/
PATCH 2/21 hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h
In reply to Philippe Mathieu-DaudéCommit fd3f7d24d4 ("include/hw/core: Remove i386 conditional on fake_user_interrupt") remove the need to check on NEED_CPU_H.
--- include/hw/core/tcg-cpu-ops.h | 2 -- 1 file changed, 2 deletions(-)
include/hw/core/tcg-cpu-ops.h +0 -2
@@ -49,7 +49,6 @@ struct TCGCPUOps {/** @debug_excp_handler: Callback for handling debug exceptions */ void (*debug_excp_handler)(CPUState *cpu); -#ifdef NEED_CPU_H #ifdef CONFIG_USER_ONLY /** * @fake_user_interrupt: Callback for 'fake exception' handling.
@@ -174,7 +173,6 @@ struct TCGCPUOps {*/ bool (*need_replay_interrupt)(int interrupt_request);#endif /* !CONFIG_USER_ONLY */ -#endif /* NEED_CPU_H */ };
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 02/21] hw/core: Remove check on NEED_CPU_H in tcg-cpu-ops.h
Quoted 7 lines · Philippe Mathieu-Daudé
Commit
fd3f7d24d4("include/hw/core: Remove i386 conditional onfake_user_interrupt") remove the need to check onNEED_CPU_H.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/hw/core/tcg-cpu-ops.h | 2 -- 1 file changed, 2 deletions(-)
r~
PATCH 3/21 target/i386: Move APIC related code to cpu-apic.c
In reply to Philippe Mathieu-DaudéMove APIC related code split in cpu-sysemu.c andmonitor.c to cpu-apic.c.
--- target/i386/cpu-apic.c | 112 +++++++++++++++++++++++++++++++++++++++ target/i386/cpu-sysemu.c | 77 --------------------------- target/i386/monitor.c | 25 --------- target/i386/meson.build | 1 + 4 files changed, 113 insertions(+), 102 deletions(-) create mode 100644 target/i386/cpu-apic.c
target/i386/cpu-apic.c new file +112 -0
@@ -0,0 +1,112 @@ +/* +* QEMU x86 CPU <-> APIC +* +* Copyright (c) 2003-2004 Fabrice Bellard +* +* SPDX-License-Identifier: MIT +*/ + +#include "qemu/osdep.h" +#include "qapi/qmp/qdict.h" +#include "qapi/error.h" +#include "monitor/monitor.h" +#include "monitor/hmp-target.h" +#include "sysemu/hw_accel.h" +#include "sysemu/kvm.h" +#include "sysemu/xen.h" +#include "exec/address-spaces.h" +#include "hw/qdev-properties.h" +#include "hw/i386/apic_internal.h" +#include "cpu-internal.h" + +APICCommonClass *apic_get_class (Error **errp) +{ +const char *apic_type ="apic" ; + +/* TODO: in-kernel irqchip for hvf */ +if (kvm_enabled ()) { +if (!kvm_irqchip_in_kernel ()) { +error_setg (errp,"KVM does not support userspace APIC" ); +return NULL ; + } + apic_type ="kvm-apic" ; + }else if (xen_enabled ()) { + apic_type ="xen-apic" ; + }else if (whpx_apic_in_platform ()) { + apic_type ="whpx-apic" ; + } + +return APIC_COMMON_CLASS (object_class_by_name (apic_type)); +} + +void x86_cpu_apic_create (X86CPU *cpu,Error **errp) +{ +APICCommonState *apic; +APICCommonClass *apic_class =apic_get_class (errp); + +if (!apic_class) { +return ; + } + + cpu->apic_state =DEVICE (object_new_with_class (OBJECT_CLASS (apic_class))); +object_property_add_child (OBJECT (cpu),"lapic" , +OBJECT (cpu->apic_state)); +object_unref (OBJECT (cpu->apic_state)); + +/* TODO: convert to link<> */ + apic =APIC_COMMON (cpu->apic_state); + apic->cpu = cpu; + apic->apicbase =APIC_DEFAULT_ADDRESS |MSR_IA32_APICBASE_ENABLE ; + +/* +* apic_common_set_id needs to check if the CPU has x2APIC +* feature in case APIC ID >= 255, so we need to set apic->cpu +* before setting APIC ID +*/ +qdev_prop_set_uint32 (cpu->apic_state,"id" , cpu->apic_id); +} + +void x86_cpu_apic_realize (X86CPU *cpu,Error **errp) +{ +APICCommonState *apic; +static bool apic_mmio_map_once; + +if (cpu->apic_state ==NULL ) { +return ; + } +qdev_realize (DEVICE (cpu->apic_state),NULL , errp); + +/* Map APIC MMIO area */ + apic =APIC_COMMON (cpu->apic_state); +if (!apic_mmio_map_once) { +memory_region_add_subregion_overlap (get_system_memory (), + apic->apicbase & +MSR_IA32_APICBASE_BASE , + &apic->io_memory, +0x1000 ); + apic_mmio_map_once = true; + } +} + +void hmp_info_local_apic (Monitor *mon,const QDict *qdict) +{ +CPUState *cs; + +if (qdict_haskey (qdict,"apic-id" )) { +int id =qdict_get_try_int (qdict,"apic-id" ,0 ); + + cs =cpu_by_arch_id (id); +if (cs) { +cpu_synchronize_state (cs); + } + }else { + cs =mon_get_cpu (mon); + } + + +if (!cs) { +monitor_printf (mon,"No CPU available\n" ); +return ; + } +x86_cpu_dump_local_apic_state (cs,CPU_DUMP_FPU ); +}
target/i386/cpu-sysemu.c +0 -77
98 lines not on this page · raw message
target/i386/monitor.c +0 -25
@@ -28,8 +28,6 @@#include "monitor/hmp-target.h" #include "monitor/hmp.h" #include "qapi/qmp/qdict.h" -#include "sysemu/hw_accel.h" -#include "sysemu/kvm.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-commands-misc.h"
@@ -647,26 +645,3 @@ const MonitorDef *target_monitor_defs(void) {return monitor_defs; } - -void hmp_info_local_apic (Monitor *mon,const QDict *qdict) -{ -CPUState *cs; - -if (qdict_haskey (qdict,"apic-id" )) { -int id =qdict_get_try_int (qdict,"apic-id" ,0 ); - - cs =cpu_by_arch_id (id); -if (cs) { -cpu_synchronize_state (cs); - } - }else { - cs =mon_get_cpu (mon); - } - - -if (!cs) { -monitor_printf (mon,"No CPU available\n" ); -return ; - } -x86_cpu_dump_local_apic_state (cs,CPU_DUMP_FPU ); -}
target/i386/meson.build +1 -0
@@ -18,6 +18,7 @@ i386_system_ss.add(files( 'arch_memory_mapping.c', 'machine.c', 'monitor.c', + 'cpu-apic.c', 'cpu-sysemu.c', )) i386_system_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-sysemu-stub.c'))
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 03/21] target/i386: Move APIC related code to cpu-apic.c
Quoted 11 lines · Philippe Mathieu-Daudé
Move APIC related code split in
cpu-sysemu.candmonitor.ctocpu-apic.c.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/i386/cpu-apic.c | 112 +++++++++++++++++++++++++++++++++++++++ target/i386/cpu-sysemu.c | 77 --------------------------- target/i386/monitor.c | 25 --------- target/i386/meson.build | 1 + 4 files changed, 113 insertions(+), 102 deletions(-)create mode 100644
target/i386/cpu-apic.c
r~
Re: [PATCH-for-9.1 03/21] target/i386: Move APIC related code to cpu-apic.c
In reply to Philippe Mathieu-Daudétarget/i386/cpu-apic.c
Quoted 23 lines · Philippe Mathieu-Daudé
Date: Thu, 21 Mar 2024 16:48:19 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-9.1 03/21] target/i386: Move APIC related code to
cpu-apic.c
X-Mailer: git-send-email 2.41.0Move APIC related code split in
cpu-sysemu.candmonitor.ctocpu-apic.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/i386/cpu-apic.c | 112 +++++++++++++++++++++++++++++++++++++++ target/i386/cpu-sysemu.c | 77 --------------------------- target/i386/monitor.c | 25 --------- target/i386/meson.build | 1 + 4 files changed, 113 insertions(+), 102 deletions(-) create mode 100644 target/i386/cpu-apic.ctarget/i386/cpu-apic.c new file +0
-0
Nit: New file needs a MAINTAINER entry ;-).
Others LGTM,
Re: [PATCH-for-9.1 03/21] target/i386: Move APIC related code to cpu-apic.c
Quoted 19 lines · Zhao Liu
Quoted 18 lines · Philippe Mathieu-Daudé
Date: Thu, 21 Mar 2024 16:48:19 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-9.1 03/21] target/i386: Move APIC related code to
cpu-apic.c
X-Mailer: git-send-email 2.41.0Move APIC related code split in
cpu-sysemu.candmonitor.ctocpu-apic.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/i386/cpu-apic.c | 112 +++++++++++++++++++++++++++++++++++++++ target/i386/cpu-sysemu.c | 77 --------------------------- target/i386/monitor.c | 25 --------- target/i386/meson.build | 1 + 4 files changed, 113 insertions(+), 102 deletions(-)create mode 100644
target/i386/cpu-apic.c
Quoted 7 lines
target/i386/cpu-apic.c
Quoted 5 lines
target/i386/cpu-apic.c new file +0
-0Nit: New file needs a MAINTAINER entry ;-).
Already covered here:
X86 general architecture support
M: Paolo Bonzini <[email protected]>
S: Maintained
F: configs/devices/i386-softmmu/default.mak
F: configs/targets/i386-softmmu.mak
F: configs/targets/x86_64-softmmu.mak
F: docs/system/target-i386*
F: target/i386/*.[ch]
^^^^^^ $ ./scripts/get_maintainer.pl -f target/i386/cpu-apic.c Paolo Bonzini <[email protected]> (maintainer:X86 general archi...) [email protected] (open list:All patches CC here)
Quoted 3 lines
Others LGTM,
Reviewed-by Zhao Liu <[email protected]>
Thanks!
PATCH 4/21 target/i386: Extract x86_dump_mmu() from hmp_info_tlb()
In reply to Philippe Mathieu-Daudéhmp_info_tlb() is specific to tcg/system, move it to target/i386/tcg/sysemu/hmp-cmds.c, along with the functions it depend on (except addr_canonical() which is exposed in "cpu.h").
--- target/i386/cpu.h | 7 ++ target/i386/mmu.c | 231 ++++++++++++++++++++++++++++++++++++++++ target/i386/monitor.c | 215 ------------------------------------- target/i386/meson.build | 1 + 4 files changed, 239 insertions(+), 215 deletions(-) create mode 100644 target/i386/mmu.c
target/i386/cpu.h +7 -0
@@ -2342,6 +2342,13 @@ static inline int cpu_mmu_index_kernel(CPUX86State *env)return mmu_index_base + mmu_index_32; } +#if !defined(CONFIG_USER_ONLY ) +void x86_dump_mmu (Monitor *mon,CPUX86State *env); + +/* Perform linear address sign extension */ +hwaddr addr_canonical (CPUArchState *env,hwaddr addr); +#endif +#define CC_DST (env->cc_dst)#define CC_SRC (env->cc_src)#define CC_SRC2 (env->cc_src2)
target/i386/mmu.c new file +231 -0
231 lines not on this page · raw message
target/i386/monitor.c +0 -215
221 lines not on this page · raw message
target/i386/meson.build +1 -0
@@ -18,6 +18,7 @@ i386_system_ss.add(files( 'arch_memory_mapping.c', 'machine.c', 'monitor.c', + 'mmu.c', 'cpu-apic.c', 'cpu-sysemu.c', ))
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 04/21] target/i386: Extract x86_dump_mmu() from hmp_info_tlb()
Quoted 5 lines · Philippe Mathieu-Daudé
hmp_info_tlb()is specific to tcg/system, move it totarget/i386/tcg/sysemu/hmp-cmds.c, along with the functions it depend on (exceptaddr_canonical()which is exposed in "cpu.h").
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/i386/cpu.h | 7 ++ target/i386/mmu.c | 231 ++++++++++++++++++++++++++++++++++++++++ target/i386/monitor.c | 215 ------------------------------------- target/i386/meson.build | 1 + 4 files changed, 239 insertions(+), 215 deletions(-)create mode 100644
target/i386/mmu.c
Patch commit message appears to be out of date wrt filename. Otherwise,
r~
PATCH 5/21 target/m68k: Replace qemu_printf() by monitor_printf() in monitor
In reply to Philippe Mathieu-DaudéReplace qemu_printf() by monitor_printf() / monitor_puts() in monitor.
--- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-)
target/m68k/cpu.h +1 -1
@@ -620,6 +620,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu (CPUM68KState *env); +void dump_mmu (Monitor *mon,CPUM68KState *env);#endif
target/m68k/helper.c +64 -62
231 lines not on this page · raw message
target/m68k/monitor.c +2 -2
@@ -15,11 +15,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)CPUArchState *env1 =mon_get_cpu_env (mon);if (!env1) { -monitor_printf (mon,"No CPU available\n" ); +monitor_puts (mon,"No CPU available\n" );return ; } -dump_mmu (env1); +dump_mmu (mon, env1); }static const MonitorDef monitor_defs[] = {
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
Quoted 8 lines · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-)
r~
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
In reply to Philippe Mathieu-DaudéQuoted 219 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-)target/m68k/cpu.h +1
-1@@ -620,6 +620,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu (CPUM68KState *env); +void dump_mmu (Monitor *mon,CPUM68KState *env);#endif target/m68k/helper.c +48
-46@@ -25,7 +25,7 @@#include "exec/helper-proto.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" -#include "qemu/qemu-print.h" +#include "monitor/monitor.h" #define SIGNBIT (1u << 31)@@ -455,28 +455,30 @@ void m68k_switch_sp(CPUM68KState *env)#if !defined(CONFIG_USER_ONLY )/* MMU: 68040 only */ -static void print_address_zone (uint32_t logical,uint32_t physical, +static void print_address_zone (Monitor *mon, +uint32_t logical,uint32_t physical,uint32_t size,int attr) { -qemu_printf ("%08x - %08x -> %08x - %08x %c " , - logical, logical + size -1 , - physical, physical + size -1 , - attr &4 ?'W' :'-' ); +monitor_printf (mon,"%08x - %08x -> %08x - %08x %c " , + logical, logical + size -1 , + physical, physical + size -1 , + attr &4 ?'W' :'-' ); size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d KiB)\n" , size); +monitor_printf (mon,"(%d KiB)\n" , size); }else { size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d MiB)\n" , size); +monitor_printf (mon,"(%d MiB)\n" , size); }else { size >>=10 ; -qemu_printf ("(%d GiB)\n" , size); +monitor_printf (mon,"(%d GiB)\n" , size); } } } -static void dump_address_map (CPUM68KState *env,uint32_t root_pointer) +static void dump_address_map (Monitor *mon,CPUM68KState *env, +uint32_t root_pointer) {int i, j, k;int tic_size, tic_shift;@@ -545,7 +547,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer)if (first_logical !=0xffffffff ) { size = last_logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, +print_address_zone (mon, first_logical, first_physical, size, last_attr); } first_logical = logical;@@ -556,125 +558,125 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) }if (first_logical != logical || (attr &4 ) != (last_attr &4 )) { size = logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, first_physical, size, last_attr); +print_address_zone (mon, first_logical, first_physical, size, last_attr); } }#define DUMP_CACHEFLAGS (a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU:/* cacheable, write-through */ \ -qemu_printf ("T" ); \ +monitor_puts (mon,"T" ); \break ; \case M68K_DESC_CM_COPYBK :/* cacheable, copyback */ \ -qemu_printf ("C" ); \ +monitor_puts (mon,"C" ); \break ; \case M68K_DESC_CM_SERIAL :/* noncachable, serialized */ \ -qemu_printf ("S" ); \ +monitor_puts (mon,"S" ); \break ; \case M68K_DESC_CM_NCACHE :/* noncachable */ \ -qemu_printf ("N" ); \ +monitor_puts (mon,"N" ); \break ; \ } -static void dump_ttr (uint32_t ttr) +static void dump_ttr (Monitor *mon,uint32_t ttr) {if ((ttr &M68K_TTR_ENABLED ) ==0 ) { -qemu_printf ("disabled\n" ); +monitor_puts (mon,"disabled\n" );return ; } -qemu_printf ("Base: 0x%08x Mask: 0x%08x Control: " , - ttr &M68K_TTR_ADDR_BASE , - (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT ); +monitor_printf (mon,"Base: 0x%08x Mask: 0x%08x Control: " , + ttr &M68K_TTR_ADDR_BASE , + (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT );switch (ttr &M68K_TTR_SFIELD ) {case M68K_TTR_SFIELD_USER : -qemu_printf ("U" ); +monitor_puts (mon,"U" );break ;case M68K_TTR_SFIELD_SUPER : -qemu_printf ("S" ); +monitor_puts (mon,"S" );break ;default : -qemu_printf ("*" ); +monitor_puts (mon,"*" );break ; }DUMP_CACHEFLAGS (ttr);if (ttr &M68K_DESC_WRITEPROT ) { -qemu_printf ("R" ); +monitor_puts (mon,"R" ); }else { -qemu_printf ("W" ); +monitor_puts (mon,"W" ); } -qemu_printf (" U: %d\n" , (ttr &M68K_DESC_USERATTR ) >> +monitor_printf (mon," U: %d\n" , (ttr &M68K_DESC_USERATTR ) >>M68K_DESC_USERATTR_SHIFT ); } -void dump_mmu (CPUM68KState *env) +void dump_mmu (Monitor *mon,CPUM68KState *env) {if ((env->mmu.tcr &M68K_TCR_ENABLED ) ==0 ) { -qemu_printf ("Translation disabled\n" ); +monitor_puts (mon,"Translation disabled\n" );return ; } -qemu_printf ("Page Size: " ); +monitor_puts (mon,"Page Size: " );if (env->mmu.tcr &M68K_TCR_PAGE_8K ) { -qemu_printf ("8kB\n" ); +monitor_puts (mon,"8kB\n" ); }else { -qemu_printf ("4kB\n" ); +monitor_puts (mon,"4kB\n" ); } -qemu_printf ("MMUSR: " ); +monitor_puts (mon,"MMUSR: " );if (env->mmu.mmusr &M68K_MMU_B_040 ) { -qemu_printf ("BUS ERROR\n" ); +monitor_puts (mon,"BUS ERROR\n" ); }else { -qemu_printf ("Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 ); +monitor_printf (mon,"Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 );/* flags found on the page descriptor */ if (env->mmu.mmusr &M68K_MMU_G_040 ) { -qemu_printf ("G" );/* Global */ +monitor_puts (mon,"G" );/* Global */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_S_040 ) { -qemu_printf ("S" );/* Supervisor */ +monitor_puts (mon,"S" );/* Supervisor */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_M_040 ) { -qemu_printf ("M" );/* Modified */ +monitor_puts (mon,"M" );/* Modified */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_WP_040 ) { -qemu_printf ("W" );/* Write protect */ +monitor_puts (mon,"W" );/* Write protect */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_T_040 ) { -qemu_printf ("T" );/* Transparent */ +monitor_puts (mon,"T" );/* Transparent */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_R_040 ) { -qemu_printf ("R" );/* Resident */ +monitor_puts (mon,"R" );/* Resident */ }else {
target/m68k/helper.c static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) · line 663
Quoted 10 lines
target/m68k/helper.c +4
-4-qemu_printf ("." ); +monitor_puts (mon,"." ); } -qemu_printf (" Cache: " ); +monitor_puts (mon," Cache: " );DUMP_CACHEFLAGS (env->mmu.mmusr); -qemu_printf (" U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); -qemu_printf ("\n" ); +monitor_printf (mon," U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); +monitor_puts (mon,"\n" );
That one is a little odd isn't it; still, generally
Quoted 52 lines
target/m68k/helper.c +12
-12} -qemu_printf ("ITTR0: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR0 ]); -qemu_printf ("ITTR1: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR1 ]); -qemu_printf ("DTTR0: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR0 ]); -qemu_printf ("DTTR1: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR1 ]); +monitor_puts (mon,"ITTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR0 ]); +monitor_puts (mon,"ITTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR1 ]); +monitor_puts (mon,"DTTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR0 ]); +monitor_puts (mon,"DTTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR1 ]); -qemu_printf ("SRP: 0x%08x\n" , env->mmu.srp); -dump_address_map (env, env->mmu.srp); +monitor_printf (mon,"SRP: 0x%08x\n" , env->mmu.srp); +dump_address_map (mon, env, env->mmu.srp); -qemu_printf ("URP: 0x%08x\n" , env->mmu.urp); -dump_address_map (env, env->mmu.urp); +monitor_printf (mon,"URP: 0x%08x\n" , env->mmu.urp); +dump_address_map (mon, env, env->mmu.urp); } static int check_TTR(uint32_t ttr, int *prot, target_ulong addr,target/m68k/monitor.c +2
-2@@ -15,11 +15,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)CPUArchState *env1 =mon_get_cpu_env (mon);if (!env1) { -monitor_printf (mon,"No CPU available\n" ); +monitor_puts (mon,"No CPU available\n" );return ; } -dump_mmu (env1); +dump_mmu (mon, env1); }static const MonitorDef monitor_defs[] = {Signature · 1 line
2.41.0
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
Quoted 224 lines · Dr. David Alan Gilbert
Quoted 223 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-)target/m68k/cpu.h +1
-1@@ -620,6 +620,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu (CPUM68KState *env); +void dump_mmu (Monitor *mon,CPUM68KState *env);#endif target/m68k/helper.c +49
-48@@ -25,7 +25,7 @@#include "exec/helper-proto.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" -#include "qemu/qemu-print.h" +#include "monitor/monitor.h" #define SIGNBIT (1u << 31)@@ -455,28 +455,30 @@ void m68k_switch_sp(CPUM68KState *env)#if !defined(CONFIG_USER_ONLY )/* MMU: 68040 only */ -static void print_address_zone (uint32_t logical,uint32_t physical, +static void print_address_zone (Monitor *mon, +uint32_t logical,uint32_t physical,uint32_t size,int attr) { -qemu_printf ("%08x - %08x -> %08x - %08x %c " , - logical, logical + size -1 , - physical, physical + size -1 , - attr &4 ?'W' :'-' ); +monitor_printf (mon,"%08x - %08x -> %08x - %08x %c " , + logical, logical + size -1 , + physical, physical + size -1 , + attr &4 ?'W' :'-' ); size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d KiB)\n" , size); +monitor_printf (mon,"(%d KiB)\n" , size); }else { size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d MiB)\n" , size); +monitor_printf (mon,"(%d MiB)\n" , size); }else { size >>=10 ; -qemu_printf ("(%d GiB)\n" , size); +monitor_printf (mon,"(%d GiB)\n" , size); } } } -static void dump_address_map (CPUM68KState *env,uint32_t root_pointer) +static void dump_address_map (Monitor *mon,CPUM68KState *env, +uint32_t root_pointer) {int i, j, k;int tic_size, tic_shift;@@ -545,7 +547,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer)if (first_logical !=0xffffffff ) { size = last_logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, +print_address_zone (mon, first_logical, first_physical, size, last_attr); } first_logical = logical;@@ -556,125 +558,125 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) }if (first_logical != logical || (attr &4 ) != (last_attr &4 )) { size = logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, first_physical, size, last_attr); +print_address_zone (mon, first_logical, first_physical, size, last_attr); } }#define DUMP_CACHEFLAGS (a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU:/* cacheable, write-through */ \ -qemu_printf ("T" ); \ +monitor_puts (mon,"T" ); \break ; \case M68K_DESC_CM_COPYBK :/* cacheable, copyback */ \ -qemu_printf ("C" ); \ +monitor_puts (mon,"C" ); \break ; \case M68K_DESC_CM_SERIAL :/* noncachable, serialized */ \ -qemu_printf ("S" ); \ +monitor_puts (mon,"S" ); \break ; \case M68K_DESC_CM_NCACHE :/* noncachable */ \ -qemu_printf ("N" ); \ +monitor_puts (mon,"N" ); \break ; \ } -static void dump_ttr (uint32_t ttr) +static void dump_ttr (Monitor *mon,uint32_t ttr) {if ((ttr &M68K_TTR_ENABLED ) ==0 ) { -qemu_printf ("disabled\n" ); +monitor_puts (mon,"disabled\n" );return ; } -qemu_printf ("Base: 0x%08x Mask: 0x%08x Control: " , - ttr &M68K_TTR_ADDR_BASE , - (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT ); +monitor_printf (mon,"Base: 0x%08x Mask: 0x%08x Control: " , + ttr &M68K_TTR_ADDR_BASE , + (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT );switch (ttr &M68K_TTR_SFIELD ) {case M68K_TTR_SFIELD_USER : -qemu_printf ("U" ); +monitor_puts (mon,"U" );break ;case M68K_TTR_SFIELD_SUPER : -qemu_printf ("S" ); +monitor_puts (mon,"S" );break ;default : -qemu_printf ("*" ); +monitor_puts (mon,"*" );break ; }DUMP_CACHEFLAGS (ttr);if (ttr &M68K_DESC_WRITEPROT ) { -qemu_printf ("R" ); +monitor_puts (mon,"R" ); }else { -qemu_printf ("W" ); +monitor_puts (mon,"W" ); } -qemu_printf (" U: %d\n" , (ttr &M68K_DESC_USERATTR ) >> +monitor_printf (mon," U: %d\n" , (ttr &M68K_DESC_USERATTR ) >>M68K_DESC_USERATTR_SHIFT ); } -void dump_mmu (CPUM68KState *env) +void dump_mmu (Monitor *mon,CPUM68KState *env) {if ((env->mmu.tcr &M68K_TCR_ENABLED ) ==0 ) { -qemu_printf ("Translation disabled\n" ); +monitor_puts (mon,"Translation disabled\n" );return ; } -qemu_printf ("Page Size: " ); +monitor_puts (mon,"Page Size: " );if (env->mmu.tcr &M68K_TCR_PAGE_8K ) { -qemu_printf ("8kB\n" ); +monitor_puts (mon,"8kB\n" ); }else { -qemu_printf ("4kB\n" ); +monitor_puts (mon,"4kB\n" ); } -qemu_printf ("MMUSR: " ); +monitor_puts (mon,"MMUSR: " );if (env->mmu.mmusr &M68K_MMU_B_040 ) { -qemu_printf ("BUS ERROR\n" ); +monitor_puts (mon,"BUS ERROR\n" ); }else { -qemu_printf ("Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 ); +monitor_printf (mon,"Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 );/* flags found on the page descriptor */ if (env->mmu.mmusr &M68K_MMU_G_040 ) { -qemu_printf ("G" );/* Global */ +monitor_puts (mon,"G" );/* Global */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_S_040 ) { -qemu_printf ("S" );/* Supervisor */ +monitor_puts (mon,"S" );/* Supervisor */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_M_040 ) { -qemu_printf ("M" );/* Modified */ +monitor_puts (mon,"M" );/* Modified */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_WP_040 ) { -qemu_printf ("W" );/* Write protect */ +monitor_puts (mon,"W" );/* Write protect */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_T_040 ) { -qemu_printf ("T" );/* Transparent */ +monitor_puts (mon,"T" );/* Transparent */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_R_040 ) { -qemu_printf ("R" );/* Resident */ +monitor_puts (mon,"R" );/* Resident */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); } -qemu_printf (" Cache: " );
Quoted 8 lines
target/m68k/helper.c static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) · line 663
Quoted 6 lines
target/m68k/helper.c +3
-2+monitor_puts (mon," Cache: " );DUMP_CACHEFLAGS (env->mmu.mmusr); -qemu_printf (" U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); -qemu_printf ("\n" ); +monitor_printf (mon," U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); +monitor_puts (mon,"\n" );That one is a little odd isn't it; still, generally
Doesn't puts append a newline? Then this would add an extra empty line.
Regards,
BALATON Zoltan
Quoted 55 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>Quoted 52 lines
target/m68k/helper.c +12
-12} -qemu_printf ("ITTR0: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR0 ]); -qemu_printf ("ITTR1: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR1 ]); -qemu_printf ("DTTR0: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR0 ]); -qemu_printf ("DTTR1: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR1 ]); +monitor_puts (mon,"ITTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR0 ]); +monitor_puts (mon,"ITTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR1 ]); +monitor_puts (mon,"DTTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR0 ]); +monitor_puts (mon,"DTTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR1 ]); -qemu_printf ("SRP: 0x%08x\n" , env->mmu.srp); -dump_address_map (env, env->mmu.srp); +monitor_printf (mon,"SRP: 0x%08x\n" , env->mmu.srp); +dump_address_map (mon, env, env->mmu.srp); -qemu_printf ("URP: 0x%08x\n" , env->mmu.urp); -dump_address_map (env, env->mmu.urp); +monitor_printf (mon,"URP: 0x%08x\n" , env->mmu.urp); +dump_address_map (mon, env, env->mmu.urp); } static int check_TTR(uint32_t ttr, int *prot, target_ulong addr,target/m68k/monitor.c +2
-3@@ -15,11 +15,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)CPUArchState *env1 =mon_get_cpu_env (mon);if (!env1) { -monitor_printf (mon,"No CPU available\n" ); +monitor_puts (mon,"No CPU available\n" );return ; } -dump_mmu (env1); +dump_mmu (mon, env1); }static const MonitorDef monitor_defs[] = { --2.41.0
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
Quoted 234 lines · * BALATON Zoltan ([email protected]) wrote:
Quoted 224 lines · Dr. David Alan Gilbert
Quoted 223 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-)target/m68k/cpu.h +1
-1@@ -620,6 +620,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu (CPUM68KState *env); +void dump_mmu (Monitor *mon,CPUM68KState *env);#endif target/m68k/helper.c +49
-48@@ -25,7 +25,7 @@#include "exec/helper-proto.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" -#include "qemu/qemu-print.h" +#include "monitor/monitor.h" #define SIGNBIT (1u << 31)@@ -455,28 +455,30 @@ void m68k_switch_sp(CPUM68KState *env)#if !defined(CONFIG_USER_ONLY )/* MMU: 68040 only */ -static void print_address_zone (uint32_t logical,uint32_t physical, +static void print_address_zone (Monitor *mon, +uint32_t logical,uint32_t physical,uint32_t size,int attr) { -qemu_printf ("%08x - %08x -> %08x - %08x %c " , - logical, logical + size -1 , - physical, physical + size -1 , - attr &4 ?'W' :'-' ); +monitor_printf (mon,"%08x - %08x -> %08x - %08x %c " , + logical, logical + size -1 , + physical, physical + size -1 , + attr &4 ?'W' :'-' ); size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d KiB)\n" , size); +monitor_printf (mon,"(%d KiB)\n" , size); }else { size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d MiB)\n" , size); +monitor_printf (mon,"(%d MiB)\n" , size); }else { size >>=10 ; -qemu_printf ("(%d GiB)\n" , size); +monitor_printf (mon,"(%d GiB)\n" , size); } } } -static void dump_address_map (CPUM68KState *env,uint32_t root_pointer) +static void dump_address_map (Monitor *mon,CPUM68KState *env, +uint32_t root_pointer) {int i, j, k;int tic_size, tic_shift;@@ -545,7 +547,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer)if (first_logical !=0xffffffff ) { size = last_logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, +print_address_zone (mon, first_logical, first_physical, size, last_attr); } first_logical = logical;@@ -556,125 +558,125 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) }if (first_logical != logical || (attr &4 ) != (last_attr &4 )) { size = logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, first_physical, size, last_attr); +print_address_zone (mon, first_logical, first_physical, size, last_attr); } }#define DUMP_CACHEFLAGS (a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU:/* cacheable, write-through */ \ -qemu_printf ("T" ); \ +monitor_puts (mon,"T" ); \break ; \case M68K_DESC_CM_COPYBK :/* cacheable, copyback */ \ -qemu_printf ("C" ); \ +monitor_puts (mon,"C" ); \break ; \case M68K_DESC_CM_SERIAL :/* noncachable, serialized */ \ -qemu_printf ("S" ); \ +monitor_puts (mon,"S" ); \break ; \case M68K_DESC_CM_NCACHE :/* noncachable */ \ -qemu_printf ("N" ); \ +monitor_puts (mon,"N" ); \break ; \ } -static void dump_ttr (uint32_t ttr) +static void dump_ttr (Monitor *mon,uint32_t ttr) {if ((ttr &M68K_TTR_ENABLED ) ==0 ) { -qemu_printf ("disabled\n" ); +monitor_puts (mon,"disabled\n" );return ; } -qemu_printf ("Base: 0x%08x Mask: 0x%08x Control: " , - ttr &M68K_TTR_ADDR_BASE , - (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT ); +monitor_printf (mon,"Base: 0x%08x Mask: 0x%08x Control: " , + ttr &M68K_TTR_ADDR_BASE , + (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT );switch (ttr &M68K_TTR_SFIELD ) {case M68K_TTR_SFIELD_USER : -qemu_printf ("U" ); +monitor_puts (mon,"U" );break ;case M68K_TTR_SFIELD_SUPER : -qemu_printf ("S" ); +monitor_puts (mon,"S" );break ;default : -qemu_printf ("*" ); +monitor_puts (mon,"*" );break ; }DUMP_CACHEFLAGS (ttr);if (ttr &M68K_DESC_WRITEPROT ) { -qemu_printf ("R" ); +monitor_puts (mon,"R" ); }else { -qemu_printf ("W" ); +monitor_puts (mon,"W" ); } -qemu_printf (" U: %d\n" , (ttr &M68K_DESC_USERATTR ) >> +monitor_printf (mon," U: %d\n" , (ttr &M68K_DESC_USERATTR ) >>M68K_DESC_USERATTR_SHIFT ); } -void dump_mmu (CPUM68KState *env) +void dump_mmu (Monitor *mon,CPUM68KState *env) {if ((env->mmu.tcr &M68K_TCR_ENABLED ) ==0 ) { -qemu_printf ("Translation disabled\n" ); +monitor_puts (mon,"Translation disabled\n" );return ; } -qemu_printf ("Page Size: " ); +monitor_puts (mon,"Page Size: " );if (env->mmu.tcr &M68K_TCR_PAGE_8K ) { -qemu_printf ("8kB\n" ); +monitor_puts (mon,"8kB\n" ); }else { -qemu_printf ("4kB\n" ); +monitor_puts (mon,"4kB\n" ); } -qemu_printf ("MMUSR: " ); +monitor_puts (mon,"MMUSR: " );if (env->mmu.mmusr &M68K_MMU_B_040 ) { -qemu_printf ("BUS ERROR\n" ); +monitor_puts (mon,"BUS ERROR\n" ); }else { -qemu_printf ("Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 ); +monitor_printf (mon,"Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 );/* flags found on the page descriptor */ if (env->mmu.mmusr &M68K_MMU_G_040 ) { -qemu_printf ("G" );/* Global */ +monitor_puts (mon,"G" );/* Global */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_S_040 ) { -qemu_printf ("S" );/* Supervisor */ +monitor_puts (mon,"S" );/* Supervisor */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_M_040 ) { -qemu_printf ("M" );/* Modified */ +monitor_puts (mon,"M" );/* Modified */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_WP_040 ) { -qemu_printf ("W" );/* Write protect */ +monitor_puts (mon,"W" );/* Write protect */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_T_040 ) { -qemu_printf ("T" );/* Transparent */ +monitor_puts (mon,"T" );/* Transparent */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_R_040 ) { -qemu_printf ("R" );/* Resident */ +monitor_puts (mon,"R" );/* Resident */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); } -qemu_printf (" Cache: " );Quoted 8 lines
target/m68k/helper.c static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) · line 663
Quoted 6 lines
target/m68k/helper.c +3
-2+monitor_puts (mon," Cache: " );DUMP_CACHEFLAGS (env->mmu.mmusr); -qemu_printf (" U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); -qemu_printf ("\n" ); +monitor_printf (mon," U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); +monitor_puts (mon,"\n" );That one is a little odd isn't it; still, generally
Quoted 1 line
Doesn't puts append a newline? Then this would add an extra empty line.
As rth said, apparently not.
But what made me more curious in this case is why not just flatten it down so that the printf has a second \n rather than needing the second call to puts.
Dave
Quoted 58 lines
Regards,
BALATON ZoltanQuoted 55 lines
Reviewed-by Dr. David Alan Gilbert <[email protected]>Quoted 52 lines
target/m68k/helper.c +12
-12} -qemu_printf ("ITTR0: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR0 ]); -qemu_printf ("ITTR1: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR1 ]); -qemu_printf ("DTTR0: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR0 ]); -qemu_printf ("DTTR1: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR1 ]); +monitor_puts (mon,"ITTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR0 ]); +monitor_puts (mon,"ITTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR1 ]); +monitor_puts (mon,"DTTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR0 ]); +monitor_puts (mon,"DTTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR1 ]); -qemu_printf ("SRP: 0x%08x\n" , env->mmu.srp); -dump_address_map (env, env->mmu.srp); +monitor_printf (mon,"SRP: 0x%08x\n" , env->mmu.srp); +dump_address_map (mon, env, env->mmu.srp); -qemu_printf ("URP: 0x%08x\n" , env->mmu.urp); -dump_address_map (env, env->mmu.urp); +monitor_printf (mon,"URP: 0x%08x\n" , env->mmu.urp); +dump_address_map (mon, env, env->mmu.urp); } static int check_TTR(uint32_t ttr, int *prot, target_ulong addr,target/m68k/monitor.c +2
-3@@ -15,11 +15,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)CPUArchState *env1 =mon_get_cpu_env (mon);if (!env1) { -monitor_printf (mon,"No CPU available\n" ); +monitor_puts (mon,"No CPU available\n" );return ; } -dump_mmu (env1); +dump_mmu (mon, env1); }static const MonitorDef monitor_defs[] = { --2.41.0
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
Quoted 235 lines · Dr. David Alan Gilbert
Quoted 234 lines · * BALATON Zoltan ([email protected]) wrote:
Quoted 232 lines · Dr. David Alan Gilbert
Quoted 219 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-)target/m68k/cpu.h +1
-1@@ -620,6 +620,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu (CPUM68KState *env); +void dump_mmu (Monitor *mon,CPUM68KState *env);#endif target/m68k/helper.c +48
-46@@ -25,7 +25,7 @@#include "exec/helper-proto.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" -#include "qemu/qemu-print.h" +#include "monitor/monitor.h" #define SIGNBIT (1u << 31)@@ -455,28 +455,30 @@ void m68k_switch_sp(CPUM68KState *env)#if !defined(CONFIG_USER_ONLY )/* MMU: 68040 only */ -static void print_address_zone (uint32_t logical,uint32_t physical, +static void print_address_zone (Monitor *mon, +uint32_t logical,uint32_t physical,uint32_t size,int attr) { -qemu_printf ("%08x - %08x -> %08x - %08x %c " , - logical, logical + size -1 , - physical, physical + size -1 , - attr &4 ?'W' :'-' ); +monitor_printf (mon,"%08x - %08x -> %08x - %08x %c " , + logical, logical + size -1 , + physical, physical + size -1 , + attr &4 ?'W' :'-' ); size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d KiB)\n" , size); +monitor_printf (mon,"(%d KiB)\n" , size); }else { size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d MiB)\n" , size); +monitor_printf (mon,"(%d MiB)\n" , size); }else { size >>=10 ; -qemu_printf ("(%d GiB)\n" , size); +monitor_printf (mon,"(%d GiB)\n" , size); } } } -static void dump_address_map (CPUM68KState *env,uint32_t root_pointer) +static void dump_address_map (Monitor *mon,CPUM68KState *env, +uint32_t root_pointer) {int i, j, k;int tic_size, tic_shift;@@ -545,7 +547,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer)if (first_logical !=0xffffffff ) { size = last_logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, +print_address_zone (mon, first_logical, first_physical, size, last_attr); } first_logical = logical;@@ -556,125 +558,125 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) }if (first_logical != logical || (attr &4 ) != (last_attr &4 )) { size = logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, first_physical, size, last_attr); +print_address_zone (mon, first_logical, first_physical, size, last_attr); } }#define DUMP_CACHEFLAGS (a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU:/* cacheable, write-through */ \ -qemu_printf ("T" ); \ +monitor_puts (mon,"T" ); \break ; \case M68K_DESC_CM_COPYBK :/* cacheable, copyback */ \ -qemu_printf ("C" ); \ +monitor_puts (mon,"C" ); \break ; \case M68K_DESC_CM_SERIAL :/* noncachable, serialized */ \ -qemu_printf ("S" ); \ +monitor_puts (mon,"S" ); \break ; \case M68K_DESC_CM_NCACHE :/* noncachable */ \ -qemu_printf ("N" ); \ +monitor_puts (mon,"N" ); \break ; \ } -static void dump_ttr (uint32_t ttr) +static void dump_ttr (Monitor *mon,uint32_t ttr) {if ((ttr &M68K_TTR_ENABLED ) ==0 ) { -qemu_printf ("disabled\n" ); +monitor_puts (mon,"disabled\n" );return ; } -qemu_printf ("Base: 0x%08x Mask: 0x%08x Control: " , - ttr &M68K_TTR_ADDR_BASE , - (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT ); +monitor_printf (mon,"Base: 0x%08x Mask: 0x%08x Control: " , + ttr &M68K_TTR_ADDR_BASE , + (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT );switch (ttr &M68K_TTR_SFIELD ) {case M68K_TTR_SFIELD_USER : -qemu_printf ("U" ); +monitor_puts (mon,"U" );break ;case M68K_TTR_SFIELD_SUPER : -qemu_printf ("S" ); +monitor_puts (mon,"S" );break ;default : -qemu_printf ("*" ); +monitor_puts (mon,"*" );break ; }DUMP_CACHEFLAGS (ttr);if (ttr &M68K_DESC_WRITEPROT ) { -qemu_printf ("R" ); +monitor_puts (mon,"R" ); }else { -qemu_printf ("W" ); +monitor_puts (mon,"W" ); } -qemu_printf (" U: %d\n" , (ttr &M68K_DESC_USERATTR ) >> +monitor_printf (mon," U: %d\n" , (ttr &M68K_DESC_USERATTR ) >>M68K_DESC_USERATTR_SHIFT ); } -void dump_mmu (CPUM68KState *env) +void dump_mmu (Monitor *mon,CPUM68KState *env) {if ((env->mmu.tcr &M68K_TCR_ENABLED ) ==0 ) { -qemu_printf ("Translation disabled\n" ); +monitor_puts (mon,"Translation disabled\n" );return ; } -qemu_printf ("Page Size: " ); +monitor_puts (mon,"Page Size: " );if (env->mmu.tcr &M68K_TCR_PAGE_8K ) { -qemu_printf ("8kB\n" ); +monitor_puts (mon,"8kB\n" ); }else { -qemu_printf ("4kB\n" ); +monitor_puts (mon,"4kB\n" ); } -qemu_printf ("MMUSR: " ); +monitor_puts (mon,"MMUSR: " );if (env->mmu.mmusr &M68K_MMU_B_040 ) { -qemu_printf ("BUS ERROR\n" ); +monitor_puts (mon,"BUS ERROR\n" ); }else { -qemu_printf ("Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 ); +monitor_printf (mon,"Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 );/* flags found on the page descriptor */ if (env->mmu.mmusr &M68K_MMU_G_040 ) { -qemu_printf ("G" );/* Global */ +monitor_puts (mon,"G" );/* Global */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_S_040 ) { -qemu_printf ("S" );/* Supervisor */ +monitor_puts (mon,"S" );/* Supervisor */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_M_040 ) { -qemu_printf ("M" );/* Modified */ +monitor_puts (mon,"M" );/* Modified */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_WP_040 ) { -qemu_printf ("W" );/* Write protect */ +monitor_puts (mon,"W" );/* Write protect */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_T_040 ) { -qemu_printf ("T" );/* Transparent */ +monitor_puts (mon,"T" );/* Transparent */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_R_040 ) { -qemu_printf ("R" );/* Resident */ +monitor_puts (mon,"R" );/* Resident */ }else {target/m68k/helper.c static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) · line 663
Quoted 10 lines
target/m68k/helper.c +4
-4-qemu_printf ("." ); +monitor_puts (mon,"." ); } -qemu_printf (" Cache: " ); +monitor_puts (mon," Cache: " );DUMP_CACHEFLAGS (env->mmu.mmusr); -qemu_printf (" U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); -qemu_printf ("\n" ); +monitor_printf (mon," U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); +monitor_puts (mon,"\n" );That one is a little odd isn't it; still, generally
Quoted 6 lines
Quoted 1 line
Doesn't puts append a newline? Then this would add an extra empty line.
As rth said, apparently not.
But what made me more curious in this case is why not just flatten it down so that the printf has a second \n rather than needing the second call to puts.
Maybe because monitor_puts also seems to have a flush so that separate call would do an additional flush to make sure the previously printed lines are displayed? But I have no idea just guessing.
Regards,
BALATON Zoltan
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
In reply to Philippe Mathieu-DaudéQuoted 1 line · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.
Why? Here's my attempt at an answer: because this runs only within HMP command "info tlb". Using qemu_printf() there isn't wrong, but with monitor_printf(), it's obvious that we print to the monitor.
On monitor_printf() vs. monitor_puts().
qemu_printf() behaves like monitor_printf() when monitor_cur() returns non-null, which it certainly does within a monitor command.
monitor_printf() prints like monitor_puts() when monitor_is_qmp() returns false, which it certainly does within an HMP command.
Note: despite their names, monitor_printf() and monitor_puts() are at different interface layers!
We need a low-level function to send to a monitor, be it HMP or QMP:monitor_puts().
We need a high-level function to format JSON and send it to QMP:qmp_send_response().
We need a high-level functions to format text and send it to HMP:monitor_printf(), ...
Naming the functions that expect an HMP monitor hmp_FOO() would make more sense. Renaming them now would be quite some churn, though. Discussed at
<https://lore.kernel.org/qemu-devel/[email protected]/>.
HMP code using both two layers to print gives me a slightly queasy feeling. It's not wrong, though.
Quoted 85 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 126 +++++++++++++++++++++--------------------- target/m68k/monitor.c | 4 +- 3 files changed, 67 insertions(+), 65 deletions(-)target/m68k/cpu.h +1
-1@@ -620,6 +620,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu (CPUM68KState *env); +void dump_mmu (Monitor *mon,CPUM68KState *env);#endif target/m68k/helper.c +13
-11@@ -25,7 +25,7 @@#include "exec/helper-proto.h" #include "gdbstub/helpers.h" #include "fpu/softfloat.h" -#include "qemu/qemu-print.h" +#include "monitor/monitor.h" #define SIGNBIT (1u << 31)@@ -455,28 +455,30 @@ void m68k_switch_sp(CPUM68KState *env)#if !defined(CONFIG_USER_ONLY )/* MMU: 68040 only */ -static void print_address_zone (uint32_t logical,uint32_t physical, +static void print_address_zone (Monitor *mon, +uint32_t logical,uint32_t physical,uint32_t size,int attr) { -qemu_printf ("%08x - %08x -> %08x - %08x %c " , - logical, logical + size -1 , - physical, physical + size -1 , - attr &4 ?'W' :'-' ); +monitor_printf (mon,"%08x - %08x -> %08x - %08x %c " , + logical, logical + size -1 , + physical, physical + size -1 , + attr &4 ?'W' :'-' ); size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d KiB)\n" , size); +monitor_printf (mon,"(%d KiB)\n" , size); }else { size >>=10 ;if (size <1024 ) { -qemu_printf ("(%d MiB)\n" , size); +monitor_printf (mon,"(%d MiB)\n" , size); }else { size >>=10 ; -qemu_printf ("(%d GiB)\n" , size); +monitor_printf (mon,"(%d GiB)\n" , size); } } } -static void dump_address_map (CPUM68KState *env,uint32_t root_pointer) +static void dump_address_map (Monitor *mon,CPUM68KState *env, +uint32_t root_pointer) {int i, j, k;int tic_size, tic_shift;@@ -545,7 +547,7 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer)if (first_logical !=0xffffffff ) { size = last_logical + (1 << tic_shift) - first_logical; -print_address_zone (first_logical, +print_address_zone (mon, first_logical, first_physical, size, last_attr); } first_logical = logical;@@ -556,125 +558,125 @@ static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) }if (first_logical != logical || (attr &4 ) != (last_attr &4 )) { size = logical + (1 << tic_shift) - first_logical;
target/m68k/helper.c static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) · line 568
Quoted 10 lines
target/m68k/helper.c +2
-2-print_address_zone (first_logical, first_physical, size, last_attr); +print_address_zone (mon, first_logical, first_physical, size, last_attr); } }#define DUMP_CACHEFLAGS (a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU:/* cacheable, write-through */ \ -qemu_printf ("T" ); \ +monitor_puts (mon,"T" ); \
Not wrong, but I'd stick to monitor_printf() to keep the transformation as simple as possible, and to sidestep the need for explaining the subtleties around monitor_printf() vs. monitor_puts() in the commit message.
target/m68k/helper.c static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) · line 571
Quoted 4 lines
target/m68k/helper.c +1
-1break ; \case M68K_DESC_CM_COPYBK :/* cacheable, copyback */ \ -qemu_printf ("C" ); \ +monitor_puts (mon,"C" ); \
Likewise. Not going to note this again.
Quoted 167 lines
target/m68k/helper.c +48
-48break ; \case M68K_DESC_CM_SERIAL :/* noncachable, serialized */ \ -qemu_printf ("S" ); \ +monitor_puts (mon,"S" ); \break ; \case M68K_DESC_CM_NCACHE :/* noncachable */ \ -qemu_printf ("N" ); \ +monitor_puts (mon,"N" ); \break ; \ } -static void dump_ttr (uint32_t ttr) +static void dump_ttr (Monitor *mon,uint32_t ttr) {if ((ttr &M68K_TTR_ENABLED ) ==0 ) { -qemu_printf ("disabled\n" ); +monitor_puts (mon,"disabled\n" );return ; } -qemu_printf ("Base: 0x%08x Mask: 0x%08x Control: " , - ttr &M68K_TTR_ADDR_BASE , - (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT ); +monitor_printf (mon,"Base: 0x%08x Mask: 0x%08x Control: " , + ttr &M68K_TTR_ADDR_BASE , + (ttr &M68K_TTR_ADDR_MASK ) <<M68K_TTR_ADDR_MASK_SHIFT );switch (ttr &M68K_TTR_SFIELD ) {case M68K_TTR_SFIELD_USER : -qemu_printf ("U" ); +monitor_puts (mon,"U" );break ;case M68K_TTR_SFIELD_SUPER : -qemu_printf ("S" ); +monitor_puts (mon,"S" );break ;default : -qemu_printf ("*" ); +monitor_puts (mon,"*" );break ; }DUMP_CACHEFLAGS (ttr);if (ttr &M68K_DESC_WRITEPROT ) { -qemu_printf ("R" ); +monitor_puts (mon,"R" ); }else { -qemu_printf ("W" ); +monitor_puts (mon,"W" ); } -qemu_printf (" U: %d\n" , (ttr &M68K_DESC_USERATTR ) >> +monitor_printf (mon," U: %d\n" , (ttr &M68K_DESC_USERATTR ) >>M68K_DESC_USERATTR_SHIFT ); } -void dump_mmu (CPUM68KState *env) +void dump_mmu (Monitor *mon,CPUM68KState *env) {if ((env->mmu.tcr &M68K_TCR_ENABLED ) ==0 ) { -qemu_printf ("Translation disabled\n" ); +monitor_puts (mon,"Translation disabled\n" );return ; } -qemu_printf ("Page Size: " ); +monitor_puts (mon,"Page Size: " );if (env->mmu.tcr &M68K_TCR_PAGE_8K ) { -qemu_printf ("8kB\n" ); +monitor_puts (mon,"8kB\n" ); }else { -qemu_printf ("4kB\n" ); +monitor_puts (mon,"4kB\n" ); } -qemu_printf ("MMUSR: " ); +monitor_puts (mon,"MMUSR: " );if (env->mmu.mmusr &M68K_MMU_B_040 ) { -qemu_printf ("BUS ERROR\n" ); +monitor_puts (mon,"BUS ERROR\n" ); }else { -qemu_printf ("Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 ); +monitor_printf (mon,"Phy=%08x Flags: " , env->mmu.mmusr &0xfffff000 );/* flags found on the page descriptor */ if (env->mmu.mmusr &M68K_MMU_G_040 ) { -qemu_printf ("G" );/* Global */ +monitor_puts (mon,"G" );/* Global */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_S_040 ) { -qemu_printf ("S" );/* Supervisor */ +monitor_puts (mon,"S" );/* Supervisor */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_M_040 ) { -qemu_printf ("M" );/* Modified */ +monitor_puts (mon,"M" );/* Modified */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_WP_040 ) { -qemu_printf ("W" );/* Write protect */ +monitor_puts (mon,"W" );/* Write protect */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_T_040 ) { -qemu_printf ("T" );/* Transparent */ +monitor_puts (mon,"T" );/* Transparent */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); }if (env->mmu.mmusr &M68K_MMU_R_040 ) { -qemu_printf ("R" );/* Resident */ +monitor_puts (mon,"R" );/* Resident */ }else { -qemu_printf ("." ); +monitor_puts (mon,"." ); } -qemu_printf (" Cache: " ); +monitor_puts (mon," Cache: " );DUMP_CACHEFLAGS (env->mmu.mmusr); -qemu_printf (" U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); -qemu_printf ("\n" ); +monitor_printf (mon," U: %d\n" , (env->mmu.mmusr >>8 ) &3 ); +monitor_puts (mon,"\n" ); } -qemu_printf ("ITTR0: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR0 ]); -qemu_printf ("ITTR1: " ); -dump_ttr (env->mmu.ttr[M68K_ITTR1 ]); -qemu_printf ("DTTR0: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR0 ]); -qemu_printf ("DTTR1: " ); -dump_ttr (env->mmu.ttr[M68K_DTTR1 ]); +monitor_puts (mon,"ITTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR0 ]); +monitor_puts (mon,"ITTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_ITTR1 ]); +monitor_puts (mon,"DTTR0: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR0 ]); +monitor_puts (mon,"DTTR1: " ); +dump_ttr (mon, env->mmu.ttr[M68K_DTTR1 ]); -qemu_printf ("SRP: 0x%08x\n" , env->mmu.srp); -dump_address_map (env, env->mmu.srp); +monitor_printf (mon,"SRP: 0x%08x\n" , env->mmu.srp); +dump_address_map (mon, env, env->mmu.srp); -qemu_printf ("URP: 0x%08x\n" , env->mmu.urp); -dump_address_map (env, env->mmu.urp); +monitor_printf (mon,"URP: 0x%08x\n" , env->mmu.urp); +dump_address_map (mon, env, env->mmu.urp); } static int check_TTR(uint32_t ttr, int *prot, target_ulong addr,target/m68k/monitor.c +0
-0@@ -15,11 +15,11 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)CPUArchState *env1 =mon_get_cpu_env (mon);if (!env1) {
target/m68k/monitor.c void hmp_info_tlb(Monitor *mon, const QDict *qdict) · line 25
Quoted 10 lines
target/m68k/monitor.c +2
-2-monitor_printf (mon,"No CPU available\n" ); +monitor_puts (mon,"No CPU available\n" );return ; } -dump_mmu (env1); +dump_mmu (mon, env1); }static const MonitorDef monitor_defs[] = {
In addition to replacing qemu_printf(), the patch passes the current monitor around. The alternative is monitor_cur(). I guess you pass because you consider it cleaner and/or simpler. No objection, but I suggest to mention it the commit message.
The patch is not wrong, so
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
Quoted 25 lines · Markus Armbruster
Quoted 1 line · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Why? Here's my attempt at an answer: because this runs only within HMP command "info tlb". Using
qemu_printf()there isn't wrong, but withmonitor_printf(), it's obvious that we print to the monitor.On
monitor_printf()vs.monitor_puts().
qemu_printf()behaves likemonitor_printf()whenmonitor_cur()returns non-null, which it certainly does within a monitor command.
monitor_printf()prints likemonitor_puts()whenmonitor_is_qmp()returns false, which it certainly does within an HMP command.Note: despite their names,
monitor_printf()andmonitor_puts()are at different interface layers!We need a low-level function to send to a monitor, be it HMP or QMP:
monitor_puts().We need a high-level function to format JSON and send it to QMP:
qmp_send_response().
Quoted 7 lines
We need a high-level functions to format text and send it to HMP:
monitor_printf(), ...Naming the functions that expect an HMP monitor
hmp_FOO()would make more sense. Renaming them now would be quite some churn, though. Discussed at
<https://lore.kernel.org/qemu-devel/[email protected]/>.
The hmp_ prefix is more cryptic than monitor_. Without knowing QEMU too much I can guess what monitor_ does but would have to look up what hmp_means so keeping monitor_ is better IMO. The solution to the naming issue mentioned above may be renaming monitor_puts to something that tells it's a low level function (and add a momitor_puts that behaves as expected) but I can't come up with a name either. Maybe the low level function could be called hmp_putt? Or add a comment near monitor_puts to explain this for now.
Regards,
BALATON Zoltan
Re: [PATCH-for-9.1 05/21] target/m68k: Replace qemu_printf() by monitor_printf() in monitor
Quoted 29 lines · BALATON Zoltan
Quoted 28 lines · Markus Armbruster
Quoted 1 line · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Why? Here's my attempt at an answer: because this runs only within HMP command "info tlb". Using
qemu_printf()there isn't wrong, but withmonitor_printf(), it's obvious that we print to the monitor.On
monitor_printf()vs.monitor_puts().
qemu_printf()behaves likemonitor_printf()whenmonitor_cur()returns non-null, which it certainly does within a monitor command.
monitor_printf()prints likemonitor_puts()whenmonitor_is_qmp()returns false, which it certainly does within an HMP command.Note: despite their names,
monitor_printf()andmonitor_puts()are at different interface layers!We need a low-level function to send to a monitor, be it HMP or QMP:
monitor_puts().We need a high-level function to format JSON and send it to QMP:
qmp_send_response().We need a high-level functions to format text and send it to HMP:
monitor_printf(), ...
Quoted 6 lines
Quoted 4 lines
Naming the functions that expect an HMP monitor
hmp_FOO()would make more sense. Renaming them now would be quite some churn, though. Discussed at
<https://lore.kernel.org/qemu-devel/[email protected]/>.The
hmp_prefix is more cryptic thanmonitor_. Without knowing QEMU too much I can guess whatmonitor_does but would have to look up whathmp_meansso keepingmonitor_is better IMO. The solution to the naming issue mentioned above may be renamingmonitor_putsto something that tells it's a low level function (and add amomitor_putsthat behaves as expected) but I can't come up with a name either. Maybe the low level function could be calledhmp_putt?
Meant hmp_puts.
Quoted 3 lines
Or add a comment near
monitor_putsto explain this for now. Regards,
BALATON Zoltan
PATCH 6/21 target/m68k: Have dump_ttr() take a @description argument
In reply to Philippe Mathieu-DaudéSlightly simplify dump_mmu() by passing the description as argument to dump_ttr().
--- target/m68k/helper.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
target/m68k/helper.c +6 -9
@@ -578,8 +578,9 @@ static void dump_address_map(Monitor *mon, CPUM68KState *env,break ; \ } -static void dump_ttr (Monitor *mon,uint32_t ttr) +static void dump_ttr (Monitor *mon,const char *desc,uint32_t ttr) { +monitor_printf (mon,"%s: " , desc);if ((ttr &M68K_TTR_ENABLED ) ==0 ) {monitor_puts (mon,"disabled\n" );return ;
@@ -663,14 +664,10 @@ void dump_mmu(Monitor *mon, CPUM68KState *env)monitor_puts (mon,"\n" ); } -monitor_puts (mon,"ITTR0: " ); -dump_ttr (mon, env->mmu.ttr[M68K_ITTR0 ]); -monitor_puts (mon,"ITTR1: " ); -dump_ttr (mon, env->mmu.ttr[M68K_ITTR1 ]); -monitor_puts (mon,"DTTR0: " ); -dump_ttr (mon, env->mmu.ttr[M68K_DTTR0 ]); -monitor_puts (mon,"DTTR1: " ); -dump_ttr (mon, env->mmu.ttr[M68K_DTTR1 ]); +dump_ttr (mon,"ITTR0" , env->mmu.ttr[M68K_ITTR0 ]); +dump_ttr (mon,"ITTR1" , env->mmu.ttr[M68K_ITTR1 ]); +dump_ttr (mon,"DTTR0" , env->mmu.ttr[M68K_DTTR0 ]); +dump_ttr (mon,"DTTR1" , env->mmu.ttr[M68K_DTTR1 ]);monitor_printf (mon,"SRP: 0x%08x\n" , env->mmu.srp);dump_address_map (mon, env, env->mmu.srp);
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 06/21] target/m68k: Have dump_ttr() take a @description argument
Quoted 7 lines · Philippe Mathieu-Daudé
Slightly simplify
dump_mmu()by passing the description as argument todump_ttr().Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/m68k/helper.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
r~
PATCH 7/21 target/m68k: Move MMU monitor commands from helper.c to monitor.c
In reply to Philippe Mathieu-DaudéKeep all HMP commands in monitor.c.
--- target/m68k/cpu.h | 3 +- target/m68k/helper.c | 222 ----------------------------------------- target/m68k/monitor.c | 223 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 223 insertions(+), 225 deletions(-)
target/m68k/cpu.h +1 -2
@@ -589,6 +589,7 @@ void m68k_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr); +void m68k_dump_mmu (Monitor *mon,CPUM68KState *env);#endif #include "exec/cpu-all.h"
@@ -620,6 +621,4 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, vaddr *pc, } } -void dump_mmu (Monitor *mon,CPUM68KState *env); -#endif
target/m68k/helper.c +0 -222
234 lines not on this page · raw message
target/m68k/monitor.c +222 -1
235 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 07/21] target/m68k: Move MMU monitor commands from helper.c to monitor.c
Quoted 8 lines · Philippe Mathieu-Daudé
Keep all HMP commands in
monitor.c.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/m68k/cpu.h | 3 +- target/m68k/helper.c | 222 ----------------------------------------- target/m68k/monitor.c | 223 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 223 insertions(+), 225 deletions(-)
r~
PATCH 8/21 target/microblaze: Prefix MMU API with 'mb_'
In reply to Philippe Mathieu-DaudéMicroBlaze MMU API is exposed in "mmu.h". In order to avoid name clashing with other targets, prefix the API with 'mb_'.
--- target/microblaze/mmu.h | 10 +++++----- target/microblaze/cpu.c | 2 +- target/microblaze/helper.c | 4 ++-- target/microblaze/mmu.c | 14 +++++++------- target/microblaze/op_helper.c | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-)
target/microblaze/mmu.h +5 -5
@@ -85,10 +85,10 @@ typedef struct { } err; } MicroBlazeMMULookup; -unsigned int mmu_translate (MicroBlazeCPU *cpu,MicroBlazeMMULookup *lu, -target_ulong vaddr,MMUAccessType rw,int mmu_idx); -uint32_t mmu_read (CPUMBState *env,bool ea,uint32_t rn); -void mmu_write (CPUMBState *env,bool ea,uint32_t rn,uint32_t v); -void mmu_init (MicroBlazeMMU *mmu); +unsigned int mb_mmu_translate (MicroBlazeCPU *cpu,MicroBlazeMMULookup *lu, +target_ulong vaddr,MMUAccessType rw,int mmu_idx); +uint32_t mb_mmu_read (CPUMBState *env,bool ea,uint32_t rn); +void mb_mmu_write (CPUMBState *env,bool ea,uint32_t rn,uint32_t v); +void mb_mmu_init (MicroBlazeMMU *mmu);#endif
target/microblaze/cpu.c +1 -1
@@ -205,7 +205,7 @@ static void mb_cpu_reset_hold(Object *obj)mb_cpu_write_msr (env,MSR_EE |MSR_IE |MSR_VM |MSR_UM );#else mb_cpu_write_msr (env,0 ); -mmu_init (&env->mmu); +mb_mmu_init (&env->mmu);#endif }
target/microblaze/helper.c +2 -2
@@ -57,7 +57,7 @@ bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size,return true; } - hit =mmu_translate (cpu, &lu, address, access_type, mmu_idx); + hit =mb_mmu_translate (cpu, &lu, address, access_type, mmu_idx);if (likely (hit)) {uint32_t vaddr = address &TARGET_PAGE_MASK ;uint32_t paddr = lu.paddr + vaddr - lu.vaddr;
@@ -238,7 +238,7 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, attrs->secure =mb_cpu_access_is_secure (cpu,MMU_DATA_LOAD );if (mmu_idx !=MMU_NOMMU_IDX ) { - hit =mmu_translate (cpu, &lu, addr,0 ,0 ); + hit =mb_mmu_translate (cpu, &lu, addr,0 ,0 );if (hit) { vaddr = addr &TARGET_PAGE_MASK ; paddr = lu.paddr + vaddr - lu.vaddr;
target/microblaze/mmu.c +7 -7
@@ -74,8 +74,8 @@ static void mmu_change_pid(CPUMBState *env, unsigned int newpid) }/* rw - 0 = read, 1 = write, 2 = fetch. */ -unsigned int mmu_translate (MicroBlazeCPU *cpu,MicroBlazeMMULookup *lu, -target_ulong vaddr,MMUAccessType rw,int mmu_idx) +unsigned int mb_mmu_translate (MicroBlazeCPU *cpu,MicroBlazeMMULookup *lu, +target_ulong vaddr,MMUAccessType rw,int mmu_idx) {MicroBlazeMMU *mmu = &cpu->env.mmu;unsigned int i, hit =0 ;
@@ -175,7 +175,7 @@ done: }/* Writes/reads to the MMU's special regs end up here. */ -uint32_t mmu_read (CPUMBState *env,bool ext,uint32_t rn) +uint32_t mb_mmu_read (CPUMBState *env,bool ext,uint32_t rn) {MicroBlazeCPU *cpu =env_archcpu (env);unsigned int i;
@@ -228,7 +228,7 @@ uint32_t mmu_read(CPUMBState *env, bool ext, uint32_t rn)return r; } -void mmu_write (CPUMBState *env,bool ext,uint32_t rn,uint32_t v) +void mb_mmu_write (CPUMBState *env,bool ext,uint32_t rn,uint32_t v) {MicroBlazeCPU *cpu =env_archcpu (env);uint64_t tmp64;
@@ -304,8 +304,8 @@ void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v)return ; } - hit =mmu_translate (cpu, &lu, v &TLB_EPN_MASK , -0 ,cpu_mmu_index (env_cpu (env), false)); + hit =mb_mmu_translate (cpu, &lu, v &TLB_EPN_MASK , +0 ,cpu_mmu_index (env_cpu (env), false));if (hit) { env->mmu.regs[MMU_R_TLBX ] = lu.idx; }else {
@@ -319,7 +319,7 @@ void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) } } -void mmu_init (MicroBlazeMMU *mmu) +void mb_mmu_init (MicroBlazeMMU *mmu) {int i;for (i =0 ; i <ARRAY_SIZE (mmu->regs); i++) {
target/microblaze/op_helper.c +2 -2
@@ -386,12 +386,12 @@ void helper_stackprot(CPUMBState *env, target_ulong addr)/* Writes/reads to the MMU's special regs end up here. */ uint32_t helper_mmu_read (CPUMBState *env,uint32_t ext,uint32_t rn) { -return mmu_read (env, ext, rn); +return mb_mmu_read (env, ext, rn); }void helper_mmu_write (CPUMBState *env,uint32_t ext,uint32_t rn,uint32_t v) { -mmu_write (env, ext, rn, v); +mb_mmu_write (env, ext, rn, v); } void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 08/21] target/microblaze: Prefix MMU API with 'mb_'
Quoted 3 lines · Philippe Mathieu-Daudé
MicroBlaze MMU API is exposed in "
mmu.h". In order to avoid name clashing with other targets, prefix the API with 'mb_'.
Quoted 153 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/microblaze/mmu.h | 10 +++++----- target/microblaze/cpu.c | 2 +- target/microblaze/helper.c | 4 ++-- target/microblaze/mmu.c | 14 +++++++------- target/microblaze/op_helper.c | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-)target/microblaze/mmu.h +5
-5@@ -85,10 +85,10 @@ typedef struct { } err; } MicroBlazeMMULookup; -unsigned int mmu_translate (MicroBlazeCPU *cpu,MicroBlazeMMULookup *lu, -target_ulong vaddr,MMUAccessType rw,int mmu_idx); -uint32_t mmu_read (CPUMBState *env,bool ea,uint32_t rn); -void mmu_write (CPUMBState *env,bool ea,uint32_t rn,uint32_t v); -void mmu_init (MicroBlazeMMU *mmu); +unsigned int mb_mmu_translate (MicroBlazeCPU *cpu,MicroBlazeMMULookup *lu, +target_ulong vaddr,MMUAccessType rw,int mmu_idx); +uint32_t mb_mmu_read (CPUMBState *env,bool ea,uint32_t rn); +void mb_mmu_write (CPUMBState *env,bool ea,uint32_t rn,uint32_t v); +void mb_mmu_init (MicroBlazeMMU *mmu);#endif
target/microblaze/cpu.c +1
-1@@ -205,7 +205,7 @@ static void mb_cpu_reset_hold(Object *obj)mb_cpu_write_msr (env,MSR_EE |MSR_IE |MSR_VM |MSR_UM );#else mb_cpu_write_msr (env,0 ); -mmu_init (&env->mmu); +mb_mmu_init (&env->mmu);#endif }target/microblaze/helper.c +1
-1@@ -57,7 +57,7 @@ bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size, return true; } - hit =mmu_translate (cpu, &lu, address, access_type, mmu_idx); + hit =mb_mmu_translate (cpu, &lu, address, access_type, mmu_idx);if (likely (hit)) {uint32_t vaddr = address &TARGET_PAGE_MASK ;uint32_t paddr = lu.paddr + vaddr - lu.vaddr;target/microblaze/helper.c +1
-1@@ -238,7 +238,7 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs,vaddr addr, attrs->secure = mb_cpu_access_is_secure(cpu, MMU_DATA_LOAD);if (mmu_idx !=MMU_NOMMU_IDX ) { - hit =mmu_translate (cpu, &lu, addr,0 ,0 ); + hit =mb_mmu_translate (cpu, &lu, addr,0 ,0 );if (hit) { vaddr = addr &TARGET_PAGE_MASK ;paddr = lu.paddr + vaddr - lu.vaddr;target/microblaze/mmu.c +2
-2@@ -74,8 +74,8 @@ static void mmu_change_pid(CPUMBState *env, unsigned int newpid) }/* rw - 0 = read, 1 = write, 2 = fetch. */ -unsigned int mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu, - target_ulong vaddr, MMUAccessType rw, int mmu_idx) +unsigned int mb_mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu, +target_ulong vaddr,MMUAccessType rw,int mmu_idx){ MicroBlazeMMU *mmu = &cpu->env.mmu; unsigned int i, hit = 0;target/microblaze/mmu.c +2
-2@@ -175,7 +175,7 @@ done: }/* Writes/reads to the MMU's special regs end up here. */ -uint32_t mmu_read (CPUMBState *env,bool ext,uint32_t rn) +uint32_t mb_mmu_read (CPUMBState *env,bool ext,uint32_t rn) {MicroBlazeCPU *cpu =env_archcpu (env);unsigned int i;@@ -228,7 +228,7 @@ uint32_t mmu_read(CPUMBState *env, bool ext, uint32_t rn)return r; } -void mmu_write (CPUMBState *env,bool ext,uint32_t rn,uint32_t v) +void mb_mmu_write (CPUMBState *env,bool ext,uint32_t rn,uint32_t v) {MicroBlazeCPU *cpu =env_archcpu (env);uint64_t tmp64;target/microblaze/mmu.c +2
-2@@ -304,8 +304,8 @@ void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) return; } - hit =mmu_translate (cpu, &lu, v &TLB_EPN_MASK , -0 ,cpu_mmu_index (env_cpu (env), false)); + hit =mb_mmu_translate (cpu, &lu, v &TLB_EPN_MASK , +0 ,cpu_mmu_index (env_cpu (env), false));if (hit) { env->mmu.regs[MMU_R_TLBX ] = lu.idx;} else {target/microblaze/mmu.c +1
-1@@ -319,7 +319,7 @@ void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) } } -void mmu_init (MicroBlazeMMU *mmu) +void mb_mmu_init (MicroBlazeMMU *mmu) {int i;for (i = 0; i < ARRAY_SIZE(mmu->regs); i++) {target/microblaze/op_helper.c +2
-2@@ -386,12 +386,12 @@ void helper_stackprot(CPUMBState *env, target_ulong addr)/* Writes/reads to the MMU's special regs end up here. */ uint32_t helper_mmu_read (CPUMBState *env,uint32_t ext,uint32_t rn) { -return mmu_read (env, ext, rn); +return mb_mmu_read (env, ext, rn); }void helper_mmu_write (CPUMBState *env,uint32_t ext,uint32_t rn,uint32_t v) { -mmu_write (env, ext, rn, v); +mb_mmu_write (env, ext, rn, v); }void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
--
2.41.0
PATCH 9/21 target/mips: Prefix MMU API with 'mips_'
In reply to Philippe Mathieu-DaudéMIPS MMU API declared in tcg-internal.h has public linkage. In order to avoid name clashing with other targets, prefix the API with 'mips_'.
--- target/mips/tcg/tcg-internal.h | 2 +- target/mips/cpu.c | 2 +- target/mips/tcg/sysemu/tlb_helper.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
target/mips/tcg/tcg-internal.h +1 -1
@@ -43,7 +43,7 @@ void do_raise_exception(CPUMIPSState *env,void mips_cpu_do_interrupt (CPUState *cpu);bool mips_cpu_exec_interrupt (CPUState *cpu,int int_req); -void mmu_init (CPUMIPSState *env,const mips_def_t *def); +void mips_mmu_init (CPUMIPSState *env,const mips_def_t *def);void update_pagemask (CPUMIPSState *env,target_ulong arg1,int32_t *pagemask);
target/mips/cpu.c +1 -1
@@ -485,7 +485,7 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp) env->exception_base = (int32_t )0xBFC00000 ;#if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY ) -mmu_init (env, env->cpu_model); +mips_mmu_init (env, env->cpu_model);#endif fpu_init (env, env->cpu_model);mvp_init (env);
target/mips/tcg/sysemu/tlb_helper.c +1 -1
@@ -464,7 +464,7 @@ static void r4k_mmu_init(CPUMIPSState *env, const mips_def_t *def) env->tlb->helper_tlbinvf = r4k_helper_tlbinvf; } -void mmu_init (CPUMIPSState *env,const mips_def_t *def) +void mips_mmu_init (CPUMIPSState *env,const mips_def_t *def) { env->tlb =g_malloc0 (sizeof (CPUMIPSTLBContext));
Signature · 1 line
2.41.0
PATCH 10/21 target/nios2: Prefix MMU API with 'nios2_'
In reply to Philippe Mathieu-DaudéNios2 MMU API is exposed in "mmu.h". In order to avoid name clashing with other targets, prefix the API with 'nios2_'.
--- target/nios2/mmu.h | 11 +++++------ target/nios2/cpu.c | 2 +- target/nios2/helper.c | 4 ++-- target/nios2/mmu.c | 7 +++---- 4 files changed, 11 insertions(+), 13 deletions(-)
target/nios2/mmu.h +5 -6
@@ -42,11 +42,10 @@ typedef struct Nios2MMULookup { int prot; } Nios2MMULookup; -void mmu_flip_um (CPUNios2State *env,unsigned int um); -unsigned int mmu_translate (CPUNios2State *env, -Nios2MMULookup *lu, -target_ulong vaddr,int rw,int mmu_idx); -void mmu_write (CPUNios2State *env,uint32_t rn,uint32_t v); -void mmu_init (CPUNios2State *env); +void nios2_mmu_flip_um (CPUNios2State *env,unsigned int um); +unsigned int nios2_mmu_translate (CPUNios2State *env,Nios2MMULookup *lu, +target_ulong vaddr,int rw,int mmu_idx); +void nios2_mmu_write (CPUNios2State *env,uint32_t rn,uint32_t v); +void nios2_mmu_init (CPUNios2State *env);#endif /* NIOS2_MMU_H */
target/nios2/cpu.c +1 -1
@@ -113,7 +113,7 @@ static void nios2_cpu_initfn(Object *obj)#if !defined(CONFIG_USER_ONLY )Nios2CPU *cpu =NIOS2_CPU (obj); -mmu_init (&cpu->env); +nios2_mmu_init (&cpu->env);#endif }
target/nios2/helper.c +2 -2
@@ -268,7 +268,7 @@ hwaddr nios2_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)unsigned int hit;if (cpu->mmu_present && (addr <0xC0000000 )) { - hit =mmu_translate (env, &lu, addr,0 ,0 ); + hit =nios2_mmu_translate (env, &lu, addr,0 ,0 );if (hit) { vaddr = addr &TARGET_PAGE_MASK ; paddr = lu.paddr + vaddr - lu.vaddr;
@@ -335,7 +335,7 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, }/* Virtual page. */ - hit =mmu_translate (env, &lu, address, access_type, mmu_idx); + hit =nios2_mmu_translate (env, &lu, address, access_type, mmu_idx);if (hit) { vaddr = address &TARGET_PAGE_MASK ; paddr = lu.paddr + vaddr - lu.vaddr;
target/nios2/mmu.c +3 -4
@@ -28,9 +28,8 @@/* rw - 0 = read, 1 = write, 2 = fetch. */ -unsigned int mmu_translate (CPUNios2State *env, -Nios2MMULookup *lu, -target_ulong vaddr,int rw,int mmu_idx) +unsigned int nios2_mmu_translate (CPUNios2State *env,Nios2MMULookup *lu, +target_ulong vaddr,int rw,int mmu_idx) {Nios2CPU *cpu =env_archcpu (env);int pid =FIELD_EX32 (env->mmu.tlbmisc_wr,CR_TLBMISC ,PID );
@@ -180,7 +179,7 @@ void helper_mmu_write_pteaddr(CPUNios2State *env, uint32_t v) env->mmu.pteaddr_wr = v; } -void mmu_init (CPUNios2State *env) +void nios2_mmu_init (CPUNios2State *env) {Nios2CPU *cpu =env_archcpu (env);Nios2MMU *mmu = &env->mmu;
Signature · 1 line
2.41.0
PATCH 11/21 target/nios2: Move monitor commands to monitor.c
In reply to Philippe Mathieu-DaudéMove 'info tlb' monitor commands to monitor.c,
rename dump_mmu() as nios2_info_mmu().
--- target/nios2/cpu.h | 2 +- target/nios2/mmu.c | 27 --------------------------- target/nios2/monitor.c | 28 +++++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 29 deletions(-)
target/nios2/cpu.h +1 -1
@@ -250,7 +250,7 @@ static inline void nios2_update_crs(CPUNios2State *env)void nios2_tcg_init (void );void nios2_cpu_do_interrupt (CPUState *cs); -void dump_mmu (CPUNios2State *env); +void nios2_info_mmu (Monitor *mon,CPUNios2State *env);void nios2_cpu_dump_state (CPUState *cpu,FILE *f,int flags); G_NORETURN void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx,
target/nios2/mmu.c +0 -27
@@ -19,7 +19,6 @@*/ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h" #include "mmu.h"
@@ -187,29 +186,3 @@ void nios2_mmu_init(CPUNios2State *env) mmu->tlb_entry_mask = (cpu->tlb_num_entries / cpu->tlb_num_ways) -1 ; mmu->tlb =g_new0 (Nios2TLBEntry, cpu->tlb_num_entries); } - -void dump_mmu (CPUNios2State *env) -{ -Nios2CPU *cpu =env_archcpu (env); -int i; - -qemu_printf ("MMU: ways %d, entries %d, pid bits %d\n" , - cpu->tlb_num_ways, cpu->tlb_num_entries, - cpu->pid_num_bits); - -for (i =0 ; i < cpu->tlb_num_entries; i++) { -Nios2TLBEntry *entry = &env->mmu.tlb[i]; -qemu_printf ("TLB[%d] = %08X %08X %c VPN %05X " -"PID %02X %c PFN %05X %c%c%c%c\n" , - i, entry->tag, entry->data, - (entry->tag & (1 <<10 )) ?'V' :'-' , - entry->tag >>12 , - entry->tag & ((1 << cpu->pid_num_bits) -1 ), - (entry->tag & (1 <<11 )) ?'G' :'-' , -FIELD_EX32 (entry->data,CR_TLBACC ,PFN ), - (entry->data &CR_TLBACC_C ) ?'C' :'-' , - (entry->data &CR_TLBACC_R ) ?'R' :'-' , - (entry->data &CR_TLBACC_W ) ?'W' :'-' , - (entry->data &CR_TLBACC_X ) ?'X' :'-' ); - } -}
target/nios2/monitor.c +27 -1
@@ -22,14 +22,40 @@* THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "monitor/monitor.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" +void nios2_info_mmu (Monitor *mon,CPUNios2State *env) +{ +Nios2CPU *cpu =env_archcpu (env); + +qemu_printf ("MMU: ways %d, entries %d, pid bits %d\n" , + cpu->tlb_num_ways, cpu->tlb_num_entries, + cpu->pid_num_bits); + +for (int i =0 ; i < cpu->tlb_num_entries; i++) { +Nios2TLBEntry *entry = &env->mmu.tlb[i]; +qemu_printf ("TLB[%d] = %08X %08X %c VPN %05X " +"PID %02X %c PFN %05X %c%c%c%c\n" , + i, entry->tag, entry->data, + (entry->tag & (1 <<10 )) ?'V' :'-' , + entry->tag >>12 , + entry->tag & ((1 << cpu->pid_num_bits) -1 ), + (entry->tag & (1 <<11 )) ?'G' :'-' , +FIELD_EX32 (entry->data,CR_TLBACC ,PFN ), + (entry->data &CR_TLBACC_C ) ?'C' :'-' , + (entry->data &CR_TLBACC_R ) ?'R' :'-' , + (entry->data &CR_TLBACC_W ) ?'W' :'-' , + (entry->data &CR_TLBACC_X ) ?'X' :'-' ); + } +} +void hmp_info_tlb (Monitor *mon,const QDict *qdict) {CPUArchState *env1 =mon_get_cpu_env (mon); -dump_mmu (env1); +nios2_info_mmu (mon, env1); }
Signature · 1 line
2.41.0
PATCH 12/21 target/nios2: Replace qemu_printf() by monitor_printf() in monitor
In reply to Philippe Mathieu-Daudé--- target/nios2/monitor.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
target/nios2/monitor.c +15 -16
@@ -22,7 +22,6 @@* THE SOFTWARE. */ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" #include "cpu.h" #include "monitor/monitor.h" #include "monitor/hmp-target.h"
@@ -32,24 +31,24 @@ void nios2_info_mmu(Monitor *mon, CPUNios2State *env) {Nios2CPU *cpu =env_archcpu (env); -qemu_printf ("MMU: ways %d, entries %d, pid bits %d\n" , - cpu->tlb_num_ways, cpu->tlb_num_entries, - cpu->pid_num_bits); +monitor_printf (mon,"MMU: ways %d, entries %d, pid bits %d\n" , + cpu->tlb_num_ways, cpu->tlb_num_entries, + cpu->pid_num_bits);for (int i =0 ; i < cpu->tlb_num_entries; i++) {Nios2TLBEntry *entry = &env->mmu.tlb[i]; -qemu_printf ("TLB[%d] = %08X %08X %c VPN %05X " -"PID %02X %c PFN %05X %c%c%c%c\n" , - i, entry->tag, entry->data, - (entry->tag & (1 <<10 )) ?'V' :'-' , - entry->tag >>12 , - entry->tag & ((1 << cpu->pid_num_bits) -1 ), - (entry->tag & (1 <<11 )) ?'G' :'-' , -FIELD_EX32 (entry->data,CR_TLBACC ,PFN ), - (entry->data &CR_TLBACC_C ) ?'C' :'-' , - (entry->data &CR_TLBACC_R ) ?'R' :'-' , - (entry->data &CR_TLBACC_W ) ?'W' :'-' , - (entry->data &CR_TLBACC_X ) ?'X' :'-' ); +monitor_printf (mon,"TLB[%d] = %08X %08X %c VPN %05X " +"PID %02X %c PFN %05X %c%c%c%c\n" , + i, entry->tag, entry->data, + (entry->tag & (1 <<10 )) ?'V' :'-' , + entry->tag >>12 , + entry->tag & ((1 << cpu->pid_num_bits) -1 ), + (entry->tag & (1 <<11 )) ?'G' :'-' , +FIELD_EX32 (entry->data,CR_TLBACC ,PFN ), + (entry->data &CR_TLBACC_C ) ?'C' :'-' , + (entry->data &CR_TLBACC_R ) ?'R' :'-' , + (entry->data &CR_TLBACC_W ) ?'W' :'-' , + (entry->data &CR_TLBACC_X ) ?'X' :'-' ); } }
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 12/21] target/nios2: Replace qemu_printf() by monitor_printf() in monitor
Quoted 1 line · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Same "why?" as for PATCH 05.
PATCH 13/21 target/ppc: Replace qemu_printf() by monitor_printf() in monitor
In reply to Philippe Mathieu-DaudéReplace qemu_printf() by monitor_printf() / monitor_puts() in monitor.
--- target/ppc/cpu.h | 2 +- target/ppc/mmu_common.c | 147 +++++++++++++++++++------------------- target/ppc/ppc-qmp-cmds.c | 2 +- 3 files changed, 77 insertions(+), 74 deletions(-)
target/ppc/cpu.h +1 -1
@@ -2982,7 +2982,7 @@ static inline bool ppc_interrupts_little_endian(PowerPCCPU *cpu, bool hv) }#endif -void dump_mmu (CPUPPCState *env); +void ppc_dump_mmu (Monitor *mon,CPUPPCState *env);void ppc_maybe_bswap_register (CPUPPCState *env,uint8_t *mem_buf,int len);void ppc_store_vscr (CPUPPCState *env,uint32_t vscr);
target/ppc/mmu_common.c +75 -72
253 lines not on this page · raw message
target/ppc/ppc-qmp-cmds.c +1 -1
@@ -88,7 +88,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu (env1); +ppc_dump_mmu (mon, env1); }const MonitorDef monitor_defs[] = {
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 13/21] target/ppc: Replace qemu_printf() by monitor_printf() in monitor
Quoted 3 lines · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
My review comments to PATCH 05 apply.
PATCH 14/21 target/sh4: Extract sh4_dump_mmu() from hmp_info_tlb()
In reply to Philippe Mathieu-DaudéExtract sh4_dump_mmu() from hmp_info_tlb(), replacing monitor_printf(FIXED_STRING_WITHOUT_FORMAT) by monitor_puts().
--- target/sh4/cpu.h | 2 ++ target/sh4/monitor.c | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-)
target/sh4/cpu.h +2 -0
@@ -385,4 +385,6 @@ static inline void cpu_get_tb_cpu_state(CPUSH4State *env, vaddr *pc, #endif } +void sh4_dump_mmu (Monitor *mon,CPUSH4State *env); +#endif /* SH4_CPU_H */
target/sh4/monitor.c +15 -7
@@ -39,20 +39,28 @@ static void print_tlb(Monitor *mon, int idx, tlb_t *tlb) tlb->d, tlb->wt); } +void sh4_dump_mmu (Monitor *mon,CPUSH4State *env) +{ +int i; + +monitor_puts (mon,"ITLB:\n" ); +for (i =0 ; i <ITLB_SIZE ; i++) { +print_tlb (mon, i, &env->itlb[i]); + } +monitor_puts (mon,"UTLB:\n" ); +for (i =0 ; i <UTLB_SIZE ; i++) { +print_tlb (mon, i, &env->utlb[i]); + } +} +void hmp_info_tlb (Monitor *mon,const QDict *qdict) {CPUArchState *env =mon_get_cpu_env (mon); -int i;if (!env) {monitor_printf (mon,"No CPU available\n" );return ; } -monitor_printf (mon,"ITLB:\n" ); -for (i =0 ; i <ITLB_SIZE ; i++) -print_tlb (mon, i, &env->itlb[i]); -monitor_printf (mon,"UTLB:\n" ); -for (i =0 ; i <UTLB_SIZE ; i++) -print_tlb (mon, i, &env->utlb[i]); +sh4_dump_mmu (mon, env); }
Signature · 1 line
2.41.0
PATCH 15/21 target/sparc: Fix string format errors when DEBUG_MMU is defined
In reply to Philippe Mathieu-DaudéFix when building with DEBUG_MMU:
target/sparc/ldst_helper.c:245:72: error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
DPRINTF_MMU("auto demap entry [%d] %lx->%lx\n", i, vaddr,
~~~ ^~~~~
%llx
target/sparc/ldst_helper.c:1736:60: error: no member named 'immuregs' in 'struct CPUArchState'
PRIx64 "\n", reg, oldreg, env->immuregs[reg]);
~~~ ^
target/sparc/ldst_helper.c:1820:60: error: no member named 'dmmuregs' in 'struct CPUArchState'
PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]);
~~~ ^--- target/sparc/ldst_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/sparc/ldst_helper.c +4 -4
@@ -242,8 +242,8 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,if (new_vaddr == vaddr || (new_vaddr < vaddr + size && vaddr < new_vaddr + new_size)) { -DPRINTF_MMU ("auto demap entry [%d] %lx->%lx\n" , i, vaddr, - new_vaddr); +DPRINTF_MMU ("auto demap entry [%d] %" PRIx64"->%" PRIx64"\n" , + i, vaddr, new_vaddr);replace_tlb_entry (&tlb[i], tlb_tag, tlb_tte, env1);return ; }
@@ -1733,7 +1733,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,if (oldreg != env->immu.mmuregs[reg]) {DPRINTF_MMU ("immu change reg[%d]: 0x%016" PRIx64" -> 0x%016" - PRIx64"\n" , reg, oldreg, env->immuregs[reg]); + PRIx64"\n" , reg, oldreg, env->immu.mmuregs[reg]); }#ifdef DEBUG_MMU dump_mmu (env);
@@ -1817,7 +1817,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,if (oldreg != env->dmmu.mmuregs[reg]) {DPRINTF_MMU ("dmmu change reg[%d]: 0x%016" PRIx64" -> 0x%016" - PRIx64"\n" , reg, oldreg, env->dmmuregs[reg]); + PRIx64"\n" , reg, oldreg, env->dmmu.mmuregs[reg]); }#ifdef DEBUG_MMU dump_mmu (env);
Signature · 1 line
2.41.0
PATCH 16/21 target/sparc: Replace qemu_printf() by monitor_printf() in monitor
In reply to Philippe Mathieu-DaudéReplace qemu_printf() by monitor_printf() in monitor.c. Rename dump_mmu() as sparc_dump_mmu().
--- target/sparc/cpu.h | 2 +- target/sparc/ldst_helper.c | 18 +++---- target/sparc/mmu_helper.c | 102 ++++++++++++++++++------------------- target/sparc/monitor.c | 2 +- 4 files changed, 62 insertions(+), 62 deletions(-)
target/sparc/cpu.h +1 -1
@@ -601,7 +601,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr);target_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev); -void dump_mmu (CPUSPARCState *env); +void sparc_dump_mmu (Monitor *mon,CPUSPARCState *env);#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
target/sparc/ldst_helper.c +9 -9
@@ -195,7 +195,7 @@ static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr,replace_tlb_entry (&tlb[i],0 ,0 , env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s demap invalidated entry [%02u]\n" , strmmu, i); -dump_mmu (env1); +sparc_dump_mmu (env1);#endif } }
@@ -257,7 +257,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,replace_tlb_entry (&tlb[i], tlb_tag, tlb_tte, env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s lru replaced invalid entry [%i]\n" , strmmu, i); -dump_mmu (env1); +sparc_dump_mmu (env1);#endif return ; }
@@ -276,7 +276,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,#ifdef DEBUG_MMU DPRINTF_MMU ("%s lru replaced unlocked %s entry [%i]\n" , strmmu, (replace_used ?"used" :"unused" ), i); -dump_mmu (env1); +sparc_dump_mmu (env1);#endif return ; }
@@ -995,7 +995,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,break ; }#ifdef DEBUG_MMU -dump_mmu (env); +sparc_dump_mmu (env);#endif }break ;
@@ -1050,7 +1050,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val, reg, oldreg, env->mmuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (env); +sparc_dump_mmu (env);#endif }break ;
@@ -1736,7 +1736,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (env); +sparc_dump_mmu (env);#endif return ; }
@@ -1760,7 +1760,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, }#ifdef DEBUG_MMU DPRINTF_MMU ("immu data access replaced entry [%i]\n" , i); -dump_mmu (env); +sparc_dump_mmu (env);#endif return ; }
@@ -1820,7 +1820,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, PRIx64 "\n", reg, oldreg, env->dmmu.mmuregs[reg]); }#ifdef DEBUG_MMU -dump_mmu (env); +sparc_dump_mmu (env);#endif return ; }
@@ -1842,7 +1842,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, }#ifdef DEBUG_MMU DPRINTF_MMU ("dmmu data access replaced entry [%i]\n" , i); -dump_mmu (env); +sparc_dump_mmu (env);#endif return ; }
target/sparc/mmu_helper.c +51 -51
161 lines not on this page · raw message
target/sparc/monitor.c +1 -1
@@ -36,7 +36,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict)monitor_printf (mon,"No CPU available\n" );return ; } -dump_mmu (env1); +sparc_dump_mmu (mon, env1); }#ifndef TARGET_SPARC64
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 16/21] target/sparc: Replace qemu_printf() by monitor_printf() in monitor
Quoted 4 lines · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()inmonitor.c. Renamedump_mmu()assparc_dump_mmu().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Same "why?" and "suggest to mention passing current monitor" as for PATCH 05.
In addition:
Quoted 25 lines
--- target/sparc/cpu.h | 2 +- target/sparc/ldst_helper.c | 18 +++---- target/sparc/mmu_helper.c | 102 ++++++++++++++++++------------------- target/sparc/monitor.c | 2 +- 4 files changed, 62 insertions(+), 62 deletions(-)target/sparc/cpu.h +1
-1@@ -601,7 +601,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr);target_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev); -void dump_mmu (CPUSPARCState *env); +void sparc_dump_mmu (Monitor *mon,CPUSPARCState *env);#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,target/sparc/ldst_helper.c +0
-0
target/sparc/ldst_helper.c static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr, · line 198
Quoted 5 lines
target/sparc/ldst_helper.c +1
-1@@ -195,7 +195,7 @@ static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr,replace_tlb_entry (&tlb[i],0 ,0 , env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s demap invalidated entry [%02u]\n" , strmmu, i); -dump_mmu (env1); +sparc_dump_mmu (env1);
You add a parameter below. I don't think this compiles :)
Several more instances follow.
target/sparc/ldst_helper.c static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr, · line 201
Quoted 3 lines
target/sparc/ldst_helper.c +0
-0#endif } }
[...]
With that fixed
Re: [PATCH-for-9.1 16/21] target/sparc: Replace qemu_printf() by monitor_printf() in monitor
Quoted 30 lines · Markus Armbruster
Quoted 4 lines · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()inmonitor.c. Renamedump_mmu()assparc_dump_mmu().Signed-off-by Philippe Mathieu-Daudé <[email protected]>Same "why?" and "suggest to mention passing current monitor" as for PATCH 05.
In addition:
Quoted 18 lines
--- target/sparc/cpu.h | 2 +- target/sparc/ldst_helper.c | 18 +++---- target/sparc/mmu_helper.c | 102 ++++++++++++++++++------------------- target/sparc/monitor.c | 2 +- 4 files changed, 62 insertions(+), 62 deletions(-)target/sparc/cpu.h +1
-1@@ -601,7 +601,7 @@ bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr);target_ulong mmu_probe (CPUSPARCState *env,target_ulong address,int mmulev); -void dump_mmu (CPUSPARCState *env); +void sparc_dump_mmu (Monitor *mon,CPUSPARCState *env);
Quoted 14 lines
target/sparc/ldst_helper.c static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr, · line 198
Quoted 12 lines
target/sparc/cpu.h +0
-0#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr,target/sparc/ldst_helper.c +1
-1@@ -195,7 +195,7 @@ static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr,replace_tlb_entry (&tlb[i],0 ,0 , env1);#ifdef DEBUG_MMU DPRINTF_MMU ("%s demap invalidated entry [%02u]\n" , strmmu, i); -dump_mmu (env1); +sparc_dump_mmu (env1);You add a parameter below. I don't think this compiles :)
It does compile, because this is dead code (guarded by undefined DEBUG_MMU). Good example that dead code tends to bitrot, thanks for noticing.
Quoted 12 lines
Several more instances follow.
target/sparc/ldst_helper.c static void demap_tlb(SparcTLBEntry *tlb, target_ulong demap_addr, · line 201
Quoted 3 lines
target/sparc/ldst_helper.c +0
-0#endif } }[...]
With that fixed
Reviewed-by Markus Armbruster <[email protected]>
PATCH 17/21 target/xtensa: Prefix MMU API with 'xtensa_'
In reply to Philippe Mathieu-DaudéIn order to extract the MMU API to a new "mmu.h" header, prefix it with the target name.
--- target/xtensa/cpu.h | 4 ++-- target/xtensa/cpu.c | 2 +- target/xtensa/mmu_helper.c | 41 +++++++++++++++++++++----------------- target/xtensa/monitor.c | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-)
target/xtensa/cpu.h +2 -2
@@ -692,8 +692,8 @@ static inline int xtensa_get_cring(const CPUXtensaState *env)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_reset_mmu (CPUXtensaState *env); +void xtensa_dump_mmu (CPUXtensaState *env);static inline MemoryRegion *xtensa_get_er_region (CPUXtensaState *env) {
target/xtensa/cpu.c +1 -1
@@ -130,7 +130,7 @@ static void xtensa_cpu_reset_hold(Object *obj) env->exclusive_addr =-1 ;#ifndef CONFIG_USER_ONLY -reset_mmu (env); +xtensa_reset_mmu (env); cs->halted = env->runstall;#endif set_no_signaling_nans (!dfpu, &env->fp_status);
target/xtensa/mmu_helper.c +23 -18
125 lines not on this page · raw message
target/xtensa/monitor.c +1 -1
@@ -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_dump_mmu (env1); }
Signature · 1 line
2.41.0
PATCH 18/21 target/xtensa: Extract MMU API to new mmu.c/mmu.h files
In reply to Philippe Mathieu-DaudéExtract the MMU API and expose it via "mmu.h" so we can reuse the methods in target/xtensa/ files.
--- target/xtensa/cpu.h | 32 +- target/xtensa/mmu.h | 95 ++++ target/xtensa/mmu.c | 889 ++++++++++++++++++++++++++++++++++++ target/xtensa/mmu_helper.c | 892 +------------------------------------ target/xtensa/meson.build | 1 + 5 files changed, 991 insertions(+), 918 deletions(-) create mode 100644 target/xtensa/mmu.h create mode 100644 target/xtensa/mmu.c
target/xtensa/cpu.h +4 -28
@@ -34,6 +34,10 @@#include "hw/clock.h" #include "xtensa-isa.h" +typedef struct CPUArchState CPUXtensaState ; + +#include "mmu.h" +/* Xtensa processors have a weak memory model */ #define TCG_GUEST_DEFAULT_MO (0)
@@ -309,28 +313,6 @@ typedef enum {INTTYPE_MAX } interrupt_type; -typedef struct CPUArchState CPUXtensaState ; - -typedef struct xtensa_tlb_entry { -uint32_t vaddr; -uint32_t paddr; -uint8_t asid; -uint8_t attr; -bool variable; -}xtensa_tlb_entry ; - -typedef struct xtensa_tlb { -unsigned nways; -const unsigned way_size[10 ]; -bool varway56; -unsigned nrefillentries; -}xtensa_tlb ; - -typedef struct xtensa_mpu_entry { -uint32_t vaddr; -uint32_t attr; -}xtensa_mpu_entry ; - typedef struct XtensaGdbReg { int targno; unsigned flags;
@@ -689,12 +671,6 @@ static inline int xtensa_get_cring(const CPUXtensaState *env) }#ifndef CONFIG_USER_ONLY -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 xtensa_reset_mmu (CPUXtensaState *env); -void xtensa_dump_mmu (CPUXtensaState *env); -static inline MemoryRegion *xtensa_get_er_region (CPUXtensaState *env) {return env->system_er;
target/xtensa/mmu.h new file +95 -0
95 lines not on this page · raw message
target/xtensa/mmu.c new file +889 -0
889 lines not on this page · raw message
target/xtensa/mmu_helper.c +2 -890
920 lines not on this page · raw message
target/xtensa/meson.build +1 -0
@@ -18,6 +18,7 @@ xtensa_ss.add(files( xtensa_system_ss = ss.source_set() xtensa_system_ss.add(files( 'dbg_helper.c', + 'mmu.c', 'mmu_helper.c', 'monitor.c', 'xtensa-semi.c',
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 18/21] target/xtensa: Extract MMU API to new mmu.c/mmu.h files
Quoted 3 lines · Philippe Mathieu-Daudé
Extract the MMU API and expose it via "
mmu.h" so we can reuse the methods in target/xtensa/ files.
The MMU/MPU are replaceable configuration blocks in the xtensa architecture, their internals don't have architecture-wide significance and I believe their exposure should be kept to a minimum.
I have a half-done xtensa MMU rework which I'd like to complete, it only exposes the interface for address translation, opcode translation and dumping.
Quoted 10 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/xtensa/cpu.h | 32 +- target/xtensa/mmu.h | 95 ++++ target/xtensa/mmu.c | 889 ++++++++++++++++++++++++++++++++++++ target/xtensa/mmu_helper.c | 892 +------------------------------------ target/xtensa/meson.build | 1 + 5 files changed, 991 insertions(+), 918 deletions(-) create mode 100644 target/xtensa/mmu.h create mode 100644 target/xtensa/mmu.c
Signature · 2 lines
Thanks. -- Max
PATCH 19/21 target/xtensa: Simplify dump_mpu() and dump_tlb()
In reply to Philippe Mathieu-DaudéRemove few qemu_printf() calls in xtensa_dump_mmu() by slightly reworking dump_mpu() and dump_tlb().
--- target/xtensa/mmu_helper.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
target/xtensa/mmu_helper.c +9 -7
@@ -203,6 +203,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; +qemu_printf ("%s:\n" , dtlb ?"DTLB" :"IBLB" );for (wi =0 ; wi < conf->nways; ++wi) {uint32_t sz = ~xtensa_tlb_get_addr_mask (env, dtlb, wi) +1 ;const char *sz_text;
@@ -252,11 +253,12 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb) } } -static void dump_mpu (CPUXtensaState *env, +static void dump_mpu (CPUXtensaState *env,const char *map_desc,const xtensa_mpu_entry *entry,unsigned n) {unsigned i; +qemu_printf ("%s map:\n" , map_desc); qemu_printf("\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n" "\t%s ---------- ---------- ----- ----- ------------- ---------\n", env ? "En" : " ",
@@ -316,15 +318,15 @@ void xtensa_dump_mmu(CPUXtensaState *env) 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" ); +qemu_printf ("\n" );dump_tlb (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); +dump_mpu (env,"Foreground" , + env->mpu_fg, env->config->n_mpu_fg_segments); +qemu_printf ("\n" ); +dump_mpu (NULL ,"Background" , + env->config->mpu_bg, env->config->n_mpu_bg_segments); } else {qemu_printf ("No TLB for this CPU core\n" ); }
Signature · 1 line
2.41.0
PATCH 20/21 target/xtensa: Move monitor commands to monitor.c
In reply to Philippe Mathieu-Daudé--- target/xtensa/mmu_helper.c | 140 ------------------------------------ target/xtensa/monitor.c | 144 ++++++++++++++++++++++++++++++++++++- 2 files changed, 143 insertions(+), 141 deletions(-)
target/xtensa/mmu_helper.c +0 -140
@@ -26,8 +26,6 @@*/ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" -#include "qemu/units.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "cpu.h"
@@ -193,141 +191,3 @@ uint32_t HELPER(pptlb)(CPUXtensaState *env, uint32_t v)return env->config->mpu_bg[bg_segment].attr | segment; } } - -static void dump_tlb (CPUXtensaState *env,bool dtlb) -{ -unsigned wi, ei; -const xtensa_tlb *conf = - dtlb ? &env->config->dtlb : &env->config->itlb; -unsigned (*attr_to_access)(uint32_t ) = -xtensa_option_enabled (env->config,XTENSA_OPTION_MMU ) ? - mmu_attr_to_access : region_attr_to_access; - -qemu_printf ("%s:\n" , dtlb ?"DTLB" :"IBLB" ); -for (wi =0 ; wi < conf->nways; ++wi) { -uint32_t sz = ~xtensa_tlb_get_addr_mask (env, dtlb, wi) +1 ; -const char *sz_text; -bool print_header = true; - -if (sz >=0x100000 ) { - sz /= MiB; - sz_text ="MB" ; - }else { - sz /= KiB; - sz_text ="KB" ; - } - -for (ei =0 ; ei < conf->way_size[wi]; ++ei) { -const xtensa_tlb_entry *entry = -xtensa_tlb_get_entry (env, dtlb, wi, ei); - -if (entry->asid) { -static const char *const cache_text[8 ] = { - [PAGE_CACHE_BYPASS >>PAGE_CACHE_SHIFT ] ="Bypass" , - [PAGE_CACHE_WT >>PAGE_CACHE_SHIFT ] ="WT" , - [PAGE_CACHE_WB >>PAGE_CACHE_SHIFT ] ="WB" , - [PAGE_CACHE_ISOLATE >>PAGE_CACHE_SHIFT ] ="Isolate" , - }; -unsigned access =attr_to_access (entry->attr); -unsigned cache_idx = (access &PAGE_CACHE_MASK ) >> -PAGE_CACHE_SHIFT ; - -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" -"\t---------- ---------- ---- ---- --- -------\n" ); - } -qemu_printf ("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %s\n" , - entry->vaddr, - entry->paddr, - entry->asid, - entry->attr, - (access &PAGE_READ ) ?'R' :'-' , - (access &PAGE_WRITE ) ?'W' :'-' , - (access &PAGE_EXEC ) ?'X' :'-' , - cache_text[cache_idx] ? - cache_text[cache_idx] :"Invalid" ); - } - } - } -} - -static void dump_mpu (CPUXtensaState *env,const char *map_desc, -const xtensa_mpu_entry *entry,unsigned n) -{ -unsigned i; - -qemu_printf ("%s map:\n" , map_desc); -qemu_printf ("\t%s Vaddr Attr Ring0 Ring1 System Type CPU cache\n" -"\t%s ---------- ---------- ----- ----- ------------- ---------\n" , - env ?"En" :" " , - env ?"--" :" " ); - -for (i =0 ; i < n; ++i) { -uint32_t attr = entry[i].attr; -unsigned access0 =mpu_attr_to_access (attr,0 ); -unsigned access1 =mpu_attr_to_access (attr,1 ); -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 " , - env ? - ((env->sregs[MPUENB ] & (1u << i)) ?'+' :'-' ) :' ' , - entry[i].vaddr, attr, - (access0 &PAGE_READ ) ?'R' :'-' , - (access0 &PAGE_WRITE ) ?'W' :'-' , - (access0 &PAGE_EXEC ) ?'X' :'-' , - (access1 &PAGE_READ ) ?'R' :'-' , - (access1 &PAGE_WRITE ) ?'W' :'-' , - (access1 &PAGE_EXEC ) ?'X' :'-' ); - -switch (type &XTENSA_MPU_SYSTEM_TYPE_MASK ) { -case XTENSA_MPU_SYSTEM_TYPE_DEVICE : -qemu_printf ("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" , - (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" , - (type &XTENSA_MPU_TYPE_SYS_R ) ?'R' :'-' , - (type &XTENSA_MPU_TYPE_SYS_W ) ?'W' :'-' , - (type &XTENSA_MPU_TYPE_SYS_C ) ?'C' :'-' , - (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 ; -default : -qemu_printf ("Unknown\n" ); -break ; - } - } -} - -void xtensa_dump_mmu (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 ))) { - -dump_tlb (env, false); -qemu_printf ("\n" ); -dump_tlb (env, true); - }else if (xtensa_option_enabled (env->config,XTENSA_OPTION_MPU )) { -dump_mpu (env,"Foreground" , - env->mpu_fg, env->config->n_mpu_fg_segments); -qemu_printf ("\n" ); -dump_mpu (NULL ,"Background" , - env->config->mpu_bg, env->config->n_mpu_bg_segments); - }else { -qemu_printf ("No TLB for this CPU core\n" ); - } -}
target/xtensa/monitor.c +143 -1
153 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH 21/21 target/xtensa: Replace qemu_printf() by monitor_printf() in monitor
In reply to Philippe Mathieu-DaudéReplace qemu_printf() by monitor_printf() / monitor_puts() in monitor.
--- target/xtensa/mmu.h | 2 +- target/xtensa/monitor.c | 117 ++++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 58 deletions(-)
target/xtensa/mmu.h +1 -1
@@ -90,6 +90,6 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, unsigned *access);void xtensa_reset_mmu (CPUXtensaState *env); -void xtensa_dump_mmu (CPUXtensaState *env); +void xtensa_dump_mmu (Monitor *mon,CPUXtensaState *env);#endif
target/xtensa/monitor.c +60 -57
185 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH-for-9.1 21/21] target/xtensa: Replace qemu_printf() by monitor_printf() in monitor
Quoted 3 lines · Philippe Mathieu-Daudé
Replace
qemu_printf()bymonitor_printf()/monitor_puts()in monitor.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
My review comments to PATCH 05 apply.