vboxguest.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR CDDL-1.0) */
  2. /*
  3. * VBoxGuest - VirtualBox Guest Additions Driver Interface.
  4. *
  5. * Copyright (C) 2006-2016 Oracle Corporation
  6. */
  7. #ifndef __UAPI_VBOXGUEST_H__
  8. #define __UAPI_VBOXGUEST_H__
  9. #include <asm/bitsperlong.h>
  10. #include <linux/ioctl.h>
  11. #include <linux/vbox_err.h>
  12. #include <linux/vbox_vmmdev_types.h>
  13. /* Version of vbg_ioctl_hdr structure. */
  14. #define VBG_IOCTL_HDR_VERSION 0x10001
  15. /* Default request type. Use this for non-VMMDev requests. */
  16. #define VBG_IOCTL_HDR_TYPE_DEFAULT 0
  17. /**
  18. * Common ioctl header.
  19. *
  20. * This is a mirror of vmmdev_request_header to prevent duplicating data and
  21. * needing to verify things multiple times.
  22. */
  23. struct vbg_ioctl_hdr {
  24. /** IN: The request input size, and output size if size_out is zero. */
  25. __u32 size_in;
  26. /** IN: Structure version (VBG_IOCTL_HDR_VERSION) */
  27. __u32 version;
  28. /** IN: The VMMDev request type or VBG_IOCTL_HDR_TYPE_DEFAULT. */
  29. __u32 type;
  30. /**
  31. * OUT: The VBox status code of the operation, out direction only.
  32. * This is a VINF_ or VERR_ value as defined in vbox_err.h.
  33. */
  34. __s32 rc;
  35. /** IN: Output size. Set to zero to use size_in as output size. */
  36. __u32 size_out;
  37. /** Reserved, MBZ. */
  38. __u32 reserved;
  39. };
  40. VMMDEV_ASSERT_SIZE(vbg_ioctl_hdr, 24);
  41. /*
  42. * The VBoxGuest I/O control version.
  43. *
  44. * As usual, the high word contains the major version and changes to it
  45. * signifies incompatible changes.
  46. *
  47. * The lower word is the minor version number, it is increased when new
  48. * functions are added or existing changed in a backwards compatible manner.
  49. */
  50. #define VBG_IOC_VERSION 0x00010000u
  51. /**
  52. * VBG_IOCTL_DRIVER_VERSION_INFO data structure
  53. *
  54. * Note VBG_IOCTL_DRIVER_VERSION_INFO may switch the session to a backwards
  55. * compatible interface version if uClientVersion indicates older client code.
  56. */
  57. struct vbg_ioctl_driver_version_info {
  58. /** The header. */
  59. struct vbg_ioctl_hdr hdr;
  60. union {
  61. struct {
  62. /** Requested interface version (VBG_IOC_VERSION). */
  63. __u32 req_version;
  64. /**
  65. * Minimum interface version number (typically the
  66. * major version part of VBG_IOC_VERSION).
  67. */
  68. __u32 min_version;
  69. /** Reserved, MBZ. */
  70. __u32 reserved1;
  71. /** Reserved, MBZ. */
  72. __u32 reserved2;
  73. } in;
  74. struct {
  75. /** Version for this session (typ. VBG_IOC_VERSION). */
  76. __u32 session_version;
  77. /** Version of the IDC interface (VBG_IOC_VERSION). */
  78. __u32 driver_version;
  79. /** The SVN revision of the driver, or 0. */
  80. __u32 driver_revision;
  81. /** Reserved \#1 (zero until defined). */
  82. __u32 reserved1;
  83. /** Reserved \#2 (zero until defined). */
  84. __u32 reserved2;
  85. } out;
  86. } u;
  87. };
  88. VMMDEV_ASSERT_SIZE(vbg_ioctl_driver_version_info, 24 + 20);
  89. #define VBG_IOCTL_DRIVER_VERSION_INFO \
  90. _IOWR('V', 0, struct vbg_ioctl_driver_version_info)
  91. /* IOCTL to perform a VMM Device request less than 1KB in size. */
  92. #define VBG_IOCTL_VMMDEV_REQUEST(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 2, s)
  93. /* IOCTL to perform a VMM Device request larger then 1KB. */
  94. #define VBG_IOCTL_VMMDEV_REQUEST_BIG _IOC(_IOC_READ | _IOC_WRITE, 'V', 3, 0)
  95. /** VBG_IOCTL_HGCM_CONNECT data structure. */
  96. struct vbg_ioctl_hgcm_connect {
  97. struct vbg_ioctl_hdr hdr;
  98. union {
  99. struct {
  100. struct vmmdev_hgcm_service_location loc;
  101. } in;
  102. struct {
  103. __u32 client_id;
  104. } out;
  105. } u;
  106. };
  107. VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_connect, 24 + 132);
  108. #define VBG_IOCTL_HGCM_CONNECT \
  109. _IOWR('V', 4, struct vbg_ioctl_hgcm_connect)
  110. /** VBG_IOCTL_HGCM_DISCONNECT data structure. */
  111. struct vbg_ioctl_hgcm_disconnect {
  112. struct vbg_ioctl_hdr hdr;
  113. union {
  114. struct {
  115. __u32 client_id;
  116. } in;
  117. } u;
  118. };
  119. VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_disconnect, 24 + 4);
  120. #define VBG_IOCTL_HGCM_DISCONNECT \
  121. _IOWR('V', 5, struct vbg_ioctl_hgcm_disconnect)
  122. /** VBG_IOCTL_HGCM_CALL data structure. */
  123. struct vbg_ioctl_hgcm_call {
  124. /** The header. */
  125. struct vbg_ioctl_hdr hdr;
  126. /** Input: The id of the caller. */
  127. __u32 client_id;
  128. /** Input: Function number. */
  129. __u32 function;
  130. /**
  131. * Input: How long to wait (milliseconds) for completion before
  132. * cancelling the call. Set to -1 to wait indefinitely.
  133. */
  134. __u32 timeout_ms;
  135. /** Interruptable flag, ignored for userspace calls. */
  136. __u8 interruptible;
  137. /** Explicit padding, MBZ. */
  138. __u8 reserved;
  139. /**
  140. * Input: How many parameters following this structure.
  141. *
  142. * The parameters are either HGCMFunctionParameter64 or 32,
  143. * depending on whether we're receiving a 64-bit or 32-bit request.
  144. *
  145. * The current maximum is 61 parameters (given a 1KB max request size,
  146. * and a 64-bit parameter size of 16 bytes).
  147. */
  148. __u16 parm_count;
  149. /*
  150. * Parameters follow in form:
  151. * struct hgcm_function_parameter<32|64> parms[parm_count]
  152. */
  153. };
  154. VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_call, 24 + 16);
  155. #define VBG_IOCTL_HGCM_CALL_32(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 6, s)
  156. #define VBG_IOCTL_HGCM_CALL_64(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 7, s)
  157. #if __BITS_PER_LONG == 64
  158. #define VBG_IOCTL_HGCM_CALL(s) VBG_IOCTL_HGCM_CALL_64(s)
  159. #else
  160. #define VBG_IOCTL_HGCM_CALL(s) VBG_IOCTL_HGCM_CALL_32(s)
  161. #endif
  162. /** VBG_IOCTL_LOG data structure. */
  163. struct vbg_ioctl_log {
  164. /** The header. */
  165. struct vbg_ioctl_hdr hdr;
  166. union {
  167. struct {
  168. /**
  169. * The log message, this may be zero terminated. If it
  170. * is not zero terminated then the length is determined
  171. * from the input size.
  172. */
  173. char msg[1];
  174. } in;
  175. } u;
  176. };
  177. #define VBG_IOCTL_LOG(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 9, s)
  178. /** VBG_IOCTL_WAIT_FOR_EVENTS data structure. */
  179. struct vbg_ioctl_wait_for_events {
  180. /** The header. */
  181. struct vbg_ioctl_hdr hdr;
  182. union {
  183. struct {
  184. /** Timeout in milliseconds. */
  185. __u32 timeout_ms;
  186. /** Events to wait for. */
  187. __u32 events;
  188. } in;
  189. struct {
  190. /** Events that occurred. */
  191. __u32 events;
  192. } out;
  193. } u;
  194. };
  195. VMMDEV_ASSERT_SIZE(vbg_ioctl_wait_for_events, 24 + 8);
  196. #define VBG_IOCTL_WAIT_FOR_EVENTS \
  197. _IOWR('V', 10, struct vbg_ioctl_wait_for_events)
  198. /*
  199. * IOCTL to VBoxGuest to interrupt (cancel) any pending
  200. * VBG_IOCTL_WAIT_FOR_EVENTS and return.
  201. *
  202. * Handled inside the vboxguest driver and not seen by the host at all.
  203. * After calling this, VBG_IOCTL_WAIT_FOR_EVENTS should no longer be called in
  204. * the same session. Any VBOXGUEST_IOCTL_WAITEVENT calls in the same session
  205. * done after calling this will directly exit with -EINTR.
  206. */
  207. #define VBG_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS \
  208. _IOWR('V', 11, struct vbg_ioctl_hdr)
  209. /** VBG_IOCTL_CHANGE_FILTER_MASK data structure. */
  210. struct vbg_ioctl_change_filter {
  211. /** The header. */
  212. struct vbg_ioctl_hdr hdr;
  213. union {
  214. struct {
  215. /** Flags to set. */
  216. __u32 or_mask;
  217. /** Flags to remove. */
  218. __u32 not_mask;
  219. } in;
  220. } u;
  221. };
  222. VMMDEV_ASSERT_SIZE(vbg_ioctl_change_filter, 24 + 8);
  223. /* IOCTL to VBoxGuest to control the event filter mask. */
  224. #define VBG_IOCTL_CHANGE_FILTER_MASK \
  225. _IOWR('V', 12, struct vbg_ioctl_change_filter)
  226. /** VBG_IOCTL_CHANGE_GUEST_CAPABILITIES data structure. */
  227. struct vbg_ioctl_set_guest_caps {
  228. /** The header. */
  229. struct vbg_ioctl_hdr hdr;
  230. union {
  231. struct {
  232. /** Capabilities to set (VMMDEV_GUEST_SUPPORTS_XXX). */
  233. __u32 or_mask;
  234. /** Capabilities to drop (VMMDEV_GUEST_SUPPORTS_XXX). */
  235. __u32 not_mask;
  236. } in;
  237. struct {
  238. /** Capabilities held by the session after the call. */
  239. __u32 session_caps;
  240. /** Capabilities for all the sessions after the call. */
  241. __u32 global_caps;
  242. } out;
  243. } u;
  244. };
  245. VMMDEV_ASSERT_SIZE(vbg_ioctl_set_guest_caps, 24 + 8);
  246. #define VBG_IOCTL_CHANGE_GUEST_CAPABILITIES \
  247. _IOWR('V', 14, struct vbg_ioctl_set_guest_caps)
  248. /** VBG_IOCTL_CHECK_BALLOON data structure. */
  249. struct vbg_ioctl_check_balloon {
  250. /** The header. */
  251. struct vbg_ioctl_hdr hdr;
  252. union {
  253. struct {
  254. /** The size of the balloon in chunks of 1MB. */
  255. __u32 balloon_chunks;
  256. /**
  257. * false = handled in R0, no further action required.
  258. * true = allocate balloon memory in R3.
  259. */
  260. __u8 handle_in_r3;
  261. /** Explicit padding, MBZ. */
  262. __u8 padding[3];
  263. } out;
  264. } u;
  265. };
  266. VMMDEV_ASSERT_SIZE(vbg_ioctl_check_balloon, 24 + 8);
  267. /*
  268. * IOCTL to check memory ballooning.
  269. *
  270. * The guest kernel module will ask the host for the current size of the
  271. * balloon and adjust the size. Or it will set handle_in_r3 = true and R3 is
  272. * responsible for allocating memory and calling VBG_IOCTL_CHANGE_BALLOON.
  273. */
  274. #define VBG_IOCTL_CHECK_BALLOON \
  275. _IOWR('V', 17, struct vbg_ioctl_check_balloon)
  276. /** VBG_IOCTL_WRITE_CORE_DUMP data structure. */
  277. struct vbg_ioctl_write_coredump {
  278. struct vbg_ioctl_hdr hdr;
  279. union {
  280. struct {
  281. __u32 flags; /** Flags (reserved, MBZ). */
  282. } in;
  283. } u;
  284. };
  285. VMMDEV_ASSERT_SIZE(vbg_ioctl_write_coredump, 24 + 4);
  286. #define VBG_IOCTL_WRITE_CORE_DUMP \
  287. _IOWR('V', 19, struct vbg_ioctl_write_coredump)
  288. #endif