HV: vpci: Fix do not mask I/O BAR upper 16-bit

Now we use pci_vdev_update_vbar_base to update vBAR base address when
guest re-programming BAR. For a IO BAR, we would calculate the 32 bits
base address then mask the high 16 bits. However, the mask code would
never be called since the first if condition statement is always true.

This patch fix it by move the unamsk code into the first if condition
statement.

Tracked-On: #6011
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Li Fei <fei1.li@intel.com>
This commit is contained in:
Tao Yuhong 2021-05-10 06:01:54 -04:00 committed by wenlingz
parent f97c0d32ca
commit 7da53ce138
1 changed files with 4 additions and 2 deletions

View File

@ -128,11 +128,13 @@ static void pci_vdev_update_vbar_base(struct pci_vdev *vdev, uint32_t idx)
base = 0UL;
}
}
} else if (is_pci_io_bar(vbar)) {
if (is_pci_io_bar(vbar)) {
/* Because guest driver may write to upper 16-bits of PIO BAR and expect that should have no effect,
* SO PIO BAR base may bigger than 0xffff after calculation, should mask the upper 16-bits.
*/
base &= 0xffffUL;
base &= 0xffffUL;
}
}
/* TODO: 1. check whether the address locate in the MMIO windows 2. base must aligned with size */