HV: use is_prelaunched_vm/is_hostbridge to check if the code is only for pre-launched VMs

Currently host bridge emulation and bar emulation are only for pre-launched vms,
use is_prelaunched_vm to check if it is for pre-launched vms when calling
init/deinit/cfgread/cfgwrite, also use is_hostbridge() to check if the access if
for host bridge, so that these functions can be unified for sos and pre-launched
vm in subsequent commits.

Move is_hostbridge function to vpci_priv.h so that it can be used by multiple
files.

vhostbridge_cfgread/vhostbridge_cfgwrite: return -ENODEV if the pci cfg access is not
targeted for vhostbridge so that cfgread/cfgwrite functions can be unified for sos and
pre-launched vm in subsequent commits

Fix @pre for functions

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2019-05-13 18:26:13 -07:00
committed by ACRN System Integration
parent a97e6e6465
commit cf48b9c38f
4 changed files with 85 additions and 53 deletions

View File

@@ -50,7 +50,7 @@ int32_t vdev_pt_cfgread(const struct pci_vdev *vdev, uint32_t offset,
int32_t ret = -ENODEV;
/* PCI BARs is emulated */
if (pci_bar_access(offset)) {
if (is_prelaunched_vm(vdev->vpci->vm) && pci_bar_access(offset)) {
*val = pci_vdev_read_cfg(vdev, offset, bytes);
ret = 0;
}
@@ -254,7 +254,7 @@ int32_t vdev_pt_cfgwrite(struct pci_vdev *vdev, uint32_t offset,
int32_t ret = -ENODEV;
/* PCI BARs are emulated */
if (pci_bar_access(offset)) {
if (is_prelaunched_vm(vdev->vpci->vm) && pci_bar_access(offset)) {
vdev_pt_cfgwrite_bar(vdev, offset, bytes, val);
ret = 0;
}