lguest.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Things the lguest guest needs to know. Note: like all lguest interfaces,
  2. * this is subject to wild and random change between versions. */
  3. #ifndef _ASM_LGUEST_H
  4. #define _ASM_LGUEST_H
  5. #ifndef __ASSEMBLY__
  6. #include <asm/irq.h>
  7. #define LHCALL_FLUSH_ASYNC 0
  8. #define LHCALL_LGUEST_INIT 1
  9. #define LHCALL_CRASH 2
  10. #define LHCALL_LOAD_GDT 3
  11. #define LHCALL_NEW_PGTABLE 4
  12. #define LHCALL_FLUSH_TLB 5
  13. #define LHCALL_LOAD_IDT_ENTRY 6
  14. #define LHCALL_SET_STACK 7
  15. #define LHCALL_TS 8
  16. #define LHCALL_SET_CLOCKEVENT 9
  17. #define LHCALL_HALT 10
  18. #define LHCALL_GET_WALLCLOCK 11
  19. #define LHCALL_BIND_DMA 12
  20. #define LHCALL_SEND_DMA 13
  21. #define LHCALL_SET_PTE 14
  22. #define LHCALL_SET_PMD 15
  23. #define LHCALL_LOAD_TLS 16
  24. #define LG_CLOCK_MIN_DELTA 100UL
  25. #define LG_CLOCK_MAX_DELTA ULONG_MAX
  26. #define LGUEST_TRAP_ENTRY 0x1F
  27. static inline unsigned long
  28. hcall(unsigned long call,
  29. unsigned long arg1, unsigned long arg2, unsigned long arg3)
  30. {
  31. asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY)
  32. : "=a"(call)
  33. : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3)
  34. : "memory");
  35. return call;
  36. }
  37. void async_hcall(unsigned long call,
  38. unsigned long arg1, unsigned long arg2, unsigned long arg3);
  39. /* Can't use our min() macro here: needs to be a constant */
  40. #define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32)
  41. #define LHCALL_RING_SIZE 64
  42. struct hcall_ring
  43. {
  44. u32 eax, edx, ebx, ecx;
  45. };
  46. /* All the good stuff happens here: guest registers it with LGUEST_INIT */
  47. struct lguest_data
  48. {
  49. /* Fields which change during running: */
  50. /* 512 == enabled (same as eflags) */
  51. unsigned int irq_enabled;
  52. /* Interrupts blocked by guest. */
  53. DECLARE_BITMAP(blocked_interrupts, LGUEST_IRQS);
  54. /* Virtual address of page fault. */
  55. unsigned long cr2;
  56. /* Async hypercall ring. 0xFF == done, 0 == pending. */
  57. u8 hcall_status[LHCALL_RING_SIZE];
  58. struct hcall_ring hcalls[LHCALL_RING_SIZE];
  59. /* Fields initialized by the hypervisor at boot: */
  60. /* Memory not to try to access */
  61. unsigned long reserve_mem;
  62. /* ID of this guest (used by network driver to set ethernet address) */
  63. u16 guestid;
  64. /* KHz for the TSC clock. */
  65. u32 tsc_khz;
  66. /* Fields initialized by the guest at boot: */
  67. /* Instruction range to suppress interrupts even if enabled */
  68. unsigned long noirq_start, noirq_end;
  69. };
  70. extern struct lguest_data lguest_data;
  71. #endif /* __ASSEMBLY__ */
  72. #endif /* _ASM_LGUEST_H */