summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-06-13 03:08:51 -0400
committerGreg Ungerer <gerg@kernel.org>2019-06-23 19:16:46 -0400
commitbdd15a288492f2f496a904c69c4b332057ae2ef6 (patch)
tree453e2a0303f4ff9c2b8381a413fe9285a56472d5
parent1d52dca117434eca9c6efc9c22d24e7a341ad903 (diff)
binfmt_flat: replace flat_argvp_envp_on_stack with a Kconfig variable
This will eventually allow us to kill the need for an <asm/flat.h> for many cases. Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/include/asm/flat.h2
-rw-r--r--arch/c6x/include/asm/flat.h1
-rw-r--r--arch/h8300/Kconfig1
-rw-r--r--arch/h8300/include/asm/flat.h2
-rw-r--r--arch/m68k/Kconfig1
-rw-r--r--arch/m68k/include/asm/flat.h1
-rw-r--r--arch/microblaze/include/asm/flat.h2
-rw-r--r--arch/sh/include/asm/flat.h1
-rw-r--r--arch/xtensa/include/asm/flat.h1
-rw-r--r--fs/Kconfig.binfmt3
-rw-r--r--fs/binfmt_flat.c5
12 files changed, 9 insertions, 12 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8869742a85df..b1b48c0bde76 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -30,6 +30,7 @@ config ARM
30 select ARCH_USE_BUILTIN_BSWAP 30 select ARCH_USE_BUILTIN_BSWAP
31 select ARCH_USE_CMPXCHG_LOCKREF 31 select ARCH_USE_CMPXCHG_LOCKREF
32 select ARCH_WANT_IPC_PARSE_VERSION 32 select ARCH_WANT_IPC_PARSE_VERSION
33 select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
33 select BUILDTIME_EXTABLE_SORT if MMU 34 select BUILDTIME_EXTABLE_SORT if MMU
34 select CLONE_BACKWARDS 35 select CLONE_BACKWARDS
35 select CPU_PM if SUSPEND || CPU_IDLE 36 select CPU_PM if SUSPEND || CPU_IDLE
diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h
index acf162111ee2..bbc27901446f 100644
--- a/arch/arm/include/asm/flat.h
+++ b/arch/arm/include/asm/flat.h
@@ -8,8 +8,6 @@
8 8
9#include <linux/uaccess.h> 9#include <linux/uaccess.h>
10 10
11#define flat_argvp_envp_on_stack() 1
12
13static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, 11static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
14 u32 *addr, u32 *persistent) 12 u32 *addr, u32 *persistent)
15{ 13{
diff --git a/arch/c6x/include/asm/flat.h b/arch/c6x/include/asm/flat.h
index 353e4d06e8c0..2d57a9204d21 100644
--- a/arch/c6x/include/asm/flat.h
+++ b/arch/c6x/include/asm/flat.h
@@ -4,7 +4,6 @@
4 4
5#include <asm/unaligned.h> 5#include <asm/unaligned.h>
6 6
7#define flat_argvp_envp_on_stack() 0
8static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, 7static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
9 u32 *addr, u32 *persistent) 8 u32 *addr, u32 *persistent)
10{ 9{
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index d30e8727b02d..7457f190caaa 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -2,6 +2,7 @@
2config H8300 2config H8300
3 def_bool y 3 def_bool y
4 select ARCH_32BIT_OFF_T 4 select ARCH_32BIT_OFF_T
5 select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
5 select BINFMT_FLAT_OLD_ALWAYS_RAM 6 select BINFMT_FLAT_OLD_ALWAYS_RAM
6 select GENERIC_ATOMIC64 7 select GENERIC_ATOMIC64
7 select HAVE_UID16 8 select HAVE_UID16
diff --git a/arch/h8300/include/asm/flat.h b/arch/h8300/include/asm/flat.h
index 14cc928d5478..4683146f0e9e 100644
--- a/arch/h8300/include/asm/flat.h
+++ b/arch/h8300/include/asm/flat.h
@@ -8,8 +8,6 @@
8 8
9#include <asm/unaligned.h> 9#include <asm/unaligned.h>
10 10
11#define flat_argvp_envp_on_stack() 1
12
13/* 11/*
14 * on the H8 a couple of the relocations have an instruction in the 12 * on the H8 a couple of the relocations have an instruction in the
15 * top byte. As there can only be 24bits of address space, we just 13 * top byte. As there can only be 24bits of address space, we just
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 218e037ef901..fd69ee5ad6ab 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -7,6 +7,7 @@ config M68K
7 select ARCH_MIGHT_HAVE_PC_PARPORT if ISA 7 select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
8 select ARCH_NO_COHERENT_DMA_MMAP if !MMU 8 select ARCH_NO_COHERENT_DMA_MMAP if !MMU
9 select ARCH_NO_PREEMPT if !COLDFIRE 9 select ARCH_NO_PREEMPT if !COLDFIRE
10 select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
10 select HAVE_IDE 11 select HAVE_IDE
11 select HAVE_AOUT if MMU 12 select HAVE_AOUT if MMU
12 select HAVE_DEBUG_BUGVERBOSE 13 select HAVE_DEBUG_BUGVERBOSE
diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h
index 7b1fb5c2809e..d7102fcd43eb 100644
--- a/arch/m68k/include/asm/flat.h
+++ b/arch/m68k/include/asm/flat.h
@@ -8,7 +8,6 @@
8 8
9#include <linux/uaccess.h> 9#include <linux/uaccess.h>
10 10
11#define flat_argvp_envp_on_stack() 1
12static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, 11static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
13 u32 *addr, u32 *persistent) 12 u32 *addr, u32 *persistent)
14{ 13{
diff --git a/arch/microblaze/include/asm/flat.h b/arch/microblaze/include/asm/flat.h
index 1cd8d7f4cf12..9e3d8e01d294 100644
--- a/arch/microblaze/include/asm/flat.h
+++ b/arch/microblaze/include/asm/flat.h
@@ -13,8 +13,6 @@
13 13
14#include <asm/unaligned.h> 14#include <asm/unaligned.h>
15 15
16#define flat_argvp_envp_on_stack() 0
17
18/* 16/*
19 * Microblaze works a little differently from other arches, because 17 * Microblaze works a little differently from other arches, because
20 * of the MICROBLAZE_64 reloc type. Here, a 32 bit address is split 18 * of the MICROBLAZE_64 reloc type. Here, a 32 bit address is split
diff --git a/arch/sh/include/asm/flat.h b/arch/sh/include/asm/flat.h
index 015678d7b771..1002343dd84a 100644
--- a/arch/sh/include/asm/flat.h
+++ b/arch/sh/include/asm/flat.h
@@ -11,7 +11,6 @@
11 11
12#include <asm/unaligned.h> 12#include <asm/unaligned.h>
13 13
14#define flat_argvp_envp_on_stack() 0
15static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, 14static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
16 u32 *addr, u32 *persistent) 15 u32 *addr, u32 *persistent)
17{ 16{
diff --git a/arch/xtensa/include/asm/flat.h b/arch/xtensa/include/asm/flat.h
index b215c1e66958..3d357371b28b 100644
--- a/arch/xtensa/include/asm/flat.h
+++ b/arch/xtensa/include/asm/flat.h
@@ -4,7 +4,6 @@
4 4
5#include <asm/unaligned.h> 5#include <asm/unaligned.h>
6 6
7#define flat_argvp_envp_on_stack() 0
8static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, 7static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
9 u32 *addr, u32 *persistent) 8 u32 *addr, u32 *persistent)
10{ 9{
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 5658e12ad944..82f7d7f234f3 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -97,6 +97,9 @@ config BINFMT_FLAT
97 help 97 help
98 Support uClinux FLAT format binaries. 98 Support uClinux FLAT format binaries.
99 99
100config BINFMT_FLAT_ARGVP_ENVP_ON_STACK
101 bool
102
100config BINFMT_FLAT_OLD_ALWAYS_RAM 103config BINFMT_FLAT_OLD_ALWAYS_RAM
101 bool 104 bool
102 105
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 3e7f4a6cffa2..a15fdd5d95ed 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -124,14 +124,15 @@ static int create_flat_tables(struct linux_binprm *bprm, unsigned long arg_start
124 124
125 sp -= bprm->envc + 1; 125 sp -= bprm->envc + 1;
126 sp -= bprm->argc + 1; 126 sp -= bprm->argc + 1;
127 sp -= flat_argvp_envp_on_stack() ? 2 : 0; 127 if (IS_ENABLED(CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK))
128 sp -= 2; /* argvp + envp */
128 sp -= 1; /* &argc */ 129 sp -= 1; /* &argc */
129 130
130 current->mm->start_stack = (unsigned long)sp & -FLAT_STACK_ALIGN; 131 current->mm->start_stack = (unsigned long)sp & -FLAT_STACK_ALIGN;
131 sp = (unsigned long __user *)current->mm->start_stack; 132 sp = (unsigned long __user *)current->mm->start_stack;
132 133
133 __put_user(bprm->argc, sp++); 134 __put_user(bprm->argc, sp++);
134 if (flat_argvp_envp_on_stack()) { 135 if (IS_ENABLED(CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK)) {
135 unsigned long argv, envp; 136 unsigned long argv, envp;
136 argv = (unsigned long)(sp + 2); 137 argv = (unsigned long)(sp + 2);
137 envp = (unsigned long)(sp + 2 + bprm->argc + 1); 138 envp = (unsigned long)(sp + 2 + bprm->argc + 1);