(&mut self, cpu: &mut Cpu)
| 670 | } |
| 671 | |
| 672 | fn handle_exception(&mut self, cpu: &mut Cpu) -> Option<VmExit> { |
| 673 | match ExceptionCode::from_u32(cpu.exception.code) { |
| 674 | ExceptionCode::Syscall => { |
| 675 | // Update PC to point to the next pc value (this is not done inside of the SVC |
| 676 | // handler). |
| 677 | cpu.resume_next(); |
| 678 | unsafe { |
| 679 | fuzzware::handler_svc(self.uc_ptr, crate::arm::EXCP_SWI, std::ptr::null_mut()); |
| 680 | } |
| 681 | } |
| 682 | ExceptionCode::SoftwareBreakpoint => { |
| 683 | // Ignore software breakpoints while fuzzing (these sometimes occur during panic |
| 684 | // handlers). |
| 685 | cpu.exception.clear(); |
| 686 | cpu.resume_next(); |
| 687 | } |
| 688 | ExceptionCode::Sleep => { |
| 689 | self.trigger_next_time_based_interrupt(); |
| 690 | cpu.exception.clear(); |
| 691 | cpu.resume_next(); |
| 692 | } |
| 693 | ExceptionCode::Halt => { |
| 694 | // Report as a deadlock if halt occurs inside of a IRQ |
| 695 | let exception_number = self.get_active_exception(cpu); |
| 696 | if exception_number != 0 { |
| 697 | // @todo: allow this if nested interrupts are enabled?. |
| 698 | tracing::debug!("Deadlock in IRQ: {exception_number}"); |
| 699 | return Some(VmExit::Deadlock); |
| 700 | } |
| 701 | |
| 702 | if self.trigger_interrupt_on_halt { |
| 703 | self.force_trigger_next_time_based_interrupt(); |
| 704 | cpu.exception.clear(); |
| 705 | } |
| 706 | else { |
| 707 | return Some(VmExit::InstructionLimit); |
| 708 | } |
| 709 | } |
| 710 | ExceptionCode::CodeNotTranslated |
| 711 | | ExceptionCode::InvalidInstruction |
| 712 | | ExceptionCode::ShadowStackInvalid => { |
| 713 | let value = cpu.exception.value as u32; |
| 714 | if is_arm_exception_return(value) { |
| 715 | cpu.exception.clear(); |
| 716 | unsafe { fuzzware::ExceptionReturn(self.uc_ptr, value) } |
| 717 | } |
| 718 | } |
| 719 | _ => { |
| 720 | // Any other exceptions are left for the emulator to handle. |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | None |
| 725 | } |
| 726 | |
| 727 | fn snapshot(&mut self) -> Box<dyn std::any::Any> { |
| 728 | Box::new((self.saved_prev, FuzzwareSnapshot::take(self.uc_ptr))) |
nothing calls this directly
no test coverage detected