File tree Expand file tree Collapse file tree 3 files changed +18
-17
lines changed Expand file tree Collapse file tree 3 files changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ fn handle_page_fault(tf: &mut TrapFrame, access_flags: PageFaultFlags) {
22
22
if core:: hint:: likely ( handle_trap ! ( PAGE_FAULT , vaddr, access_flags) ) {
23
23
return ;
24
24
}
25
- if !crate :: trap :: fixup_exception ( tf ) {
25
+ if !tf . fixup_exception ( ) {
26
26
panic ! (
27
27
"Unhandled PLV0 Page Fault @ {:#x}, fault_vaddr={:#x} ({:?}):\n {:#x?}\n {}" ,
28
28
tf. era,
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ fn handle_page_fault(tf: &mut TrapFrame, access_flags: PageFaultFlags) {
23
23
if core:: hint:: likely ( handle_trap ! ( PAGE_FAULT , vaddr, access_flags) ) {
24
24
return ;
25
25
}
26
- if !crate :: trap :: fixup_exception ( tf ) {
26
+ if !tf . fixup_exception ( ) {
27
27
panic ! (
28
28
"Unhandled Supervisor Page Fault @ {:#x}, fault_vaddr={:#x} ({:?}):\n {:#x?}\n {}" ,
29
29
tf. sepc,
Original file line number Diff line number Diff line change @@ -58,21 +58,22 @@ struct ExceptionTableEntry {
58
58
to : usize ,
59
59
}
60
60
61
- pub fn fixup_exception ( tf : & mut TrapFrame ) -> bool {
62
- let ip = tf. ip ( ) ;
63
- let entries = unsafe {
64
- core:: slice:: from_raw_parts (
65
- _ex_table_start as * const ExceptionTableEntry ,
66
- ( _ex_table_end as usize - _ex_table_start as usize )
67
- / core:: mem:: size_of :: < ExceptionTableEntry > ( ) ,
68
- )
69
- } ;
70
- match entries. binary_search_by ( |e| e. from . cmp ( & ip) ) {
71
- Ok ( entry) => {
72
- tf. set_ip ( entries[ entry] . to ) ;
73
- true
61
+ impl TrapFrame {
62
+ pub ( crate ) fn fixup_exception ( & mut self ) -> bool {
63
+ let entries = unsafe {
64
+ core:: slice:: from_raw_parts (
65
+ _ex_table_start as * const ExceptionTableEntry ,
66
+ ( _ex_table_end as usize - _ex_table_start as usize )
67
+ / core:: mem:: size_of :: < ExceptionTableEntry > ( ) ,
68
+ )
69
+ } ;
70
+ match entries. binary_search_by ( |e| e. from . cmp ( & self . ip ( ) ) ) {
71
+ Ok ( entry) => {
72
+ self . set_ip ( entries[ entry] . to ) ;
73
+ true
74
+ }
75
+ Err ( _) => false ,
74
76
}
75
- Err ( _) => false ,
76
77
}
77
78
}
78
79
@@ -84,7 +85,7 @@ pub(crate) fn init_exception_table() {
84
85
( _ex_table_end as usize - _ex_table_start as usize ) / size_of :: < ExceptionTableEntry > ( ) ,
85
86
)
86
87
} ;
87
- ex_table. sort ( ) ;
88
+ ex_table. sort_unstable ( ) ;
88
89
}
89
90
90
91
unsafe extern "C" {
You can’t perform that action at this time.
0 commit comments