mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-24 14:33:38 +00:00
hv: bugfix for hv-emulated device de-init
- fix bug in 'hcall_destroy_vdev()', the availability of vpci device shall be checked on 'target_vm". - refine 'vpci_update_one_vbar()' to avoid potential NULL pointer access. Tracked-On: #5508 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
parent
c1451f4721
commit
6225f690f3
@ -1241,7 +1241,7 @@ int32_t hcall_destroy_vdev(struct acrn_vm *vm, struct acrn_vm *target_vm, __unus
|
|||||||
op = find_emul_dev_ops(&dev);
|
op = find_emul_dev_ops(&dev);
|
||||||
if (op != NULL) {
|
if (op != NULL) {
|
||||||
bdf.value = (uint16_t) dev.slot;
|
bdf.value = (uint16_t) dev.slot;
|
||||||
vdev = pci_find_vdev(&vm->vpci, bdf);
|
vdev = pci_find_vdev(&target_vm->vpci, bdf);
|
||||||
if (vdev != NULL) {
|
if (vdev != NULL) {
|
||||||
vdev->pci_dev_config->vbdf.value = UNASSIGNED_VBDF;
|
vdev->pci_dev_config->vbdf.value = UNASSIGNED_VBDF;
|
||||||
if (op->destroy != NULL) {
|
if (op->destroy != NULL) {
|
||||||
|
@ -18,7 +18,10 @@
|
|||||||
#define IVSHMEM_CLASS 0x05U
|
#define IVSHMEM_CLASS 0x05U
|
||||||
#define IVSHMEM_REV 0x01U
|
#define IVSHMEM_REV 0x01U
|
||||||
|
|
||||||
/* ivshmem device supports bar0, bar1 and bar2 */
|
/*
|
||||||
|
* ivshmem device supports bar0, bar1 and bar2,
|
||||||
|
* indexes of them shall begin with 0 and be continuous.
|
||||||
|
*/
|
||||||
#define IVSHMEM_MMIO_BAR 0U
|
#define IVSHMEM_MMIO_BAR 0U
|
||||||
#define IVSHMEM_MSIX_BAR 1U
|
#define IVSHMEM_MSIX_BAR 1U
|
||||||
#define IVSHMEM_SHM_BAR 2U
|
#define IVSHMEM_SHM_BAR 2U
|
||||||
@ -337,7 +340,7 @@ static void init_ivshmem_vdev(struct pci_vdev *vdev)
|
|||||||
add_vmsix_capability(vdev, MAX_IVSHMEM_MSIX_TBL_ENTRY_NUM, IVSHMEM_MSIX_BAR);
|
add_vmsix_capability(vdev, MAX_IVSHMEM_MSIX_TBL_ENTRY_NUM, IVSHMEM_MSIX_BAR);
|
||||||
|
|
||||||
/* initialize ivshmem bars */
|
/* initialize ivshmem bars */
|
||||||
vdev->nr_bars = PCI_BAR_COUNT;
|
vdev->nr_bars = 3U;
|
||||||
init_ivshmem_bar(vdev, IVSHMEM_MMIO_BAR);
|
init_ivshmem_bar(vdev, IVSHMEM_MMIO_BAR);
|
||||||
init_ivshmem_bar(vdev, IVSHMEM_MSIX_BAR);
|
init_ivshmem_bar(vdev, IVSHMEM_MSIX_BAR);
|
||||||
init_ivshmem_bar(vdev, IVSHMEM_SHM_BAR);
|
init_ivshmem_bar(vdev, IVSHMEM_SHM_BAR);
|
||||||
|
@ -773,6 +773,9 @@ int32_t vpci_deassign_pcidev(struct acrn_vm *tgt_vm, struct acrn_assign_pcidev *
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @pre unmap_cb != NULL
|
||||||
|
*/
|
||||||
void vpci_update_one_vbar(struct pci_vdev *vdev, uint32_t bar_idx, uint32_t val,
|
void vpci_update_one_vbar(struct pci_vdev *vdev, uint32_t bar_idx, uint32_t val,
|
||||||
map_pcibar map_cb, unmap_pcibar unmap_cb)
|
map_pcibar map_cb, unmap_pcibar unmap_cb)
|
||||||
{
|
{
|
||||||
@ -786,7 +789,9 @@ void vpci_update_one_vbar(struct pci_vdev *vdev, uint32_t bar_idx, uint32_t val,
|
|||||||
unmap_cb(vdev, update_idx);
|
unmap_cb(vdev, update_idx);
|
||||||
if (val != ~0U) {
|
if (val != ~0U) {
|
||||||
pci_vdev_write_vbar(vdev, bar_idx, val);
|
pci_vdev_write_vbar(vdev, bar_idx, val);
|
||||||
|
if (map_cb != NULL) {
|
||||||
map_cb(vdev, update_idx);
|
map_cb(vdev, update_idx);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pci_vdev_write_vcfg(vdev, offset, 4U, val);
|
pci_vdev_write_vcfg(vdev, offset, 4U, val);
|
||||||
vdev->vbars[update_idx].base_gpa = 0UL;
|
vdev->vbars[update_idx].base_gpa = 0UL;
|
||||||
|
Loading…
Reference in New Issue
Block a user