@@ -29,12 +29,6 @@ enum TrapSource {
29
29
LowerAArch32 = 3 ,
30
30
}
31
31
32
- impl TrapSource {
33
- fn is_from_user ( & self ) -> bool {
34
- matches ! ( self , TrapSource :: LowerAArch64 | TrapSource :: LowerAArch32 )
35
- }
36
- }
37
-
38
32
#[ unsafe( no_mangle) ]
39
33
fn invalid_exception ( tf : & TrapFrame , kind : TrapKind , source : TrapSource ) {
40
34
panic ! (
@@ -44,26 +38,21 @@ fn invalid_exception(tf: &TrapFrame, kind: TrapKind, source: TrapSource) {
44
38
}
45
39
46
40
#[ unsafe( no_mangle) ]
47
- fn handle_irq_exception ( tf : & mut TrapFrame , source : TrapSource ) {
48
- crate :: trap:: pre_trap_callback ( tf, source. is_from_user ( ) ) ;
41
+ fn handle_irq_exception ( _tf : & mut TrapFrame ) {
49
42
handle_trap ! ( IRQ , 0 ) ;
50
- crate :: trap:: post_trap_callback ( tf, source. is_from_user ( ) ) ;
51
43
}
52
44
53
- fn handle_instruction_abort ( tf : & TrapFrame , iss : u64 , is_user : bool ) {
54
- let mut access_flags = PageFaultFlags :: EXECUTE ;
55
- if is_user {
56
- access_flags |= PageFaultFlags :: USER ;
57
- }
45
+ fn handle_instruction_abort ( tf : & TrapFrame , iss : u64 ) {
46
+ let access_flags = PageFaultFlags :: EXECUTE ;
58
47
let vaddr = va ! ( FAR_EL1 . get( ) as usize ) ;
59
48
49
+ // TODO: fixup_exception
60
50
// Only handle Translation fault and Permission fault
61
51
if !matches ! ( iss & 0b111100 , 0b0100 | 0b1100 ) // IFSC or DFSC bits
62
- || !handle_trap ! ( PAGE_FAULT , vaddr, access_flags, is_user )
52
+ || !handle_trap ! ( PAGE_FAULT , vaddr, access_flags)
63
53
{
64
54
panic ! (
65
- "Unhandled {} Instruction Abort @ {:#x}, fault_vaddr={:#x}, ESR={:#x} ({:?}):\n {:#x?}\n {}" ,
66
- if is_user { "EL0" } else { "EL1" } ,
55
+ "Unhandled EL1 Instruction Abort @ {:#x}, fault_vaddr={:#x}, ESR={:#x} ({:?}):\n {:#x?}\n {}" ,
67
56
tf. elr,
68
57
vaddr,
69
58
ESR_EL1 . get( ) ,
@@ -74,26 +63,23 @@ fn handle_instruction_abort(tf: &TrapFrame, iss: u64, is_user: bool) {
74
63
}
75
64
}
76
65
77
- fn handle_data_abort ( tf : & TrapFrame , iss : u64 , is_user : bool ) {
66
+ fn handle_data_abort ( tf : & TrapFrame , iss : u64 ) {
78
67
let wnr = ( iss & ( 1 << 6 ) ) != 0 ; // WnR: Write not Read
79
68
let cm = ( iss & ( 1 << 8 ) ) != 0 ; // CM: Cache maintenance
80
- let mut access_flags = if wnr & !cm {
69
+ let access_flags = if wnr & !cm {
81
70
PageFaultFlags :: WRITE
82
71
} else {
83
72
PageFaultFlags :: READ
84
73
} ;
85
- if is_user {
86
- access_flags |= PageFaultFlags :: USER ;
87
- }
88
74
let vaddr = va ! ( FAR_EL1 . get( ) as usize ) ;
89
75
76
+ // TODO: fixup_exception
90
77
// Only handle Translation fault and Permission fault
91
78
if !matches ! ( iss & 0b111100 , 0b0100 | 0b1100 ) // IFSC or DFSC bits
92
- || !handle_trap ! ( PAGE_FAULT , vaddr, access_flags, is_user )
79
+ || !handle_trap ! ( PAGE_FAULT , vaddr, access_flags)
93
80
{
94
81
panic ! (
95
- "Unhandled {} Data Abort @ {:#x}, fault_vaddr={:#x}, ESR={:#x} ({:?}):\n {:#x?}\n {}" ,
96
- if is_user { "EL0" } else { "EL1" } ,
82
+ "Unhandled EL1 Data Abort @ {:#x}, fault_vaddr={:#x}, ESR={:#x} ({:?}):\n {:#x?}\n {}" ,
97
83
tf. elr,
98
84
vaddr,
99
85
ESR_EL1 . get( ) ,
@@ -105,19 +91,12 @@ fn handle_data_abort(tf: &TrapFrame, iss: u64, is_user: bool) {
105
91
}
106
92
107
93
#[ unsafe( no_mangle) ]
108
- fn handle_sync_exception ( tf : & mut TrapFrame , source : TrapSource ) {
94
+ fn handle_sync_exception ( tf : & mut TrapFrame ) {
109
95
let esr = ESR_EL1 . extract ( ) ;
110
96
let iss = esr. read ( ESR_EL1 :: ISS ) ;
111
- crate :: trap:: pre_trap_callback ( tf, source. is_from_user ( ) ) ;
112
97
match esr. read_as_enum ( ESR_EL1 :: EC ) {
113
- #[ cfg( feature = "uspace" ) ]
114
- Some ( ESR_EL1 :: EC :: Value :: SVC64 ) => {
115
- tf. r [ 0 ] = crate :: trap:: handle_syscall ( tf, tf. r [ 8 ] as usize ) as u64 ;
116
- }
117
- Some ( ESR_EL1 :: EC :: Value :: InstrAbortLowerEL ) => handle_instruction_abort ( tf, iss, true ) ,
118
- Some ( ESR_EL1 :: EC :: Value :: InstrAbortCurrentEL ) => handle_instruction_abort ( tf, iss, false ) ,
119
- Some ( ESR_EL1 :: EC :: Value :: DataAbortLowerEL ) => handle_data_abort ( tf, iss, true ) ,
120
- Some ( ESR_EL1 :: EC :: Value :: DataAbortCurrentEL ) => handle_data_abort ( tf, iss, false ) ,
98
+ Some ( ESR_EL1 :: EC :: Value :: InstrAbortCurrentEL ) => handle_instruction_abort ( tf, iss) ,
99
+ Some ( ESR_EL1 :: EC :: Value :: DataAbortCurrentEL ) => handle_data_abort ( tf, iss) ,
121
100
Some ( ESR_EL1 :: EC :: Value :: Brk64 ) => {
122
101
debug ! ( "BRK #{:#x} @ {:#x} " , iss, tf. elr) ;
123
102
tf. elr += 4 ;
@@ -128,10 +107,9 @@ fn handle_sync_exception(tf: &mut TrapFrame, source: TrapSource) {
128
107
tf. elr,
129
108
esr. get( ) ,
130
109
esr. read( ESR_EL1 :: EC ) ,
131
- esr . read ( ESR_EL1 :: ISS ) ,
110
+ iss ,
132
111
tf. backtrace( )
133
112
) ;
134
113
}
135
114
}
136
- crate :: trap:: post_trap_callback ( tf, source. is_from_user ( ) ) ;
137
115
}
0 commit comments