Skip to content

Commit 65ca6ae

Browse files
donshengacrnsi
authored andcommitted
HV: add get_vbar_base() to get vbar base address in 64-bit
vbar base can be built by using the base address fields stored in struct pci_bar's reg member. get_vbar_base: return vbar's base address in 64-bit. For 64-bit MMIO bar, its lower 32-bits base address and upper 32-bits base are combined into one 64-bit base address And changed related code to use get_vbar_base to get vbar base address in 64-bit. Tracked-On: #3241 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com>
1 parent 7a2f524 commit 65ca6ae

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

hypervisor/dm/vpci/pci_pt.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ static uint64_t pci_bar_2_bar_base(const struct pci_bar *pbars, uint32_t nr_bars
103103
return base;
104104
}
105105

106+
/**
107+
* @brief get vbar's full base address in 64-bit
108+
* For 64-bit MMIO bar, its lower 32-bits base address and upper 32-bits base are combined
109+
* into one 64-bit base address
110+
* @pre vdev != NULL
111+
*/
112+
static uint64_t get_vbar_base(const struct pci_vdev *vdev, uint32_t idx)
113+
{
114+
return pci_bar_2_bar_base(&vdev->bar[0], vdev->nr_bars, idx);
115+
}
116+
106117
/**
107118
* @brief get pbar's full address in 64-bit
108119
* For 64-bit MMIO bar, its lower 32-bits base address and upper 32-bits base are combined
@@ -158,9 +169,10 @@ void vdev_pt_remap_msix_table_bar(struct pci_vdev *vdev)
158169
pbar = &pdev->bar[msix->table_bar];
159170
if (pbar != NULL) {
160171
uint64_t pbar_base = get_pbar_base(pdev, msix->table_bar); /* pbar (hpa) */
172+
161173
msix->mmio_hpa = pbar_base;
162174
if (is_prelaunched_vm(vdev->vpci->vm)) {
163-
msix->mmio_gpa = vdev->bar[msix->table_bar].base;
175+
msix->mmio_gpa = get_vbar_base(vdev, msix->table_bar);
164176
} else {
165177
msix->mmio_gpa = sos_vm_hpa2gpa(pbar_base);
166178
}
@@ -250,9 +262,10 @@ static void vdev_pt_remap_generic_mem_vbar(const struct pci_vdev *vdev, uint32_t
250262
{
251263
struct acrn_vm *vm = vdev->vpci->vm;
252264

265+
/* If the old vbar is mapped before, unmap it first */
253266
if (vdev->bar[idx].base != 0UL) {
254267
ept_del_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
255-
vdev->bar[idx].base,
268+
vdev->bar[idx].base, /* GPA (old vbar) */
256269
vdev->bar[idx].size);
257270
}
258271

0 commit comments

Comments
 (0)