sys_getrlimit: modified to return mcexec's RLIMIT_STACK
This commit is contained in:
@@ -48,6 +48,8 @@ struct program_load_desc {
|
|||||||
unsigned long args_len;
|
unsigned long args_len;
|
||||||
char *envs;
|
char *envs;
|
||||||
unsigned long envs_len;
|
unsigned long envs_len;
|
||||||
|
unsigned long rlimit_stack_cur;
|
||||||
|
unsigned long rlimit_stack_max;
|
||||||
struct program_image_section sections[0];
|
struct program_image_section sections[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -491,6 +491,8 @@ int main(int argc, char **argv)
|
|||||||
FILE *interp = NULL;
|
FILE *interp = NULL;
|
||||||
char *interp_path;
|
char *interp_path;
|
||||||
char *path;
|
char *path;
|
||||||
|
int error;
|
||||||
|
struct rlimit rlim_stack;
|
||||||
|
|
||||||
#ifdef USE_SYSCALL_MOD_CALL
|
#ifdef USE_SYSCALL_MOD_CALL
|
||||||
__glob_argc = argc;
|
__glob_argc = argc;
|
||||||
@@ -502,6 +504,12 @@ int main(int argc, char **argv)
|
|||||||
altroot = "/usr/linux-k1om-4.7/linux-k1om";
|
altroot = "/usr/linux-k1om-4.7/linux-k1om";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error = getrlimit(RLIMIT_STACK, &rlim_stack);
|
||||||
|
if (error) {
|
||||||
|
fprintf(stderr, "Error: Failed to get stack limit.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(dev, "/dev/mcos0");
|
strcpy(dev, "/dev/mcos0");
|
||||||
if(argv[1]){
|
if(argv[1]){
|
||||||
for(p = argv[1]; *p && *p >= '0' && *p <= '9'; p++);
|
for(p = argv[1]; *p && *p >= '0' && *p <= '9'; p++);
|
||||||
@@ -562,6 +570,9 @@ int main(int argc, char **argv)
|
|||||||
desc->args = args;
|
desc->args = args;
|
||||||
//print_flat(args);
|
//print_flat(args);
|
||||||
|
|
||||||
|
desc->rlimit_stack_cur = rlim_stack.rlim_cur;
|
||||||
|
desc->rlimit_stack_max = rlim_stack.rlim_max;
|
||||||
|
|
||||||
fd = open(dev, O_RDWR);
|
fd = open(dev, O_RDWR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "Error: Failed to open %s.\n", dev);
|
fprintf(stderr, "Error: Failed to open %s.\n", dev);
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ static int process_msg_prepare_process(unsigned long rphys)
|
|||||||
proc->pid = pn->pid;
|
proc->pid = pn->pid;
|
||||||
proc->vm->region.user_start = pn->user_start;
|
proc->vm->region.user_start = pn->user_start;
|
||||||
proc->vm->region.user_end = pn->user_end;
|
proc->vm->region.user_end = pn->user_end;
|
||||||
|
proc->rlimit_stack.rlim_cur = pn->rlimit_stack_cur;
|
||||||
|
proc->rlimit_stack.rlim_max = pn->rlimit_stack_max;
|
||||||
|
|
||||||
/* TODO: Clear it at the proper timing */
|
/* TODO: Clear it at the proper timing */
|
||||||
cpu_local_var(scp).post_idx = 0;
|
cpu_local_var(scp).post_idx = 0;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <waitq.h>
|
#include <waitq.h>
|
||||||
#include <futex.h>
|
#include <futex.h>
|
||||||
|
#include <rlimit.h>
|
||||||
|
|
||||||
struct vm_range {
|
struct vm_range {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
@@ -90,6 +91,7 @@ struct process {
|
|||||||
char sigstack[512];
|
char sigstack[512];
|
||||||
// TODO: backup FR and MMX regs
|
// TODO: backup FR and MMX regs
|
||||||
unsigned long sigrc; // return code of rt_sigreturn (x86_64: rax reg.)
|
unsigned long sigrc; // return code of rt_sigreturn (x86_64: rax reg.)
|
||||||
|
struct rlimit rlimit_stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct process_vm {
|
struct process_vm {
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ struct program_load_desc {
|
|||||||
unsigned long args_len;
|
unsigned long args_len;
|
||||||
char *envs;
|
char *envs;
|
||||||
unsigned long envs_len;
|
unsigned long envs_len;
|
||||||
|
unsigned long rlimit_stack_cur;
|
||||||
|
unsigned long rlimit_stack_max;
|
||||||
struct program_image_section sections[0];
|
struct program_image_section sections[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ struct process *clone_process(struct process *org, unsigned long pc,
|
|||||||
|
|
||||||
ihk_atomic_inc(&org->vm->refcount);
|
ihk_atomic_inc(&org->vm->refcount);
|
||||||
proc->vm = org->vm;
|
proc->vm = org->vm;
|
||||||
|
proc->rlimit_stack = org->rlimit_stack;
|
||||||
|
|
||||||
proc->sighandler = org->sighandler;
|
proc->sighandler = org->sighandler;
|
||||||
ihk_atomic_inc(&org->sighandler->use);
|
ihk_atomic_inc(&org->sighandler->use);
|
||||||
|
|||||||
@@ -1106,14 +1106,14 @@ SYSCALL_DECLARE(getrlimit)
|
|||||||
int ret;
|
int ret;
|
||||||
int resource = ihk_mc_syscall_arg0(ctx);
|
int resource = ihk_mc_syscall_arg0(ctx);
|
||||||
struct rlimit *rlm = (struct rlimit *)ihk_mc_syscall_arg1(ctx);
|
struct rlimit *rlm = (struct rlimit *)ihk_mc_syscall_arg1(ctx);
|
||||||
|
struct process *proc = cpu_local_var(current);
|
||||||
|
|
||||||
switch (resource) {
|
switch (resource) {
|
||||||
|
|
||||||
case RLIMIT_STACK:
|
case RLIMIT_STACK:
|
||||||
|
|
||||||
dkprintf("[%d] getrlimit() RLIMIT_STACK\n", ihk_mc_get_processor_id());
|
dkprintf("[%d] getrlimit() RLIMIT_STACK\n", ihk_mc_get_processor_id());
|
||||||
rlm->rlim_cur = (512*4096); /* Linux provides 8MB */
|
rlm->rlim_cur = proc->rlimit_stack.rlim_cur;
|
||||||
rlm->rlim_max = (1024*1024*1024);
|
rlm->rlim_max = proc->rlimit_stack.rlim_max;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user