Guest-side macros to generate backdoor instructions. Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu> --- 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