Blob Blame Raw
From 5abddb02644d2a63d5dff21c936374d6ac3df31e Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Wed, 16 Feb 2011 17:19:00 -0500
Subject: [PATCH] Turn shadowfb off on virtualized hardware

There's no benefit to shadowfb, since the framebuffer is in the same
memory domain as host memory; all you're doing is adding extra copies.

Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 src/vesa.c |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/vesa.c b/src/vesa.c
index 61d3550..9fd166f 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -841,9 +841,37 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
     memcpy(pVesa->Options, VESAOptions, sizeof(VESAOptions));
     xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pVesa->Options);
 
-    /* Use shadow by default */
-    if (xf86ReturnOptValBool(pVesa->Options, OPTION_SHADOW_FB, TRUE)) 
-	pVesa->shadowFB = TRUE;
+    /* Use shadow by default, for non-virt hardware */
+    if (!xf86GetOptValBool(pVesa->Options, OPTION_SHADOW_FB, &pVesa->shadowFB))
+    {
+	switch (pVesa->pciInfo->vendor_id) {
+	    case 0x1234: /* bochs vga (not in pci.ids) */
+	    case 0x15ad: /* vmware */
+	    case 0x1b36: /* qemu qxl */
+	    case 0x80ee: /* virtualbox */
+	    case 0xaaaa: /* parallels (not in pci.ids) */
+		pVesa->shadowFB = FALSE;
+		break;
+
+	    case 0x1013: /* qemu's cirrus emulation */
+		if (pVesa->pciInfo->subvendor_id == 0x1af4)
+		    pVesa->shadowFB = FALSE;
+		else
+		    pVesa->shadowFB = TRUE;
+		break;
+
+	    case 0x1414: /* microsoft hyper-v */
+		if (pVesa->pciInfo->device_id == 0x5353)
+		    pVesa->shadowFB = FALSE;
+		else
+		    pVesa->shadowFB = TRUE;
+		break;
+
+	    default:
+		pVesa->shadowFB = TRUE;
+		break;
+	}	    
+    }
 
     if (xf86ReturnOptValBool(pVesa->Options, OPTION_DFLT_REFRESH, FALSE))
 	pVesa->defaultRefresh = TRUE;
-- 
1.7.3.5