mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
hv: vPCI: add assign/deassign PCI device HC APIs
Add assign/deassign PCI device hypercall APIs to assign a PCI device from SOS to post-launched VM or deassign a PCI device from post-launched VM to SOS. This patch is prepared for spliting passthrough PCI device from DM to HV. The old assign/deassign ptdev APIs will be discarded. Tracked-On: #4371 Signed-off-by: Li Fei1 <fei1.li@intel.com>
This commit is contained in:
@@ -272,6 +272,32 @@ int32_t hcall_assign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param);
|
||||
*/
|
||||
int32_t hcall_deassign_ptdev(struct acrn_vm *vm, uint16_t vmid, uint64_t param);
|
||||
|
||||
/**
|
||||
* @brief Assign one PCI dev to VM.
|
||||
*
|
||||
* @param vm Pointer to VM data structure
|
||||
* @param vmid ID of the VM
|
||||
* @param param guest physical address. This gpa points to data structure of
|
||||
* acrn_assign_pcidev including assign PCI device info
|
||||
*
|
||||
* @pre Pointer vm shall point to SOS_VM
|
||||
* @return 0 on success, non-zero on error.
|
||||
*/
|
||||
int32_t hcall_assign_pcidev(struct acrn_vm *vm, uint16_t vmid, uint64_t param);
|
||||
|
||||
/**
|
||||
* @brief Deassign one PCI dev to VM.
|
||||
*
|
||||
* @param vm Pointer to VM data structure
|
||||
* @param vmid ID of the VM
|
||||
* @param param guest physical address. This gpa points to data structure of
|
||||
* acrn_assign_pcidev including deassign PCI device info
|
||||
*
|
||||
* @pre Pointer vm shall point to SOS_VM
|
||||
* @return 0 on success, non-zero on error.
|
||||
*/
|
||||
int32_t hcall_deassign_pcidev(struct acrn_vm *vm, uint16_t vmid, uint64_t param);
|
||||
|
||||
/**
|
||||
* @brief Set interrupt mapping info of ptdev.
|
||||
*
|
||||
|
@@ -134,5 +134,8 @@ void vpci_cleanup(struct acrn_vm *vm);
|
||||
struct pci_vdev *pci_find_vdev(struct acrn_vpci *vpci, union pci_bdf vbdf);
|
||||
void vpci_set_ptdev_intr_info(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);
|
||||
struct acrn_assign_pcidev;
|
||||
int32_t vpci_assign_pcidev(struct acrn_vm *tgt_vm, struct acrn_assign_pcidev *pcidev);
|
||||
int32_t vpci_deassign_pcidev(struct acrn_vm *tgt_vm, struct acrn_assign_pcidev *pcidev);
|
||||
|
||||
#endif /* VPCI_H_ */
|
||||
|
@@ -90,6 +90,8 @@
|
||||
#define PCIR_CAP_PTR_CARDBUS 0x14U
|
||||
#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL)
|
||||
#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL)
|
||||
#define PCIR_INTERRUPT_LINE 0x3cU
|
||||
#define PCIR_INTERRUPT_PIN 0x3dU
|
||||
|
||||
/* config registers for header type 1 (PCI-to-PCI bridge) devices */
|
||||
#define PCIR_PRIBUS_1 0x18U
|
||||
|
@@ -64,6 +64,8 @@
|
||||
#define HC_VM_PCI_MSIX_REMAP BASE_HC_ID(HC_ID, HC_ID_PCI_BASE + 0x02UL)
|
||||
#define HC_SET_PTDEV_INTR_INFO BASE_HC_ID(HC_ID, HC_ID_PCI_BASE + 0x03UL)
|
||||
#define HC_RESET_PTDEV_INTR_INFO BASE_HC_ID(HC_ID, HC_ID_PCI_BASE + 0x04UL)
|
||||
#define HC_ASSIGN_PCIDEV BASE_HC_ID(HC_ID, HC_ID_PCI_BASE + 0x05UL)
|
||||
#define HC_DEASSIGN_PCIDEV BASE_HC_ID(HC_ID, HC_ID_PCI_BASE + 0x06UL)
|
||||
|
||||
/* DEBUG */
|
||||
#define HC_ID_DBG_BASE 0x60UL
|
||||
@@ -271,6 +273,39 @@ struct hc_ptdev_irq {
|
||||
} is; /* irq source */
|
||||
} __aligned(8);
|
||||
|
||||
/**
|
||||
* @brief Info to assign or deassign PCI for a VM
|
||||
*
|
||||
* the parameter for HC_ASSIGN_PCIDEV or HC_DEASSIGN_PCIDEV hypercall
|
||||
*/
|
||||
struct acrn_assign_pcidev {
|
||||
/** reversed for externed compatibility */
|
||||
uint32_t rsvd1;
|
||||
|
||||
/** virtual BDF# of the pass-through PCI device */
|
||||
uint16_t virt_bdf;
|
||||
|
||||
/** physical BDF# of the pass-through PCI device */
|
||||
uint16_t phys_bdf;
|
||||
|
||||
/** the PCI Interrupt Line, initialized by ACRN-DM, which is RO and
|
||||
* ideally not used for pass-through MSI/MSI-x devices.
|
||||
*/
|
||||
uint8_t intr_line;
|
||||
|
||||
/** the PCI Interrupt Pin, initialized by ACRN-DM, which is RO and
|
||||
* ideally not used for pass-through MSI/MSI-x devices.
|
||||
*/
|
||||
uint8_t intr_pin;
|
||||
|
||||
/** the base address of the PCI BAR, initialized by ACRN-DM. */
|
||||
uint32_t bar[6];
|
||||
|
||||
/** reserved for extension */
|
||||
uint32_t rsvd2[6];
|
||||
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
/**
|
||||
* Hypervisor api version info, return it for HC_GET_API_VERSION hypercall
|
||||
*/
|
||||
|
Reference in New Issue
Block a user