1 /* SPDX-License-Identifier: (GPL-2.0 OR CDDL-1.0) */
3 * Virtual Device for Guest <-> VMM/Host communication interface
5 * Copyright (C) 2006-2016 Oracle Corporation
8 #ifndef __VBOX_VMMDEV_H__
9 #define __VBOX_VMMDEV_H__
11 #include <asm/bitsperlong.h>
12 #include <linux/sizes.h>
13 #include <linux/types.h>
14 #include <linux/vbox_vmmdev_types.h>
16 /* Port for generic request interface (relative offset). */
17 #define VMMDEV_PORT_OFF_REQUEST 0
19 /** Layout of VMMDEV RAM region that contains information for guest. */
20 struct vmmdev_memory
{
21 /** The size of this structure. */
23 /** The structure version. (VMMDEV_MEMORY_VERSION) */
28 /** Flag telling that VMMDev has events pending. */
30 /** Explicit padding, MBZ. */
35 /** Pending events flags, set by host. */
37 /** Mask of events the guest wants, set by guest. */
42 /* struct vbva_memory, not used */
44 VMMDEV_ASSERT_SIZE(vmmdev_memory
, 8 + 8);
46 /** Version of vmmdev_memory structure (vmmdev_memory::version). */
47 #define VMMDEV_MEMORY_VERSION (1)
49 /* Host mouse capabilities has been changed. */
50 #define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED BIT(0)
52 #define VMMDEV_EVENT_HGCM BIT(1)
53 /* A display change request has been issued. */
54 #define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST BIT(2)
55 /* Credentials are available for judgement. */
56 #define VMMDEV_EVENT_JUDGE_CREDENTIALS BIT(3)
57 /* The guest has been restored. */
58 #define VMMDEV_EVENT_RESTORED BIT(4)
59 /* Seamless mode state changed. */
60 #define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST BIT(5)
61 /* Memory balloon size changed. */
62 #define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST BIT(6)
63 /* Statistics interval changed. */
64 #define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST BIT(7)
65 /* VRDP status changed. */
66 #define VMMDEV_EVENT_VRDP BIT(8)
67 /* New mouse position data available. */
68 #define VMMDEV_EVENT_MOUSE_POSITION_CHANGED BIT(9)
69 /* CPU hotplug event occurred. */
70 #define VMMDEV_EVENT_CPU_HOTPLUG BIT(10)
71 /* The mask of valid events, for sanity checking. */
72 #define VMMDEV_EVENT_VALID_EVENT_MASK 0x000007ffU
75 * Additions are allowed to work only if additions_major == vmmdev_current &&
76 * additions_minor <= vmmdev_current. Additions version is reported to host
77 * (VMMDev) by VMMDEVREQ_REPORT_GUEST_INFO.
79 #define VMMDEV_VERSION 0x00010004
80 #define VMMDEV_VERSION_MAJOR (VMMDEV_VERSION >> 16)
81 #define VMMDEV_VERSION_MINOR (VMMDEV_VERSION & 0xffff)
83 /* Maximum request packet size. */
84 #define VMMDEV_MAX_VMMDEVREQ_SIZE 1048576
86 /* Version of vmmdev_request_header structure. */
87 #define VMMDEV_REQUEST_HEADER_VERSION 0x10001
89 /** struct vmmdev_request_header - Generic VMMDev request header. */
90 struct vmmdev_request_header
{
91 /** IN: Size of the structure in bytes (including body). */
93 /** IN: Version of the structure. */
95 /** IN: Type of the request. */
96 enum vmmdev_request_type request_type
;
97 /** OUT: Return code. */
99 /** Reserved field no.1. MBZ. */
101 /** Reserved field no.2. MBZ. */
104 VMMDEV_ASSERT_SIZE(vmmdev_request_header
, 24);
107 * struct vmmdev_mouse_status - Mouse status request structure.
109 * Used by VMMDEVREQ_GET_MOUSE_STATUS and VMMDEVREQ_SET_MOUSE_STATUS.
111 struct vmmdev_mouse_status
{
113 struct vmmdev_request_header header
;
114 /** Mouse feature mask. See VMMDEV_MOUSE_*. */
116 /** Mouse x position. */
118 /** Mouse y position. */
121 VMMDEV_ASSERT_SIZE(vmmdev_mouse_status
, 24 + 12);
123 /* The guest can (== wants to) handle absolute coordinates. */
124 #define VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE BIT(0)
126 * The host can (== wants to) send absolute coordinates.
127 * (Input not captured.)
129 #define VMMDEV_MOUSE_HOST_WANTS_ABSOLUTE BIT(1)
131 * The guest can *NOT* switch to software cursor and therefore depends on the
134 * When guest additions are installed and the host has promised to display the
135 * cursor itself, the guest installs a hardware mouse driver. Don't ask the
136 * guest to switch to a software cursor then.
138 #define VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR BIT(2)
139 /* The host does NOT provide support for drawing the cursor itself. */
140 #define VMMDEV_MOUSE_HOST_CANNOT_HWPOINTER BIT(3)
141 /* The guest can read VMMDev events to find out about pointer movement */
142 #define VMMDEV_MOUSE_NEW_PROTOCOL BIT(4)
144 * If the guest changes the status of the VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR
145 * bit, the host will honour this.
147 #define VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR BIT(5)
149 * The host supplies an absolute pointing device. The Guest Additions may
150 * wish to use this to decide whether to install their own driver.
152 #define VMMDEV_MOUSE_HOST_HAS_ABS_DEV BIT(6)
154 /* The minimum value our pointing device can return. */
155 #define VMMDEV_MOUSE_RANGE_MIN 0
156 /* The maximum value our pointing device can return. */
157 #define VMMDEV_MOUSE_RANGE_MAX 0xFFFF
160 * struct vmmdev_host_version - VirtualBox host version request structure.
162 * VBG uses this to detect the precense of new features in the interface.
164 struct vmmdev_host_version
{
166 struct vmmdev_request_header header
;
167 /** Major version. */
169 /** Minor version. */
178 VMMDEV_ASSERT_SIZE(vmmdev_host_version
, 24 + 16);
180 /* Physical page lists are supported by HGCM. */
181 #define VMMDEV_HVF_HGCM_PHYS_PAGE_LIST BIT(0)
184 * struct vmmdev_mask - Structure to set / clear bits in a mask used for
185 * VMMDEVREQ_SET_GUEST_CAPABILITIES and VMMDEVREQ_CTL_GUEST_FILTER_MASK.
189 struct vmmdev_request_header header
;
190 /** Mask of bits to be set. */
192 /** Mask of bits to be cleared. */
195 VMMDEV_ASSERT_SIZE(vmmdev_mask
, 24 + 8);
197 /* The guest supports seamless display rendering. */
198 #define VMMDEV_GUEST_SUPPORTS_SEAMLESS BIT(0)
199 /* The guest supports mapping guest to host windows. */
200 #define VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING BIT(1)
202 * The guest graphical additions are active.
203 * Used for fast activation and deactivation of certain graphical operations
204 * (e.g. resizing & seamless). The legacy VMMDEVREQ_REPORT_GUEST_CAPABILITIES
205 * request sets this automatically, but VMMDEVREQ_SET_GUEST_CAPABILITIES does
208 #define VMMDEV_GUEST_SUPPORTS_GRAPHICS BIT(2)
210 /** struct vmmdev_hypervisorinfo - Hypervisor info structure. */
211 struct vmmdev_hypervisorinfo
{
213 struct vmmdev_request_header header
;
215 * Guest virtual address of proposed hypervisor start.
216 * Not used by VMMDEVREQ_GET_HYPERVISOR_INFO.
218 u32 hypervisor_start
;
219 /** Hypervisor size in bytes. */
222 VMMDEV_ASSERT_SIZE(vmmdev_hypervisorinfo
, 24 + 8);
224 /** struct vmmdev_events - Pending events structure. */
225 struct vmmdev_events
{
227 struct vmmdev_request_header header
;
228 /** OUT: Pending event mask. */
231 VMMDEV_ASSERT_SIZE(vmmdev_events
, 24 + 4);
233 #define VMMDEV_OSTYPE_LINUX26 0x53000
234 #define VMMDEV_OSTYPE_X64 BIT(8)
236 /** struct vmmdev_guestinfo - Guest information report. */
237 struct vmmdev_guest_info
{
239 struct vmmdev_request_header header
;
241 * The VMMDev interface version expected by additions.
242 * *Deprecated*, do not use anymore! Will be removed.
244 u32 interface_version
;
245 /** Guest OS type. */
248 VMMDEV_ASSERT_SIZE(vmmdev_guest_info
, 24 + 8);
250 /** struct vmmdev_guestinfo2 - Guest information report, version 2. */
251 struct vmmdev_guest_info2
{
253 struct vmmdev_request_header header
;
254 /** Major version. */
256 /** Minor version. */
261 u32 additions_revision
;
262 /** Feature mask, currently unused. */
263 u32 additions_features
;
265 * The intentional meaning of this field was:
266 * Some additional information, for example 'Beta 1' or something like
269 * The way it was implemented was implemented: VBG_VERSION_STRING.
271 * This means the first three members are duplicated in this field (if
272 * the guest build config is sane). So, the user must check this and
273 * chop it off before usage. There is, because of the Main code's blind
274 * trust in the field's content, no way back.
278 VMMDEV_ASSERT_SIZE(vmmdev_guest_info2
, 24 + 144);
280 enum vmmdev_guest_facility_type
{
281 VBOXGUEST_FACILITY_TYPE_UNKNOWN
= 0,
282 VBOXGUEST_FACILITY_TYPE_VBOXGUEST_DRIVER
= 20,
283 /* VBoxGINA / VBoxCredProv / pam_vbox. */
284 VBOXGUEST_FACILITY_TYPE_AUTO_LOGON
= 90,
285 VBOXGUEST_FACILITY_TYPE_VBOX_SERVICE
= 100,
286 /* VBoxTray (Windows), VBoxClient (Linux, Unix). */
287 VBOXGUEST_FACILITY_TYPE_VBOX_TRAY_CLIENT
= 101,
288 VBOXGUEST_FACILITY_TYPE_SEAMLESS
= 1000,
289 VBOXGUEST_FACILITY_TYPE_GRAPHICS
= 1100,
290 VBOXGUEST_FACILITY_TYPE_ALL
= 0x7ffffffe,
291 /* Ensure the enum is a 32 bit data-type */
292 VBOXGUEST_FACILITY_TYPE_SIZEHACK
= 0x7fffffff
295 enum vmmdev_guest_facility_status
{
296 VBOXGUEST_FACILITY_STATUS_INACTIVE
= 0,
297 VBOXGUEST_FACILITY_STATUS_PAUSED
= 1,
298 VBOXGUEST_FACILITY_STATUS_PRE_INIT
= 20,
299 VBOXGUEST_FACILITY_STATUS_INIT
= 30,
300 VBOXGUEST_FACILITY_STATUS_ACTIVE
= 50,
301 VBOXGUEST_FACILITY_STATUS_TERMINATING
= 100,
302 VBOXGUEST_FACILITY_STATUS_TERMINATED
= 101,
303 VBOXGUEST_FACILITY_STATUS_FAILED
= 800,
304 VBOXGUEST_FACILITY_STATUS_UNKNOWN
= 999,
305 /* Ensure the enum is a 32 bit data-type */
306 VBOXGUEST_FACILITY_STATUS_SIZEHACK
= 0x7fffffff
309 /** struct vmmdev_guest_status - Guest Additions status structure. */
310 struct vmmdev_guest_status
{
312 struct vmmdev_request_header header
;
313 /** Facility the status is indicated for. */
314 enum vmmdev_guest_facility_type facility
;
315 /** Current guest status. */
316 enum vmmdev_guest_facility_status status
;
317 /** Flags, not used at the moment. */
320 VMMDEV_ASSERT_SIZE(vmmdev_guest_status
, 24 + 12);
322 #define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE (1048576)
323 #define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (1048576 / 4096)
325 /** struct vmmdev_memballoon_info - Memory-balloon info structure. */
326 struct vmmdev_memballoon_info
{
328 struct vmmdev_request_header header
;
329 /** Balloon size in megabytes. */
331 /** Guest ram size in megabytes. */
334 * Setting this to VMMDEV_EVENT_BALLOON_CHANGE_REQUEST indicates that
335 * the request is a response to that event.
336 * (Don't confuse this with VMMDEVREQ_ACKNOWLEDGE_EVENTS.)
340 VMMDEV_ASSERT_SIZE(vmmdev_memballoon_info
, 24 + 12);
342 /** struct vmmdev_memballoon_change - Change the size of the balloon. */
343 struct vmmdev_memballoon_change
{
345 struct vmmdev_request_header header
;
346 /** The number of pages in the array. */
348 /** true = inflate, false = deflate. */
350 /** Physical address (u64) of each page. */
351 u64 phys_page
[VMMDEV_MEMORY_BALLOON_CHUNK_PAGES
];
354 /** struct vmmdev_write_core_dump - Write Core Dump request data. */
355 struct vmmdev_write_core_dump
{
357 struct vmmdev_request_header header
;
358 /** Flags (reserved, MBZ). */
361 VMMDEV_ASSERT_SIZE(vmmdev_write_core_dump
, 24 + 4);
363 /** struct vmmdev_heartbeat - Heart beat check state structure. */
364 struct vmmdev_heartbeat
{
366 struct vmmdev_request_header header
;
367 /** OUT: Guest heartbeat interval in nanosec. */
369 /** Heartbeat check flag. */
371 /** Explicit padding, MBZ. */
374 VMMDEV_ASSERT_SIZE(vmmdev_heartbeat
, 24 + 12);
376 #define VMMDEV_HGCM_REQ_DONE BIT(0)
377 #define VMMDEV_HGCM_REQ_CANCELLED BIT(1)
379 /** struct vmmdev_hgcmreq_header - vmmdev HGCM requests header. */
380 struct vmmdev_hgcmreq_header
{
381 /** Request header. */
382 struct vmmdev_request_header header
;
390 VMMDEV_ASSERT_SIZE(vmmdev_hgcmreq_header
, 24 + 8);
392 /** struct vmmdev_hgcm_connect - HGCM connect request structure. */
393 struct vmmdev_hgcm_connect
{
394 /** HGCM request header. */
395 struct vmmdev_hgcmreq_header header
;
397 /** IN: Description of service to connect to. */
398 struct vmmdev_hgcm_service_location loc
;
400 /** OUT: Client identifier assigned by local instance of HGCM. */
403 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_connect
, 32 + 132 + 4);
405 /** struct vmmdev_hgcm_disconnect - HGCM disconnect request structure. */
406 struct vmmdev_hgcm_disconnect
{
407 /** HGCM request header. */
408 struct vmmdev_hgcmreq_header header
;
410 /** IN: Client identifier. */
413 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_disconnect
, 32 + 4);
415 #define VMMDEV_HGCM_MAX_PARMS 32
417 /** struct vmmdev_hgcm_call - HGCM call request structure. */
418 struct vmmdev_hgcm_call
{
420 struct vmmdev_hgcmreq_header header
;
422 /** IN: Client identifier. */
424 /** IN: Service function number. */
426 /** IN: Number of parameters. */
428 /** Parameters follow in form: HGCMFunctionParameter32|64 parms[X]; */
430 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_call
, 32 + 12);
433 * struct vmmdev_hgcm_cancel2 - HGCM cancel request structure, version 2.
435 * After the request header.rc will be:
437 * VINF_SUCCESS when cancelled.
438 * VERR_NOT_FOUND if the specified request cannot be found.
439 * VERR_INVALID_PARAMETER if the address is invalid valid.
441 struct vmmdev_hgcm_cancel2
{
443 struct vmmdev_request_header header
;
444 /** The physical address of the request to cancel. */
445 u32 phys_req_to_cancel
;
447 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_cancel2
, 24 + 4);