File xf86-input-vmmouse-iopl.diff of Package xorg-x11-driver-input

diff --git a/shared/vmmouse_proto.c b/shared/vmmouse_proto.c
index b50e071..263bb36 100644
--- a/shared/vmmouse_proto.c
+++ b/shared/vmmouse_proto.c
@@ -33,6 +33,7 @@
  */
 
 
+#include <sys/io.h>
 #include "vmmouse_proto.h"
 
 
@@ -119,6 +120,31 @@ VMMouseProtoInOut(VMMouseProtoCmd *cmd) // IN/OUT
 #endif
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMMouseGetIOPL --
+ *
+ *      Helper to figure out the current I/O privilege level (idea by
+ *      Jiri Kosina <jkosina@suse.cz>)
+ *
+ * Results:
+ *      Returns I/O privilege level
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int 
+VMMouseGetIOPL()
+{
+        unsigned long eflags;
+
+        asm ("pushf\n\tpop %0" : "=r" (eflags));
+        return (eflags >> 12) & 3;
+}
 
 /*
  *-----------------------------------------------------------------------------
@@ -140,8 +166,22 @@ VMMouseProtoInOut(VMMouseProtoCmd *cmd) // IN/OUT
 void
 VMMouseProto_SendCmd(VMMouseProtoCmd *cmd) // IN/OUT
 {
+   int cpl;
+
    cmd->in.magic = VMMOUSE_PROTO_MAGIC;
    cmd->in.port = VMMOUSE_PROTO_PORT;
 
+#if defined __i386__ || defined __x86_64__ 
+   cpl = VMMouseGetIOPL();
+   /*
+    * To access i/o ports above 0x3ff, we need to be in iopl(3).
+    */
+   iopl(3);
+#endif
+
    VMMouseProtoInOut(cmd);
+
+#if defined __i386__ || defined __x86_64__ 
+   iopl(cpl);
+#endif
 }
openSUSE Build Service is sponsored by