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 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Li Fei1 2019-12-23 22:52:02 +08:00 committed by wenlingz
parent d2089889d8
commit 58b3a05863
3 changed files with 23 additions and 23 deletions

View File

@ -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;

View File

@ -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);

View File

@ -34,7 +34,7 @@
#include <pci.h>
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;