[RevertMe] dm: pci: restore workaround when alloc pci mem64 bar

There was a workaround in DM that allocates PCI 64bit mem bar in 32bit mem space
if the bar size is within 32MB.

After the workaround being removed, there is an issue to enter fastboot
mode for inappropriate handling of 64bit mem bar in guest driver.
The patch bring the workaround back, and skip the workaround when the guest
is booted by OVMF.

Revert the patch after the guest fixs the issue of handling 64bit mem bar in
fastboot mode.

Tracked-On: #2677
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Binbin Wu 2019-03-05 11:02:09 +08:00 committed by wenlingz
parent ca3d4fca55
commit f572d1ecdd
2 changed files with 20 additions and 0 deletions

View File

@ -89,6 +89,7 @@ uint8_t trusty_enabled;
char *mac_seed;
bool stdio_in_use;
bool lapic_pt;
bool skip_pci_mem64bar_workaround = false;
static int virtio_msix = 1;
static bool debugexit_enabled;
@ -859,6 +860,7 @@ dm_run(int argc, char *argv[])
errx(EX_USAGE, "invalid ovmf param %s", optarg);
exit(1);
}
skip_pci_mem64bar_workaround = true;
break;
case CMD_OPT_PART_INFO:
if (acrn_parse_guest_part_info(optarg) != 0) {

View File

@ -88,6 +88,8 @@ static uint64_t pci_emul_iobase;
static uint64_t pci_emul_membase32;
static uint64_t pci_emul_membase64;
extern bool skip_pci_mem64bar_workaround;
#define PCI_EMUL_IOBASE 0x2000
#define PCI_EMUL_IOLIMIT 0x10000
@ -694,6 +696,22 @@ pci_emul_alloc_pbar(struct pci_vdev *pdi, int idx, uint64_t hostbase,
lobits = PCIM_BAR_IO_SPACE;
break;
case PCIBAR_MEM64:
/*
* FIXME
* Some drivers do not work well if the 64-bit BAR is allocated
* above 4GB. Allow for this by allocating small requests under
* 4GB unless then allocation size is larger than some arbitrary
* number (32MB currently). If guest booted by ovmf, then skip the
* workaround.
*/
if (!skip_pci_mem64bar_workaround && (size <= 32 * 1024 * 1024)) {
baseptr = &pci_emul_membase32;
limit = PCI_EMUL_MEMLIMIT32;
mask = PCIM_BAR_MEM_BASE;
lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_64;
break;
}
/*
* XXX special case for device requiring peer-peer DMA
*/