map kernel instructions r/o
This commit is contained in:
parent
26d11ee8dc
commit
a9183883b8
2 changed files with 35 additions and 2 deletions
28
usertests.c
28
usertests.c
|
@ -1419,6 +1419,7 @@ validatetest(void)
|
|||
printf(stdout, "validate ok\n");
|
||||
}
|
||||
|
||||
// does unintialized data start out zero?
|
||||
char uninit[10000];
|
||||
void
|
||||
bsstest(void)
|
||||
|
@ -1434,6 +1435,32 @@ bsstest(void)
|
|||
printf(stdout, "bss test ok\n");
|
||||
}
|
||||
|
||||
// does exec do something sensible if the arguments
|
||||
// are larger than a page?
|
||||
void
|
||||
bigargtest(void)
|
||||
{
|
||||
int pid, ppid;
|
||||
|
||||
ppid = getpid();
|
||||
pid = fork();
|
||||
if(pid == 0){
|
||||
char *args[100];
|
||||
int i;
|
||||
for(i = 0; i < 99; i++)
|
||||
args[i] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
args[99] = 0;
|
||||
printf(stdout, "bigarg test\n");
|
||||
exec("echo", args);
|
||||
printf(stdout, "bigarg test ok\n");
|
||||
exit();
|
||||
} else if(pid < 0){
|
||||
printf(stdout, "bigargtest: fork failed\n");
|
||||
exit();
|
||||
}
|
||||
wait();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -1445,6 +1472,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
close(open("usertests.ran", O_CREATE));
|
||||
|
||||
// bigargtest();
|
||||
bsstest();
|
||||
sbrktest();
|
||||
validatetest();
|
||||
|
|
9
vm.c
9
vm.c
|
@ -125,6 +125,9 @@ pde_t*
|
|||
setupkvm(void)
|
||||
{
|
||||
pde_t *pgdir;
|
||||
extern char etext[];
|
||||
char *rwstart = PGROUNDDOWN(etext) - PGSIZE;
|
||||
uint rwlen = (uint)rwstart - 0x100000;
|
||||
|
||||
// Allocate page directory
|
||||
if(!(pgdir = (pde_t *) kalloc()))
|
||||
|
@ -132,8 +135,10 @@ setupkvm(void)
|
|||
memset(pgdir, 0, PGSIZE);
|
||||
if(// Map IO space from 640K to 1Mbyte
|
||||
!mappages(pgdir, (void *)USERTOP, 0x60000, USERTOP, PTE_W) ||
|
||||
// Map kernel and free memory pool
|
||||
!mappages(pgdir, (void *)0x100000, PHYSTOP-0x100000, 0x100000, PTE_W) ||
|
||||
// Map kernel instructions
|
||||
!mappages(pgdir, (void *)0x100000, rwlen, 0x100000, 0) ||
|
||||
// Map kernel data and free memory pool
|
||||
!mappages(pgdir, rwstart, PHYSTOP-(uint)rwstart, (uint)rwstart, PTE_W) ||
|
||||
// Map devices such as ioapic, lapic, ...
|
||||
!mappages(pgdir, (void *)0xFE000000, 0x2000000, 0xFE000000, PTE_W))
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue