[PATCH v2 2/8] Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file

Taylor Simpson posted 8 patches 1 month, 3 weeks ago
Only 6 patches received!
There is a newer version of this series
[PATCH v2 2/8] Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file
Posted by Taylor Simpson 1 month, 3 weeks ago
Return proper Hexagon CPU version from get_elf_cpu_model

Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
---
 linux-user/hexagon/elfload.c | 43 ++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/linux-user/hexagon/elfload.c b/linux-user/hexagon/elfload.c
index d8b545032a..39b0201814 100644
--- a/linux-user/hexagon/elfload.c
+++ b/linux-user/hexagon/elfload.c
@@ -10,23 +10,32 @@ const char *get_elf_cpu_model(uint32_t eflags)
     static char buf[32];
     int err;
 
-    /* For now, treat anything newer than v5 as a v73 */
-    /* FIXME - Disable instructions that are newer than the specified arch */
-    if (eflags == 0x04 ||    /* v5  */
-        eflags == 0x05 ||    /* v55 */
-        eflags == 0x60 ||    /* v60 */
-        eflags == 0x61 ||    /* v61 */
-        eflags == 0x62 ||    /* v62 */
-        eflags == 0x65 ||    /* v65 */
-        eflags == 0x66 ||    /* v66 */
-        eflags == 0x67 ||    /* v67 */
-        eflags == 0x8067 ||  /* v67t */
-        eflags == 0x68 ||    /* v68 */
-        eflags == 0x69 ||    /* v69 */
-        eflags == 0x71 ||    /* v71 */
-        eflags == 0x8071 ||  /* v71t */
-        eflags == 0x73       /* v73 */
-       ) {
+    switch (eflags) {
+    case 0x04:
+        return "v5";
+    case 0x05:
+        return "v55";
+    case 0x60:
+        return "v60";
+    case 0x61:
+        return "v61";
+    case 0x62:
+        return "v62";
+    case 0x65:
+        return "v65";
+    case 0x66:
+        return "v66";
+    case 0x67:
+    case 0x8067:        /* v67t */
+        return "v67";
+    case 0x68:
+        return "v68";
+    case 0x69:
+        return "v69";
+    case 0x71:
+    case 0x8071:        /* v71t */
+        return "v71";
+    case 0x73:
         return "v73";
     }
 
-- 
2.43.0
Re: [PATCH v2 2/8] Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file
Posted by Anton Johansson via qemu development 1 month, 3 weeks ago
On 15/02/26, Taylor Simpson wrote:
> Return proper Hexagon CPU version from get_elf_cpu_model
> 
> Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
> Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
> Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
> ---
>  linux-user/hexagon/elfload.c | 43 ++++++++++++++++++++++--------------
>  1 file changed, 26 insertions(+), 17 deletions(-)
> 
> diff --git a/linux-user/hexagon/elfload.c b/linux-user/hexagon/elfload.c
> index d8b545032a..39b0201814 100644
> --- a/linux-user/hexagon/elfload.c
> +++ b/linux-user/hexagon/elfload.c
> @@ -10,23 +10,32 @@ const char *get_elf_cpu_model(uint32_t eflags)
>      static char buf[32];
>      int err;
>  
> -    /* For now, treat anything newer than v5 as a v73 */
> -    /* FIXME - Disable instructions that are newer than the specified arch */
> -    if (eflags == 0x04 ||    /* v5  */
> -        eflags == 0x05 ||    /* v55 */
> -        eflags == 0x60 ||    /* v60 */
> -        eflags == 0x61 ||    /* v61 */
> -        eflags == 0x62 ||    /* v62 */
> -        eflags == 0x65 ||    /* v65 */
> -        eflags == 0x66 ||    /* v66 */
> -        eflags == 0x67 ||    /* v67 */
> -        eflags == 0x8067 ||  /* v67t */
> -        eflags == 0x68 ||    /* v68 */
> -        eflags == 0x69 ||    /* v69 */
> -        eflags == 0x71 ||    /* v71 */
> -        eflags == 0x8071 ||  /* v71t */
> -        eflags == 0x73       /* v73 */
> -       ) {
> +    switch (eflags) {
> +    case 0x04:
> +        return "v5";
> +    case 0x05:
> +        return "v55";
> +    case 0x60:
> +        return "v60";
> +    case 0x61:
> +        return "v61";
> +    case 0x62:
> +        return "v62";
> +    case 0x65:
> +        return "v65";
> +    case 0x66:
> +        return "v66";
> +    case 0x67:
> +    case 0x8067:        /* v67t */
> +        return "v67";
> +    case 0x68:
> +        return "v68";
> +    case 0x69:
> +        return "v69";
> +    case 0x71:
> +    case 0x8071:        /* v71t */
> +        return "v71";
> +    case 0x73:
>          return "v73";
>      }

Hmm could we not add v67t/v71t to HexagonVersion and use the enums here?

-- 
Anton Johansson
rev.ng Labs Srl.
Re: [PATCH v2 2/8] Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file
Posted by Taylor Simpson 1 month, 3 weeks ago
On Mon, Feb 16, 2026 at 8:05 AM Anton Johansson <anjo@rev.ng> wrote:

> On 15/02/26, Taylor Simpson wrote:
> > Return proper Hexagon CPU version from get_elf_cpu_model
> >
> > Co-authored-by: Matheus Tavares Bernardino <
> matheus.bernardino@oss.qualcomm.com>
> > Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
> > Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
> > ---
> >  linux-user/hexagon/elfload.c | 43 ++++++++++++++++++++++--------------
> >  1 file changed, 26 insertions(+), 17 deletions(-)
> >
> > diff --git a/linux-user/hexagon/elfload.c b/linux-user/hexagon/elfload.c
> > index d8b545032a..39b0201814 100644
> > --- a/linux-user/hexagon/elfload.c
> > +++ b/linux-user/hexagon/elfload.c
> > @@ -10,23 +10,32 @@ const char *get_elf_cpu_model(uint32_t eflags)
> >      static char buf[32];
> >      int err;
> >
> > -    /* For now, treat anything newer than v5 as a v73 */
> > -    /* FIXME - Disable instructions that are newer than the specified
> arch */
> > -    if (eflags == 0x04 ||    /* v5  */
> > -        eflags == 0x05 ||    /* v55 */
> > -        eflags == 0x60 ||    /* v60 */
> > -        eflags == 0x61 ||    /* v61 */
> > -        eflags == 0x62 ||    /* v62 */
> > -        eflags == 0x65 ||    /* v65 */
> > -        eflags == 0x66 ||    /* v66 */
> > -        eflags == 0x67 ||    /* v67 */
> > -        eflags == 0x8067 ||  /* v67t */
> > -        eflags == 0x68 ||    /* v68 */
> > -        eflags == 0x69 ||    /* v69 */
> > -        eflags == 0x71 ||    /* v71 */
> > -        eflags == 0x8071 ||  /* v71t */
> > -        eflags == 0x73       /* v73 */
> > -       ) {
> > +    switch (eflags) {
> > +    case 0x04:
> > +        return "v5";
> > +    case 0x05:
> > +        return "v55";
> > +    case 0x60:
> > +        return "v60";
> > +    case 0x61:
> > +        return "v61";
> > +    case 0x62:
> > +        return "v62";
> > +    case 0x65:
> > +        return "v65";
> > +    case 0x66:
> > +        return "v66";
> > +    case 0x67:
> > +    case 0x8067:        /* v67t */
> > +        return "v67";
> > +    case 0x68:
> > +        return "v68";
> > +    case 0x69:
> > +        return "v69";
> > +    case 0x71:
> > +    case 0x8071:        /* v71t */
> > +        return "v71";
> > +    case 0x73:
> >          return "v73";
> >      }
>
> Hmm could we not add v67t/v71t to HexagonVersion and use the enums here?
>
> --
> Anton Johansson
> rev.ng Labs Srl.
>

Brian Cain, please advise.  Aren't the "t" cores just
micorarchitecture differences that aren't modelled in QEMU?

Thanks,
Taylor
Re: [PATCH v2 2/8] Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file
Posted by Brian Cain 1 month, 3 weeks ago
On Mon, Feb 16, 2026 at 6:47 PM Taylor Simpson <ltaylorsimpson@gmail.com> wrote:
>
>
>
> On Mon, Feb 16, 2026 at 8:05 AM Anton Johansson <anjo@rev.ng> wrote:
>>
>> On 15/02/26, Taylor Simpson wrote:
>> > Return proper Hexagon CPU version from get_elf_cpu_model
>> >
>> > Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
>> > Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
>> > Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com>
>> > ---
>> >  linux-user/hexagon/elfload.c | 43 ++++++++++++++++++++++--------------
>> >  1 file changed, 26 insertions(+), 17 deletions(-)
>> >
>> > diff --git a/linux-user/hexagon/elfload.c b/linux-user/hexagon/elfload.c
>> > index d8b545032a..39b0201814 100644
>> > --- a/linux-user/hexagon/elfload.c
>> > +++ b/linux-user/hexagon/elfload.c
>> > @@ -10,23 +10,32 @@ const char *get_elf_cpu_model(uint32_t eflags)
>> >      static char buf[32];
>> >      int err;
>> >
>> > -    /* For now, treat anything newer than v5 as a v73 */
>> > -    /* FIXME - Disable instructions that are newer than the specified arch */
>> > -    if (eflags == 0x04 ||    /* v5  */
>> > -        eflags == 0x05 ||    /* v55 */
>> > -        eflags == 0x60 ||    /* v60 */
>> > -        eflags == 0x61 ||    /* v61 */
>> > -        eflags == 0x62 ||    /* v62 */
>> > -        eflags == 0x65 ||    /* v65 */
>> > -        eflags == 0x66 ||    /* v66 */
>> > -        eflags == 0x67 ||    /* v67 */
>> > -        eflags == 0x8067 ||  /* v67t */
>> > -        eflags == 0x68 ||    /* v68 */
>> > -        eflags == 0x69 ||    /* v69 */
>> > -        eflags == 0x71 ||    /* v71 */
>> > -        eflags == 0x8071 ||  /* v71t */
>> > -        eflags == 0x73       /* v73 */
>> > -       ) {
>> > +    switch (eflags) {
>> > +    case 0x04:
>> > +        return "v5";
>> > +    case 0x05:
>> > +        return "v55";
>> > +    case 0x60:
>> > +        return "v60";
>> > +    case 0x61:
>> > +        return "v61";
>> > +    case 0x62:
>> > +        return "v62";
>> > +    case 0x65:
>> > +        return "v65";
>> > +    case 0x66:
>> > +        return "v66";
>> > +    case 0x67:
>> > +    case 0x8067:        /* v67t */
>> > +        return "v67";
>> > +    case 0x68:
>> > +        return "v68";
>> > +    case 0x69:
>> > +        return "v69";
>> > +    case 0x71:
>> > +    case 0x8071:        /* v71t */
>> > +        return "v71";
>> > +    case 0x73:
>> >          return "v73";
>> >      }
>>
>> Hmm could we not add v67t/v71t to HexagonVersion and use the enums here?
>>
>> --
>> Anton Johansson
>> rev.ng Labs Srl.
>
>
> Brian Cain, please advise.  Aren't the "t" cores just micorarchitecture differences that aren't modelled in QEMU?

Yes - that's the case.  In practice they happen to usually include the
audio ISA extension but I don't think that's necessarily implied by
the tiny core.

-Brian