From patchwork Mon Oct 18 18:08:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [06/18] backdoor: [i386] Declare guest-side interface macros Date: Mon, 18 Oct 2010 08:08:44 -0000 From: =?utf-8?Q?Llu=C3=ADs?= X-Patchwork-Id: 68962 Message-Id: <24199c1d4204958e5fe5294fb6e5c11189c5c493.1287772676.git.vilanova@ac.upc.edu> To: qemu-devel@nongnu.org Guest-side macros to generate backdoor instructions. Signed-off-by: LluĂ­s Vilanova --- 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)