mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-31 11:25:30 +00:00
hv: vpci: rename ptdev_config to pci_dev_config
pci_dev_config in VM configure stores all the PCI devices for a VM. Besides PT devices, there're other type devices, like virtual host bridge. So rename ptdev to pci_dev for these configure. Tracked-On: #3475 Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
83e887dbb3
commit
adbaaaf6cb
@ -290,7 +290,7 @@ The rules of error detection and error handling on a module level are shown in
|
||||
| | | array size and non-null | | |
|
||||
| | | pointer. | | |
|
||||
+--------------------+-----------+----------------------------+---------------------------+-------------------------+
|
||||
| Configuration data | Corrupted | No. | The bootloader initializes| 'vm_config->pci_ptdevs' |
|
||||
| Configuration data | Corrupted | No. | The bootloader initializes| 'vm_config->pci_devs' |
|
||||
| of the VM | VM config | The related pre-conditions | hypervisor (including | is configured |
|
||||
| | | are required. | code, data, and bss) and | statically. |
|
||||
| | | Note: VM configuration data| verifies the integrity of | |
|
||||
@ -328,19 +328,19 @@ a module level.
|
||||
struct acrn_vpci *vpci = (struct acrn_vpci *)&(vm->vpci);
|
||||
struct pci_vdev *vdev;
|
||||
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||
struct acrn_vm_pci_ptdev_config *ptdev_config;
|
||||
struct acrn_vm_pci_dev_config *pci_dev_config;
|
||||
uint32_t i;
|
||||
|
||||
vpci->pci_vdev_cnt = vm_config->pci_ptdev_num;
|
||||
vpci->pci_vdev_cnt = vm_config->pci_dev_num;
|
||||
|
||||
for (i = 0U; i < vpci->pci_vdev_cnt; i++) {
|
||||
vdev = &vpci->pci_vdevs[i];
|
||||
vdev->vpci = vpci;
|
||||
ptdev_config = &vm_config->pci_ptdevs[i];
|
||||
vdev->vbdf.value = ptdev_config->vbdf.value;
|
||||
pci_dev_config = &vm_config->pci_devs[i];
|
||||
vdev->vbdf.value = pci_dev_config->vbdf.value;
|
||||
|
||||
if (vdev->vbdf.value != 0U) {
|
||||
partition_mode_pdev_init(vdev, ptdev_config->pbdf);
|
||||
partition_mode_pdev_init(vdev, pci_dev_config->pbdf);
|
||||
vdev->ops = &pci_ops_vdev_pt;
|
||||
} else {
|
||||
vdev->ops = &pci_ops_vdev_hostbridge;
|
||||
@ -367,7 +367,7 @@ pre-conditions and ``get_vm_config`` itself shall guarantee the post-condition.
|
||||
/**
|
||||
* @pre vm_id < CONFIG_MAX_VM_NUM
|
||||
* @post retval != NULL
|
||||
* @post retval->pci_ptdev_num <= MAX_PCI_DEV_NUM
|
||||
* @post retval->pci_dev_num <= MAX_PCI_DEV_NUM
|
||||
*/
|
||||
struct acrn_vm_config *get_vm_config(uint16_t vm_id)
|
||||
{
|
||||
@ -398,9 +398,9 @@ Given the two reasons above, 'vdev' is always not NULL. So, the error checking
|
||||
codes are not required for 'vdev'.
|
||||
|
||||
|
||||
**Question_3: Is error checking required for 'ptdev_config'?**
|
||||
**Question_3: Is error checking required for 'pci_dev_config'?**
|
||||
|
||||
No. 'ptdev_config' is getting data from the array 'pci_vdevs[]', which is the
|
||||
No. 'pci_dev_config' is getting data from the array 'pci_vdevs[]', which is the
|
||||
physical PCI device information coming from Board Support Package and firmware.
|
||||
For physical PCI device information, the related application constraints
|
||||
shall be defined in the design document or safety manual. For debug purpose,
|
||||
|
@ -229,7 +229,7 @@ Enable partition mode in ACRN hypervisor
|
||||
|
||||
PCI devices that are available to the privileged VMs
|
||||
are hardcoded in the source file ``hypervisor/arch/x86/configs/up2/pt_dev.c``.
|
||||
You need to review and modify the ``vm0_pci_ptdevs`` and ``vm1_pci_ptdevs``
|
||||
You need to review and modify the ``vm0_pci_devs`` and ``vm1_pci_devs``
|
||||
structures in the source code to match the PCI BDF addresses of the SATA
|
||||
controller and the USB controller noted in step 1:
|
||||
|
||||
@ -238,7 +238,7 @@ Enable partition mode in ACRN hypervisor
|
||||
:caption: hypervisor/arch/x86/configs/up2/pt_dev.c
|
||||
|
||||
...
|
||||
struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[2] = {
|
||||
struct acrn_vm_pci_dev_config vm0_pci_devs[2] = {
|
||||
{
|
||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
@ -250,7 +250,7 @@ Enable partition mode in ACRN hypervisor
|
||||
};
|
||||
|
||||
...
|
||||
struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[3] = {
|
||||
struct acrn_vm_pci_dev_config vm1_pci_devs[3] = {
|
||||
{
|
||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
|
@ -498,7 +498,7 @@ void init_vdev_pt(struct pci_vdev *vdev)
|
||||
vbar_base = get_pbar_base(vdev->pdev, idx);
|
||||
} else if (idx > 0U) {
|
||||
/* For pre-launched VMs: vbar base is predefined in vm_config */
|
||||
vbar_base = vdev->ptdev_config->vbar_base[idx - 1U];
|
||||
vbar_base = vdev->pci_dev_config->vbar_base[idx - 1U];
|
||||
} else {
|
||||
vbar_base = 0UL;
|
||||
}
|
||||
@ -522,7 +522,7 @@ void init_vdev_pt(struct pci_vdev *vdev)
|
||||
vbar_base = get_pbar_base(vdev->pdev, idx);
|
||||
} else {
|
||||
/* For pre-launched VMs: vbar base is predefined in vm_config */
|
||||
vbar_base = vdev->ptdev_config->vbar_base[idx];
|
||||
vbar_base = vdev->pci_dev_config->vbar_base[idx];
|
||||
}
|
||||
vdev_pt_write_vbar(vdev, pci_bar_offset(idx), (uint32_t)vbar_base);
|
||||
break;
|
||||
|
@ -420,25 +420,25 @@ static void write_cfg(const struct acrn_vpci *vpci, union pci_bdf bdf,
|
||||
|
||||
/**
|
||||
* @pre vm_config != NULL
|
||||
* @pre vm_config->pci_ptdev_num <= CONFIG_MAX_PCI_DEV_NUM
|
||||
* @pre vm_config->pci_dev_num <= CONFIG_MAX_PCI_DEV_NUM
|
||||
*/
|
||||
static struct acrn_vm_pci_ptdev_config *find_ptdev_config_by_pbdf(const struct acrn_vm_config *vm_config,
|
||||
static struct acrn_vm_pci_dev_config *find_pci_dev_config(const struct acrn_vm_config *vm_config,
|
||||
union pci_bdf pbdf)
|
||||
{
|
||||
struct acrn_vm_pci_ptdev_config *ptdev_config, *tmp;
|
||||
struct acrn_vm_pci_dev_config *pci_dev_config, *tmp;
|
||||
uint16_t i;
|
||||
|
||||
ptdev_config = NULL;
|
||||
for (i = 0U; i < vm_config->pci_ptdev_num; i++) {
|
||||
tmp = &vm_config->pci_ptdevs[i];
|
||||
pci_dev_config = NULL;
|
||||
for (i = 0U; i < vm_config->pci_dev_num; i++) {
|
||||
tmp = &vm_config->pci_devs[i];
|
||||
|
||||
if (bdf_is_equal(&tmp->pbdf, &pbdf)) {
|
||||
ptdev_config = tmp;
|
||||
pci_dev_config = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ptdev_config;
|
||||
return pci_dev_config;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,11 +450,11 @@ static void init_vdev_for_pdev(struct pci_pdev *pdev, const struct acrn_vm *vm)
|
||||
{
|
||||
const struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||
struct acrn_vpci *vpci = &(((struct acrn_vm *)vm)->vpci);
|
||||
struct acrn_vm_pci_ptdev_config *ptdev_config;
|
||||
struct acrn_vm_pci_dev_config *pci_dev_config;
|
||||
|
||||
ptdev_config = find_ptdev_config_by_pbdf(vm_config, pdev->bdf);
|
||||
pci_dev_config = find_pci_dev_config(vm_config, pdev->bdf);
|
||||
|
||||
if (((is_prelaunched_vm(vm) && (ptdev_config != NULL)) || is_sos_vm(vm))
|
||||
if (((is_prelaunched_vm(vm) && (pci_dev_config != NULL)) || is_sos_vm(vm))
|
||||
&& (vpci->pci_vdev_cnt < CONFIG_MAX_PCI_DEV_NUM)) {
|
||||
struct pci_vdev *vdev;
|
||||
|
||||
@ -463,11 +463,11 @@ static void init_vdev_for_pdev(struct pci_pdev *pdev, const struct acrn_vm *vm)
|
||||
|
||||
vdev->vpci = vpci;
|
||||
vdev->pdev = pdev;
|
||||
vdev->ptdev_config = ptdev_config;
|
||||
vdev->pci_dev_config = pci_dev_config;
|
||||
|
||||
if (ptdev_config != NULL) {
|
||||
if (pci_dev_config != NULL) {
|
||||
/* vbdf is defined in vm_config */
|
||||
vdev->bdf.value = ptdev_config->vbdf.value;
|
||||
vdev->bdf.value = pci_dev_config->vbdf.value;
|
||||
} else {
|
||||
/* vbdf is not defined in vm_config, set it to equal to pbdf */
|
||||
vdev->bdf.value = pdev->bdf.value;
|
||||
|
@ -78,10 +78,10 @@ struct acrn_vm_os_config {
|
||||
uint64_t kernel_ramdisk_addr;
|
||||
} __aligned(8);
|
||||
|
||||
struct acrn_vm_pci_ptdev_config {
|
||||
union pci_bdf vbdf; /* virtual BDF of PCI PT device */
|
||||
union pci_bdf pbdf; /* physical BDF of PCI PT device */
|
||||
uint64_t vbar_base[PCI_BAR_COUNT]; /* vbar base address of PCI PT device */
|
||||
struct acrn_vm_pci_dev_config {
|
||||
union pci_bdf vbdf; /* virtual BDF of PCI device */
|
||||
union pci_bdf pbdf; /* physical BDF of PCI device */
|
||||
uint64_t vbar_base[PCI_BAR_COUNT]; /* vbar base address of PCI device */
|
||||
} __aligned(8);
|
||||
|
||||
struct acrn_vm_config {
|
||||
@ -97,8 +97,8 @@ struct acrn_vm_config {
|
||||
*/
|
||||
struct acrn_vm_mem_config memory; /* memory configuration of VM */
|
||||
struct epc_section epc; /* EPC memory configuration of VM */
|
||||
uint16_t pci_ptdev_num; /* indicate how many PCI PT devices in VM */
|
||||
struct acrn_vm_pci_ptdev_config *pci_ptdevs; /* point to PCI PT devices BDF list */
|
||||
uint16_t pci_dev_num; /* indicate how many PCI devices in VM */
|
||||
struct acrn_vm_pci_dev_config *pci_devs; /* point to PCI devices BDF list */
|
||||
struct acrn_vm_os_config os_config; /* OS information the VM */
|
||||
uint16_t clos; /* if guest_flags has GUEST_FLAG_CLOS_REQUIRED, then VM use this CLOS */
|
||||
|
||||
|
@ -91,8 +91,8 @@ struct pci_vdev {
|
||||
struct pci_msi msi;
|
||||
struct pci_msix msix;
|
||||
|
||||
/* Pointer to corresponding PCI PT device's vm_config */
|
||||
struct acrn_vm_pci_ptdev_config *ptdev_config;
|
||||
/* Pointer to corresponding PCI device's vm_config */
|
||||
struct acrn_vm_pci_dev_config *pci_dev_config;
|
||||
|
||||
/* Pointer to corressponding operations */
|
||||
const struct pci_vdev_ops *vdev_ops;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The memory range of vBAR should exactly match with the e820 layout of VM.
|
||||
*/
|
||||
|
||||
struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = {
|
||||
struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_PTDEV_NUM] = {
|
||||
{
|
||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
HOST_BRIDGE
|
||||
@ -27,7 +27,7 @@ struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = {
|
||||
},
|
||||
};
|
||||
|
||||
struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM] = {
|
||||
struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_PTDEV_NUM] = {
|
||||
{
|
||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
HOST_BRIDGE
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <vm_config.h>
|
||||
#include <vuart.h>
|
||||
|
||||
extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM];
|
||||
extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM];
|
||||
extern struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_PTDEV_NUM];
|
||||
extern struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_PTDEV_NUM];
|
||||
|
||||
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
{ /* VM0 */
|
||||
@ -46,8 +46,8 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.t_vuart.vm_id = 1U,
|
||||
.t_vuart.vuart_id = 1U,
|
||||
},
|
||||
.pci_ptdev_num = VM0_CONFIG_PCI_PTDEV_NUM,
|
||||
.pci_ptdevs = vm0_pci_ptdevs,
|
||||
.pci_dev_num = VM0_CONFIG_PCI_PTDEV_NUM,
|
||||
.pci_devs = vm0_pci_devs,
|
||||
},
|
||||
{ /* VM1 */
|
||||
.load_order = PRE_LAUNCHED_VM,
|
||||
@ -85,7 +85,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.t_vuart.vm_id = 0U,
|
||||
.t_vuart.vuart_id = 1U,
|
||||
},
|
||||
.pci_ptdev_num = VM1_CONFIG_PCI_PTDEV_NUM,
|
||||
.pci_ptdevs = vm1_pci_ptdevs,
|
||||
.pci_dev_num = VM1_CONFIG_PCI_PTDEV_NUM,
|
||||
.pci_devs = vm1_pci_devs,
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user