summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiaxun Yang <jiaxun.yang@flygoat.com>2019-10-10 11:01:57 -0400
committerPaul Burton <paul.burton@mips.com>2019-10-10 14:57:36 -0400
commit38dffe1e4dde1d3174fdce09d67370412843ebb5 (patch)
tree988621d9c668af750b9d4c360b7d8fd63827652f
parentefcb529694c3b707dc0471b312944337ba16e4dd (diff)
MIPS: elf_hwcap: Export userspace ASEs
A Golang developer reported MIPS hwcap isn't reflecting instructions that the processor actually supported so programs can't apply optimized code at runtime. Thus we export the ASEs that can be used in userspace programs. Reported-by: Meng Zhuo <mengzhuo1203@gmail.com> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Cc: linux-mips@vger.kernel.org Cc: Paul Burton <paul.burton@mips.com> Cc: <stable@vger.kernel.org> # 4.14+ Signed-off-by: Paul Burton <paul.burton@mips.com>
-rw-r--r--arch/mips/include/uapi/asm/hwcap.h11
-rw-r--r--arch/mips/kernel/cpu-probe.c33
2 files changed, 44 insertions, 0 deletions
diff --git a/arch/mips/include/uapi/asm/hwcap.h b/arch/mips/include/uapi/asm/hwcap.h
index a2aba4b059e6..1ade1daa4921 100644
--- a/arch/mips/include/uapi/asm/hwcap.h
+++ b/arch/mips/include/uapi/asm/hwcap.h
@@ -6,5 +6,16 @@
6#define HWCAP_MIPS_R6 (1 << 0) 6#define HWCAP_MIPS_R6 (1 << 0)
7#define HWCAP_MIPS_MSA (1 << 1) 7#define HWCAP_MIPS_MSA (1 << 1)
8#define HWCAP_MIPS_CRC32 (1 << 2) 8#define HWCAP_MIPS_CRC32 (1 << 2)
9#define HWCAP_MIPS_MIPS16 (1 << 3)
10#define HWCAP_MIPS_MDMX (1 << 4)
11#define HWCAP_MIPS_MIPS3D (1 << 5)
12#define HWCAP_MIPS_SMARTMIPS (1 << 6)
13#define HWCAP_MIPS_DSP (1 << 7)
14#define HWCAP_MIPS_DSP2 (1 << 8)
15#define HWCAP_MIPS_DSP3 (1 << 9)
16#define HWCAP_MIPS_MIPS16E2 (1 << 10)
17#define HWCAP_LOONGSON_MMI (1 << 11)
18#define HWCAP_LOONGSON_EXT (1 << 12)
19#define HWCAP_LOONGSON_EXT2 (1 << 13)
9 20
10#endif /* _UAPI_ASM_HWCAP_H */ 21#endif /* _UAPI_ASM_HWCAP_H */
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index c2eb392597bf..f521cbf934e7 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -2180,6 +2180,39 @@ void cpu_probe(void)
2180 elf_hwcap |= HWCAP_MIPS_MSA; 2180 elf_hwcap |= HWCAP_MIPS_MSA;
2181 } 2181 }
2182 2182
2183 if (cpu_has_mips16)
2184 elf_hwcap |= HWCAP_MIPS_MIPS16;
2185
2186 if (cpu_has_mdmx)
2187 elf_hwcap |= HWCAP_MIPS_MDMX;
2188
2189 if (cpu_has_mips3d)
2190 elf_hwcap |= HWCAP_MIPS_MIPS3D;
2191
2192 if (cpu_has_smartmips)
2193 elf_hwcap |= HWCAP_MIPS_SMARTMIPS;
2194
2195 if (cpu_has_dsp)
2196 elf_hwcap |= HWCAP_MIPS_DSP;
2197
2198 if (cpu_has_dsp2)
2199 elf_hwcap |= HWCAP_MIPS_DSP2;
2200
2201 if (cpu_has_dsp3)
2202 elf_hwcap |= HWCAP_MIPS_DSP3;
2203
2204 if (cpu_has_mips16e2)
2205 elf_hwcap |= HWCAP_MIPS_MIPS16E2;
2206
2207 if (cpu_has_loongson_mmi)
2208 elf_hwcap |= HWCAP_LOONGSON_MMI;
2209
2210 if (cpu_has_loongson_ext)
2211 elf_hwcap |= HWCAP_LOONGSON_EXT;
2212
2213 if (cpu_has_loongson_ext2)
2214 elf_hwcap |= HWCAP_LOONGSON_EXT2;
2215
2183 if (cpu_has_vz) 2216 if (cpu_has_vz)
2184 cpu_probe_vz(c); 2217 cpu_probe_vz(c);
2185 2218