[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/37] linux-user: Set ELF_BASE_PLATFORM for MIPS
From: |
Laurent Vivier |
Subject: |
[PULL 29/37] linux-user: Set ELF_BASE_PLATFORM for MIPS |
Date: |
Wed, 28 Sep 2022 22:27:29 +0200 |
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
Match most appropriate base platform string based on insn_flags.
Logic is aligned with aligned with set_isa() from
arch/mips/kernel/cpu-probe.c in Linux kernel.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220803103009.95972-3-jiaxun.yang@flygoat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/elfload.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 581fbc858b48..20894b633f58 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1080,6 +1080,37 @@ static uint32_t get_elf_hwcap(void)
#define elf_check_abi(x) (!((x) & EF_MIPS_ABI2))
#endif
+#define ELF_BASE_PLATFORM get_elf_base_platform()
+
+#define MATCH_PLATFORM_INSN(_flags, _base_platform) \
+ do { if ((cpu->env.insn_flags & (_flags)) == _flags) \
+ { return _base_platform; } } while (0)
+
+static const char *get_elf_base_platform(void)
+{
+ MIPSCPU *cpu = MIPS_CPU(thread_cpu);
+
+ /* 64 bit ISAs goes first */
+ MATCH_PLATFORM_INSN(CPU_MIPS64R6, "mips64r6");
+ MATCH_PLATFORM_INSN(CPU_MIPS64R5, "mips64r5");
+ MATCH_PLATFORM_INSN(CPU_MIPS64R2, "mips64r2");
+ MATCH_PLATFORM_INSN(CPU_MIPS64R1, "mips64");
+ MATCH_PLATFORM_INSN(CPU_MIPS5, "mips5");
+ MATCH_PLATFORM_INSN(CPU_MIPS4, "mips4");
+ MATCH_PLATFORM_INSN(CPU_MIPS3, "mips3");
+
+ /* 32 bit ISAs */
+ MATCH_PLATFORM_INSN(CPU_MIPS32R6, "mips32r6");
+ MATCH_PLATFORM_INSN(CPU_MIPS32R5, "mips32r5");
+ MATCH_PLATFORM_INSN(CPU_MIPS32R2, "mips32r2");
+ MATCH_PLATFORM_INSN(CPU_MIPS32R1, "mips32");
+ MATCH_PLATFORM_INSN(CPU_MIPS2, "mips2");
+
+ /* Fallback */
+ return "mips";
+}
+#undef MATCH_PLATFORM_INSN
+
static inline void init_thread(struct target_pt_regs *regs,
struct image_info *infop)
{
--
2.37.3
- [PULL 16/37] linux-user: Passthrough MADV_DONTNEED for certain file mappings, (continued)
- [PULL 16/37] linux-user: Passthrough MADV_DONTNEED for certain file mappings, Laurent Vivier, 2022/09/28
- [PULL 17/37] tests/tcg/linux-test: Add linux-madvise test, Laurent Vivier, 2022/09/28
- [PULL 23/37] linux-user/hppa: Allow PROT_GROWSUP and PROT_GROWSDOWN in mprotect(), Laurent Vivier, 2022/09/28
- [PULL 22/37] linux-user/hppa: Increase guest stack size to 80MB for hppa target, Laurent Vivier, 2022/09/28
- [PULL 24/37] linux-user/hppa: Fix setup_sigcontext(), Laurent Vivier, 2022/09/28
- [PULL 26/37] linux-user: Don't assume 0 is not a valid host timer_t value, Laurent Vivier, 2022/09/28
- [PULL 30/37] linux-user: Combine do_futex and do_futex_time64, Laurent Vivier, 2022/09/28
- [PULL 27/37] linux-user/s390x: Save/restore fpc when handling a signal, Laurent Vivier, 2022/09/28
- [PULL 32/37] linux-user: Implement FUTEX_WAKE_BITSET, Laurent Vivier, 2022/09/28
- [PULL 33/37] linux-user: Convert signal number for FUTEX_FD, Laurent Vivier, 2022/09/28
- [PULL 29/37] linux-user: Set ELF_BASE_PLATFORM for MIPS,
Laurent Vivier <=
- [PULL 19/37] linux-user: Add proper strace format strings for getdents()/getdents64(), Laurent Vivier, 2022/09/28
- [PULL 31/37] linux-user: Sink call to do_safe_futex, Laurent Vivier, 2022/09/28
- [PULL 34/37] linux-user: Implement PI futexes, Laurent Vivier, 2022/09/28
- [PULL 35/37] linux-user: Update print_futex_op, Laurent Vivier, 2022/09/28
- [PULL 28/37] linux-user: Introduce stubs for ELF AT_BASE_PLATFORM, Laurent Vivier, 2022/09/28
- [PULL 37/37] linux-user: Add parameters of getrandom() syscall for strace, Laurent Vivier, 2022/09/28
- [PULL 25/37] linux-user: fix bug about missing signum convert of sigqueue, Laurent Vivier, 2022/09/28
- [PULL 36/37] linux-user: Lock log around strace, Laurent Vivier, 2022/09/28
- Re: [PULL 00/37] Linux user for 7.2 patches, Stefan Hajnoczi, 2022/09/29