mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:22:45 +00:00 
			
		
		
		
	Kernel: Track previous mode when entering/exiting traps
This allows us to determine what the previous mode (user or kernel) was, e.g. in the timer interrupt. This is used e.g. to determine whether a signal handler should be set up. Fixes #5096
This commit is contained in:
		
							parent
							
								
									fa18010477
								
							
						
					
					
						commit
						0bd558081e
					
				
					 6 changed files with 70 additions and 7 deletions
				
			
		|  | @ -137,6 +137,7 @@ void syscall_handler(TrapFrame* trap) | |||
| { | ||||
|     auto& regs = *trap->regs; | ||||
|     auto current_thread = Thread::current(); | ||||
|     ASSERT(current_thread->previous_mode() == Thread::PreviousMode::UserMode); | ||||
|     auto& process = current_thread->process(); | ||||
| 
 | ||||
|     if (auto tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) { | ||||
|  | @ -206,6 +207,9 @@ void syscall_handler(TrapFrame* trap) | |||
| 
 | ||||
|     current_thread->check_dispatch_pending_signal(); | ||||
| 
 | ||||
|     // If the previous mode somehow changed something is seriously messed up...
 | ||||
|     ASSERT(current_thread->previous_mode() == Thread::PreviousMode::UserMode); | ||||
| 
 | ||||
|     // Check if we're supposed to return to userspace or just die.
 | ||||
|     current_thread->die_if_needed(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Tom
						Tom