Skip to content

Commit

Permalink
MIPS: elf_hwcap: Export userspace ASEs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
FlyGoat authored and paulburton committed Oct 10, 2019
1 parent efcb529 commit 38dffe1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions arch/mips/include/uapi/asm/hwcap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@
#define HWCAP_MIPS_R6 (1 << 0)
#define HWCAP_MIPS_MSA (1 << 1)
#define HWCAP_MIPS_CRC32 (1 << 2)
#define HWCAP_MIPS_MIPS16 (1 << 3)
#define HWCAP_MIPS_MDMX (1 << 4)
#define HWCAP_MIPS_MIPS3D (1 << 5)
#define HWCAP_MIPS_SMARTMIPS (1 << 6)
#define HWCAP_MIPS_DSP (1 << 7)
#define HWCAP_MIPS_DSP2 (1 << 8)
#define HWCAP_MIPS_DSP3 (1 << 9)
#define HWCAP_MIPS_MIPS16E2 (1 << 10)
#define HWCAP_LOONGSON_MMI (1 << 11)
#define HWCAP_LOONGSON_EXT (1 << 12)
#define HWCAP_LOONGSON_EXT2 (1 << 13)

#endif /* _UAPI_ASM_HWCAP_H */
33 changes: 33 additions & 0 deletions arch/mips/kernel/cpu-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,39 @@ void cpu_probe(void)
elf_hwcap |= HWCAP_MIPS_MSA;
}

if (cpu_has_mips16)
elf_hwcap |= HWCAP_MIPS_MIPS16;

if (cpu_has_mdmx)
elf_hwcap |= HWCAP_MIPS_MDMX;

if (cpu_has_mips3d)
elf_hwcap |= HWCAP_MIPS_MIPS3D;

if (cpu_has_smartmips)
elf_hwcap |= HWCAP_MIPS_SMARTMIPS;

if (cpu_has_dsp)
elf_hwcap |= HWCAP_MIPS_DSP;

if (cpu_has_dsp2)
elf_hwcap |= HWCAP_MIPS_DSP2;

if (cpu_has_dsp3)
elf_hwcap |= HWCAP_MIPS_DSP3;

if (cpu_has_mips16e2)
elf_hwcap |= HWCAP_MIPS_MIPS16E2;

if (cpu_has_loongson_mmi)
elf_hwcap |= HWCAP_LOONGSON_MMI;

if (cpu_has_loongson_ext)
elf_hwcap |= HWCAP_LOONGSON_EXT;

if (cpu_has_loongson_ext2)
elf_hwcap |= HWCAP_LOONGSON_EXT2;

if (cpu_has_vz)
cpu_probe_vz(c);

Expand Down

0 comments on commit 38dffe1

Please sign in to comment.