From 58b3a05863a64df9b642b85cac25059e93a1305e Mon Sep 17 00:00:00 2001 From: Li Fei1 Date: Mon, 23 Dec 2019 22:52:02 +0800 Subject: [PATCH] hv: vpci: rename pci_bar to pci_vbar Structure pci_vbar is used to define the virtual BAR rather than physical BAR. It's better to name as pci_vbar. Tracked-On: #3475 Signed-off-by: Li Fei1 Acked-by: Eddie Dong --- hypervisor/dm/vpci/pci_pt.c | 24 ++++++++++++------------ hypervisor/dm/vpci/vdev.c | 18 +++++++++--------- hypervisor/include/dm/vpci.h | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/hypervisor/dm/vpci/pci_pt.c b/hypervisor/dm/vpci/pci_pt.c index 424869019..6e4c55ae8 100644 --- a/hypervisor/dm/vpci/pci_pt.c +++ b/hypervisor/dm/vpci/pci_pt.c @@ -40,10 +40,10 @@ static void vdev_pt_unmap_mem_vbar(struct pci_vdev *vdev, uint32_t idx) { bool is_msix_table_bar; - struct pci_bar *vbar; + struct pci_vbar *vbar; struct acrn_vm *vm = vdev->vpci->vm; - vbar = &vdev->bar[idx]; + vbar = &vdev->vbars[idx]; if (vbar->base != 0UL) { ept_del_mr(vm, (uint64_t *)(vm->arch_vm.nworld_eptp), @@ -87,10 +87,10 @@ static void vdev_pt_unmap_mem_vbar(struct pci_vdev *vdev, uint32_t idx) static void vdev_pt_map_mem_vbar(struct pci_vdev *vdev, uint32_t idx) { bool is_msix_table_bar; - struct pci_bar *vbar; + struct pci_vbar *vbar; struct acrn_vm *vm = vdev->vpci->vm; - vbar = &vdev->bar[idx]; + vbar = &vdev->vbars[idx]; if (vbar->base != 0UL) { ept_add_mr(vm, (uint64_t *)(vm->arch_vm.nworld_eptp), @@ -129,7 +129,7 @@ static void vdev_pt_allow_io_vbar(struct pci_vdev *vdev, uint32_t idx) { /* For SOS, all port IO access is allowed by default, so skip SOS here */ if (!is_sos_vm(vdev->vpci->vm)) { - struct pci_bar *vbar = &vdev->bar[idx]; + struct pci_vbar *vbar = &vdev->vbars[idx]; if (vbar->base != 0UL) { allow_guest_pio_access(vdev->vpci->vm, (uint16_t)vbar->base, (uint32_t)(vbar->size)); } @@ -146,7 +146,7 @@ static void vdev_pt_deny_io_vbar(struct pci_vdev *vdev, uint32_t idx) { /* For SOS, all port IO access is allowed by default, so skip SOS here */ if (!is_sos_vm(vdev->vpci->vm)) { - struct pci_bar *vbar = &vdev->bar[idx]; + struct pci_vbar *vbar = &vdev->vbars[idx]; if (vbar->base != 0UL) { deny_guest_pio_access(vdev->vpci->vm, (uint16_t)(vbar->base), (uint32_t)(vbar->size)); } @@ -161,7 +161,7 @@ void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t idx, uint32_t val) { uint32_t update_idx = idx; uint32_t offset = pci_bar_offset(idx); - struct pci_bar *vbar = &vdev->bar[idx]; + struct pci_vbar *vbar = &vdev->vbars[idx]; switch (vbar->type) { case PCIBAR_IO_SPACE: @@ -171,7 +171,7 @@ void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t idx, uint32_t val) vdev_pt_allow_io_vbar(vdev, update_idx); } else { pci_vdev_write_cfg_u32(vdev, offset, val); - vdev->bar[update_idx].base = 0UL; + vdev->vbars[update_idx].base = 0UL; } break; @@ -189,7 +189,7 @@ void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t idx, uint32_t val) vdev_pt_map_mem_vbar(vdev, update_idx); } else { pci_vdev_write_cfg_u32(vdev, offset, val); - vdev->bar[update_idx].base = 0UL; + vdev->vbars[update_idx].base = 0UL; } break; } @@ -224,7 +224,7 @@ void init_vdev_pt(struct pci_vdev *vdev) { enum pci_bar_type type; uint32_t idx; - struct pci_bar *vbar; + struct pci_vbar *vbar; uint16_t pci_command; uint32_t size32, offset, lo, hi = 0U; union pci_bdf pbdf; @@ -239,7 +239,7 @@ void init_vdev_pt(struct pci_vdev *vdev) vdev->af_capoff = vdev->pdev->af_capoff; for (idx = 0U; idx < vdev->nr_bars; idx++) { - vbar = &vdev->bar[idx]; + vbar = &vdev->vbars[idx]; offset = pci_bar_offset(idx); lo = pci_pdev_read_cfg(pbdf, offset, 4U); @@ -280,7 +280,7 @@ void init_vdev_pt(struct pci_vdev *vdev) vbar->size = vbar->size & ~(vbar->size - 1UL); vbar->size = round_page_up(vbar->size); - vbar = &vdev->bar[idx]; + vbar = &vdev->vbars[idx]; vbar->mask = size32; vbar->type = PCIBAR_MEM64HI; diff --git a/hypervisor/dm/vpci/vdev.c b/hypervisor/dm/vpci/vdev.c index e8ebd70b8..ed6019926 100644 --- a/hypervisor/dm/vpci/vdev.c +++ b/hypervisor/dm/vpci/vdev.c @@ -102,20 +102,20 @@ uint32_t pci_vdev_read_bar(const struct pci_vdev *vdev, uint32_t idx) bar = pci_vdev_read_cfg_u32(vdev, offset); /* Sizing BAR */ if (bar == ~0U) { - bar = vdev->bar[idx].mask; + bar = vdev->vbars[idx].mask; } return bar; } static void pci_vdev_update_bar_base(struct pci_vdev *vdev, uint32_t idx) { - struct pci_bar *vbar; + struct pci_vbar *vbar; enum pci_bar_type type; uint64_t base = 0UL; uint32_t lo, hi, offset; struct acrn_vm *vm = vdev->vpci->vm; - vbar = &vdev->bar[idx]; + vbar = &vdev->vbars[idx]; offset = pci_bar_offset(idx); lo = pci_vdev_read_cfg_u32(vdev, offset); if ((vbar->type != PCIBAR_NONE) && (lo != ~0U)) { @@ -123,7 +123,7 @@ static void pci_vdev_update_bar_base(struct pci_vdev *vdev, uint32_t idx) base = lo & vbar->mask; if (vbar->type == PCIBAR_MEM64) { - vbar = &vdev->bar[idx + 1U]; + vbar = &vdev->vbars[idx + 1U]; hi = pci_vdev_read_cfg_u32(vdev, offset + 4U); if (hi != ~0U) { hi &= vbar->mask; @@ -137,23 +137,23 @@ static void pci_vdev_update_bar_base(struct pci_vdev *vdev, uint32_t idx) } } - if ((base != 0UL) && !ept_is_mr_valid(vm, base, vdev->bar[idx].size)) { + if ((base != 0UL) && !ept_is_mr_valid(vm, base, vdev->vbars[idx].size)) { pr_fatal("%s, %x:%x.%x set invalid bar[%d] base: 0x%lx, size: 0x%lx\n", __func__, - vdev->bdf.bits.b, vdev->bdf.bits.d, vdev->bdf.bits.f, idx, base, vdev->bar[idx].size); + vdev->bdf.bits.b, vdev->bdf.bits.d, vdev->bdf.bits.f, idx, base, vdev->vbars[idx].size); /* If guest set a invalid GPA, ignore it temporarily */ base = 0UL; } - vdev->bar[idx].base = base; + vdev->vbars[idx].base = base; } void pci_vdev_write_bar(struct pci_vdev *vdev, uint32_t idx, uint32_t val) { - struct pci_bar *vbar; + struct pci_vbar *vbar; uint32_t bar, offset; uint32_t update_idx = idx; - vbar = &vdev->bar[idx]; + vbar = &vdev->vbars[idx]; bar = val & vbar->mask; bar |= vbar->fixed; offset = pci_bar_offset(idx); diff --git a/hypervisor/include/dm/vpci.h b/hypervisor/include/dm/vpci.h index dfe970962..2de601e53 100644 --- a/hypervisor/include/dm/vpci.h +++ b/hypervisor/include/dm/vpci.h @@ -34,7 +34,7 @@ #include -struct pci_bar { +struct pci_vbar { enum pci_bar_type type; uint64_t size; /* BAR size */ uint64_t base; /* BAR guest physical address */ @@ -94,7 +94,7 @@ struct pci_vdev { /* The bar info of the virtual PCI device. */ uint32_t nr_bars; /* 6 for normal device, 2 for bridge, 1 for cardbus */ - struct pci_bar bar[PCI_BAR_COUNT]; + struct pci_vbar vbars[PCI_BAR_COUNT]; struct pci_msi msi; struct pci_msix msix;