Important

This is the latest documentation for the unstable development branch of Project ACRN (master).
Use the drop-down menu on the left to select documentation for a stable release such as v3.2 or v3.0.

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. Nevertheless, the Device Model still owns the overall resource management such as memory/MMIO space and interrupt pins.

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 184 PCI Config space access in the Service VM or Pre-launched VM

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

Figure 185 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 186 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_vcpu *vcpu, struct acrn_vm *target_vm, uint64_t param1, uint64_t param2)

Assign one PCI dev to VM.

Preconditions

is_service_vm(vcpu->vm)

Parameters
  • vcpu – Pointer to vCPU that initiates the hypercall

  • target_vm – Pointer to target VM data structure

  • param1 – not used

  • param2 – guest physical address. This gpa points to data structure of acrn_pcidev including assign PCI device info

Returns

0 on success, non-zero on error.

int32_t hcall_deassign_pcidev(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm, uint64_t param1, uint64_t param2)

Deassign one PCI dev to VM.

Preconditions

is_service_vm(vcpu->vm)

Parameters
  • vcpu – Pointer to vCPU that initiates the hypercall

  • target_vm – Pointer to target VM data structure

  • param1 – not used

  • param2 – guest physical address. This gpa points to data structure of acrn_pcidev including deassign PCI device info

Returns

0 on success, non-zero on error.