• Paul Burton's avatar
    MIPS: fix FP mode selection in lieu of .MIPS.abiflags data · 620b1550
    Paul Burton authored
    Commit 46490b57 ("MIPS: kernel: elf: Improve the overall ABI and FPU
    mode checks") reworked the ELF FP ABI mode selection logic, but when
    CONFIG_MIPS_O32_FP64_SUPPORT is enabled it breaks the use of binaries
    which have no PT_MIPS_ABIFLAGS program header & associated
    .MIPS.abiflags section.
    
    A default mode is selected based upon whether the ELF contains MIPS32 or
    MIPS64 code, but that selection is made in arch_elf_pt_proc.
    arch_elf_pt_proc only executes when a PT_MIPS_ABIFLAGS program header is
    found. If one is not found then arch_elf_pt_proc is never called, and no
    default overall_fp_mode value is selected. When arch_check_elf is
    called, both abi0 & abi1 are MIPS_ABI_FP_UNKNOWN which leads to both
    prog_req & interp_req being set to none_req. none_req matches none of
    the conditions for mode selection at the end of arch_check_elf, so
    overall_fp_mode is left untouched. Finally once mips_set_personality_fp
    is called the BUG() in the default case is then hit & the kernel likely
    panics.
    
    Fix this by moving the selection of a default overall mode to the start
    of arch_check_elf, which runs once per ELF executed regardless of
    whether it has a PT_MIPS_ABIFLAGS program header.
    Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
    Cc: Markos Chandras <markos.chandras@imgtec.com>
    Cc: Matthew Fortune <matthew.fortune@imgtec.com>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: linux-mips@linux-mips.org
    Cc: stable@vger.kernel.org # v4.0+
    Patchwork: http://patchwork.linux-mips.org/patch/9978/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    620b1550
elf.c 7.61 KB