All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Hexagon: improve output for arch version debugging
@ 2023-05-04 18:53 Matheus Tavares Bernardino
  2023-05-04 18:53 ` [PATCH 1/2] Hexagon: list available CPUs with `-cpu help` Matheus Tavares Bernardino
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Matheus Tavares Bernardino @ 2023-05-04 18:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: bcain, tsimpson

If we run qemu with an Hexagon binary compiled to an arch version that
is higher than the threshold modeled by qemu, we will get the following
error:

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

This can be confusing ("Was qemu unable to read the arch version from
this binary? Or did it read but does not know such version?").

And running `qemu-hexagon -cpu help` doesn't help either, as it just
errors out with no output. This patchset tries to improve this process.

https://lore.kernel.org/qemu-devel/cover.1673616964.git.quic_mathbern@quicinc.com/

Matheus Tavares Bernardino (2):
  Hexagon: list available CPUs with `-cpu help`
  Hexagon: append eflags to unknown cpu model string

 linux-user/hexagon/target_elf.h |  7 ++++++-
 target/hexagon/cpu.h            |  3 +++
 target/hexagon/cpu.c            | 20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

-- 
2.37.2



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] Hexagon: list available CPUs with `-cpu help`
  2023-05-04 18:53 [PATCH 0/2] Hexagon: improve output for arch version debugging Matheus Tavares Bernardino
@ 2023-05-04 18:53 ` Matheus Tavares Bernardino
  2023-05-05 18:58   ` Taylor Simpson
  2023-05-04 18:53 ` [PATCH 2/2] Hexagon: append eflags to unknown cpu model string Matheus Tavares Bernardino
  2023-05-05 18:59 ` [PATCH 0/2] Hexagon: improve output for arch version debugging Taylor Simpson
  2 siblings, 1 reply; 6+ messages in thread
From: Matheus Tavares Bernardino @ 2023-05-04 18:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: bcain, tsimpson

Currently, qemu-hexagon only models the v67 cpu. Nonetheless if we try
to get this information with `-cpu help`, qemu just exists with an error
code and no output. Let's correct that.

The code is basically a copy from target/alpha/cpu.h, but we strip the
"-hexagon-cpu" suffix before printing. This is to avoid confusing
situations like the following:

    $ qemu-hexagon -cpu help

    Available CPUs:
      v67-hexagon-cpu

    $ qemu-hexagon -cpu v67-hexagon-cpu ./prog

    qemu-hexagon: unable to find CPU model 'v67-hexagon-cpu'

Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
---
 target/hexagon/cpu.h |  3 +++
 target/hexagon/cpu.c | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h
index 81b663ecfb..d59e5bbff8 100644
--- a/target/hexagon/cpu.h
+++ b/target/hexagon/cpu.h
@@ -44,6 +44,9 @@
 
 #define TYPE_HEXAGON_CPU_V67 HEXAGON_CPU_TYPE_NAME("v67")
 
+void hexagon_cpu_list(void);
+#define cpu_list hexagon_cpu_list
+
 #define MMU_USER_IDX 0
 
 typedef struct {
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
index ab40cfc283..e8c2b5e910 100644
--- a/target/hexagon/cpu.c
+++ b/target/hexagon/cpu.c
@@ -29,6 +29,26 @@ static void hexagon_v67_cpu_init(Object *obj)
 {
 }
 
+static void hexagon_cpu_list_entry(gpointer data, gpointer user_data)
+{
+    ObjectClass *oc = data;
+    char *name = g_strdup(object_class_get_name(oc));
+    if (g_str_has_suffix(name, HEXAGON_CPU_TYPE_SUFFIX)) {
+        name[strlen(name) - strlen(HEXAGON_CPU_TYPE_SUFFIX)] = '\0';
+    }
+    qemu_printf("  %s\n", name);
+    g_free(name);
+}
+
+void hexagon_cpu_list(void)
+{
+    GSList *list;
+    list = object_class_get_list_sorted(TYPE_HEXAGON_CPU, false);
+    qemu_printf("Available CPUs:\n");
+    g_slist_foreach(list, hexagon_cpu_list_entry, NULL);
+    g_slist_free(list);
+}
+
 static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model)
 {
     ObjectClass *oc;
-- 
2.37.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] Hexagon: append eflags to unknown cpu model string
  2023-05-04 18:53 [PATCH 0/2] Hexagon: improve output for arch version debugging Matheus Tavares Bernardino
  2023-05-04 18:53 ` [PATCH 1/2] Hexagon: list available CPUs with `-cpu help` Matheus Tavares Bernardino
@ 2023-05-04 18:53 ` Matheus Tavares Bernardino
  2023-05-05 18:58   ` Taylor Simpson
  2023-05-05 18:59 ` [PATCH 0/2] Hexagon: improve output for arch version debugging Taylor Simpson
  2 siblings, 1 reply; 6+ messages in thread
From: Matheus Tavares Bernardino @ 2023-05-04 18:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: bcain, tsimpson, Laurent Vivier

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(-)

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
-- 
2.37.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH 1/2] Hexagon: list available CPUs with `-cpu help`
  2023-05-04 18:53 ` [PATCH 1/2] Hexagon: list available CPUs with `-cpu help` Matheus Tavares Bernardino
@ 2023-05-05 18:58   ` Taylor Simpson
  0 siblings, 0 replies; 6+ messages in thread
From: Taylor Simpson @ 2023-05-05 18:58 UTC (permalink / raw)
  To: Matheus Bernardino (QUIC), qemu-devel; +Cc: Brian Cain



> -----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>
> Subject: [PATCH 1/2] Hexagon: list available CPUs with `-cpu help`
> 
> Currently, qemu-hexagon only models the v67 cpu. Nonetheless if we try to
> get this information with `-cpu help`, qemu just exists with an error code and
> no output. Let's correct that.
> 
> The code is basically a copy from target/alpha/cpu.h, but we strip the "-
> hexagon-cpu" suffix before printing. This is to avoid confusing situations like
> the following:
> 
>     $ qemu-hexagon -cpu help
> 
>     Available CPUs:
>       v67-hexagon-cpu
> 
>     $ qemu-hexagon -cpu v67-hexagon-cpu ./prog
> 
>     qemu-hexagon: unable to find CPU model 'v67-hexagon-cpu'
> 
> Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
> ---
>  target/hexagon/cpu.h |  3 +++
>  target/hexagon/cpu.c | 20 ++++++++++++++++++++
>  2 files changed, 23 insertions(+)

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 2/2] Hexagon: append eflags to unknown cpu model string
  2023-05-04 18:53 ` [PATCH 2/2] Hexagon: append eflags to unknown cpu model string Matheus Tavares Bernardino
@ 2023-05-05 18:58   ` Taylor Simpson
  0 siblings, 0 replies; 6+ messages in thread
From: Taylor Simpson @ 2023-05-05 18:58 UTC (permalink / raw)
  To: Matheus Bernardino (QUIC), qemu-devel; +Cc: Brian Cain, Laurent Vivier



> -----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>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 0/2] Hexagon: improve output for arch version debugging
  2023-05-04 18:53 [PATCH 0/2] Hexagon: improve output for arch version debugging Matheus Tavares Bernardino
  2023-05-04 18:53 ` [PATCH 1/2] Hexagon: list available CPUs with `-cpu help` Matheus Tavares Bernardino
  2023-05-04 18:53 ` [PATCH 2/2] Hexagon: append eflags to unknown cpu model string Matheus Tavares Bernardino
@ 2023-05-05 18:59 ` Taylor Simpson
  2 siblings, 0 replies; 6+ messages in thread
From: Taylor Simpson @ 2023-05-05 18:59 UTC (permalink / raw)
  To: Matheus Bernardino (QUIC), qemu-devel; +Cc: Brian Cain



> -----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>
> Subject: [PATCH 0/2] Hexagon: improve output for arch version debugging
> 
> If we run qemu with an Hexagon binary compiled to an arch version that is
> higher than the threshold modeled by qemu, we will get the following
> error:
> 
>     qemu-hexagon: unable to find CPU model 'unknown'
> 
> This can be confusing ("Was qemu unable to read the arch version from this
> binary? Or did it read but does not know such version?").
> 
> And running `qemu-hexagon -cpu help` doesn't help either, as it just errors
> out with no output. This patchset tries to improve this process.
> 
> https://lore.kernel.org/qemu-
> devel/cover.1673616964.git.quic_mathbern@quicinc.com/
> 
> Matheus Tavares Bernardino (2):
>   Hexagon: list available CPUs with `-cpu help`
>   Hexagon: append eflags to unknown cpu model string
> 
>  linux-user/hexagon/target_elf.h |  7 ++++++-
>  target/hexagon/cpu.h            |  3 +++
>  target/hexagon/cpu.c            | 20 ++++++++++++++++++++
>  3 files changed, 29 insertions(+), 1 deletion(-)

Queued for next Hexagon PR

Thanks,
Taylor


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-05 19:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 18:53 [PATCH 0/2] Hexagon: improve output for arch version debugging Matheus Tavares Bernardino
2023-05-04 18:53 ` [PATCH 1/2] Hexagon: list available CPUs with `-cpu help` Matheus Tavares Bernardino
2023-05-05 18:58   ` Taylor Simpson
2023-05-04 18:53 ` [PATCH 2/2] Hexagon: append eflags to unknown cpu model string Matheus Tavares Bernardino
2023-05-05 18:58   ` Taylor Simpson
2023-05-05 18:59 ` [PATCH 0/2] Hexagon: improve output for arch version debugging Taylor Simpson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.