[Spice-devel] [PATCH xf86-drv-qxl F14-branch 1/3] Don't access the qxl device when our vt is not focussed

Hans de Goede hdegoede at redhat.com
Fri Oct 15 07:36:37 PDT 2010


Trying to do so causes the X-server to segfault as it has
dropped iopl permission, which is, erm, undesirable :)
---
 src/qxl.h         |   10 ----------
 src/qxl_cursor.c  |    2 +-
 src/qxl_driver.c  |   21 +--------------------
 src/qxl_surface.c |    8 ++++++--
 4 files changed, 8 insertions(+), 33 deletions(-)

diff --git a/src/qxl.h b/src/qxl.h
index e126546..54849a6 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -694,16 +694,6 @@ struct _qxl_screen_t
     } u;
 };
 
-static inline Bool
-in_vga_mode (qxl_screen_t *qxl)
-{
-    /* FIXME: The ability to detect whether we are in VGA
-     * mode has been remvoed in newer devices.
-     */
-    
-    return FALSE;
-}
-
 static uint64_t
 physical_address (qxl_screen_t *qxl, void *virtual, uint8_t slot_id)
 {
diff --git a/src/qxl_cursor.c b/src/qxl_cursor.c
index 475796e..9e0bea8 100644
--- a/src/qxl_cursor.c
+++ b/src/qxl_cursor.c
@@ -30,7 +30,7 @@ push_cursor (qxl_screen_t *qxl, struct qxl_cursor_cmd *cursor)
     struct qxl_command cmd;
 
     /* See comment on push_command() in qxl_driver.c */
-    if (!in_vga_mode (qxl))
+    if (qxl->pScrn->vtSema)
     {
         cmd.type = QXL_CMD_CURSOR;
         cmd.data = physical_address (qxl, cursor, qxl->main_mem_slot);
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 6d99430..bd237dc 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -460,7 +460,7 @@ push_drawable (qxl_screen_t *qxl, struct qxl_drawable *drawable)
      * the next time a mode set set, an assertion in the
      * device will take down the entire virtual machine.
      */
-    if (!in_vga_mode (qxl))
+    if (qxl->pScrn->vtSema)
     {
 	cmd.type = QXL_CMD_DRAW;
 	cmd.data = physical_address (qxl, drawable, qxl->main_mem_slot);
@@ -601,25 +601,6 @@ paint_shadow (qxl_screen_t *qxl)
     submit_copy (qxl, &qrect);
 }
 
-static void
-qxl_sanity_check (qxl_screen_t *qxl)
-{
-    /* read the mode back from the rom */
-    if (!qxl->rom || !qxl->pScrn)
-	return;
-    
-    if (in_vga_mode (qxl))
-    {
- 	ErrorF("QXL device jumped back to VGA mode - resetting mode\n");
- 	qxl_switch_mode(qxl->pScrn->scrnIndex, qxl->pScrn->currentMode, 0);
-    }
-}
-
-static void
-qxl_wakeup_handler (pointer data, int i, pointer LastSelectMask)
-{
-}
-
 static Bool
 qxl_create_screen_resources(ScreenPtr pScreen)
 {
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 3b177fe..420eb2c 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -168,7 +168,7 @@ push_surface_cmd (qxl_screen_t *qxl, struct qxl_surface_cmd *cmd)
 {
     struct qxl_command command;
 
-    if (!in_vga_mode (qxl))
+    if (qxl->pScrn->vtSema)
     {
 	command.type = QXL_CMD_SURFACE;
 	command.data = physical_address (qxl, cmd, qxl->main_mem_slot);
@@ -439,8 +439,12 @@ qxl_surface_prepare_access (qxl_surface_t  *surface,
     int n_boxes;
     BoxPtr boxes;
     ScreenPtr pScreen = pixmap->drawable.pScreen;
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     RegionRec new;
 
+    if (!pScrn->vtSema)
+        return FALSE;
+
     REGION_INIT (NULL, &new, (BoxPtr)NULL, 0);
     REGION_SUBTRACT (NULL, &new, region, &surface->access_region);
 
@@ -557,7 +561,7 @@ push_drawable (qxl_screen_t *qxl, struct qxl_drawable *drawable)
      * the next time a mode set set, an assertion in the
      * device will take down the entire virtual machine.
      */
-    if (!in_vga_mode (qxl))
+    if (qxl->pScrn->vtSema)
     {
 	cmd.type = QXL_CMD_DRAW;
 	cmd.data = physical_address (qxl, drawable, qxl->main_mem_slot);
-- 
1.7.3.1



More information about the Spice-devel mailing list