qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 50/53] monitor: merge duplicate "info tlb" handlers


From: David Gibson
Subject: Re: [PATCH v2 50/53] monitor: merge duplicate "info tlb" handlers
Date: Wed, 15 Sep 2021 11:41:28 +1000

On Tue, Sep 14, 2021 at 03:20:39PM +0100, Daniel P. Berrangé wrote:
> Now that all target architectures are converted to use the "format_tlb"
> callback, we can merge all the duplicate "info tlb" handlers into one
> and remove the architecture condition on the command.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

ppc parts
Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hmp-commands-info.hx         |  3 ---
>  include/monitor/hmp-target.h |  1 -
>  monitor/misc.c               | 15 +++++++++++++++
>  target/i386/monitor.c        | 15 ---------------
>  target/m68k/monitor.c        | 15 ---------------
>  target/nios2/monitor.c       | 15 ---------------
>  target/ppc/monitor.c         | 15 ---------------
>  target/sh4/monitor.c         | 15 ---------------
>  target/sparc/monitor.c       | 16 ----------------
>  target/xtensa/monitor.c      | 15 ---------------
>  10 files changed, 15 insertions(+), 110 deletions(-)
> 
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index f8312342cd..7bd1e04d46 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -206,8 +206,6 @@ SRST
>      Show PCI information.
>  ERST
>  
> -#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
> -    defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K)
>      {
>          .name       = "tlb",
>          .args_type  = "",
> @@ -215,7 +213,6 @@ ERST
>          .help       = "show virtual to physical memory mappings",
>          .cmd        = hmp_info_tlb,
>      },
> -#endif
>  
>  SRST
>    ``info tlb``
> diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h
> index df79ad3355..04e02e8895 100644
> --- a/include/monitor/hmp-target.h
> +++ b/include/monitor/hmp-target.h
> @@ -45,7 +45,6 @@ CPUArchState *mon_get_cpu_env(Monitor *mon);
>  CPUState *mon_get_cpu(Monitor *mon);
>  
>  void hmp_info_mem(Monitor *mon, const QDict *qdict);
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict);
>  void hmp_mce(Monitor *mon, const QDict *qdict);
>  void hmp_info_local_apic(Monitor *mon, const QDict *qdict);
>  
> diff --git a/monitor/misc.c b/monitor/misc.c
> index 6b07efdddd..c7d138914d 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -936,6 +936,21 @@ static void hmp_info_mtree(Monitor *mon, const QDict 
> *qdict)
>      mtree_info(flatview, dispatch_tree, owner, disabled);
>  }
>  
> +static void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> +{
> +    g_autoptr(GString) buf = g_string_new("");
> +    CPUState *cpu = mon_get_cpu(mon);
> +
> +    if (!cpu) {
> +        monitor_printf(mon, "No CPU available\n");
> +        return;
> +    }
> +
> +    cpu_format_tlb(cpu, buf);
> +
> +    monitor_printf(mon, "%s", buf->str);
> +}
> +
>  static void hmp_info_profile(Monitor *mon, const QDict *qdict)
>  {
>      Error *err = NULL;
> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
> index 698fbbc80b..a7eb4205c7 100644
> --- a/target/i386/monitor.c
> +++ b/target/i386/monitor.c
> @@ -248,21 +248,6 @@ void x86_cpu_format_tlb(CPUState *cpu, GString *buf)
>      }
>  }
>  
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> -{
> -    g_autoptr(GString) buf = g_string_new("");
> -    CPUState *cpu = mon_get_cpu(mon);
> -
> -    if (!cpu) {
> -        monitor_printf(mon, "No CPU available\n");
> -        return;
> -    }
> -
> -    cpu_format_tlb(cpu, buf);
> -
> -    monitor_printf(mon, "%s", buf->str);
> -}
> -
>  static void mem_print(Monitor *mon, CPUArchState *env,
>                        hwaddr *pstart, int *plast_prot,
>                        hwaddr end, int prot)
> diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c
> index 003a665246..0dc729692b 100644
> --- a/target/m68k/monitor.c
> +++ b/target/m68k/monitor.c
> @@ -12,21 +12,6 @@
>  #include "qapi/error.h"
>  #include "qapi/qapi-commands-machine-target.h"
>  
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> -{
> -    g_autoptr(GString) buf = g_string_new("");
> -    CPUState *cpu = mon_get_cpu(mon);
> -
> -    if (!cpu) {
> -        monitor_printf(mon, "No CPU available\n");
> -        return;
> -    }
> -
> -    cpu_format_tlb(cpu, buf);
> -
> -    monitor_printf(mon, "%s", buf->str);
> -}
> -
>  static const MonitorDef monitor_defs[] = {
>      { "d0", offsetof(CPUM68KState, dregs[0]) },
>      { "d1", offsetof(CPUM68KState, dregs[1]) },
> diff --git a/target/nios2/monitor.c b/target/nios2/monitor.c
> index 99d35e8ef1..1180a32f80 100644
> --- a/target/nios2/monitor.c
> +++ b/target/nios2/monitor.c
> @@ -26,18 +26,3 @@
>  #include "monitor/monitor.h"
>  #include "monitor/hmp-target.h"
>  #include "monitor/hmp.h"
> -
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> -{
> -    g_autoptr(GString) buf = g_string_new("");
> -    CPUState *cpu = mon_get_cpu(mon);
> -
> -    if (!cpu) {
> -        monitor_printf(mon, "No CPU available\n");
> -        return;
> -    }
> -
> -    cpu_format_tlb(cpu, buf);
> -
> -    monitor_printf(mon, "%s", buf->str);
> -}
> diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c
> index 401a36c2eb..3564fd5f45 100644
> --- a/target/ppc/monitor.c
> +++ b/target/ppc/monitor.c
> @@ -65,21 +65,6 @@ static target_long monitor_get_tbl(Monitor *mon, const 
> struct MonitorDef *md,
>      return cpu_ppc_load_tbl(env);
>  }
>  
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> -{
> -    g_autoptr(GString) buf = g_string_new("");
> -    CPUState *cpu = mon_get_cpu(mon);
> -
> -    if (!cpu) {
> -        monitor_printf(mon, "No CPU available\n");
> -        return;
> -    }
> -
> -    cpu_format_tlb(cpu, buf);
> -
> -    monitor_printf(mon, "%s", buf->str);
> -}
> -
>  const MonitorDef monitor_defs[] = {
>      { "fpscr", offsetof(CPUPPCState, fpscr) },
>      /* Next instruction pointer */
> diff --git a/target/sh4/monitor.c b/target/sh4/monitor.c
> index 5ccb95af93..d641d95316 100644
> --- a/target/sh4/monitor.c
> +++ b/target/sh4/monitor.c
> @@ -53,18 +53,3 @@ void superh_cpu_format_tlb(CPUState *cpu, GString *buf)
>          print_tlb(buf, i, &env->utlb[i]);
>      }
>  }
> -
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> -{
> -    g_autoptr(GString) buf = g_string_new("");
> -    CPUState *cpu = mon_get_cpu(mon);
> -
> -    if (!cpu) {
> -        monitor_printf(mon, "No CPU available\n");
> -        return;
> -    }
> -
> -    cpu_format_tlb(cpu, buf);
> -
> -    monitor_printf(mon, "%s", buf->str);
> -}
> diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c
> index cc7fe74e3e..0c51669c08 100644
> --- a/target/sparc/monitor.c
> +++ b/target/sparc/monitor.c
> @@ -27,22 +27,6 @@
>  #include "monitor/hmp-target.h"
>  #include "monitor/hmp.h"
>  
> -
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> -{
> -    g_autoptr(GString) buf = g_string_new("");
> -    CPUState *cpu = mon_get_cpu(mon);
> -
> -    if (!cpu) {
> -        monitor_printf(mon, "No CPU available\n");
> -        return;
> -    }
> -
> -    cpu_format_tlb(cpu, buf);
> -
> -    monitor_printf(mon, "%s", buf->str);
> -}
> -
>  #ifndef TARGET_SPARC64
>  static target_long monitor_get_psr(Monitor *mon, const struct MonitorDef *md,
>                                     int val)
> diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c
> index 99d35e8ef1..1180a32f80 100644
> --- a/target/xtensa/monitor.c
> +++ b/target/xtensa/monitor.c
> @@ -26,18 +26,3 @@
>  #include "monitor/monitor.h"
>  #include "monitor/hmp-target.h"
>  #include "monitor/hmp.h"
> -
> -void hmp_info_tlb(Monitor *mon, const QDict *qdict)
> -{
> -    g_autoptr(GString) buf = g_string_new("");
> -    CPUState *cpu = mon_get_cpu(mon);
> -
> -    if (!cpu) {
> -        monitor_printf(mon, "No CPU available\n");
> -        return;
> -    }
> -
> -    cpu_format_tlb(cpu, buf);
> -
> -    monitor_printf(mon, "%s", buf->str);
> -}

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]