mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-16 14:28:56 +00:00
hv: resolve the negative impacts to UOS MSI/MSI-X remapping
After enabling vPCI in hypervisor for vm0, UOS may not able be launched successfully. Consider this scenario (take MSI-X for example): - DM makes hypercall to hypervisor to do MSI-X remapping on behalf of UOS guests. - After the hypercall, VHM module in SOS kernel updates the physical MSI-X table with the physical Message Data/Addr. - These MMIO write requests are intercepted by hypervisor, which will call ptdev_msix_remap() to do MSI-S remapping. It may fail due to 2 possible reasons: 1) wrong target VM because: hypervisor thinks it's a VM0 MSI-X device but they have been registered as UOS guests through HC_SET_PTDEV_INTR_INFO hypercall. 2) wrong ptdev_msi_info->vmsi_data because: The virtual MSI-X table is supposed to hold virtual Message data/addr but the SOS VHM writes the physical ones to it. This patch resolves these problems by ignoring the HC_VM_PCI_MSIX_REMAP hypercall, so virtual and physical Message Data are the same from SOS' perspective and it won't mess up the virtual PCI device in HV. Also in HC_SET_PTDEV_INTR_INFO handler, vpci updates the target VM when the PCI devices are assigned to different VMs. The UOS' MSI/MSI-X remapping is triggered by hypervisor when SOS (either DM or VHM) updates the Message Data/Addr. Tracked-On: #1568 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Signed-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
@@ -200,3 +200,39 @@ struct vpci_ops sharing_mode_vpci_ops = {
|
||||
.cfgread = sharing_mode_cfgread,
|
||||
.cfgwrite = sharing_mode_cfgwrite,
|
||||
};
|
||||
|
||||
void vpci_set_ptdev_intr_info(struct vm *target_vm, uint16_t vbdf, uint16_t pbdf)
|
||||
{
|
||||
struct pci_vdev *vdev;
|
||||
|
||||
vdev = sharing_mode_find_vdev((union pci_bdf)pbdf);
|
||||
if (vdev == NULL) {
|
||||
pr_err("%s, can't find PCI device for vm%d, vbdf (0x%x) pbdf (0x%x)", __func__,
|
||||
target_vm->vm_id, vbdf, pbdf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* UOS may do BDF mapping */
|
||||
vdev->vpci = &target_vm->vpci;
|
||||
vdev->vbdf.value = vbdf;
|
||||
vdev->pdev.bdf.value = pbdf;
|
||||
}
|
||||
|
||||
void vpci_reset_ptdev_intr_info(struct vm *target_vm, uint16_t vbdf, uint16_t pbdf)
|
||||
{
|
||||
struct pci_vdev *vdev;
|
||||
struct vm *vm;
|
||||
|
||||
vdev = sharing_mode_find_vdev((union pci_bdf)pbdf);
|
||||
if (vdev == NULL) {
|
||||
pr_err("%s, can't find PCI device for vm%d, vbdf (0x%x) pbdf (0x%x)", __func__,
|
||||
target_vm->vm_id, vbdf, pbdf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Return this PCI device to SOS */
|
||||
if (vdev->vpci->vm == target_vm) {
|
||||
vm = get_vm_from_vmid(0U);
|
||||
vdev->vpci = &vm->vpci;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user