Skip to content

Commit 38dffe1

Browse files
FlyGoatpaulburton
authored andcommitted
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 <[email protected]> Signed-off-by: Jiaxun Yang <[email protected]> Cc: [email protected] Cc: Paul Burton <[email protected]> Cc: <[email protected]> # 4.14+ Signed-off-by: Paul Burton <[email protected]>
1 parent efcb529 commit 38dffe1

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

arch/mips/include/uapi/asm/hwcap.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,16 @@
66
#define HWCAP_MIPS_R6 (1 << 0)
77
#define HWCAP_MIPS_MSA (1 << 1)
88
#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)
920

1021
#endif /* _UAPI_ASM_HWCAP_H */

arch/mips/kernel/cpu-probe.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,39 @@ void cpu_probe(void)
21802180
elf_hwcap |= HWCAP_MIPS_MSA;
21812181
}
21822182

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+
21832216
if (cpu_has_vz)
21842217
cpu_probe_vz(c);
21852218

0 commit comments

Comments
 (0)