Split Device Model

We usually emulate devices in the Device Model. However, in some cases, we need to emulate devices in the ACRN Hypervisor. For example, the post-launched RTVM needs to emulate passthrough PCI(e) devices in the ACRN Hypervisor so that it can continue to run even if the Device Model is no longer working. In spite of this, the Device Model still owns the overall resource management such as memory/MMIO space, interrupt pin, etc.

One communication method provided by the ACRN Hypervisor aligns the resource information for the Device Model with the ACRN Hypervisor emulated device.

Let’s take the passthrough PCI(e) device as an example. Before we split passthrough PCI(e) devices from the Device Model to the ACRN Hypervisor, the whole picture looks like this:

../../_images/split-dm-image1.png

Figure 238 PCI Config space access in the Service VM or Pre-launched VM

../../_images/split-dm-image2.png

Figure 239 PCI Config space access in the Post-launched VM

After we split passthrough PCI(e) devices from the Device Model to the ACRN Hypervisor, the whole picture looks like this:

../../_images/split-dm-image3.png
../../_images/split-dm-image4.png

Figure 241 PCI Config space access in the Post-launched VM

Interfaces Design

In order to achieve this, we have added a new pair of hypercalls to align the PCI(e) BAR and INTx information.

int32_t hcall_assign_pcidev(struct acrn_vm *vm, uint16_t vmid, uint64_t param)

Assign one PCI dev to VM.

Preconditions
Pointer vm shall point to SOS_VM
Return
0 on success, non-zero on error.
Parameters
  • vm: Pointer to VM data structure
  • vmid: ID of the VM
  • param: guest physical address. This gpa points to data structure of acrn_assign_pcidev including assign PCI device info

int32_t hcall_deassign_pcidev(struct acrn_vm *vm, uint16_t vmid, uint64_t param)

Deassign one PCI dev to VM.

Preconditions
Pointer vm shall point to SOS_VM
Return
0 on success, non-zero on error.
Parameters
  • vm: Pointer to VM data structure
  • vmid: ID of the VM
  • param: guest physical address. This gpa points to data structure of acrn_assign_pcidev including deassign PCI device info