mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-04 23:24:56 +00:00
Fix: HV: keep reshuffling on VBARs
The commit 'Fix: HV: VM OS failed to assign new address to pci-vuart BARs' need more reshuffle. Tracked-On: #5491 Signed-off-by: Tao Yuhong <yuhong.tao@intel.com> Signed-off-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -38,11 +38,11 @@
|
||||
#define VDEV_LIST_HASHSIZE (1U << VDEV_LIST_HASHBITS)
|
||||
|
||||
struct pci_vbar {
|
||||
bool is_mem64hi;;
|
||||
bool is_mem64hi; /* this is to indicate the high part of 64 bits MMIO bar */
|
||||
uint64_t size; /* BAR size */
|
||||
uint64_t base_gpa; /* BAR guest physical address */
|
||||
uint64_t base_hpa; /* BAR host physical address */
|
||||
union pci_bar_type bar_type;
|
||||
union pci_bar_type bar_type; /* the low 2(PIO)/4(MMIO) bits of BAR */
|
||||
uint32_t mask; /* BAR size mask */
|
||||
};
|
||||
|
||||
@@ -184,4 +184,30 @@ int32_t vpci_assign_pcidev(struct acrn_vm *tgt_vm, struct acrn_assign_pcidev *pc
|
||||
int32_t vpci_deassign_pcidev(struct acrn_vm *tgt_vm, struct acrn_assign_pcidev *pcidev);
|
||||
struct pci_vdev *vpci_init_vdev(struct acrn_vpci *vpci, struct acrn_vm_pci_dev_config *dev_config, struct pci_vdev *parent_pf_vdev);
|
||||
|
||||
static inline bool is_pci_io_bar(struct pci_vbar *vbar)
|
||||
{
|
||||
return ((vbar->bar_type.io_space.indicator == 1U) && (!vbar->is_mem64hi));
|
||||
}
|
||||
|
||||
static inline bool is_pci_mem_bar(struct pci_vbar *vbar)
|
||||
{
|
||||
return ((vbar->is_mem64hi) || ((vbar->bar_type.mem_space.indicator == 0U)));
|
||||
}
|
||||
|
||||
/* Reserved PCI BAR type: 1.Memory bar with reserved memory type; 2.IO bar reserved bit is set */
|
||||
static inline bool is_pci_reserved_bar(struct pci_vbar *vbar)
|
||||
{
|
||||
return (((vbar->bar_type.mem_space.indicator == 0U) && ((vbar->bar_type.mem_space.mem_type & 0x1U) == 0x1U) && (!vbar->is_mem64hi)) ||
|
||||
((vbar->bar_type.io_space.indicator == 1U) && (vbar->bar_type.io_space.reserved == 1U)));
|
||||
}
|
||||
|
||||
static inline bool is_pci_mem32_bar(struct pci_vbar *vbar)
|
||||
{
|
||||
return ((vbar->bar_type.mem_space.indicator == 0U) && (vbar->bar_type.mem_space.mem_type == 0U) && (!vbar->is_mem64hi));
|
||||
}
|
||||
|
||||
static inline bool is_pci_mem64lo_bar(struct pci_vbar *vbar)
|
||||
{
|
||||
return ((vbar->bar_type.mem_space.indicator == 0U) && (vbar->bar_type.mem_space.mem_type == 2U) && (!vbar->is_mem64hi));
|
||||
}
|
||||
#endif /* VPCI_H_ */
|
||||
|
||||
@@ -203,16 +203,22 @@ union pci_bdf {
|
||||
} fields;
|
||||
};
|
||||
|
||||
/*
|
||||
* The next data structure is to reflect the format of PCI BAR base on the PCI sepc.
|
||||
*/
|
||||
|
||||
union pci_bar_type {
|
||||
uint32_t bits;
|
||||
struct {
|
||||
uint8_t indicator :1; /* BITs[0], mapped to I/O space if read as 1 */
|
||||
uint8_t reserved :1; /* BITs[1], reserved */
|
||||
uint32_t indicator :1; /* BITs[0], mapped to I/O space if read as 1 */
|
||||
uint32_t reserved :1; /* BITs[1], reserved and must be "0" per spec. */
|
||||
uint32_t reserved2 : 30;
|
||||
} io_space;
|
||||
struct {
|
||||
uint8_t indicator :1; /* BITs[0], mapped to memory space if read as 0 */
|
||||
uint8_t mem_type :2; /* BITs[1:2], 32-bit address if read as 00b, 64-bit address as 01b */
|
||||
uint8_t prefetchable :1; /* BITs[3], set to 1b if the data is prefetchable and set to 0b otherwise */
|
||||
uint32_t indicator :1; /* BITs[0], mapped to memory space if read as 0 */
|
||||
uint32_t mem_type :2; /* BITs[1:2], 32-bit address if read as 00b, 64-bit address as 01b */
|
||||
uint32_t prefetchable :1; /* BITs[3], set to 1b if the data is prefetchable and set to 0b otherwise */
|
||||
uint32_t reserved2 : 28;
|
||||
} mem_space;
|
||||
};
|
||||
|
||||
@@ -309,34 +315,6 @@ static inline bool is_bar_offset(uint32_t nr_bars, uint32_t offset)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline bool is_pci_io_bar(uint32_t val)
|
||||
{
|
||||
union pci_bar_type bar_type = {.bits = val};
|
||||
|
||||
return (bar_type.io_space.indicator == 1U);
|
||||
}
|
||||
|
||||
static inline bool is_pci_mem_bar(uint32_t val)
|
||||
{
|
||||
union pci_bar_type bar_type = {.bits = val};
|
||||
|
||||
return ((bar_type.mem_space.indicator == 0U));
|
||||
}
|
||||
|
||||
static inline bool is_pci_mem32_bar(uint32_t val)
|
||||
{
|
||||
union pci_bar_type bar_type = {.bits = val};
|
||||
|
||||
return (is_pci_mem_bar(val) && (bar_type.mem_space.mem_type == 0U));
|
||||
}
|
||||
|
||||
static inline bool is_pci_mem64_bar(uint32_t val)
|
||||
{
|
||||
union pci_bar_type bar_type = {.bits = val};
|
||||
|
||||
return (is_pci_mem_bar(val) && (bar_type.mem_space.mem_type == 2U));
|
||||
}
|
||||
|
||||
static inline bool bdf_is_equal(union pci_bdf a, union pci_bdf b)
|
||||
{
|
||||
return (a.value == b.value);
|
||||
|
||||
Reference in New Issue
Block a user