@@ -105,17 +105,7 @@ pub fn handle_exception_sync(ctx: &mut TrapFrame) -> AxResult<AxVCpuExitReason>
105105 let elr = ctx. exception_pc ( ) ;
106106 let val = elr + exception_next_instruction_step ( ) ;
107107 ctx. set_exception_pc ( val) ;
108-
109- // Is this a psci call?
110- if let Some ( result) = handle_psci_call ( ctx) {
111- return result;
112- } else {
113- // We just forward the SMC call to the ATF directly.
114- // The args are from lower EL, so it is safe to call the ATF.
115- ( ctx. gpr [ 0 ] , ctx. gpr [ 1 ] , ctx. gpr [ 2 ] , ctx. gpr [ 3 ] ) =
116- unsafe { crate :: smc:: smc_call ( ctx. gpr [ 0 ] , ctx. gpr [ 1 ] , ctx. gpr [ 2 ] , ctx. gpr [ 3 ] ) } ;
117- Ok ( AxVCpuExitReason :: Nothing )
118- }
108+ handle_smc64_exception ( ctx)
119109 }
120110 _ => {
121111 panic ! (
@@ -263,6 +253,23 @@ fn handle_psci_call(ctx: &mut TrapFrame) -> Option<AxResult<AxVCpuExitReason>> {
263253 }
264254}
265255
256+ /// Handles SMC (Secure Monitor Call) exceptions.
257+ ///
258+ /// This function will judge if the SMC call is a PSCI call, if so, it will handle it as a PSCI call.
259+ /// Otherwise, it will forward the SMC call to the ATF directly.
260+ fn handle_smc64_exception ( ctx : & mut TrapFrame ) -> AxResult < AxVCpuExitReason > {
261+ // Is this a psci call?
262+ if let Some ( result) = handle_psci_call ( ctx) {
263+ return result;
264+ } else {
265+ // We just forward the SMC call to the ATF directly.
266+ // The args are from lower EL, so it is safe to call the ATF.
267+ ( ctx. gpr [ 0 ] , ctx. gpr [ 1 ] , ctx. gpr [ 2 ] , ctx. gpr [ 3 ] ) =
268+ unsafe { crate :: smc:: smc_call ( ctx. gpr [ 0 ] , ctx. gpr [ 1 ] , ctx. gpr [ 2 ] , ctx. gpr [ 3 ] ) } ;
269+ Ok ( AxVCpuExitReason :: Nothing )
270+ }
271+ }
272+
266273/// Dispatches IRQs to the appropriate handler provided by the underlying host OS,
267274/// which is registered at [`crate::pcpu::IRQ_HANDLER`] during `Aarch64PerCpu::new()`.
268275fn dispatch_irq ( ) {
0 commit comments