aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-04-15 16:14:03 -0700
committerAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-04-15 16:14:03 -0700
commit6b9ea8b8e0d3bdf66727a2bc3e9dce72a77fa514 (patch)
treea78893262ececb2728f07a9ae591ec0d78538eb4
parent0d603acb91f455adb879ea45fdb84313067f4293 (diff)
downloadpk-6b9ea8b8e0d3bdf66727a2bc3e9dce72a77fa514.zip
pk-6b9ea8b8e0d3bdf66727a2bc3e9dce72a77fa514.tar.gz
pk-6b9ea8b8e0d3bdf66727a2bc3e9dce72a77fa514.tar.bz2
[pk] limit programs to 2GB (for RV32 simplicity)
-rw-r--r--pk/pk.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/pk/pk.c b/pk/pk.c
index 4ed7e1e..7260601 100644
--- a/pk/pk.c
+++ b/pk/pk.c
@@ -145,13 +145,10 @@ struct args
uint64_t argv[];
};
-static struct args* mainvars_init()
+static struct args* mainvars_init(long loc)
{
- long loc = (mfpcr(PCR_MEMSIZE) << MEMSIZE_SHIFT) - USER_MAINVARS_SIZE;
-
sysret_t r = frontend_syscall(SYS_getmainvars, loc, USER_MAINVARS_SIZE, 0, 0);
kassert(r.result == 0);
-
return (struct args*)loc;
}
@@ -162,6 +159,7 @@ static void jump_usrstart(const char* fn, long sp)
int user64;
long start = load_elf(fn, &user64);
asm volatile("cflush; fence");
+
init_tf(&tf, start, sp, user64);
pop_tf(&tf);
}
@@ -171,6 +169,11 @@ void boot()
bss_init();
file_init();
- struct args* args = mainvars_init();
- jump_usrstart((char*)(long)args->argv[0], (long)args);
+ long stack_top = (mfpcr(PCR_MEMSIZE) << MEMSIZE_SHIFT);
+ if(stack_top >= 0x80000000)
+ stack_top = 0x80000000;
+ stack_top -= USER_MAINVARS_SIZE;
+
+ struct args* args = mainvars_init(stack_top);
+ jump_usrstart((char*)(long)args->argv[0], stack_top);
}