summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrzej Zaborowski <balrog@zabor.org>2009-05-30 16:30:04 +0200
committerAndrzej Zaborowski <balrog@zabor.org>2009-05-30 16:30:04 +0200
commit33466cd83c2a9d7d3fb9fe437fb6a4d6fbd866b9 (patch)
treecffd74551280a0c1a6bc96f6cf723120f679f72c
parent8786e15bb84ba7b13ccebc001e48c8af6696d653 (diff)
downloadqemugl-33466cd83c2a9d7d3fb9fe437fb6a4d6fbd866b9.tar.gz
qemugl-33466cd83c2a9d7d3fb9fe437fb6a4d6fbd866b9.tar.bz2
qemugl-33466cd83c2a9d7d3fb9fe437fb6a4d6fbd866b9.zip
Try to use breakpoints to genereate vmexits to the hypervisor.HEADmaster
-rw-r--r--opengl_client.c66
1 files changed, 64 insertions, 2 deletions
diff --git a/opengl_client.c b/opengl_client.c
index 0fcc4d5..0a32e48 100644
--- a/opengl_client.c
+++ b/opengl_client.c
@@ -1157,7 +1157,7 @@ static void opengl_uart_init(void)
}
#endif
-#define IO_COMM_SUPPORT
+#undef IO_COMM_SUPPORT
#ifdef IO_COMM_SUPPORT
static int use_io_comm = 1;
static uint64_t volatile params[6] __attribute__ ((aligned (0x40)));
@@ -1266,11 +1266,64 @@ static void opengl_io_init(void)
#else
__asm__ volatile ("mov $-1, %%eax" ::: "eax", "rax");
__asm__ volatile ("mov $0x270c, %%edx" ::: "edx", "rdx");
- __asm__ volatile ("outl %eax,(%dx)");
+ __asm__ volatile ("outl %eax, (%dx)");
#endif
}
#endif
+#define BP_COMM_SUPPORT
+#ifdef BP_COMM_SUPPORT
+static int use_bp_comm = 1;
+static __attribute__((noinline)) int call_opengl_bp(int func_number, int pid,
+ void *ret_string, void *args, void *args_size)
+{
+#if defined(__i386__)
+ register unsigned long int ax asm ("eax") = func_number;
+ register unsigned long int bx asm ("edx") = pid;
+ register unsigned long int cx asm ("ecx") = (long int) ret_string;
+ register unsigned long int dx asm ("edx") = (long int) args;
+ register unsigned long int si asm ("esi") = (long int) args_size;
+#elif defined(__x86_64__)
+ register unsigned long int ax asm ("rax") = func_number;
+ register unsigned long int bx asm ("rdx") = pid;
+ register unsigned long int cx asm ("rcx") = (long int) ret_string;
+ register unsigned long int dx asm ("rdx") = (long int) args;
+ register unsigned long int si asm ("rsi") = (long int) args_size;
+#else
+#error Unsupported architecture
+#endif
+
+ asm volatile ("opengl_bp:");
+ asm volatile ("int $0x99" : "=r" (ax) : "r" (ax), "r" (bx), "r" (cx), "r" (dx), "r" (si));
+
+ return ax;
+}
+
+static uint64_t opengl_get_bp_addr(void)
+{
+ unsigned long int ret;
+
+ __asm__ volatile ("movl $opengl_bp, %0" : "=r" (ret));
+
+ return ret;
+}
+
+static void opengl_bp_init(void)
+{
+ char cmd[17];
+ struct termios tios;
+ int fd;
+
+ sprintf(cmd, "%016llx", opengl_get_bp_addr());
+
+ fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_SYNC);
+ cfmakeraw(&tios);
+ tcsetattr(fd, TCSAFLUSH, &tios);
+ write(fd, cmd, 16);
+ close(fd);
+}
+#endif
+
#undef UDP_COMM_SUPPORT
#ifdef UDP_COMM_SUPPORT
#include <arpa/inet.h>
@@ -1315,6 +1368,11 @@ static int use_tcp_communication = 0;
#endif
static int call_opengl(int func_number, int pid, void* ret_string, void* args, void* args_size)
{
+#ifdef BP_COMM_SUPPORT
+ if (use_bp_comm)
+ return call_opengl_bp(func_number, pid, ret_string, args, args_size);
+ else
+#endif
#ifdef IO_COMM_SUPPORT
if (use_io_comm)
return call_opengl_io(func_number, pid, ret_string, args, args_size);
@@ -1340,6 +1398,10 @@ static int call_opengl(int func_number, int pid, void* ret_string, void* args, v
static void do_init()
{
+#ifdef BP_COMM_SUPPORT
+ if (use_bp_comm)
+ opengl_bp_init();
+#endif
#ifdef IO_COMM_SUPPORT
if (use_io_comm)
opengl_io_init();