Skip to content

Commit

Permalink
Merge tag 'metag-for-v3.15-2' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/jhogan/metag

Pull Metag architecture and related fixes from James Hogan:
 "Mostly fixes for metag and parisc relating to upgrowing stacks.

   - Fix missing compiler barriers in metag memory barriers.
   - Fix BUG_ON on metag when RLIMIT_STACK hard limit is increased
     beyond safe value.
   - Make maximum stack size configurable.  This reduces the default
     user stack size back to 80MB (especially on parisc after their
     removal of _STK_LIM_MAX override).  This only affects metag and
     parisc.
   - Remove metag _STK_LIM_MAX override to match other arches and follow
     parisc, now that it is safe to do so (due to the BUG_ON fix
     mentioned above).
   - Finally now that both metag and parisc _STK_LIM_MAX overrides have
     been removed, it makes sense to remove _STK_LIM_MAX altogether"

* tag 'metag-for-v3.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/metag:
  asm-generic: remove _STK_LIM_MAX
  metag: Remove _STK_LIM_MAX override
  parisc,metag: Do not hardcode maximum userspace stack size
  metag: Reduce maximum stack size to 256MB
  metag: fix memory barriers
  • Loading branch information
Linus Torvalds committed May 20, 2014
2 parents a7b0806 + ffe6902 commit 41abc90
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 22 deletions.
3 changes: 3 additions & 0 deletions arch/metag/include/asm/barrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static inline void wr_fence(void)
volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_FENCE;
barrier();
*flushptr = 0;
barrier();
}

#else /* CONFIG_METAG_META21 */
Expand All @@ -35,6 +36,7 @@ static inline void wr_fence(void)
*flushptr = 0;
*flushptr = 0;
*flushptr = 0;
barrier();
}

#endif /* !CONFIG_METAG_META21 */
Expand Down Expand Up @@ -68,6 +70,7 @@ static inline void fence(void)
volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
barrier();
*flushptr = 0;
barrier();
}
#define smp_mb() fence()
#define smp_rmb() fence()
Expand Down
2 changes: 2 additions & 0 deletions arch/metag/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
/* Add an extra page of padding at the top of the stack for the guard page. */
#define STACK_TOP (TASK_SIZE - PAGE_SIZE)
#define STACK_TOP_MAX STACK_TOP
/* Maximum virtual space for stack */
#define STACK_SIZE_MAX (CONFIG_MAX_STACK_SIZE_MB*1024*1024)

/* This decides where the kernel will search for a free chunk of vm
* space during mmap's.
Expand Down
2 changes: 1 addition & 1 deletion arch/metag/include/uapi/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ include include/uapi/asm-generic/Kbuild.asm
header-y += byteorder.h
header-y += ech.h
header-y += ptrace.h
header-y += resource.h
header-y += sigcontext.h
header-y += siginfo.h
header-y += swab.h
header-y += unistd.h

generic-y += mman.h
generic-y += resource.h
generic-y += setup.h
7 changes: 0 additions & 7 deletions arch/metag/include/uapi/asm/resource.h

This file was deleted.

5 changes: 5 additions & 0 deletions arch/parisc/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
#define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX DEFAULT_TASK_SIZE

/* Allow bigger stacks for 64-bit processes */
#define STACK_SIZE_MAX (USER_WIDE_MODE \
? (1 << 30) /* 1 GB */ \
: (CONFIG_MAX_STACK_SIZE_MB*1024*1024))

#endif

#ifndef __ASSEMBLY__
Expand Down
6 changes: 3 additions & 3 deletions arch/parisc/kernel/sys_parisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ static unsigned long mmap_upper_limit(void)
{
unsigned long stack_base;

/* Limit stack size to 1GB - see setup_arg_pages() in fs/exec.c */
/* Limit stack size - see setup_arg_pages() in fs/exec.c */
stack_base = rlimit_max(RLIMIT_STACK);
if (stack_base > (1 << 30))
stack_base = 1 << 30;
if (stack_base > STACK_SIZE_MAX)
stack_base = STACK_SIZE_MAX;

return PAGE_ALIGN(STACK_TOP - stack_base);
}
Expand Down
6 changes: 3 additions & 3 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,10 @@ int setup_arg_pages(struct linux_binprm *bprm,
unsigned long rlim_stack;

#ifdef CONFIG_STACK_GROWSUP
/* Limit stack size to 1GB */
/* Limit stack size */
stack_base = rlimit_max(RLIMIT_STACK);
if (stack_base > (1 << 30))
stack_base = 1 << 30;
if (stack_base > STACK_SIZE_MAX)
stack_base = STACK_SIZE_MAX;

/* Make sure we didn't let the argument array grow too large. */
if (vma->vm_end - vma->vm_start > stack_base)
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[RLIMIT_CPU] = { RLIM_INFINITY, RLIM_INFINITY }, \
[RLIMIT_FSIZE] = { RLIM_INFINITY, RLIM_INFINITY }, \
[RLIMIT_DATA] = { RLIM_INFINITY, RLIM_INFINITY }, \
[RLIMIT_STACK] = { _STK_LIM, _STK_LIM_MAX }, \
[RLIMIT_STACK] = { _STK_LIM, RLIM_INFINITY }, \
[RLIMIT_CORE] = { 0, RLIM_INFINITY }, \
[RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \
[RLIMIT_NPROC] = { 0, 0 }, \
Expand Down
7 changes: 0 additions & 7 deletions include/uapi/asm-generic/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,5 @@
# define RLIM_INFINITY (~0UL)
#endif

/*
* RLIMIT_STACK default maximum - some architectures override it:
*/
#ifndef _STK_LIM_MAX
# define _STK_LIM_MAX RLIM_INFINITY
#endif


#endif /* _UAPI_ASM_GENERIC_RESOURCE_H */
15 changes: 15 additions & 0 deletions mm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,18 @@ config PGTABLE_MAPPING

config GENERIC_EARLY_IOREMAP
bool

config MAX_STACK_SIZE_MB
int "Maximum user stack size for 32-bit processes (MB)"
default 80
range 8 256 if METAG
range 8 2048
depends on STACK_GROWSUP && (!64BIT || COMPAT)
help
This is the maximum stack size in Megabytes in the VM layout of 32-bit
user processes when the stack grows upwards (currently only on parisc
and metag arch). The stack will be located at the highest memory
address minus the given value, unless the RLIMIT_STACK hard limit is
changed to a smaller value in which case that is used.

A sane initial value is 80 MB.

0 comments on commit 41abc90

Please sign in to comment.