(&mut self)
| 586 | |
| 587 | #[allow(non_upper_case_globals)] |
| 588 | fn run(&mut self) -> std::result::Result<cpu::VmExit, cpu::HypervisorCpuError> { |
| 589 | match self.fd.run() { |
| 590 | Ok(x) => match x.header.message_type { |
| 591 | hv_message_type_HVMSG_X64_HALT => { |
| 592 | debug!("HALT"); |
| 593 | Ok(cpu::VmExit::Reset) |
| 594 | } |
| 595 | #[cfg(target_arch = "aarch64")] |
| 596 | hv_message_type_HVMSG_ARM64_RESET_INTERCEPT => { |
| 597 | let reset_msg = x.to_reset_intercept_msg().unwrap(); |
| 598 | |
| 599 | match reset_msg.reset_type { |
| 600 | hv_arm64_reset_type_HV_ARM64_RESET_TYPE_REBOOT => Ok(cpu::VmExit::Reset), |
| 601 | hv_arm64_reset_type_HV_ARM64_RESET_TYPE_POWER_OFF => { |
| 602 | Ok(cpu::VmExit::Shutdown) |
| 603 | } |
| 604 | _ => Err(cpu::HypervisorCpuError::RunVcpu(anyhow!( |
| 605 | "Unhandled VCPU exit (RESET_INTERCEPT): reset type: {:?}", |
| 606 | reset_msg.reset_type |
| 607 | ))), |
| 608 | } |
| 609 | } |
| 610 | hv_message_type_HVMSG_UNRECOVERABLE_EXCEPTION => { |
| 611 | warn!("TRIPLE FAULT"); |
| 612 | Ok(cpu::VmExit::Shutdown) |
| 613 | } |
| 614 | #[cfg(target_arch = "x86_64")] |
| 615 | hv_message_type_HVMSG_X64_IO_PORT_INTERCEPT => { |
| 616 | let info = x.to_ioport_info().unwrap(); |
| 617 | let access_info = info.access_info; |
| 618 | // SAFETY: access_info is valid, otherwise we won't be here |
| 619 | let len = unsafe { access_info.__bindgen_anon_1.access_size() } as usize; |
| 620 | let is_write = info.header.intercept_access_type == 1; |
| 621 | let port = info.port_number; |
| 622 | let mut data: [u8; 4] = [0; 4]; |
| 623 | let mut ret_rax = info.rax; |
| 624 | |
| 625 | /* |
| 626 | * XXX: Ignore QEMU fw_cfg (0x5xx) and debug console (0x402) ports. |
| 627 | * |
| 628 | * Cloud Hypervisor doesn't support fw_cfg at the moment. It does support 0x402 |
| 629 | * under the "fwdebug" feature flag. But that feature is not enabled by default |
| 630 | * and is considered legacy. |
| 631 | * |
| 632 | * OVMF unconditionally pokes these IO ports with string IO. |
| 633 | * |
| 634 | * Instead of trying to implement string IO support now which does not do much |
| 635 | * now, skip those ports explicitly to avoid panicking. |
| 636 | * |
| 637 | * Proper string IO support can be added once we gain the ability to translate |
| 638 | * guest virtual addresses to guest physical addresses on MSHV. |
| 639 | */ |
| 640 | match port { |
| 641 | 0x402 | 0x510 | 0x511 | 0x514 => { |
| 642 | self.advance_rip_update_rax(&info, ret_rax)?; |
| 643 | return Ok(cpu::VmExit::Ignore); |
| 644 | } |
| 645 | _ => {} |
nothing calls this directly
no test coverage detected