Skip to contentSkip to conversation

linux-user: Add support for MIPS Loongson 2F/3E

PATCH In review Philippe Mathieu-Daudé 2 participants 6 messages Dec 1, 2020

lore
Share & tools
lore
#0 lore raw

cover linux-user: Add support for MIPS Loongson 2F/3E

Update the ELF HWCAP bits and set the Loongson instructions so we can run 2F/3E userland binaries.

Philippe Mathieu-Daudé (2):
linux-user: Update HWCAP bits from linux 5.7
linux-user: Add support for MIPS Loongson 2F/3E

 linux-user/elfload.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 linux-user: Update HWCAP bits from linux 5.7

---
 linux-user/elfload.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
linux-user/elfload.c +13 -0
index 0b02a926025..17371f8b8cd 100644
@@ -985,6 +985,19 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMIPSState *e
 enum {
     HWCAP_MIPS_R6           = (1 << 0),
     HWCAP_MIPS_MSA          = (1 << 1),
+    HWCAP_MIPS_CRC32        = (1 << 2),
+    HWCAP_MIPS_MIPS16       = (1 << 3),
+    HWCAP_MIPS_MDMX         = (1 << 4),
+    HWCAP_MIPS_MIPS3D       = (1 << 5),
+    HWCAP_MIPS_SMARTMIPS    = (1 << 6),
+    HWCAP_MIPS_DSP          = (1 << 7),
+    HWCAP_MIPS_DSP2         = (1 << 8),
+    HWCAP_MIPS_DSP3         = (1 << 9),
+    HWCAP_MIPS_MIPS16E2     = (1 << 10),
+    HWCAP_LOONGSON_MMI      = (1 << 11),
+    HWCAP_LOONGSON_EXT      = (1 << 12),
+    HWCAP_LOONGSON_EXT2     = (1 << 13),
+    HWCAP_LOONGSON_CPUCFG   = (1 << 14),
 };
 
 #define ELF_HWCAP get_elf_hwcap()
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/2 linux-user: Add support for MIPS Loongson 2F/3E

In reply to Philippe Mathieu-Daudé

Userland EFL binaries using Longsoon SIMD instructions have the HWCAP_LOONGSON_MMI bit set. Binaries compiled for Longsoon 3E have the HWCAP_LOONGSON_EXT bit set for the LQ / SQ instructions.

---
 linux-user/elfload.c | 2 ++
 1 file changed, 2 insertions(+)
linux-user/elfload.c +2 -0
index 17371f8b8cd..be82fcb2c0a 100644
@@ -1012,6 +1012,8 @@ static uint32_t get_elf_hwcap(void)
 
     GET_FEATURE(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6);
     GET_FEATURE(ASE_MSA, HWCAP_MIPS_MSA);
+    GET_FEATURE(ASE_LMMI, HWCAP_LOONGSON_MMI);
+    GET_FEATURE(ASE_LEXT, HWCAP_LOONGSON_EXT);
 
 #undef GET_FEATURE
 
Signature · 1 line
2.26.2
#3 lore raw
Quoted 5 lines · Philippe Mathieu-Daudé

Userland EFL binaries using Longsoon SIMD instructions have the HWCAP_LOONGSON_MMI bit set. Binaries compiled for Longsoon 3E have the HWCAP_LOONGSON_EXT bit set for the LQ / SQ instructions.

Eventually I can respin with references:

2F since 8e2d5831e4b ("target/mips: Legalize Loongson insn flags"). 3E since af868995e1b ("target/mips: Add Loongson-3 CPU definition").

Quoted 21 lines
---
 linux-user/elfload.c | 2 ++
 1 file changed, 2 insertions(+)
linux-user/elfload.c +2 -1
index 17371f8b8cd..be82fcb2c0a 100644
@@ -1012,6 +1012,8 @@ static uint32_t get_elf_hwcap(void)
 
     GET_FEATURE(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6);
     GET_FEATURE(ASE_MSA, HWCAP_MIPS_MSA);
+    GET_FEATURE(ASE_LMMI, HWCAP_LOONGSON_MMI);
+    GET_FEATURE(ASE_LEXT, HWCAP_LOONGSON_EXT);
 
 #undef GET_FEATURE
 
--

2.26.2

#4 lore raw
Quoted 3 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Userland EFL binaries using Longsoon SIMD instructions have the

Well I'll respin to fix the EFL -> ELF typo.

Quoted 31 lines
Quoted 3 lines

HWCAP_LOONGSON_MMI bit set. Binaries compiled for Longsoon 3E have the HWCAP_LOONGSON_EXT bit set for the LQ / SQ instructions.

Eventually I can respin with references:

2F since 8e2d5831e4b ("target/mips: Legalize Loongson insn flags"). 3E since af868995e1b ("target/mips: Add Loongson-3 CPU definition").

Quoted 21 lines
---
 linux-user/elfload.c | 2 ++
 1 file changed, 2 insertions(+)
linux-user/elfload.c +2 -1
index 17371f8b8cd..be82fcb2c0a 100644
@@ -1012,6 +1012,8 @@ static uint32_t get_elf_hwcap(void)
 
     GET_FEATURE(ISA_MIPS32R6 | ISA_MIPS64R6, HWCAP_MIPS_R6);
     GET_FEATURE(ASE_MSA, HWCAP_MIPS_MSA);
+    GET_FEATURE(ASE_LMMI, HWCAP_LOONGSON_MMI);
+    GET_FEATURE(ASE_LEXT, HWCAP_LOONGSON_EXT);
 
 #undef GET_FEATURE
 
--

2.26.2

Reviewed-by on the v1 series
#5 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Update the ELF HWCAP bits and set the Loongson instructions so we can run 2F/3E userland binaries.

Philippe Mathieu-Daudé (2):
linux-user: Update HWCAP bits from linux 5.7
linux-user: Add support for MIPS Loongson 2F/3E

 linux-user/elfload.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

r~