diff mbox series

[2/2] Hexagon: append eflags to unknown cpu model string

Message ID 8a8d013cc619b94fd4fb577ae6a8df26cedb972b.1683225804.git.quic_mathbern@quicinc.com (mailing list archive)
State New, archived
Headers show
Series Hexagon: improve output for arch version debugging | expand

Commit Message

Matheus Tavares Bernardino May 4, 2023, 6:53 p.m. UTC
Running qemu-hexagon with a binary that was compiled for an arch version
unknown by qemu can produce a somewhat confusing message:

  qemu-hexagon: unable to find CPU model 'unknown'

Let's give a bit more info by appending the eflags so that the message
becomes:

  qemu-hexagon: unable to find CPU model 'unknown (0x69)'

Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
---
 linux-user/hexagon/target_elf.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Taylor Simpson May 5, 2023, 6:58 p.m. UTC | #1
> -----Original Message-----
> From: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
> Sent: Thursday, May 4, 2023 1:53 PM
> To: qemu-devel@nongnu.org
> Cc: Brian Cain <bcain@quicinc.com>; Taylor Simpson
> <tsimpson@quicinc.com>; Laurent Vivier <laurent@vivier.eu>
> Subject: [PATCH 2/2] Hexagon: append eflags to unknown cpu model string
> 
> Running qemu-hexagon with a binary that was compiled for an arch version
> unknown by qemu can produce a somewhat confusing message:
> 
>   qemu-hexagon: unable to find CPU model 'unknown'
> 
> Let's give a bit more info by appending the eflags so that the message
> becomes:
> 
>   qemu-hexagon: unable to find CPU model 'unknown (0x69)'
> 
> Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
> ---
>  linux-user/hexagon/target_elf.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Reviewed-by: Taylor Simpson <tsimpson@quicinc.com>
Tested-by: Taylor Simpson <tsimpson@quicinc.com>
diff mbox series

Patch

diff --git a/linux-user/hexagon/target_elf.h b/linux-user/hexagon/target_elf.h
index b4e9f40527..f47e130537 100644
--- a/linux-user/hexagon/target_elf.h
+++ b/linux-user/hexagon/target_elf.h
@@ -20,6 +20,9 @@ 
 
 static inline const char *cpu_get_model(uint32_t eflags)
 {
+    static char buf[32];
+    int err;
+
     /* For now, treat anything newer than v5 as a v67 */
     /* FIXME - Disable instructions that are newer than the specified arch */
     if (eflags == 0x04 ||    /* v5  */
@@ -34,7 +37,9 @@  static inline const char *cpu_get_model(uint32_t eflags)
        ) {
         return "v67";
     }
-    return "unknown";
+
+    err = snprintf(buf, sizeof(buf), "unknown (0x%x)", eflags);
+    return err >= 0 && err < sizeof(buf) ? buf : "unknown";
 }
 
 #endif