0103-linux-user-elfload-Implement-ELF_HWCAP-for-RISC-V.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From 7a3e8e23b4cf1422ec48e9d4b4009337a05a635d Mon Sep 17 00:00:00 2001
  2. From: Kito Cheng <kito.cheng@sifive.com>
  3. Date: Thu, 3 Jun 2021 17:52:22 +0800
  4. Subject: [PATCH 103/107] linux-user/elfload: Implement ELF_HWCAP for RISC-V
  5. RISC-V define the hwcap as same as content of misa, but it only take lower
  6. 26-bits.
  7. Signed-off-by: Kito Cheng <kito.cheng@sifive.com>
  8. ---
  9. linux-user/elfload.c | 11 +++++++++++
  10. 1 file changed, 11 insertions(+)
  11. diff --git a/linux-user/elfload.c b/linux-user/elfload.c
  12. index c6731013fd..fe8d36e097 100644
  13. --- a/linux-user/elfload.c
  14. +++ b/linux-user/elfload.c
  15. @@ -1398,6 +1398,17 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
  16. #define ELF_CLASS ELFCLASS64
  17. #endif
  18. +#define ELF_HWCAP get_elf_hwcap()
  19. +
  20. +static uint32_t get_elf_hwcap(void)
  21. +{
  22. + RISCVCPU *cpu = RISCV_CPU(thread_cpu);
  23. + /* Take lower 26 bits from misa. */
  24. + uint32_t hwcap = cpu->env.misa & 0x3ffffff;
  25. +
  26. + return hwcap;
  27. +}
  28. +
  29. static inline void init_thread(struct target_pt_regs *regs,
  30. struct image_info *infop)
  31. {
  32. --
  33. 2.33.1