HV: vpci: check if address is in VM BAR MMIO space

When guest doing BAR re-programming, we should check whether
the base address of the BAR is valid.This patch does this check by:
1. whether the gpa is located in the responding MMIO window
2. whether the gpa is aligned with the BAR size

Tracked-On: #6011
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Li Fei <fei1.li@intel.com>
This commit is contained in:
Tao Yuhong
2021-04-14 10:26:21 -04:00
committed by wenlingz
parent 7da53ce138
commit 5ecca6b256
4 changed files with 47 additions and 3 deletions

View File

@@ -163,11 +163,19 @@ union pci_cfg_addr_reg {
} bits;
};
/* start address & end address of MMIO BAR */
struct pci_mmio_res {
uint64_t start;
uint64_t end;
};
struct acrn_vpci {
spinlock_t lock;
union pci_cfg_addr_reg addr;
struct pci_mmcfg_region pci_mmcfg;
uint32_t pci_vdev_cnt;
struct pci_mmio_res res32; /* 32-bit mmio start/end address */
struct pci_mmio_res res64; /* 64-bit mmio start/end address */
struct pci_vdev pci_vdevs[CONFIG_MAX_PCI_DEV_NUM];
struct hlist_head vdevs_hlist_heads [VDEV_LIST_HASHSIZE];
};