| 495 | } |
| 496 | |
| 497 | fn initialize_vm( |
| 498 | &mut self, |
| 499 | _config: &icicle_fuzzing::FuzzConfig, |
| 500 | vm: &mut icicle_vm::Vm, |
| 501 | ) -> anyhow::Result<()> { |
| 502 | // @fixme: this is needed to set the `vm` ptr inside of the `uc_engine` struct that is used |
| 503 | // in the C APIs. This usage breaks Rust's aliasing rules, so should be fixed. |
| 504 | self.ctx.as_mut().unwrap().get_mut().vm = vm; |
| 505 | |
| 506 | // Force thumb mode. |
| 507 | let pc = vm.cpu.read_pc(); |
| 508 | vm.cpu.write_pc(pc & !0b1); |
| 509 | vm.cpu.set_isa_mode(1); |
| 510 | vm.cpu.exception.clear(); |
| 511 | |
| 512 | vm.env.as_mut_any().downcast_mut::<FuzzwareEnvironment>().unwrap().init(&mut vm.cpu); |
| 513 | |
| 514 | if icicle_fuzzing::parse_bool_env("USE_HALT_PATCHER")?.unwrap_or(false) { |
| 515 | icicle_vm::cpu::lifter::register_halt_patcher(&mut vm.lifter); |
| 516 | } |
| 517 | |
| 518 | // @todo? run until the first time the input is read |
| 519 | Ok(()) |
| 520 | } |
| 521 | |
| 522 | fn exit_string(&self, exit: VmExit) -> String { |
| 523 | if self.fuzzware_exit == fuzzware::uc_err::UC_ERR_OK { |