File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
src/aero_kernel/src/arch/x86_64/interrupts Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,23 @@ pub(super) fn page_fault(stack: &mut InterruptErrorStack) {
9797 log:: error!( "stack: {:#x?}" , stack) ;
9898 } ;
9999
100+ if reason. contains ( PageFaultErrorCode :: PROTECTION_VIOLATION ) && !reason. contains ( PageFaultErrorCode :: USER_MODE ) {
101+ if controlregs:: smap_enabled ( ) {
102+ unwind:: prepare_panic ( ) ;
103+
104+ log:: error!( "SMAP violation page fault" ) ;
105+ print_info ( ) ;
106+
107+ controlregs:: with_userspace_access ( ||unwind:: unwind_stack_trace ( ) ) ;
108+
109+ unsafe {
110+ loop {
111+ super :: halt ( ) ;
112+ }
113+ }
114+ }
115+ }
116+
100117 if accessed_address < userland_last_address && scheduler:: is_initialized ( )
101118 || stack. stack . iret . is_user ( )
102119 {
@@ -130,7 +147,7 @@ pub(super) fn page_fault(stack: &mut InterruptErrorStack) {
130147 scheduler:: get_scheduler ( ) . log_ptable ( ) ;
131148 }
132149
133- unwind:: unwind_stack_trace ( ) ;
150+ controlregs :: with_userspace_access ( || unwind:: unwind_stack_trace ( ) ) ;
134151
135152 let task = scheduler:: get_scheduler ( ) . current_task ( ) ;
136153 task. signal ( aero_syscall:: signal:: SIGSEGV ) ;
@@ -147,7 +164,7 @@ pub(super) fn page_fault(stack: &mut InterruptErrorStack) {
147164 log:: error!( "Page fault" ) ;
148165 print_info ( ) ;
149166
150- unwind:: unwind_stack_trace ( ) ;
167+ controlregs :: with_userspace_access ( || unwind:: unwind_stack_trace ( ) ) ;
151168
152169 unsafe {
153170 loop {
You can’t perform that action at this time.
0 commit comments