diff mbox series

[1/8] target/ppc: Print out literal exception names in logs

Message ID 20211222064025.1541490-2-clg@kaod.org
State Superseded
Headers show
Series ppc/ppc405: Fixes | expand

Commit Message

Cédric Le Goater Dec. 22, 2021, 6:40 a.m. UTC
It facilitates reading the logs when mask CPU_LOG_INT is activated. We
should do the same for error codes.

Cc: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 target/ppc/excp_helper.c | 75 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 74 insertions(+), 1 deletion(-)

Comments

Fabiano Rosas Dec. 22, 2021, 10 a.m. UTC | #1
Cédric Le Goater <clg@kaod.org> writes:

> It facilitates reading the logs when mask CPU_LOG_INT is activated. We
> should do the same for error codes.
>
> Cc: Fabiano Rosas <farosas@linux.ibm.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
David Gibson Dec. 23, 2021, 4:25 a.m. UTC | #2
On Wed, Dec 22, 2021 at 07:40:18AM +0100, Cédric le Goater wrote:
> It facilitates reading the logs when mask CPU_LOG_INT is activated. We
> should do the same for error codes.
> 
> Cc: Fabiano Rosas <farosas@linux.ibm.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  target/ppc/excp_helper.c | 75 +++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 74 insertions(+), 1 deletion(-)
> 
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> index f90e616aacda..71ad983e67d6 100644
> --- a/target/ppc/excp_helper.c
> +++ b/target/ppc/excp_helper.c
> @@ -32,6 +32,78 @@
>  
>  /* #define DEBUG_SOFTWARE_TLB */
>  
> +static inline const char *powerpc_excp_name(int excp)
> +{
> +    switch (excp) {
> +    case POWERPC_EXCP_CRITICAL: return "CRITICAL";
> +    case POWERPC_EXCP_MCHECK:   return "MCHECK";
> +    case POWERPC_EXCP_DSI:      return "DSI";
> +    case POWERPC_EXCP_ISI:      return "ISI";
> +    case POWERPC_EXCP_EXTERNAL: return "EXTERNAL";
> +    case POWERPC_EXCP_ALIGN:    return "ALIGN";
> +    case POWERPC_EXCP_PROGRAM:  return "PROGRAM";
> +    case POWERPC_EXCP_FPU:      return "FPU";
> +    case POWERPC_EXCP_SYSCALL:  return "SYSCALL";
> +    case POWERPC_EXCP_APU:      return "APU";
> +    case POWERPC_EXCP_DECR:     return "DECR";
> +    case POWERPC_EXCP_FIT:      return "FIT";
> +    case POWERPC_EXCP_WDT:      return "WDT";
> +    case POWERPC_EXCP_DTLB:     return "DTLB";
> +    case POWERPC_EXCP_ITLB:     return "ITLB";
> +    case POWERPC_EXCP_DEBUG:    return "DEBUG";
> +    case POWERPC_EXCP_SPEU:     return "SPEU";
> +    case POWERPC_EXCP_EFPDI:    return "EFPDI";
> +    case POWERPC_EXCP_EFPRI:    return "EFPRI";
> +    case POWERPC_EXCP_EPERFM:   return "EPERFM";
> +    case POWERPC_EXCP_DOORI:    return "DOORI";
> +    case POWERPC_EXCP_DOORCI:   return "DOORCI";
> +    case POWERPC_EXCP_GDOORI:   return "GDOORI";
> +    case POWERPC_EXCP_GDOORCI:  return "GDOORCI";
> +    case POWERPC_EXCP_HYPPRIV:  return "HYPPRIV";
> +    case POWERPC_EXCP_RESET:    return "RESET";
> +    case POWERPC_EXCP_DSEG:     return "DSEG";
> +    case POWERPC_EXCP_ISEG:     return "ISEG";
> +    case POWERPC_EXCP_HDECR:    return "HDECR";
> +    case POWERPC_EXCP_TRACE:    return "TRACE";
> +    case POWERPC_EXCP_HDSI:     return "HDSI";
> +    case POWERPC_EXCP_HISI:     return "HISI";
> +    case POWERPC_EXCP_HDSEG:    return "HDSEG";
> +    case POWERPC_EXCP_HISEG:    return "HISEG";
> +    case POWERPC_EXCP_VPU:      return "VPU";
> +    case POWERPC_EXCP_PIT:      return "PIT";
> +    case POWERPC_EXCP_IO:       return "IO";
> +    case POWERPC_EXCP_RUNM:     return "RUNM";
> +    case POWERPC_EXCP_EMUL:     return "EMUL";
> +    case POWERPC_EXCP_IFTLB:    return "IFTLB";
> +    case POWERPC_EXCP_DLTLB:    return "DLTLB";
> +    case POWERPC_EXCP_DSTLB:    return "DSTLB";
> +    case POWERPC_EXCP_FPA:      return "FPA";
> +    case POWERPC_EXCP_DABR:     return "DABR";
> +    case POWERPC_EXCP_IABR:     return "IABR";
> +    case POWERPC_EXCP_SMI:      return "SMI";
> +    case POWERPC_EXCP_PERFM:    return "PERFM";
> +    case POWERPC_EXCP_THERM:    return "THERM";
> +    case POWERPC_EXCP_VPUA:     return "VPUA";
> +    case POWERPC_EXCP_SOFTP:    return "SOFTP";
> +    case POWERPC_EXCP_MAINT:    return "MAINT";
> +    case POWERPC_EXCP_MEXTBR:   return "MEXTBR";
> +    case POWERPC_EXCP_NMEXTBR:  return "NMEXTBR";
> +    case POWERPC_EXCP_ITLBE:    return "ITLBE";
> +    case POWERPC_EXCP_DTLBE:    return "DTLBE";
> +    case POWERPC_EXCP_VSXU:     return "VSXU";
> +    case POWERPC_EXCP_FU:       return "FU";
> +    case POWERPC_EXCP_HV_EMU:   return "HV_EMU";
> +    case POWERPC_EXCP_HV_MAINT: return "HV_MAINT";
> +    case POWERPC_EXCP_HV_FU:    return "HV_FU";
> +    case POWERPC_EXCP_SDOOR:    return "SDOOR";
> +    case POWERPC_EXCP_SDOOR_HV: return "SDOOR_HV";
> +    case POWERPC_EXCP_HVIRT:    return "HVIRT";
> +    case POWERPC_EXCP_SYSCALL_VECTORED: return "SYSCALL_VECTORED";
> +    default:
> +        g_assert_not_reached();
> +    }
> +}
> +
>  /*****************************************************************************/
>  /* Exception processing */
>  #if !defined(CONFIG_USER_ONLY)
> @@ -301,7 +373,8 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
>      int srr0, srr1, asrr0, asrr1, lev = -1;
>  
>      qemu_log_mask(CPU_LOG_INT, "Raise exception at " TARGET_FMT_lx
> -                  " => %08x (%02x)\n", env->nip, excp, env->error_code);
> +                  " => %s (%d) error=%02x\n", env->nip, powerpc_excp_name(excp),
> +                  excp, env->error_code);
>  
>      /* new srr1 value excluding must-be-zero bits */
>      if (excp_model == POWERPC_EXCP_BOOKE) {
Richard Henderson Dec. 23, 2021, 9:32 p.m. UTC | #3
On 12/21/21 10:40 PM, Cédric Le Goater wrote:
> +static inline const char *powerpc_excp_name(int excp)

Drop the inline.  It's not performance critical; let the compiler decide.

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index f90e616aacda..71ad983e67d6 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -32,6 +32,78 @@ 
 
 /* #define DEBUG_SOFTWARE_TLB */
 
+static inline const char *powerpc_excp_name(int excp)
+{
+    switch (excp) {
+    case POWERPC_EXCP_CRITICAL: return "CRITICAL";
+    case POWERPC_EXCP_MCHECK:   return "MCHECK";
+    case POWERPC_EXCP_DSI:      return "DSI";
+    case POWERPC_EXCP_ISI:      return "ISI";
+    case POWERPC_EXCP_EXTERNAL: return "EXTERNAL";
+    case POWERPC_EXCP_ALIGN:    return "ALIGN";
+    case POWERPC_EXCP_PROGRAM:  return "PROGRAM";
+    case POWERPC_EXCP_FPU:      return "FPU";
+    case POWERPC_EXCP_SYSCALL:  return "SYSCALL";
+    case POWERPC_EXCP_APU:      return "APU";
+    case POWERPC_EXCP_DECR:     return "DECR";
+    case POWERPC_EXCP_FIT:      return "FIT";
+    case POWERPC_EXCP_WDT:      return "WDT";
+    case POWERPC_EXCP_DTLB:     return "DTLB";
+    case POWERPC_EXCP_ITLB:     return "ITLB";
+    case POWERPC_EXCP_DEBUG:    return "DEBUG";
+    case POWERPC_EXCP_SPEU:     return "SPEU";
+    case POWERPC_EXCP_EFPDI:    return "EFPDI";
+    case POWERPC_EXCP_EFPRI:    return "EFPRI";
+    case POWERPC_EXCP_EPERFM:   return "EPERFM";
+    case POWERPC_EXCP_DOORI:    return "DOORI";
+    case POWERPC_EXCP_DOORCI:   return "DOORCI";
+    case POWERPC_EXCP_GDOORI:   return "GDOORI";
+    case POWERPC_EXCP_GDOORCI:  return "GDOORCI";
+    case POWERPC_EXCP_HYPPRIV:  return "HYPPRIV";
+    case POWERPC_EXCP_RESET:    return "RESET";
+    case POWERPC_EXCP_DSEG:     return "DSEG";
+    case POWERPC_EXCP_ISEG:     return "ISEG";
+    case POWERPC_EXCP_HDECR:    return "HDECR";
+    case POWERPC_EXCP_TRACE:    return "TRACE";
+    case POWERPC_EXCP_HDSI:     return "HDSI";
+    case POWERPC_EXCP_HISI:     return "HISI";
+    case POWERPC_EXCP_HDSEG:    return "HDSEG";
+    case POWERPC_EXCP_HISEG:    return "HISEG";
+    case POWERPC_EXCP_VPU:      return "VPU";
+    case POWERPC_EXCP_PIT:      return "PIT";
+    case POWERPC_EXCP_IO:       return "IO";
+    case POWERPC_EXCP_RUNM:     return "RUNM";
+    case POWERPC_EXCP_EMUL:     return "EMUL";
+    case POWERPC_EXCP_IFTLB:    return "IFTLB";
+    case POWERPC_EXCP_DLTLB:    return "DLTLB";
+    case POWERPC_EXCP_DSTLB:    return "DSTLB";
+    case POWERPC_EXCP_FPA:      return "FPA";
+    case POWERPC_EXCP_DABR:     return "DABR";
+    case POWERPC_EXCP_IABR:     return "IABR";
+    case POWERPC_EXCP_SMI:      return "SMI";
+    case POWERPC_EXCP_PERFM:    return "PERFM";
+    case POWERPC_EXCP_THERM:    return "THERM";
+    case POWERPC_EXCP_VPUA:     return "VPUA";
+    case POWERPC_EXCP_SOFTP:    return "SOFTP";
+    case POWERPC_EXCP_MAINT:    return "MAINT";
+    case POWERPC_EXCP_MEXTBR:   return "MEXTBR";
+    case POWERPC_EXCP_NMEXTBR:  return "NMEXTBR";
+    case POWERPC_EXCP_ITLBE:    return "ITLBE";
+    case POWERPC_EXCP_DTLBE:    return "DTLBE";
+    case POWERPC_EXCP_VSXU:     return "VSXU";
+    case POWERPC_EXCP_FU:       return "FU";
+    case POWERPC_EXCP_HV_EMU:   return "HV_EMU";
+    case POWERPC_EXCP_HV_MAINT: return "HV_MAINT";
+    case POWERPC_EXCP_HV_FU:    return "HV_FU";
+    case POWERPC_EXCP_SDOOR:    return "SDOOR";
+    case POWERPC_EXCP_SDOOR_HV: return "SDOOR_HV";
+    case POWERPC_EXCP_HVIRT:    return "HVIRT";
+    case POWERPC_EXCP_SYSCALL_VECTORED: return "SYSCALL_VECTORED";
+    default:
+        g_assert_not_reached();
+    }
+}
+
 /*****************************************************************************/
 /* Exception processing */
 #if !defined(CONFIG_USER_ONLY)
@@ -301,7 +373,8 @@  static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
     int srr0, srr1, asrr0, asrr1, lev = -1;
 
     qemu_log_mask(CPU_LOG_INT, "Raise exception at " TARGET_FMT_lx
-                  " => %08x (%02x)\n", env->nip, excp, env->error_code);
+                  " => %s (%d) error=%02x\n", env->nip, powerpc_excp_name(excp),
+                  excp, env->error_code);
 
     /* new srr1 value excluding must-be-zero bits */
     if (excp_model == POWERPC_EXCP_BOOKE) {