lguest_hcall.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Architecture specific portion of the lguest hypercalls */
  2. #ifndef _X86_LGUEST_HCALL_H
  3. #define _X86_LGUEST_HCALL_H
  4. #define LHCALL_FLUSH_ASYNC 0
  5. #define LHCALL_LGUEST_INIT 1
  6. #define LHCALL_CRASH 2
  7. #define LHCALL_LOAD_GDT 3
  8. #define LHCALL_NEW_PGTABLE 4
  9. #define LHCALL_FLUSH_TLB 5
  10. #define LHCALL_LOAD_IDT_ENTRY 6
  11. #define LHCALL_SET_STACK 7
  12. #define LHCALL_TS 8
  13. #define LHCALL_SET_CLOCKEVENT 9
  14. #define LHCALL_HALT 10
  15. #define LHCALL_BIND_DMA 12
  16. #define LHCALL_SEND_DMA 13
  17. #define LHCALL_SET_PTE 14
  18. #define LHCALL_SET_PMD 15
  19. #define LHCALL_LOAD_TLS 16
  20. /*G:031 First, how does our Guest contact the Host to ask for privileged
  21. * operations? There are two ways: the direct way is to make a "hypercall",
  22. * to make requests of the Host Itself.
  23. *
  24. * Our hypercall mechanism uses the highest unused trap code (traps 32 and
  25. * above are used by real hardware interrupts). Seventeen hypercalls are
  26. * available: the hypercall number is put in the %eax register, and the
  27. * arguments (when required) are placed in %edx, %ebx and %ecx. If a return
  28. * value makes sense, it's returned in %eax.
  29. *
  30. * Grossly invalid calls result in Sudden Death at the hands of the vengeful
  31. * Host, rather than returning failure. This reflects Winston Churchill's
  32. * definition of a gentleman: "someone who is only rude intentionally". */
  33. #define LGUEST_TRAP_ENTRY 0x1F
  34. #ifndef __ASSEMBLY__
  35. #include <asm/hw_irq.h>
  36. static inline unsigned long
  37. hcall(unsigned long call,
  38. unsigned long arg1, unsigned long arg2, unsigned long arg3)
  39. {
  40. /* "int" is the Intel instruction to trigger a trap. */
  41. asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY)
  42. /* The call is in %eax (aka "a"), and can be replaced */
  43. : "=a"(call)
  44. /* The other arguments are in %eax, %edx, %ebx & %ecx */
  45. : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3)
  46. /* "memory" means this might write somewhere in memory.
  47. * This isn't true for all calls, but it's safe to tell
  48. * gcc that it might happen so it doesn't get clever. */
  49. : "memory");
  50. return call;
  51. }
  52. /*:*/
  53. void async_hcall(unsigned long call,
  54. unsigned long arg1, unsigned long arg2, unsigned long arg3);
  55. /* Can't use our min() macro here: needs to be a constant */
  56. #define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32)
  57. #define LHCALL_RING_SIZE 64
  58. struct hcall_args
  59. {
  60. /* These map directly onto eax, ebx, ecx, edx in struct lguest_regs */
  61. unsigned long arg0, arg2, arg3, arg1;
  62. };
  63. #endif /* !__ASSEMBLY__ */
  64. #endif /* _I386_LGUEST_HCALL_H */