qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 06/18] backdoor: [i386] Declare guest-side interface


From: Lluís
Subject: [Qemu-devel] [PATCH 06/18] backdoor: [i386] Declare guest-side interface macros
Date: Mon, 18 Oct 2010 20:08:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Guest-side macros to generate backdoor instructions.

Signed-off-by: Lluís Vilanova <address@hidden>
---
 backdoor/guest.h |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/backdoor/guest.h b/backdoor/guest.h
index 58847e2..17029d3 100644
--- a/backdoor/guest.h
+++ b/backdoor/guest.h
@@ -26,8 +26,32 @@
  * -  V: value passed in register
  */
 
+#if __i386__ || __i486__ || __x86_64__
+
+#define __BACKDOOR_BASE asm volatile (".byte 0x0f, 0x04")
+#define __BACKDOOR_V(v) asm volatile ("movl %0, %%eax" : : "g"(v) : "%eax")
+
+#define BACKDOOR_i8(cmd)                                        \
+    do {                                                        \
+        __BACKDOOR_BASE;                                        \
+        __BACKDOOR_i8(0x00);                                    \
+        __BACKDOOR_i8(cmd);                                     \
+    } while (0)
+
+#define BACKDOOR_i8_V(cmd, value)                               \
+    do {                                                        \
+        __BACKDOOR_V(value);                                    \
+        __BACKDOOR_BASE;                                        \
+        __BACKDOOR_i8(0x01);                                    \
+        __BACKDOOR_i8(cmd);                                     \
+    } while (0)
+
+#else
+
 #error Undefined instruction-based backdoor interface for guest architecture
 
+#endif
+
 #define __str(s) #s
 #define __xstr(s) __str(s)
 
-- 
1.7.1

-- 
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth



reply via email to

[Prev in Thread] Current Thread [Next in Thread]