From 359e5cf794a5663ceeecae6358628ac75097f929 Mon Sep 17 00:00:00 2001 From: Anitha Chrisanthus Date: Thu, 21 Jun 2018 08:16:33 -0700 Subject: [PATCH] dm: Disable stolen memory for passthru graphics When enabling GPU passthru for guest, stolen memory needs to be disabled. This change disables stolen memory in passthru mode. Signed-off-by: Anitha Chrisanthus Reviewed-by: Gong Zhipeng --- devicemodel/hw/pci/passthrough.c | 11 +++++++++++ devicemodel/include/pcireg.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/devicemodel/hw/pci/passthrough.c b/devicemodel/hw/pci/passthrough.c index 877c5a3be..a6ef58a60 100644 --- a/devicemodel/hw/pci/passthrough.c +++ b/devicemodel/hw/pci/passthrough.c @@ -70,6 +70,8 @@ #define PCI_BDF(bus, dev, func) (((bus & 0xFF)<<8) | ((dev & 0x1F)<<3) \ | ((func & 0x7))) +#define PCI_BDF_GPU 0x00000010 /* 00:02.0 */ + /* Some audio driver get topology data from ACPI NHLT table, thus need copy host * NHLT to guest. Default audio driver doesn't require this, so make it off by * default to avoid unexpected failure. @@ -1159,6 +1161,15 @@ passthru_cfgread(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, /* Everything else just read from the device's config space */ *rv = read_config(ptdev->phys_dev, coff, bytes); + /* + * return zero for graphics stolen memory since acrn does not have + * support for RMRR + */ + if ((PCI_BDF(dev->bus, dev->slot, dev->func) == PCI_BDF_GPU) + && (coff == PCIR_GMCH_CTL)) { + *rv &= ~PCIM_GMCH_CTL_GMS; + } + return 0; } diff --git a/devicemodel/include/pcireg.h b/devicemodel/include/pcireg.h index f37b9996d..1c106cd9c 100644 --- a/devicemodel/include/pcireg.h +++ b/devicemodel/include/pcireg.h @@ -1065,4 +1065,7 @@ #define PCIM_OSC_CTL_PCIE_AER 0x08 /* PCIe Advanced Error Reporting */ #define PCIM_OSC_CTL_PCIE_CAP_STRUCT 0x10 /* Various Capability Structures */ +/* Graphics definitions */ +#define PCIR_GMCH_CTL 0x50 /*GMCH grpahics control register */ +#define PCIM_GMCH_CTL_GMS 0xFF00 /*GMS - stolen memory bits 15:8 */ #endif