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");
 | 
					  printf(stdout, "validate ok\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// does unintialized data start out zero?
 | 
				
			||||||
char uninit[10000];
 | 
					char uninit[10000];
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
bsstest(void)
 | 
					bsstest(void)
 | 
				
			||||||
| 
						 | 
					@ -1434,6 +1435,32 @@ bsstest(void)
 | 
				
			||||||
  printf(stdout, "bss test ok\n");
 | 
					  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
 | 
					int
 | 
				
			||||||
main(int argc, char *argv[])
 | 
					main(int argc, char *argv[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -1445,6 +1472,7 @@ main(int argc, char *argv[])
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  close(open("usertests.ran", O_CREATE));
 | 
					  close(open("usertests.ran", O_CREATE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // bigargtest();
 | 
				
			||||||
  bsstest();
 | 
					  bsstest();
 | 
				
			||||||
  sbrktest();
 | 
					  sbrktest();
 | 
				
			||||||
  validatetest();
 | 
					  validatetest();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										9
									
								
								vm.c
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								vm.c
									
										
									
									
									
								
							| 
						 | 
					@ -125,6 +125,9 @@ pde_t*
 | 
				
			||||||
setupkvm(void)
 | 
					setupkvm(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  pde_t *pgdir;
 | 
					  pde_t *pgdir;
 | 
				
			||||||
 | 
					  extern char etext[];
 | 
				
			||||||
 | 
					  char *rwstart = PGROUNDDOWN(etext) - PGSIZE;
 | 
				
			||||||
 | 
					  uint rwlen = (uint)rwstart - 0x100000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Allocate page directory
 | 
					  // Allocate page directory
 | 
				
			||||||
  if(!(pgdir = (pde_t *) kalloc()))
 | 
					  if(!(pgdir = (pde_t *) kalloc()))
 | 
				
			||||||
| 
						 | 
					@ -132,8 +135,10 @@ setupkvm(void)
 | 
				
			||||||
  memset(pgdir, 0, PGSIZE);
 | 
					  memset(pgdir, 0, PGSIZE);
 | 
				
			||||||
  if(// Map IO space from 640K to 1Mbyte
 | 
					  if(// Map IO space from 640K to 1Mbyte
 | 
				
			||||||
     !mappages(pgdir, (void *)USERTOP, 0x60000, USERTOP, PTE_W) ||
 | 
					     !mappages(pgdir, (void *)USERTOP, 0x60000, USERTOP, PTE_W) ||
 | 
				
			||||||
     // Map kernel and free memory pool
 | 
					     // Map kernel instructions
 | 
				
			||||||
     !mappages(pgdir, (void *)0x100000, PHYSTOP-0x100000, 0x100000, PTE_W) ||
 | 
					     !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, ...
 | 
					     // Map devices such as ioapic, lapic, ...
 | 
				
			||||||
     !mappages(pgdir, (void *)0xFE000000, 0x2000000, 0xFE000000, PTE_W))
 | 
					     !mappages(pgdir, (void *)0xFE000000, 0x2000000, 0xFE000000, PTE_W))
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue