Skip to contentSkip to conversation

linux-user/elfload: Set V in ELF_HWCAP for RISC-V

PATCH Applied Nathan Egge 5 participants 5 messages Aug 3, 2023 – Aug 10, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user/elfload: Set V in ELF_HWCAP for RISC-V

From: "Nathan Egge" <[email protected]>

Set V bit for hwcap if misa is set.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1793

---
 linux-user/elfload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/elfload.c +2 -1
index 861ec07abc..a299ba7300 100644
@@ -1710,7 +1710,8 @@ static uint32_t get_elf_hwcap(void)
 #define MISA_BIT(EXT) (1 << (EXT - 'A'))
     RISCVCPU *cpu = RISCV_CPU(thread_cpu);
     uint32_t mask = MISA_BIT('I') | MISA_BIT('M') | MISA_BIT('A')
-                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C');
+                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C')
+                    | MISA_BIT('V');
 
     return cpu->env.misa_ext & mask;
 #undef MISA_BIT
Signature · 1 line
2.35.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines · Nathan Egge

From: "Nathan Egge" <[email protected]>

Set V bit for hwcap if misa is set.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1793

---

Tested with the example program described in the bug:

===========
#include <sys/auxv.h>
#include <stdio.h>

#define ISA_V_HWCAP (1 << ('v' - 'a'))

void main() {
unsigned long hw_cap = getauxval(AT_HWCAP);
printf("RVV %s\n", hw_cap & ISA_V_HWCAP ? "detected" : "not found");
}
===========

$ ./qemu-riscv64 -cpu rv64,vext_spec=v1.0,v=true,vlen=128 -B 0x100000 ./a.out
RVV detected
$ ./qemu-riscv64 -cpu rv64,vext_spec=v1.0,vlen=128 -B 0x100000 ./a.out
RVV not found

Looks like 8.1 material to me. Thanks,

Daniel

Quoted 17 lines
  linux-user/elfload.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/elfload.c +2 -1
index 861ec07abc..a299ba7300 100644
@@ -1710,7 +1710,8 @@ static uint32_t get_elf_hwcap(void)
  #define MISA_BIT(EXT) (1 << (EXT - 'A'))
      RISCVCPU *cpu = RISCV_CPU(thread_cpu);
      uint32_t mask = MISA_BIT('I') | MISA_BIT('M') | MISA_BIT('A')
-                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C');
+                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C')
+                    | MISA_BIT('V');
 
      return cpu->env.misa_ext & mask;
  #undef MISA_BIT
#2 lore raw
Quoted 31 lines · Daniel Henrique Barboza
Quoted 7 lines · Nathan Egge

From: "Nathan Egge" <[email protected]>

Set V bit for hwcap if misa is set.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1793

---

Tested with the example program described in the bug:

===========
#include <sys/auxv.h>
#include <stdio.h>

#define ISA_V_HWCAP (1 << ('v' - 'a'))

void main() {
  unsigned long hw_cap = getauxval(AT_HWCAP);
  printf("RVV %s\n", hw_cap & ISA_V_HWCAP ? "detected" : "not found");
}
===========

$ ./qemu-riscv64 -cpu rv64,vext_spec=v1.0,v=true,vlen=128 -B 0x100000 ./a.out
RVV detected
$ ./qemu-riscv64 -cpu rv64,vext_spec=v1.0,vlen=128 -B 0x100000 ./a.out
RVV not found
Quoted 5 lines

Looks like 8.1 material to me. Thanks,

Queued to tcg-next.

r~

#3 lore raw
In reply to Nathan Egge
Quoted 15 lines · Nathan Egge

From: "Nathan Egge" <[email protected]>

Set V bit for hwcap if misa is set.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1793

---
  linux-user/elfload.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/elfload.c +0 -0
index 861ec07abc..a299ba7300 100644

linux-user/elfload.c static uint32_t get_elf_hwcap(void) · line 1714

Quoted 6 lines
linux-user/elfload.c +2 -1
@@ -1710,7 +1710,8 @@ static uint32_t get_elf_hwcap(void)
  #define MISA_BIT(EXT) (1 << (EXT - 'A'))
      RISCVCPU *cpu = RISCV_CPU(thread_cpu);
      uint32_t mask = MISA_BIT('I') | MISA_BIT('M') | MISA_BIT('A')
-                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C');
+                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C')
+                    | MISA_BIT('V');

Is smells like a -stable material (incl. 7.2), is it not?

Thanks,

/mjt

#4 lore raw
Quoted 12 lines · Michael Tokarev
Quoted 10 lines · Nathan Egge

From: "Nathan Egge" <[email protected]>

Set V bit for hwcap if misa is set.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1793

---
  linux-user/elfload.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 13 lines

linux-user/elfload.c static uint32_t get_elf_hwcap(void) · line 1714

Quoted 11 lines
linux-user/elfload.c +2 -1
index 861ec07abc..a299ba7300 100644
@@ -1710,7 +1710,8 @@ static uint32_t get_elf_hwcap(void)
  #define MISA_BIT(EXT) (1 << (EXT - 'A'))
      RISCVCPU *cpu = RISCV_CPU(thread_cpu);
      uint32_t mask = MISA_BIT('I') | MISA_BIT('M') | MISA_BIT('A')
-                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C');
+                    | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C')
+                    | MISA_BIT('V');

Is smells like a -stable material (incl. 7.2), is it not?

I think so as well

Alistair

Quoted 5 lines

Thanks,

/mjt