Commit 591fd30e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'work.elf-compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull ELF compat updates from Al Viro:
 "Sanitizing ELF compat support, especially for triarch architectures:

   - X32 handling cleaned up

   - MIPS64 uses compat_binfmt_elf.c both for O32 and N32 now

   - Kconfig side of things regularized

  Eventually I hope to have compat_binfmt_elf.c killed, with both native
  and compat built from fs/binfmt_elf.c, with -DELF_BITS={64,32} passed
  by kbuild, but that's a separate story - not included here"

* 'work.elf-compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  get rid of COMPAT_ELF_EXEC_PAGESIZE
  compat_binfmt_elf: don't bother with undef of ELF_ARCH
  Kconfig: regularize selection of CONFIG_BINFMT_ELF
  mips compat: switch to compat_binfmt_elf.c
  mips: don't bother with ELF_CORE_EFLAGS
  mips compat: don't bother with ELF_ET_DYN_BASE
  mips: KVM_GUEST makes no sense for 64bit builds...
  mips: kill unused definitions in binfmt_elf[on]32.c
  mips binfmt_elf*32.c: use elfcore-compat.h
  x32: make X32, !IA32_EMULATION setups able to execute x32 binaries
  [amd64] clean PRSTATUS_SIZE/SET_PR_FPVALID up properly
  elf_prstatus: collect the common part (everything before pr_reg) into a struct
  binfmt_elf: partially sanitize PRSTATUS_SIZE and SET_PR_FPVALID
parents 054560e9 e565d89e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1111,6 +1111,9 @@ config ARCH_SPLIT_ARG64
	   If a 32-bit architecture requires 64-bit arguments to be split into
	   pairs of 32-bit arguments, select this option.

config ARCH_HAS_ELFCORE_COMPAT
	bool

source "kernel/gcov/Kconfig"

source "scripts/gcc-plugins/Kconfig"
+0 −1
Original line number Diff line number Diff line
@@ -1213,7 +1213,6 @@ config ARM64_TAGGED_ADDR_ABI
menuconfig COMPAT
	bool "Kernel support for 32-bit EL0"
	depends on ARM64_4K_PAGES || EXPERT
	select COMPAT_BINFMT_ELF if BINFMT_ELF
	select HAVE_UID16
	select OLD_SIGSUSPEND3
	select COMPAT_OLD_SIGACTION
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ crash_save_this_cpu(void)

	elf_greg_t *dst = (elf_greg_t *)&(prstatus->pr_reg);
	memset(prstatus, 0, sizeof(*prstatus));
	prstatus->pr_pid = current->pid;
	prstatus->common.pr_pid = current->pid;

	ia64_dump_cpu_regs(dst);
	cfm = dst[43];
+2 −6
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ config MIPS
	select SET_FS
	select SYSCTL_EXCEPTION_TRACE
	select VIRT_TO_BUS
	select ARCH_HAS_ELFCORE_COMPAT

config MIPS_FIXUP_BIGPHYS_ADDR
	bool
@@ -2182,7 +2183,7 @@ endchoice
config KVM_GUEST
	bool "KVM Guest Kernel"
	depends on CPU_MIPS32_R2
	depends on BROKEN_ON_SMP
	depends on !64BIT && BROKEN_ON_SMP
	help
	  Select this option if building a guest kernel for KVM (Trap & Emulate)
	  mode.
@@ -3300,11 +3301,6 @@ config MIPS32_N32

	  If unsure, say N.

config BINFMT_ELF32
	bool
	default y if MIPS32_O32 || MIPS32_N32
	select ELFCORE

menu "Power management options"

config ARCH_HIBERNATION_POSSIBLE
+19 −37
Original line number Diff line number Diff line
@@ -201,7 +201,6 @@ struct mips_elf_abiflags_v0 {
	uint32_t flags2;
};

#ifndef ELF_ARCH
/* ELF register definitions */
#define ELF_NGREG	45
#define ELF_NFPREG	33
@@ -219,7 +218,7 @@ void mips_dump_regs64(u64 *uregs, const struct pt_regs *regs);
/*
 * This is used to ensure we don't load something for the wrong architecture.
 */
#define elf_check_arch elfo32_check_arch
#define elf_check_arch elf32_check_arch

/*
 * These are used to set parameters in the core dumps.
@@ -235,7 +234,8 @@ void mips_dump_regs64(u64 *uregs, const struct pt_regs *regs);
/*
 * This is used to ensure we don't load something for the wrong architecture.
 */
#define elf_check_arch elfn64_check_arch
#define elf_check_arch elf64_check_arch
#define compat_elf_check_arch elf32_check_arch

/*
 * These are used to set parameters in the core dumps.
@@ -257,8 +257,6 @@ void mips_dump_regs64(u64 *uregs, const struct pt_regs *regs);
#endif
#define ELF_ARCH	EM_MIPS

#endif /* !defined(ELF_ARCH) */

/*
 * In order to be sure that we don't attempt to execute an O32 binary which
 * requires 64 bit FP (FR=1) on a system which does not support it we refuse
@@ -277,9 +275,9 @@ void mips_dump_regs64(u64 *uregs, const struct pt_regs *regs);
#define vmcore_elf64_check_arch mips_elf_check_machine

/*
 * Return non-zero if HDR identifies an o32 ELF binary.
 * Return non-zero if HDR identifies an o32 or n32 ELF binary.
 */
#define elfo32_check_arch(hdr)						\
#define elf32_check_arch(hdr)						\
({									\
	int __res = 1;							\
	struct elfhdr *__h = (hdr);					\
@@ -288,21 +286,26 @@ void mips_dump_regs64(u64 *uregs, const struct pt_regs *regs);
		__res = 0;						\
	if (__h->e_ident[EI_CLASS] != ELFCLASS32)			\
		__res = 0;						\
	if ((__h->e_flags & EF_MIPS_ABI2) != 0)				\
	if ((__h->e_flags & EF_MIPS_ABI2) != 0) {			\
		if (!IS_ENABLED(CONFIG_MIPS32_N32) ||			\
		     (__h->e_flags & EF_MIPS_ABI))			\
			__res = 0;					\
	} else {							\
		if (IS_ENABLED(CONFIG_64BIT) && !IS_ENABLED(CONFIG_MIPS32_O32)) \
			__res = 0;					\
		if (((__h->e_flags & EF_MIPS_ABI) != 0) &&		\
		    ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32))	\
			__res = 0;					\
		if (__h->e_flags & __MIPS_O32_FP64_MUST_BE_ZERO)	\
			__res = 0;					\
									\
	}								\
	__res;								\
})

/*
 * Return non-zero if HDR identifies an n64 ELF binary.
 */
#define elfn64_check_arch(hdr)						\
#define elf64_check_arch(hdr)						\
({									\
	int __res = 1;							\
	struct elfhdr *__h = (hdr);					\
@@ -315,25 +318,6 @@ void mips_dump_regs64(u64 *uregs, const struct pt_regs *regs);
	__res;								\
})

/*
 * Return non-zero if HDR identifies an n32 ELF binary.
 */
#define elfn32_check_arch(hdr)						\
({									\
	int __res = 1;							\
	struct elfhdr *__h = (hdr);					\
									\
	if (!mips_elf_check_machine(__h))				\
		__res = 0;						\
	if (__h->e_ident[EI_CLASS] != ELFCLASS32)			\
		__res = 0;						\
	if (((__h->e_flags & EF_MIPS_ABI2) == 0) ||			\
	    ((__h->e_flags & EF_MIPS_ABI) != 0))			\
		__res = 0;						\
									\
	__res;								\
})

struct mips_abi;

extern struct mips_abi mips_abi;
@@ -469,9 +453,7 @@ extern const char *__elf_base_platform;
   the loader.	We need to make sure that it is out of the way of the program
   that it will "exec", and that there is sufficient room for the brk.	*/

#ifndef ELF_ET_DYN_BASE
#define ELF_ET_DYN_BASE		(TASK_SIZE / 3 * 2)
#endif

/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
#define ARCH_DLINFO							\
Loading