hv: vpci: add a global PCI lock for each VM

Concurrent access on PCI device may happened if UOS try to access PCI configuration
space on different vCPUs through IO port. This patch just adds a global PCI lock for
each VM to prevent the concurrent access.

Tracked-On: #3475
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1
2019-10-31 00:41:48 +08:00
committed by wenlingz
parent f711d3a639
commit 21cb120bcc
4 changed files with 60 additions and 43 deletions

View File

@@ -30,6 +30,7 @@
#ifndef VPCI_H_
#define VPCI_H_
#include <spinlock.h>
#include <pci.h>
@@ -112,6 +113,7 @@ union pci_cfg_addr_reg {
};
struct acrn_vpci {
spinlock_t lock;
struct acrn_vm *vm;
union pci_cfg_addr_reg addr;
uint32_t pci_vdev_cnt;
@@ -120,8 +122,8 @@ struct acrn_vpci {
extern const struct pci_vdev_ops vhostbridge_ops;
void vpci_init(struct acrn_vm *vm);
void vpci_cleanup(const struct acrn_vm *vm);
void vpci_cleanup(struct acrn_vm *vm);
void vpci_set_ptdev_intr_info(struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);
void vpci_reset_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);
void vpci_reset_ptdev_intr_info(struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);
#endif /* VPCI_H_ */