memory.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /******************************************************************************
  2. * memory.h
  3. *
  4. * Memory reservation and information.
  5. *
  6. * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
  7. */
  8. #ifndef __XEN_PUBLIC_MEMORY_H__
  9. #define __XEN_PUBLIC_MEMORY_H__
  10. #include <linux/spinlock.h>
  11. /*
  12. * Increase or decrease the specified domain's memory reservation. Returns a
  13. * -ve errcode on failure, or the # extents successfully allocated or freed.
  14. * arg == addr of struct xen_memory_reservation.
  15. */
  16. #define XENMEM_increase_reservation 0
  17. #define XENMEM_decrease_reservation 1
  18. #define XENMEM_populate_physmap 6
  19. struct xen_memory_reservation {
  20. /*
  21. * XENMEM_increase_reservation:
  22. * OUT: MFN (*not* GMFN) bases of extents that were allocated
  23. * XENMEM_decrease_reservation:
  24. * IN: GMFN bases of extents to free
  25. * XENMEM_populate_physmap:
  26. * IN: GPFN bases of extents to populate with memory
  27. * OUT: GMFN bases of extents that were allocated
  28. * (NB. This command also updates the mach_to_phys translation table)
  29. */
  30. GUEST_HANDLE(ulong) extent_start;
  31. /* Number of extents, and size/alignment of each (2^extent_order pages). */
  32. unsigned long nr_extents;
  33. unsigned int extent_order;
  34. /*
  35. * Maximum # bits addressable by the user of the allocated region (e.g.,
  36. * I/O devices often have a 32-bit limitation even in 64-bit systems). If
  37. * zero then the user has no addressing restriction.
  38. * This field is not used by XENMEM_decrease_reservation.
  39. */
  40. unsigned int address_bits;
  41. /*
  42. * Domain whose reservation is being changed.
  43. * Unprivileged domains can specify only DOMID_SELF.
  44. */
  45. domid_t domid;
  46. };
  47. DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);
  48. /*
  49. * Returns the maximum machine frame number of mapped RAM in this system.
  50. * This command always succeeds (it never returns an error code).
  51. * arg == NULL.
  52. */
  53. #define XENMEM_maximum_ram_page 2
  54. /*
  55. * Returns the current or maximum memory reservation, in pages, of the
  56. * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
  57. * arg == addr of domid_t.
  58. */
  59. #define XENMEM_current_reservation 3
  60. #define XENMEM_maximum_reservation 4
  61. /*
  62. * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
  63. * mapping table. Architectures which do not have a m2p table do not implement
  64. * this command.
  65. * arg == addr of xen_machphys_mfn_list_t.
  66. */
  67. #define XENMEM_machphys_mfn_list 5
  68. struct xen_machphys_mfn_list {
  69. /*
  70. * Size of the 'extent_start' array. Fewer entries will be filled if the
  71. * machphys table is smaller than max_extents * 2MB.
  72. */
  73. unsigned int max_extents;
  74. /*
  75. * Pointer to buffer to fill with list of extent starts. If there are
  76. * any large discontiguities in the machine address space, 2MB gaps in
  77. * the machphys table will be represented by an MFN base of zero.
  78. */
  79. GUEST_HANDLE(ulong) extent_start;
  80. /*
  81. * Number of extents written to the above array. This will be smaller
  82. * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
  83. */
  84. unsigned int nr_extents;
  85. };
  86. DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
  87. /*
  88. * Sets the GPFN at which a particular page appears in the specified guest's
  89. * pseudophysical address space.
  90. * arg == addr of xen_add_to_physmap_t.
  91. */
  92. #define XENMEM_add_to_physmap 7
  93. struct xen_add_to_physmap {
  94. /* Which domain to change the mapping for. */
  95. domid_t domid;
  96. /* Source mapping space. */
  97. #define XENMAPSPACE_shared_info 0 /* shared info page */
  98. #define XENMAPSPACE_grant_table 1 /* grant table page */
  99. unsigned int space;
  100. /* Index into source mapping space. */
  101. unsigned long idx;
  102. /* GPFN where the source mapping page should appear. */
  103. unsigned long gpfn;
  104. };
  105. DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
  106. /*
  107. * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
  108. * code on failure. This call only works for auto-translated guests.
  109. */
  110. #define XENMEM_translate_gpfn_list 8
  111. struct xen_translate_gpfn_list {
  112. /* Which domain to translate for? */
  113. domid_t domid;
  114. /* Length of list. */
  115. unsigned long nr_gpfns;
  116. /* List of GPFNs to translate. */
  117. GUEST_HANDLE(ulong) gpfn_list;
  118. /*
  119. * Output list to contain MFN translations. May be the same as the input
  120. * list (in which case each input GPFN is overwritten with the output MFN).
  121. */
  122. GUEST_HANDLE(ulong) mfn_list;
  123. };
  124. DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
  125. /*
  126. * Prevent the balloon driver from changing the memory reservation
  127. * during a driver critical region.
  128. */
  129. extern spinlock_t xen_reservation_lock;
  130. #endif /* __XEN_PUBLIC_MEMORY_H__ */