don't enable interrupts until done with sstatus, scause, &c
This commit is contained in:
		
							parent
							
								
									abfe9999f4
								
							
						
					
					
						commit
						40f1041a0a
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -37,7 +37,7 @@ void
 | 
			
		|||
usertrap(void)
 | 
			
		||||
{
 | 
			
		||||
  int which_dev = 0;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  if((r_sstatus() & SSTATUS_SPP) != 0)
 | 
			
		||||
    panic("usertrap: not from user mode");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -49,8 +49,6 @@ usertrap(void)
 | 
			
		|||
  
 | 
			
		||||
  // save user program counter.
 | 
			
		||||
  p->tf->epc = r_sepc();
 | 
			
		||||
 | 
			
		||||
  intr_on();
 | 
			
		||||
  
 | 
			
		||||
  if(r_scause() == 8){
 | 
			
		||||
    // system call
 | 
			
		||||
| 
						 | 
				
			
			@ -59,11 +57,15 @@ usertrap(void)
 | 
			
		|||
    // but we want to return to the next instruction.
 | 
			
		||||
    p->tf->epc += 4;
 | 
			
		||||
 | 
			
		||||
    // an interrupt will change sstatus &c registers,
 | 
			
		||||
    // so don't enable until done with those registers.
 | 
			
		||||
    intr_on();
 | 
			
		||||
 | 
			
		||||
    syscall();
 | 
			
		||||
  } else if((which_dev = devintr()) != 0){
 | 
			
		||||
    // ok
 | 
			
		||||
  } else {
 | 
			
		||||
    printf("usertrap(): unexpected scause 0x%p pid=%d\n", r_scause(), p->pid);
 | 
			
		||||
    printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
 | 
			
		||||
    printf("            sepc=%p stval=%p\n", r_sepc(), r_stval());
 | 
			
		||||
    p->killed = 1;
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue