From d9e6cdb593257b3ed5600a892ebc145f9cd4f7b3 Mon Sep 17 00:00:00 2001 From: Liu Xinyun Date: Tue, 26 Feb 2019 16:49:50 +0800 Subject: [PATCH] dm: not register/unregister gvt bar memory AcrnGT traps and intercepts the memory region defined by PCI bar in service OS kernel driver. No need to register the bar associated region in dm. By the way, some OS changes BAR start address and there is no mechanism to reflect the gvt changes back to dm. It causes problem that other devices may register new region which falls in GVT `old` region, and leads to hypervisor crash. v4: Add FIXME tag. It's a short term solution before migrated to OVMF v3: rewording the comments v2: removed unnecessary braces and use printf to log (Peter) Tracked-On: #2976 Reviewed-by: He, Min Reviewed-by: Yin Fengwei Signed-off-by: Liu Xinyun Acked-by: Yu Wang --- devicemodel/hw/pci/core.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/devicemodel/hw/pci/core.c b/devicemodel/hw/pci/core.c index ed30fa101..190e1ecc6 100644 --- a/devicemodel/hw/pci/core.c +++ b/devicemodel/hw/pci/core.c @@ -128,6 +128,15 @@ CFGREAD(struct pci_vdev *dev, int coff, int bytes) return pci_get_cfgdata32(dev, coff); } +static inline int +is_pci_gvt(struct pci_vdev *dev) +{ + if (dev == NULL || strncmp(dev->dev_ops->class_name, "pci-gvt",7)) + return 0; + else + return 1; +} + /* * I/O access */ @@ -494,6 +503,20 @@ modify_bar_registration(struct pci_vdev *dev, int idx, int registration) struct inout_port iop; struct mem_range mr; + if (is_pci_gvt(dev)) { + /* GVT device is the only one who traps the pci bar access and + * intercepts the corresponding contents in kernel. It needs + * register pci resource only, but no need to register the + * region. + * + * FIXME: This is a short term solution. This patch will be + * obsoleted with the migration of using OVMF to do bar + * addressing and generate ACPI PCI resource from using + * acrn-dm. + */ + printf("modify_bar_registration: bypass for pci-gvt\n"); + return; + } switch (dev->bar[idx].type) { case PCIBAR_IO: bzero(&iop, sizeof(struct inout_port));