Commit 5a5bed27 authored by Martin Hicks's avatar Martin Hicks Committed by David Mosberger

[PATCH] ia64: max user stack size of main thread configurable via RLIMIT_STACK

Make the size of the user stack based on the stack rlimit.
The stack hard stack size now defaults to 2GB, but can be increased
 with ulimit up to 1/2 of the max mappable space in a region.
For 16k pages, this makes the max stack size 8TB.
parent 58f957be
...@@ -68,6 +68,16 @@ check_pgt_cache (void) ...@@ -68,6 +68,16 @@ check_pgt_cache (void)
} }
} }
inline void
ia64_set_rbs_bot (void)
{
unsigned long stack_size = current->rlim[RLIMIT_STACK].rlim_max & -16;
if (stack_size > MAX_USER_STACK_SIZE)
stack_size = MAX_USER_STACK_SIZE;
current->thread.rbs_bot = STACK_TOP - stack_size;
}
/* /*
* This performs some platform-dependent address space initialization. * This performs some platform-dependent address space initialization.
* On IA-64, we want to setup the VM area for the register backing * On IA-64, we want to setup the VM area for the register backing
...@@ -79,6 +89,8 @@ ia64_init_addr_space (void) ...@@ -79,6 +89,8 @@ ia64_init_addr_space (void)
{ {
struct vm_area_struct *vma; struct vm_area_struct *vma;
ia64_set_rbs_bot();
/* /*
* If we're out of memory and kmem_cache_alloc() returns NULL, we simply ignore * If we're out of memory and kmem_cache_alloc() returns NULL, we simply ignore
* the problem. When the process attempts to write to the register backing store * the problem. When the process attempts to write to the register backing store
...@@ -87,7 +99,7 @@ ia64_init_addr_space (void) ...@@ -87,7 +99,7 @@ ia64_init_addr_space (void)
vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
if (vma) { if (vma) {
vma->vm_mm = current->mm; vma->vm_mm = current->mm;
vma->vm_start = IA64_RBS_BOT; vma->vm_start = current->thread.rbs_bot;
vma->vm_end = vma->vm_start + PAGE_SIZE; vma->vm_end = vma->vm_start + PAGE_SIZE;
vma->vm_page_prot = protection_map[VM_DATA_DEFAULT_FLAGS & 0x7]; vma->vm_page_prot = protection_map[VM_DATA_DEFAULT_FLAGS & 0x7];
vma->vm_flags = VM_READ|VM_WRITE|VM_MAYREAD|VM_MAYWRITE|VM_GROWSUP; vma->vm_flags = VM_READ|VM_WRITE|VM_MAYREAD|VM_MAYWRITE|VM_GROWSUP;
......
...@@ -30,9 +30,6 @@ struct exec { ...@@ -30,9 +30,6 @@ struct exec {
#define N_TXTOFF(x) 0 #define N_TXTOFF(x) 0
#ifdef __KERNEL__ #ifdef __KERNEL__
# include <asm/page.h> #include <asm/ustack.h>
# define STACK_TOP (0x6000000000000000UL + (1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE)
# define IA64_RBS_BOT (STACK_TOP - 0x80000000L + PAGE_SIZE) /* bottom of reg. backing store */
#endif #endif
#endif /* _ASM_IA64_A_OUT_H */ #endif /* _ASM_IA64_A_OUT_H */
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/kregs.h> #include <asm/kregs.h>
#include <asm/ustack.h>
#define IA64_NUM_DBG_REGS 8 #define IA64_NUM_DBG_REGS 8
/* /*
...@@ -235,6 +236,7 @@ struct thread_struct { ...@@ -235,6 +236,7 @@ struct thread_struct {
__u64 ksp; /* kernel stack pointer */ __u64 ksp; /* kernel stack pointer */
__u64 map_base; /* base address for get_unmapped_area() */ __u64 map_base; /* base address for get_unmapped_area() */
__u64 task_size; /* limit for task size */ __u64 task_size; /* limit for task size */
__u64 rbs_bot; /* the base address for the RBS */
int last_fph_cpu; /* CPU that may hold the contents of f32-f127 */ int last_fph_cpu; /* CPU that may hold the contents of f32-f127 */
#ifdef CONFIG_IA32_SUPPORT #ifdef CONFIG_IA32_SUPPORT
...@@ -283,6 +285,7 @@ struct thread_struct { ...@@ -283,6 +285,7 @@ struct thread_struct {
.on_ustack = 0, \ .on_ustack = 0, \
.ksp = 0, \ .ksp = 0, \
.map_base = DEFAULT_MAP_BASE, \ .map_base = DEFAULT_MAP_BASE, \
.rbs_bot = DEFAULT_USER_STACK_SIZE, \
.task_size = DEFAULT_TASK_SIZE, \ .task_size = DEFAULT_TASK_SIZE, \
.last_fph_cpu = -1, \ .last_fph_cpu = -1, \
INIT_THREAD_IA32 \ INIT_THREAD_IA32 \
...@@ -299,7 +302,7 @@ struct thread_struct { ...@@ -299,7 +302,7 @@ struct thread_struct {
regs->cr_iip = new_ip; \ regs->cr_iip = new_ip; \
regs->ar_rsc = 0xf; /* eager mode, privilege level 3 */ \ regs->ar_rsc = 0xf; /* eager mode, privilege level 3 */ \
regs->ar_rnat = 0; \ regs->ar_rnat = 0; \
regs->ar_bspstore = IA64_RBS_BOT; \ regs->ar_bspstore = current->thread.rbs_bot; \
regs->ar_fpsr = FPSR_DEFAULT; \ regs->ar_fpsr = FPSR_DEFAULT; \
regs->loadrs = 0; \ regs->loadrs = 0; \
regs->r8 = current->mm->dumpable; /* set "don't zap registers" flag */ \ regs->r8 = current->mm->dumpable; /* set "don't zap registers" flag */ \
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
* Copyright (C) 1998, 1999 David Mosberger-Tang <davidm@hpl.hp.com> * Copyright (C) 1998, 1999 David Mosberger-Tang <davidm@hpl.hp.com>
*/ */
#include <asm/ustack.h>
#define RLIMIT_CPU 0 /* CPU time in ms */ #define RLIMIT_CPU 0 /* CPU time in ms */
#define RLIMIT_FSIZE 1 /* Maximum filesize */ #define RLIMIT_FSIZE 1 /* Maximum filesize */
#define RLIMIT_DATA 2 /* max data size */ #define RLIMIT_DATA 2 /* max data size */
...@@ -35,7 +37,7 @@ ...@@ -35,7 +37,7 @@
{ RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \
{ RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \
{ RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \
{ _STK_LIM, RLIM_INFINITY }, \ { _STK_LIM, DEFAULT_USER_STACK_SIZE }, \
{ 0, RLIM_INFINITY }, \ { 0, RLIM_INFINITY }, \
{ RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \
{ 0, 0 }, \ { 0, 0 }, \
......
#ifndef _ASM_IA64_USTACK_H
#define _ASM_IA64_USTACK_H
/*
* Constants for the user stack size
*/
#include <asm/pgtable.h>
/* The absolute hard limit for stack size is 1/2 of the mappable space in the region */
#define MAX_USER_STACK_SIZE (RGN_MAP_LIMIT/2)
/* Make a default stack size of 2GB */
#define DEFAULT_USER_STACK_SIZE (1UL << 31)
#define STACK_TOP (0x6000000000000000UL + RGN_MAP_LIMIT)
#endif /* _ASM_IA64_USTACK_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment