summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exec.c3
-rw-r--r--kalloc.c6
-rw-r--r--usertests.c16
3 files changed, 22 insertions, 3 deletions
diff --git a/exec.c b/exec.c
index 222f64c..0a9ca59 100644
--- a/exec.c
+++ b/exec.c
@@ -62,6 +62,9 @@ exec(char *path, char **argv)
sp = sz;
argp = sz - arglen - 4*(argc+1);
+ // XXX rtm: does the following code work if the
+ // arguments &c do not fit in one page?
+
// Copy argv strings and pointers to stack.
*(uint*)(mem+argp-spbottom + 4*argc) = 0; // argv[argc]
for(i=argc-1; i>=0; i--){
diff --git a/kalloc.c b/kalloc.c
index 5f690f5..72ce58a 100644
--- a/kalloc.c
+++ b/kalloc.c
@@ -17,12 +17,12 @@ struct {
struct run *freelist;
} kmem;
+extern char end[]; // first address after kernel loaded from ELF file
+
// Initialize free list of physical pages.
void
kinit(void)
{
- extern char end[];
-
initlock(&kmem.lock, "kmem");
char *p = (char*)PGROUNDUP((uint)end);
for( ; p + PGSIZE - 1 < (char*) PHYSTOP; p += PGSIZE)
@@ -39,7 +39,7 @@ kfree(char *v)
{
struct run *r;
- if(((uint) v) % PGSIZE || (uint)v < 1024*1024 || (uint)v >= PHYSTOP)
+ if(((uint) v) % PGSIZE || v < end || (uint)v >= PHYSTOP)
panic("kfree");
// Fill with junk to catch dangling refs.
diff --git a/usertests.c b/usertests.c
index 77495bf..e62703d 100644
--- a/usertests.c
+++ b/usertests.c
@@ -1419,6 +1419,21 @@ validatetest(void)
printf(stdout, "validate ok\n");
}
+char uninit[10000];
+void
+bsstest(void)
+{
+ int i;
+ printf(stdout, "bss test\n");
+ for(i = 0; i < sizeof(uninit); i++){
+ if(uninit[i] != '\0'){
+ printf(stdout, "bss test failed\n");
+ exit();
+ }
+ }
+ printf(stdout, "bss test ok\n");
+}
+
int
main(int argc, char *argv[])
{
@@ -1430,6 +1445,7 @@ main(int argc, char *argv[])
}
close(open("usertests.ran", O_CREATE));
+ bsstest();
sbrktest();
validatetest();