vmmdev.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. /* SPDX-License-Identifier: (GPL-2.0 OR CDDL-1.0) */
  2. /*
  3. * Virtual Device for Guest <-> VMM/Host communication interface
  4. *
  5. * Copyright (C) 2006-2016 Oracle Corporation
  6. */
  7. #ifndef __VBOX_VMMDEV_H__
  8. #define __VBOX_VMMDEV_H__
  9. #include <asm/bitsperlong.h>
  10. #include <linux/sizes.h>
  11. #include <linux/types.h>
  12. #include <linux/vbox_vmmdev_types.h>
  13. /* Port for generic request interface (relative offset). */
  14. #define VMMDEV_PORT_OFF_REQUEST 0
  15. /** Layout of VMMDEV RAM region that contains information for guest. */
  16. struct vmmdev_memory {
  17. /** The size of this structure. */
  18. u32 size;
  19. /** The structure version. (VMMDEV_MEMORY_VERSION) */
  20. u32 version;
  21. union {
  22. struct {
  23. /** Flag telling that VMMDev has events pending. */
  24. u8 have_events;
  25. /** Explicit padding, MBZ. */
  26. u8 padding[3];
  27. } V1_04;
  28. struct {
  29. /** Pending events flags, set by host. */
  30. u32 host_events;
  31. /** Mask of events the guest wants, set by guest. */
  32. u32 guest_event_mask;
  33. } V1_03;
  34. } V;
  35. /* struct vbva_memory, not used */
  36. };
  37. VMMDEV_ASSERT_SIZE(vmmdev_memory, 8 + 8);
  38. /** Version of vmmdev_memory structure (vmmdev_memory::version). */
  39. #define VMMDEV_MEMORY_VERSION (1)
  40. /* Host mouse capabilities has been changed. */
  41. #define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED BIT(0)
  42. /* HGCM event. */
  43. #define VMMDEV_EVENT_HGCM BIT(1)
  44. /* A display change request has been issued. */
  45. #define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST BIT(2)
  46. /* Credentials are available for judgement. */
  47. #define VMMDEV_EVENT_JUDGE_CREDENTIALS BIT(3)
  48. /* The guest has been restored. */
  49. #define VMMDEV_EVENT_RESTORED BIT(4)
  50. /* Seamless mode state changed. */
  51. #define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST BIT(5)
  52. /* Memory balloon size changed. */
  53. #define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST BIT(6)
  54. /* Statistics interval changed. */
  55. #define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST BIT(7)
  56. /* VRDP status changed. */
  57. #define VMMDEV_EVENT_VRDP BIT(8)
  58. /* New mouse position data available. */
  59. #define VMMDEV_EVENT_MOUSE_POSITION_CHANGED BIT(9)
  60. /* CPU hotplug event occurred. */
  61. #define VMMDEV_EVENT_CPU_HOTPLUG BIT(10)
  62. /* The mask of valid events, for sanity checking. */
  63. #define VMMDEV_EVENT_VALID_EVENT_MASK 0x000007ffU
  64. /*
  65. * Additions are allowed to work only if additions_major == vmmdev_current &&
  66. * additions_minor <= vmmdev_current. Additions version is reported to host
  67. * (VMMDev) by VMMDEVREQ_REPORT_GUEST_INFO.
  68. */
  69. #define VMMDEV_VERSION 0x00010004
  70. #define VMMDEV_VERSION_MAJOR (VMMDEV_VERSION >> 16)
  71. #define VMMDEV_VERSION_MINOR (VMMDEV_VERSION & 0xffff)
  72. /* Maximum request packet size. */
  73. #define VMMDEV_MAX_VMMDEVREQ_SIZE 1048576
  74. /* Version of vmmdev_request_header structure. */
  75. #define VMMDEV_REQUEST_HEADER_VERSION 0x10001
  76. /** struct vmmdev_request_header - Generic VMMDev request header. */
  77. struct vmmdev_request_header {
  78. /** IN: Size of the structure in bytes (including body). */
  79. u32 size;
  80. /** IN: Version of the structure. */
  81. u32 version;
  82. /** IN: Type of the request. */
  83. enum vmmdev_request_type request_type;
  84. /** OUT: Return code. */
  85. s32 rc;
  86. /** Reserved field no.1. MBZ. */
  87. u32 reserved1;
  88. /** IN: Requestor information (VMMDEV_REQUESTOR_*) */
  89. u32 requestor;
  90. };
  91. VMMDEV_ASSERT_SIZE(vmmdev_request_header, 24);
  92. /**
  93. * struct vmmdev_mouse_status - Mouse status request structure.
  94. *
  95. * Used by VMMDEVREQ_GET_MOUSE_STATUS and VMMDEVREQ_SET_MOUSE_STATUS.
  96. */
  97. struct vmmdev_mouse_status {
  98. /** header */
  99. struct vmmdev_request_header header;
  100. /** Mouse feature mask. See VMMDEV_MOUSE_*. */
  101. u32 mouse_features;
  102. /** Mouse x position. */
  103. s32 pointer_pos_x;
  104. /** Mouse y position. */
  105. s32 pointer_pos_y;
  106. };
  107. VMMDEV_ASSERT_SIZE(vmmdev_mouse_status, 24 + 12);
  108. /* The guest can (== wants to) handle absolute coordinates. */
  109. #define VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE BIT(0)
  110. /*
  111. * The host can (== wants to) send absolute coordinates.
  112. * (Input not captured.)
  113. */
  114. #define VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE BIT(1)
  115. /*
  116. * The guest can *NOT* switch to software cursor and therefore depends on the
  117. * host cursor.
  118. *
  119. * When guest additions are installed and the host has promised to display the
  120. * cursor itself, the guest installs a hardware mouse driver. Don't ask the
  121. * guest to switch to a software cursor then.
  122. */
  123. #define VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR BIT(2)
  124. /* The host does NOT provide support for drawing the cursor itself. */
  125. #define VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER BIT(3)
  126. /* The guest can read VMMDev events to find out about pointer movement */
  127. #define VMMDEV_MOUSE_NEW_PROTOCOL BIT(4)
  128. /*
  129. * If the guest changes the status of the VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR
  130. * bit, the host will honour this.
  131. */
  132. #define VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR BIT(5)
  133. /*
  134. * The host supplies an absolute pointing device. The Guest Additions may
  135. * wish to use this to decide whether to install their own driver.
  136. */
  137. #define VMMDEV_MOUSE_HOST_HAS_ABS_DEV BIT(6)
  138. /* The minimum value our pointing device can return. */
  139. #define VMMDEV_MOUSE_RANGE_MIN 0
  140. /* The maximum value our pointing device can return. */
  141. #define VMMDEV_MOUSE_RANGE_MAX 0xFFFF
  142. /**
  143. * struct vmmdev_host_version - VirtualBox host version request structure.
  144. *
  145. * VBG uses this to detect the precense of new features in the interface.
  146. */
  147. struct vmmdev_host_version {
  148. /** Header. */
  149. struct vmmdev_request_header header;
  150. /** Major version. */
  151. u16 major;
  152. /** Minor version. */
  153. u16 minor;
  154. /** Build number. */
  155. u32 build;
  156. /** SVN revision. */
  157. u32 revision;
  158. /** Feature mask. */
  159. u32 features;
  160. };
  161. VMMDEV_ASSERT_SIZE(vmmdev_host_version, 24 + 16);
  162. /* Physical page lists are supported by HGCM. */
  163. #define VMMDEV_HVF_HGCM_PHYS_PAGE_LIST BIT(0)
  164. /**
  165. * struct vmmdev_mask - Structure to set / clear bits in a mask used for
  166. * VMMDEVREQ_SET_GUEST_CAPABILITIES and VMMDEVREQ_CTL_GUEST_FILTER_MASK.
  167. */
  168. struct vmmdev_mask {
  169. /** Header. */
  170. struct vmmdev_request_header header;
  171. /** Mask of bits to be set. */
  172. u32 or_mask;
  173. /** Mask of bits to be cleared. */
  174. u32 not_mask;
  175. };
  176. VMMDEV_ASSERT_SIZE(vmmdev_mask, 24 + 8);
  177. /* The guest supports seamless display rendering. */
  178. #define VMMDEV_GUEST_SUPPORTS_SEAMLESS BIT(0)
  179. /* The guest supports mapping guest to host windows. */
  180. #define VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING BIT(1)
  181. /*
  182. * The guest graphical additions are active.
  183. * Used for fast activation and deactivation of certain graphical operations
  184. * (e.g. resizing & seamless). The legacy VMMDEVREQ_REPORT_GUEST_CAPABILITIES
  185. * request sets this automatically, but VMMDEVREQ_SET_GUEST_CAPABILITIES does
  186. * not.
  187. */
  188. #define VMMDEV_GUEST_SUPPORTS_GRAPHICS BIT(2)
  189. /* The mask of valid capabilities, for sanity checking. */
  190. #define VMMDEV_GUEST_CAPABILITIES_MASK 0x00000007U
  191. /** struct vmmdev_hypervisorinfo - Hypervisor info structure. */
  192. struct vmmdev_hypervisorinfo {
  193. /** Header. */
  194. struct vmmdev_request_header header;
  195. /**
  196. * Guest virtual address of proposed hypervisor start.
  197. * Not used by VMMDEVREQ_GET_HYPERVISOR_INFO.
  198. */
  199. u32 hypervisor_start;
  200. /** Hypervisor size in bytes. */
  201. u32 hypervisor_size;
  202. };
  203. VMMDEV_ASSERT_SIZE(vmmdev_hypervisorinfo, 24 + 8);
  204. /** struct vmmdev_events - Pending events structure. */
  205. struct vmmdev_events {
  206. /** Header. */
  207. struct vmmdev_request_header header;
  208. /** OUT: Pending event mask. */
  209. u32 events;
  210. };
  211. VMMDEV_ASSERT_SIZE(vmmdev_events, 24 + 4);
  212. #define VMMDEV_OSTYPE_LINUX26 0x53000
  213. #define VMMDEV_OSTYPE_X64 BIT(8)
  214. /** struct vmmdev_guestinfo - Guest information report. */
  215. struct vmmdev_guest_info {
  216. /** Header. */
  217. struct vmmdev_request_header header;
  218. /**
  219. * The VMMDev interface version expected by additions.
  220. * *Deprecated*, do not use anymore! Will be removed.
  221. */
  222. u32 interface_version;
  223. /** Guest OS type. */
  224. u32 os_type;
  225. };
  226. VMMDEV_ASSERT_SIZE(vmmdev_guest_info, 24 + 8);
  227. #define VMMDEV_GUEST_INFO2_ADDITIONS_FEATURES_REQUESTOR_INFO BIT(0)
  228. /** struct vmmdev_guestinfo2 - Guest information report, version 2. */
  229. struct vmmdev_guest_info2 {
  230. /** Header. */
  231. struct vmmdev_request_header header;
  232. /** Major version. */
  233. u16 additions_major;
  234. /** Minor version. */
  235. u16 additions_minor;
  236. /** Build number. */
  237. u32 additions_build;
  238. /** SVN revision. */
  239. u32 additions_revision;
  240. /** Feature mask. */
  241. u32 additions_features;
  242. /**
  243. * The intentional meaning of this field was:
  244. * Some additional information, for example 'Beta 1' or something like
  245. * that.
  246. *
  247. * The way it was implemented was implemented: VBG_VERSION_STRING.
  248. *
  249. * This means the first three members are duplicated in this field (if
  250. * the guest build config is sane). So, the user must check this and
  251. * chop it off before usage. There is, because of the Main code's blind
  252. * trust in the field's content, no way back.
  253. */
  254. char name[128];
  255. };
  256. VMMDEV_ASSERT_SIZE(vmmdev_guest_info2, 24 + 144);
  257. enum vmmdev_guest_facility_type {
  258. VBOXGUEST_FACILITY_TYPE_UNKNOWN = 0,
  259. VBOXGUEST_FACILITY_TYPE_VBOXGUEST_DRIVER = 20,
  260. /* VBoxGINA / VBoxCredProv / pam_vbox. */
  261. VBOXGUEST_FACILITY_TYPE_AUTO_LOGON = 90,
  262. VBOXGUEST_FACILITY_TYPE_VBOX_SERVICE = 100,
  263. /* VBoxTray (Windows), VBoxClient (Linux, Unix). */
  264. VBOXGUEST_FACILITY_TYPE_VBOX_TRAY_CLIENT = 101,
  265. VBOXGUEST_FACILITY_TYPE_SEAMLESS = 1000,
  266. VBOXGUEST_FACILITY_TYPE_GRAPHICS = 1100,
  267. VBOXGUEST_FACILITY_TYPE_ALL = 0x7ffffffe,
  268. /* Ensure the enum is a 32 bit data-type */
  269. VBOXGUEST_FACILITY_TYPE_SIZEHACK = 0x7fffffff
  270. };
  271. enum vmmdev_guest_facility_status {
  272. VBOXGUEST_FACILITY_STATUS_INACTIVE = 0,
  273. VBOXGUEST_FACILITY_STATUS_PAUSED = 1,
  274. VBOXGUEST_FACILITY_STATUS_PRE_INIT = 20,
  275. VBOXGUEST_FACILITY_STATUS_INIT = 30,
  276. VBOXGUEST_FACILITY_STATUS_ACTIVE = 50,
  277. VBOXGUEST_FACILITY_STATUS_TERMINATING = 100,
  278. VBOXGUEST_FACILITY_STATUS_TERMINATED = 101,
  279. VBOXGUEST_FACILITY_STATUS_FAILED = 800,
  280. VBOXGUEST_FACILITY_STATUS_UNKNOWN = 999,
  281. /* Ensure the enum is a 32 bit data-type */
  282. VBOXGUEST_FACILITY_STATUS_SIZEHACK = 0x7fffffff
  283. };
  284. /** struct vmmdev_guest_status - Guest Additions status structure. */
  285. struct vmmdev_guest_status {
  286. /** Header. */
  287. struct vmmdev_request_header header;
  288. /** Facility the status is indicated for. */
  289. enum vmmdev_guest_facility_type facility;
  290. /** Current guest status. */
  291. enum vmmdev_guest_facility_status status;
  292. /** Flags, not used at the moment. */
  293. u32 flags;
  294. };
  295. VMMDEV_ASSERT_SIZE(vmmdev_guest_status, 24 + 12);
  296. #define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE (1048576)
  297. #define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (1048576 / 4096)
  298. /** struct vmmdev_memballoon_info - Memory-balloon info structure. */
  299. struct vmmdev_memballoon_info {
  300. /** Header. */
  301. struct vmmdev_request_header header;
  302. /** Balloon size in megabytes. */
  303. u32 balloon_chunks;
  304. /** Guest ram size in megabytes. */
  305. u32 phys_mem_chunks;
  306. /**
  307. * Setting this to VMMDEV_EVENT_BALLOON_CHANGE_REQUEST indicates that
  308. * the request is a response to that event.
  309. * (Don't confuse this with VMMDEVREQ_ACKNOWLEDGE_EVENTS.)
  310. */
  311. u32 event_ack;
  312. };
  313. VMMDEV_ASSERT_SIZE(vmmdev_memballoon_info, 24 + 12);
  314. /** struct vmmdev_memballoon_change - Change the size of the balloon. */
  315. struct vmmdev_memballoon_change {
  316. /** Header. */
  317. struct vmmdev_request_header header;
  318. /** The number of pages in the array. */
  319. u32 pages;
  320. /** true = inflate, false = deflate. */
  321. u32 inflate;
  322. /** Physical address (u64) of each page. */
  323. u64 phys_page[VMMDEV_MEMORY_BALLOON_CHUNK_PAGES];
  324. };
  325. /** struct vmmdev_write_core_dump - Write Core Dump request data. */
  326. struct vmmdev_write_core_dump {
  327. /** Header. */
  328. struct vmmdev_request_header header;
  329. /** Flags (reserved, MBZ). */
  330. u32 flags;
  331. };
  332. VMMDEV_ASSERT_SIZE(vmmdev_write_core_dump, 24 + 4);
  333. /** struct vmmdev_heartbeat - Heart beat check state structure. */
  334. struct vmmdev_heartbeat {
  335. /** Header. */
  336. struct vmmdev_request_header header;
  337. /** OUT: Guest heartbeat interval in nanosec. */
  338. u64 interval_ns;
  339. /** Heartbeat check flag. */
  340. u8 enabled;
  341. /** Explicit padding, MBZ. */
  342. u8 padding[3];
  343. } __packed;
  344. VMMDEV_ASSERT_SIZE(vmmdev_heartbeat, 24 + 12);
  345. #define VMMDEV_HGCM_REQ_DONE BIT(0)
  346. #define VMMDEV_HGCM_REQ_CANCELLED BIT(1)
  347. /** struct vmmdev_hgcmreq_header - vmmdev HGCM requests header. */
  348. struct vmmdev_hgcmreq_header {
  349. /** Request header. */
  350. struct vmmdev_request_header header;
  351. /** HGCM flags. */
  352. u32 flags;
  353. /** Result code. */
  354. s32 result;
  355. };
  356. VMMDEV_ASSERT_SIZE(vmmdev_hgcmreq_header, 24 + 8);
  357. /** struct vmmdev_hgcm_connect - HGCM connect request structure. */
  358. struct vmmdev_hgcm_connect {
  359. /** HGCM request header. */
  360. struct vmmdev_hgcmreq_header header;
  361. /** IN: Description of service to connect to. */
  362. struct vmmdev_hgcm_service_location loc;
  363. /** OUT: Client identifier assigned by local instance of HGCM. */
  364. u32 client_id;
  365. };
  366. VMMDEV_ASSERT_SIZE(vmmdev_hgcm_connect, 32 + 132 + 4);
  367. /** struct vmmdev_hgcm_disconnect - HGCM disconnect request structure. */
  368. struct vmmdev_hgcm_disconnect {
  369. /** HGCM request header. */
  370. struct vmmdev_hgcmreq_header header;
  371. /** IN: Client identifier. */
  372. u32 client_id;
  373. };
  374. VMMDEV_ASSERT_SIZE(vmmdev_hgcm_disconnect, 32 + 4);
  375. #define VMMDEV_HGCM_MAX_PARMS 32
  376. /** struct vmmdev_hgcm_call - HGCM call request structure. */
  377. struct vmmdev_hgcm_call {
  378. /* request header */
  379. struct vmmdev_hgcmreq_header header;
  380. /** IN: Client identifier. */
  381. u32 client_id;
  382. /** IN: Service function number. */
  383. u32 function;
  384. /** IN: Number of parameters. */
  385. u32 parm_count;
  386. /** Parameters follow in form: HGCMFunctionParameter32|64 parms[X]; */
  387. };
  388. VMMDEV_ASSERT_SIZE(vmmdev_hgcm_call, 32 + 12);
  389. /**
  390. * struct vmmdev_hgcm_cancel2 - HGCM cancel request structure, version 2.
  391. *
  392. * After the request header.rc will be:
  393. *
  394. * VINF_SUCCESS when cancelled.
  395. * VERR_NOT_FOUND if the specified request cannot be found.
  396. * VERR_INVALID_PARAMETER if the address is invalid valid.
  397. */
  398. struct vmmdev_hgcm_cancel2 {
  399. /** Header. */
  400. struct vmmdev_request_header header;
  401. /** The physical address of the request to cancel. */
  402. u32 phys_req_to_cancel;
  403. };
  404. VMMDEV_ASSERT_SIZE(vmmdev_hgcm_cancel2, 24 + 4);
  405. #endif