linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: dhowells@redhat.com
To: torvalds@osdl.org, akpm@osdl.org, davidm@snapgear.com
Cc: linux-kernel@vger.kernel.org, uclinux-dev@uclinux.org
Subject: [PATCH 19/20] FRV: change setup_arg_pages() to take stack pointer
Date: Mon, 8 Nov 2004 14:34:20 GMT	[thread overview]
Message-ID: <200411081434.iA8EYKdN023627@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <44bd214c-3193-11d9-8962-0002b3163499@redhat.com>

The attached patch changes setup_arg_pages() to take the proposed initial stack
top for the new executable image. This makes it easier for the binfmt to place
the stack at a non-fixed location, such as happens in !MMU configurations.

Signed-Off-By: dhowells@redhat.com
---
diffstat setup_arg_pages-2610rc1mm3.diff
 arch/x86_64/ia32/ia32_aout.c   |    5 +++--
 arch/x86_64/ia32/ia32_binfmt.c |    7 ++++---
 fs/binfmt_aout.c               |    2 +-
 fs/binfmt_elf.c                |    2 +-
 fs/binfmt_som.c                |    2 +-
 fs/exec.c                      |   12 +++++++-----
 include/linux/binfmts.h        |    4 +++-
 7 files changed, 20 insertions(+), 14 deletions(-)

diff -uNrp /warthog/kernels/linux-2.6.10-rc1-mm3/arch/x86_64/ia32/ia32_aout.c linux-2.6.10-rc1-mm3-frv/arch/x86_64/ia32/ia32_aout.c
--- /warthog/kernels/linux-2.6.10-rc1-mm3/arch/x86_64/ia32/ia32_aout.c	2004-10-27 17:32:14.000000000 +0100
+++ linux-2.6.10-rc1-mm3-frv/arch/x86_64/ia32/ia32_aout.c	2004-11-05 14:13:03.000000000 +0000
@@ -35,7 +35,8 @@
 #undef WARN_OLD
 #undef CORE_DUMP /* probably broken */
 
-extern int ia32_setup_arg_pages(struct linux_binprm *bprm, int exec_stack);
+extern int ia32_setup_arg_pages(struct linux_binprm *bprm,
+				unsigned long stack_top, int exec_stack);
 
 static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs);
 static int load_aout_library(struct file*);
@@ -396,7 +397,7 @@ beyond_if:
 
 	set_brk(current->mm->start_brk, current->mm->brk);
 
-	retval = ia32_setup_arg_pages(bprm, EXSTACK_DEFAULT);
+	retval = ia32_setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT);
 	if (retval < 0) { 
 		/* Someone check-me: is this error path enough? */ 
 		send_sig(SIGKILL, current, 0); 
diff -uNrp /warthog/kernels/linux-2.6.10-rc1-mm3/arch/x86_64/ia32/ia32_binfmt.c linux-2.6.10-rc1-mm3-frv/arch/x86_64/ia32/ia32_binfmt.c
--- /warthog/kernels/linux-2.6.10-rc1-mm3/arch/x86_64/ia32/ia32_binfmt.c	2004-10-27 17:32:14.000000000 +0100
+++ linux-2.6.10-rc1-mm3-frv/arch/x86_64/ia32/ia32_binfmt.c	2004-11-05 14:13:03.000000000 +0000
@@ -273,8 +273,9 @@ do {							\
 #define load_elf_binary load_elf32_binary
 
 #define ELF_PLAT_INIT(r, load_addr)	elf32_init(r)
-#define setup_arg_pages(bprm, exec_stack)	ia32_setup_arg_pages(bprm, exec_stack)
-int ia32_setup_arg_pages(struct linux_binprm *bprm, int executable_stack);
+#define setup_arg_pages(bprm, stack_top, exec_stack) \
+	ia32_setup_arg_pages(bprm, stack_top, exec_stack)
+int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, int executable_stack);
 
 #undef start_thread
 #define start_thread(regs,new_rip,new_rsp) do { \
@@ -329,7 +330,7 @@ static void elf32_init(struct pt_regs *r
 	me->thread.es = __USER_DS;
 }
 
-int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
+int setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, int executable_stack)
 {
 	unsigned long stack_base;
 	struct vm_area_struct *mpnt;
diff -uNrp /warthog/kernels/linux-2.6.10-rc1-mm3/fs/binfmt_aout.c linux-2.6.10-rc1-mm3-frv/fs/binfmt_aout.c
--- /warthog/kernels/linux-2.6.10-rc1-mm3/fs/binfmt_aout.c	2004-10-27 17:32:30.000000000 +0100
+++ linux-2.6.10-rc1-mm3-frv/fs/binfmt_aout.c	2004-11-05 14:13:03.000000000 +0000
@@ -415,7 +415,7 @@ beyond_if:
 
 	set_brk(current->mm->start_brk, current->mm->brk);
 
-	retval = setup_arg_pages(bprm, EXSTACK_DEFAULT);
+	retval = setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
 	if (retval < 0) { 
 		/* Someone check-me: is this error path enough? */ 
 		send_sig(SIGKILL, current, 0); 
diff -uNrp /warthog/kernels/linux-2.6.10-rc1-mm3/fs/binfmt_elf.c linux-2.6.10-rc1-mm3-frv/fs/binfmt_elf.c
--- /warthog/kernels/linux-2.6.10-rc1-mm3/fs/binfmt_elf.c	2004-11-05 13:15:39.000000000 +0000
+++ linux-2.6.10-rc1-mm3-frv/fs/binfmt_elf.c	2004-11-05 14:13:03.000000000 +0000
@@ -718,7 +718,7 @@ static int load_elf_binary(struct linux_
 	   change some of these later */
 	current->mm->rss = 0;
 	current->mm->free_area_cache = current->mm->mmap_base;
-	retval = setup_arg_pages(bprm, executable_stack);
+	retval = setup_arg_pages(bprm, STACK_TOP, executable_stack);
 	if (retval < 0) {
 		send_sig(SIGKILL, current, 0);
 		goto out_free_dentry;
diff -uNrp /warthog/kernels/linux-2.6.10-rc1-mm3/fs/binfmt_som.c linux-2.6.10-rc1-mm3-frv/fs/binfmt_som.c
--- /warthog/kernels/linux-2.6.10-rc1-mm3/fs/binfmt_som.c	2004-06-18 13:43:59.000000000 +0100
+++ linux-2.6.10-rc1-mm3-frv/fs/binfmt_som.c	2004-11-05 14:13:03.000000000 +0000
@@ -254,7 +254,7 @@ load_som_binary(struct linux_binprm * bp
 
 	set_binfmt(&som_format);
 	compute_creds(bprm);
-	setup_arg_pages(bprm, EXSTACK_DEFAULT);
+	setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
 
 	create_som_tables(bprm);
 
diff -uNrp /warthog/kernels/linux-2.6.10-rc1-mm3/fs/exec.c linux-2.6.10-rc1-mm3-frv/fs/exec.c
--- /warthog/kernels/linux-2.6.10-rc1-mm3/fs/exec.c	2004-11-05 13:15:39.000000000 +0000
+++ linux-2.6.10-rc1-mm3-frv/fs/exec.c	2004-11-05 14:13:03.769507090 +0000
@@ -342,7 +341,9 @@ out_sig:
 	force_sig(SIGKILL, current);
 }
 
-int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
+int setup_arg_pages(struct linux_binprm *bprm,
+		    unsigned long stack_top,
+		    int executable_stack)
 {
 	unsigned long stack_base;
 	struct vm_area_struct *mpnt;
@@ -386,7 +387,7 @@ int setup_arg_pages(struct linux_binprm 
 	stack_base = current->signal->rlim[RLIMIT_STACK].rlim_max;
 	if (stack_base > (1 << 30))
 		stack_base = 1 << 30;
-	stack_base = PAGE_ALIGN(STACK_TOP - stack_base);
+	stack_base = PAGE_ALIGN(stack_top - stack_base);
 
 	mm->arg_start = stack_base;
 	arg_size = i << PAGE_SHIFT;
@@ -395,9 +396,9 @@ int setup_arg_pages(struct linux_binprm 
 	while (i < MAX_ARG_PAGES)
 		bprm->page[i++] = NULL;
 #else
-	stack_base = STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE;
+	stack_base = stack_top - MAX_ARG_PAGES * PAGE_SIZE;
 	mm->arg_start = bprm->p + stack_base;
-	arg_size = STACK_TOP - (PAGE_MASK & (unsigned long) mm->arg_start);
+	arg_size = stack_top - (PAGE_MASK & (unsigned long) mm->arg_start);
 #endif
 
 	bprm->p += stack_base;
@@ -425,7 +426,7 @@ int setup_arg_pages(struct linux_binprm 
 			(PAGE_SIZE - 1 + (unsigned long) bprm->p);
 #else
 		mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
-		mpnt->vm_end = STACK_TOP;
+		mpnt->vm_end = stack_top;
 #endif
 		/* Adjust stack execute permissions; explicitly enable
 		 * for EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X
diff -uNrp /warthog/kernels/linux-2.6.10-rc1-mm3/include/linux/binfmts.h linux-2.6.10-rc1-mm3-frv/include/linux/binfmts.h
--- /warthog/kernels/linux-2.6.10-rc1-mm3/include/linux/binfmts.h	2004-09-16 12:06:20.000000000 +0100
+++ linux-2.6.10-rc1-mm3-frv/include/linux/binfmts.h	2004-11-05 14:13:04.353457768 +0000
@@ -74,7 +74,9 @@ extern int flush_old_exec(struct linux_b
 #define EXSTACK_DISABLE_X 1	/* Disable executable stacks */
 #define EXSTACK_ENABLE_X  2	/* Enable executable stacks */
 
-extern int setup_arg_pages(struct linux_binprm * bprm, int executable_stack);
+extern int setup_arg_pages(struct linux_binprm * bprm,
+			   unsigned long stack_top,
+			   int executable_stack);
 extern int copy_strings(int argc,char __user * __user * argv,struct linux_binprm *bprm); 
 extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
 extern void compute_creds(struct linux_binprm *binprm);

  parent reply	other threads:[~2004-11-08 15:44 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-08 14:34 [PATCH 1/20] FRV: Fujitsu FR-V CPU arch maintainer record dhowells
2004-11-08 14:34 ` [PATCH 2/20] FRV: Fujitsu FR-V arch documentation dhowells
2004-11-08 14:34 ` [PATCH 6/20] FRV: Fujitsu FR-V CPU arch implementation part 4 dhowells
2004-11-08 14:34 ` [PATCH 4/20] FRV: Fujitsu FR-V CPU arch implementation part 2 dhowells
2004-11-08 14:34 ` [PATCH 5/20] FRV: Fujitsu FR-V CPU arch implementation part 3 dhowells
2004-11-08 14:34 ` [PATCH 7/20] FRV: Fujitsu FR-V CPU arch implementation part 5 dhowells
2004-11-09 15:09   ` Geert Uytterhoeven
2004-11-08 14:34 ` [PATCH 3/20] FRV: Fujitsu FR-V CPU arch implementation part 1 dhowells
2004-11-08 14:34 ` [PATCH 8/20] FRV: Fujitsu FR-V CPU arch implementation part 6 dhowells
2004-11-08 14:34 ` [PATCH 9/20] FRV: Fujitsu FR-V CPU arch implementation part 7 dhowells
2004-11-08 14:34 ` [PATCH 11/20] FRV: Fujitsu FR-V CPU arch implementation part 9 dhowells
2004-11-08 14:34 ` [PATCH 10/20] FRV: Fujitsu FR-V CPU arch implementation part 8 dhowells
2004-11-08 14:34 ` [PATCH 15/20] FRV: Fujitsu FR-V arch include files dhowells
2004-11-08 14:34 ` [PATCH 16/20] FRV: Make calibrate_delay() optional dhowells
2004-11-08 14:34 ` [PATCH 14/20] FRV: Fujitsu FR-V arch include files dhowells
2004-11-08 14:34 ` [PATCH 13/20] " dhowells
2004-11-08 14:34 ` [PATCH 18/20] FRV: procfs changes for nommu changes dhowells
2004-11-08 14:34 ` [PATCH 20/20] FRV: Add FDPIC ELF binary format driver dhowells
2004-11-08 14:34 ` dhowells [this message]
     [not found] <76b4a884-2c3c-11d9-91a1-0002b3163499@redhat.com>
2004-11-01 19:30 ` [PATCH 4/14] FRV: Bitops fixes dhowells
2004-11-02  8:19   ` Andrew Morton
2004-11-01 19:30 ` [PATCH 3/14] FRV: Fujitsu FR-V arch documentation dhowells
2004-11-01 19:30 ` [PATCH 5/14] FRV: Fork fixes dhowells
2004-11-01 19:30 ` [PATCH 8/14] FRV: GP-REL data support dhowells
2004-11-02  8:18   ` Andrew Morton
2004-11-02  9:48   ` Christoph Hellwig
2004-11-02 16:34   ` David Howells
2004-11-03 10:42     ` Christoph Hellwig
2004-11-01 19:30 ` [PATCH 11/14] FRV: Add FDPIC ELF binary format driver dhowells
2004-11-02  8:18   ` Andrew Morton
2004-11-02 11:07   ` Andrew Morton
2004-11-02 16:47   ` David Howells
2004-11-02 17:23     ` Andi Kleen
2004-11-01 19:30 ` [PATCH 10/14] FRV: Make calibrate_delay() optional dhowells
2004-11-02  0:06   ` john stultz
2004-11-02  8:17   ` Andrew Morton
2004-11-02  9:36   ` Christoph Hellwig
2004-11-02 11:01   ` David Howells
2004-11-02 16:29   ` David Howells
2004-11-03 10:40     ` Christoph Hellwig
2004-11-01 19:30 ` [PATCH 9/14] FRV: CONFIG_MMU fixes dhowells
2004-11-02  9:43   ` Christoph Hellwig
2004-11-03 15:06   ` David Howells
2004-11-03 15:13     ` Christoph Hellwig
2004-11-03 15:30     ` David Howells
2004-11-01 19:30 ` [PATCH 7/14] FRV: GDB stub dependent additional BUG()'s dhowells
2004-11-02  9:34   ` Christoph Hellwig
2004-11-02 16:09   ` David Howells
2004-11-03 10:39     ` Christoph Hellwig
2004-11-03 13:41     ` David Howells
2004-11-01 19:30 ` [PATCH 6/14] FRV: IDE fixes dhowells
2004-11-01 22:53   ` Alan Cox
2004-11-02  0:13     ` Bartlomiej Zolnierkiewicz
2004-11-02 10:57     ` David Howells
2004-11-01 19:30 ` [PATCH 13/14] FRV: Convert extern inline -> static inline dhowells
2004-11-01 19:30 ` [PATCH 12/14] FRV: Generate more useful debug info dhowells
2004-11-02  0:29   ` Andrew Morton
2004-11-02 11:21   ` David Howells
2004-11-03  1:48     ` Linus Torvalds
2004-11-03  1:52       ` Linus Torvalds
2004-11-03 20:40         ` Florian Weimer
2004-11-03 20:42           ` Linus Torvalds
2004-11-03 13:38       ` David Howells
2004-11-03 15:32         ` Linus Torvalds
2004-11-12 14:57     ` Daniel Jacobowitz
2004-11-12 15:15     ` David Howells
2004-11-12 15:20       ` Daniel Jacobowitz
     [not found] ` <20040401020550.GG3150@beast>
2004-11-01 19:30   ` [PATCH 14/14] FRV: Better mmap support in uClinux dhowells
2004-11-02  9:54     ` Christoph Hellwig
2004-11-02 16:43     ` David Howells
2004-11-03 10:45       ` Christoph Hellwig
2004-11-08 14:34   ` [PATCH 17/20] " dhowells
2004-11-09 12:57     ` Christoph Hellwig
2004-11-09 13:55     ` David Howells
2004-11-09 14:02       ` Christoph Hellwig
2004-11-19  5:29     ` Matt Mackall
2004-11-19 16:26     ` David Howells
2004-11-19 16:56       ` Matt Mackall
2004-11-19 17:06       ` David Howells
2004-11-19 17:42         ` Linus Torvalds
2004-11-02  0:21 ` [PATCH 1/14] FRV: Fujitsu FR-V CPU arch implementation Andrew Morton
2004-11-02 23:46 ` [uClinux-dev] " Christoph Hellwig
     [not found] ` <200411011930.iA1JUKFH023161@warthog.cambridge.redhat.com>
2004-11-02 23:24   ` [uClinux-dev] [PATCH 2/14] FRV: Fujitsu FR-V arch include files Christoph Hellwig
2004-11-03 17:26   ` David Howells
2004-11-03 19:46 ` [uClinux-dev] [PATCH 1/14] FRV: Fujitsu FR-V CPU arch implementation David Howells
2004-11-03 20:32   ` Christoph Hellwig
2004-11-04 11:54 ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200411081434.iA8EYKdN023627@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=davidm@snapgear.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=uclinux-dev@uclinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).