MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / run

Method run

hypervisor/src/mshv/mod.rs:588–1338  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

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 _ => {}

Callers

nothing calls this directly

Calls 15

newFunction · 0.85
pio_writeMethod · 0.80
pio_readMethod · 0.80
emulate_insn_streamMethod · 0.80
update_cpu_stateMethod · 0.80
as_mut_sliceMethod · 0.80
as_sliceMethod · 0.80
try_intoMethod · 0.80
clear_swexit_info1Method · 0.80
mmio_readMethod · 0.80

Tested by

no test coverage detected