1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR CDDL-1.0) */ 2 /* 3 * Virtual Device for Guest <-> VMM/Host communication, type definitions 4 * which are also used for the vboxguest ioctl interface / by vboxsf 5 * 6 * Copyright (C) 2006-2016 Oracle Corporation 7 */ 8 9 #ifndef __UAPI_VBOX_VMMDEV_TYPES_H__ 10 #define __UAPI_VBOX_VMMDEV_TYPES_H__ 11 12 #include <asm/bitsperlong.h> 13 #include <linux/types.h> 14 15 /* 16 * We cannot use linux' compiletime_assert here because it expects to be used 17 * inside a function only. Use a typedef to a char array with a negative size. 18 */ 19 #define VMMDEV_ASSERT_SIZE(type, size) \ 20 typedef char type ## _asrt_size[1 - 2*!!(sizeof(struct type) != (size))] 21 22 /** enum vmmdev_request_type - VMMDev request types. */ 23 enum vmmdev_request_type { 24 VMMDEVREQ_INVALID_REQUEST = 0, 25 VMMDEVREQ_GET_MOUSE_STATUS = 1, 26 VMMDEVREQ_SET_MOUSE_STATUS = 2, 27 VMMDEVREQ_SET_POINTER_SHAPE = 3, 28 VMMDEVREQ_GET_HOST_VERSION = 4, 29 VMMDEVREQ_IDLE = 5, 30 VMMDEVREQ_GET_HOST_TIME = 10, 31 VMMDEVREQ_GET_HYPERVISOR_INFO = 20, 32 VMMDEVREQ_SET_HYPERVISOR_INFO = 21, 33 VMMDEVREQ_REGISTER_PATCH_MEMORY = 22, /* since version 3.0.6 */ 34 VMMDEVREQ_DEREGISTER_PATCH_MEMORY = 23, /* since version 3.0.6 */ 35 VMMDEVREQ_SET_POWER_STATUS = 30, 36 VMMDEVREQ_ACKNOWLEDGE_EVENTS = 41, 37 VMMDEVREQ_CTL_GUEST_FILTER_MASK = 42, 38 VMMDEVREQ_REPORT_GUEST_INFO = 50, 39 VMMDEVREQ_REPORT_GUEST_INFO2 = 58, /* since version 3.2.0 */ 40 VMMDEVREQ_REPORT_GUEST_STATUS = 59, /* since version 3.2.8 */ 41 VMMDEVREQ_REPORT_GUEST_USER_STATE = 74, /* since version 4.3 */ 42 /* Retrieve a display resize request sent by the host, deprecated. */ 43 VMMDEVREQ_GET_DISPLAY_CHANGE_REQ = 51, 44 VMMDEVREQ_VIDEMODE_SUPPORTED = 52, 45 VMMDEVREQ_GET_HEIGHT_REDUCTION = 53, 46 /** 47 * @VMMDEVREQ_GET_DISPLAY_CHANGE_REQ2: 48 * Retrieve a display resize request sent by the host. 49 * 50 * Queries a display resize request sent from the host. If the 51 * event_ack member is sent to true and there is an unqueried request 52 * available for one of the virtual display then that request will 53 * be returned. If several displays have unqueried requests the lowest 54 * numbered display will be chosen first. Only the most recent unseen 55 * request for each display is remembered. 56 * If event_ack is set to false, the last host request queried with 57 * event_ack set is resent, or failing that the most recent received 58 * from the host. If no host request was ever received then all zeros 59 * are returned. 60 */ 61 VMMDEVREQ_GET_DISPLAY_CHANGE_REQ2 = 54, 62 VMMDEVREQ_REPORT_GUEST_CAPABILITIES = 55, 63 VMMDEVREQ_SET_GUEST_CAPABILITIES = 56, 64 VMMDEVREQ_VIDEMODE_SUPPORTED2 = 57, /* since version 3.2.0 */ 65 VMMDEVREQ_GET_DISPLAY_CHANGE_REQEX = 80, /* since version 4.2.4 */ 66 VMMDEVREQ_GET_DISPLAY_CHANGE_REQ_MULTI = 81, 67 VMMDEVREQ_HGCM_CONNECT = 60, 68 VMMDEVREQ_HGCM_DISCONNECT = 61, 69 VMMDEVREQ_HGCM_CALL32 = 62, 70 VMMDEVREQ_HGCM_CALL64 = 63, 71 VMMDEVREQ_HGCM_CANCEL = 64, 72 VMMDEVREQ_HGCM_CANCEL2 = 65, 73 VMMDEVREQ_VIDEO_ACCEL_ENABLE = 70, 74 VMMDEVREQ_VIDEO_ACCEL_FLUSH = 71, 75 VMMDEVREQ_VIDEO_SET_VISIBLE_REGION = 72, 76 VMMDEVREQ_GET_SEAMLESS_CHANGE_REQ = 73, 77 VMMDEVREQ_QUERY_CREDENTIALS = 100, 78 VMMDEVREQ_REPORT_CREDENTIALS_JUDGEMENT = 101, 79 VMMDEVREQ_REPORT_GUEST_STATS = 110, 80 VMMDEVREQ_GET_MEMBALLOON_CHANGE_REQ = 111, 81 VMMDEVREQ_GET_STATISTICS_CHANGE_REQ = 112, 82 VMMDEVREQ_CHANGE_MEMBALLOON = 113, 83 VMMDEVREQ_GET_VRDPCHANGE_REQ = 150, 84 VMMDEVREQ_LOG_STRING = 200, 85 VMMDEVREQ_GET_CPU_HOTPLUG_REQ = 210, 86 VMMDEVREQ_SET_CPU_HOTPLUG_STATUS = 211, 87 VMMDEVREQ_REGISTER_SHARED_MODULE = 212, 88 VMMDEVREQ_UNREGISTER_SHARED_MODULE = 213, 89 VMMDEVREQ_CHECK_SHARED_MODULES = 214, 90 VMMDEVREQ_GET_PAGE_SHARING_STATUS = 215, 91 VMMDEVREQ_DEBUG_IS_PAGE_SHARED = 216, 92 VMMDEVREQ_GET_SESSION_ID = 217, /* since version 3.2.8 */ 93 VMMDEVREQ_WRITE_COREDUMP = 218, 94 VMMDEVREQ_GUEST_HEARTBEAT = 219, 95 VMMDEVREQ_HEARTBEAT_CONFIGURE = 220, 96 VMMDEVREQ_NT_BUG_CHECK = 221, 97 VMMDEVREQ_VIDEO_UPDATE_MONITOR_POSITIONS = 222, 98 /* Ensure the enum is a 32 bit data-type */ 99 VMMDEVREQ_SIZEHACK = 0x7fffffff 100 }; 101 102 #if __BITS_PER_LONG == 64 103 #define VMMDEVREQ_HGCM_CALL VMMDEVREQ_HGCM_CALL64 104 #else 105 #define VMMDEVREQ_HGCM_CALL VMMDEVREQ_HGCM_CALL32 106 #endif 107 108 /* vmmdev_request_header.requestor defines */ 109 110 /* Requestor user not given. */ 111 #define VMMDEV_REQUESTOR_USR_NOT_GIVEN 0x00000000 112 /* The kernel driver (vboxguest) is the requestor. */ 113 #define VMMDEV_REQUESTOR_USR_DRV 0x00000001 114 /* Some other kernel driver is the requestor. */ 115 #define VMMDEV_REQUESTOR_USR_DRV_OTHER 0x00000002 116 /* The root or a admin user is the requestor. */ 117 #define VMMDEV_REQUESTOR_USR_ROOT 0x00000003 118 /* Regular joe user is making the request. */ 119 #define VMMDEV_REQUESTOR_USR_USER 0x00000006 120 /* User classification mask. */ 121 #define VMMDEV_REQUESTOR_USR_MASK 0x00000007 122 123 /* Kernel mode request. Note this is 0, check for !USERMODE instead. */ 124 #define VMMDEV_REQUESTOR_KERNEL 0x00000000 125 /* User mode request. */ 126 #define VMMDEV_REQUESTOR_USERMODE 0x00000008 127 /* User or kernel mode classification mask. */ 128 #define VMMDEV_REQUESTOR_MODE_MASK 0x00000008 129 130 /* Don't know the physical console association of the requestor. */ 131 #define VMMDEV_REQUESTOR_CON_DONT_KNOW 0x00000000 132 /* 133 * The request originates with a process that is NOT associated with the 134 * physical console. 135 */ 136 #define VMMDEV_REQUESTOR_CON_NO 0x00000010 137 /* Requestor process is associated with the physical console. */ 138 #define VMMDEV_REQUESTOR_CON_YES 0x00000020 139 /* Console classification mask. */ 140 #define VMMDEV_REQUESTOR_CON_MASK 0x00000030 141 142 /* Requestor is member of special VirtualBox user group. */ 143 #define VMMDEV_REQUESTOR_GRP_VBOX 0x00000080 144 145 /* Note: trust level is for windows guests only, linux always uses not-given */ 146 /* Requestor trust level: Unspecified */ 147 #define VMMDEV_REQUESTOR_TRUST_NOT_GIVEN 0x00000000 148 /* Requestor trust level: Untrusted (SID S-1-16-0) */ 149 #define VMMDEV_REQUESTOR_TRUST_UNTRUSTED 0x00001000 150 /* Requestor trust level: Untrusted (SID S-1-16-4096) */ 151 #define VMMDEV_REQUESTOR_TRUST_LOW 0x00002000 152 /* Requestor trust level: Medium (SID S-1-16-8192) */ 153 #define VMMDEV_REQUESTOR_TRUST_MEDIUM 0x00003000 154 /* Requestor trust level: Medium plus (SID S-1-16-8448) */ 155 #define VMMDEV_REQUESTOR_TRUST_MEDIUM_PLUS 0x00004000 156 /* Requestor trust level: High (SID S-1-16-12288) */ 157 #define VMMDEV_REQUESTOR_TRUST_HIGH 0x00005000 158 /* Requestor trust level: System (SID S-1-16-16384) */ 159 #define VMMDEV_REQUESTOR_TRUST_SYSTEM 0x00006000 160 /* Requestor trust level >= Protected (SID S-1-16-20480, S-1-16-28672) */ 161 #define VMMDEV_REQUESTOR_TRUST_PROTECTED 0x00007000 162 /* Requestor trust level mask */ 163 #define VMMDEV_REQUESTOR_TRUST_MASK 0x00007000 164 165 /* Requestor is using the less trusted user device node (/dev/vboxuser) */ 166 #define VMMDEV_REQUESTOR_USER_DEVICE 0x00008000 167 168 /** HGCM service location types. */ 169 enum vmmdev_hgcm_service_location_type { 170 VMMDEV_HGCM_LOC_INVALID = 0, 171 VMMDEV_HGCM_LOC_LOCALHOST = 1, 172 VMMDEV_HGCM_LOC_LOCALHOST_EXISTING = 2, 173 /* Ensure the enum is a 32 bit data-type */ 174 VMMDEV_HGCM_LOC_SIZEHACK = 0x7fffffff 175 }; 176 177 /** HGCM host service location. */ 178 struct vmmdev_hgcm_service_location_localhost { 179 /** Service name */ 180 char service_name[128]; 181 }; 182 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_service_location_localhost, 128); 183 184 /** HGCM service location. */ 185 struct vmmdev_hgcm_service_location { 186 /** Type of the location. */ 187 enum vmmdev_hgcm_service_location_type type; 188 189 union { 190 struct vmmdev_hgcm_service_location_localhost localhost; 191 } u; 192 }; 193 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_service_location, 128 + 4); 194 195 /** HGCM function parameter type. */ 196 enum vmmdev_hgcm_function_parameter_type { 197 VMMDEV_HGCM_PARM_TYPE_INVALID = 0, 198 VMMDEV_HGCM_PARM_TYPE_32BIT = 1, 199 VMMDEV_HGCM_PARM_TYPE_64BIT = 2, 200 /** Deprecated Doesn't work, use PAGELIST. */ 201 VMMDEV_HGCM_PARM_TYPE_PHYSADDR = 3, 202 /** In and Out, user-memory */ 203 VMMDEV_HGCM_PARM_TYPE_LINADDR = 4, 204 /** In, user-memory (read; host<-guest) */ 205 VMMDEV_HGCM_PARM_TYPE_LINADDR_IN = 5, 206 /** Out, user-memory (write; host->guest) */ 207 VMMDEV_HGCM_PARM_TYPE_LINADDR_OUT = 6, 208 /** In and Out, kernel-memory */ 209 VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL = 7, 210 /** In, kernel-memory (read; host<-guest) */ 211 VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN = 8, 212 /** Out, kernel-memory (write; host->guest) */ 213 VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT = 9, 214 /** Physical addresses of locked pages for a buffer. */ 215 VMMDEV_HGCM_PARM_TYPE_PAGELIST = 10, 216 /* Ensure the enum is a 32 bit data-type */ 217 VMMDEV_HGCM_PARM_TYPE_SIZEHACK = 0x7fffffff 218 }; 219 220 /** HGCM function parameter, 32-bit client. */ 221 struct vmmdev_hgcm_function_parameter32 { 222 enum vmmdev_hgcm_function_parameter_type type; 223 union { 224 __u32 value32; 225 __u64 value64; 226 struct { 227 __u32 size; 228 union { 229 __u32 phys_addr; 230 __u32 linear_addr; 231 } u; 232 } pointer; 233 struct { 234 /** Size of the buffer described by the page list. */ 235 __u32 size; 236 /** Relative to the request header. */ 237 __u32 offset; 238 } page_list; 239 } u; 240 } __packed; 241 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter32, 4 + 8); 242 243 /** HGCM function parameter, 64-bit client. */ 244 struct vmmdev_hgcm_function_parameter64 { 245 enum vmmdev_hgcm_function_parameter_type type; 246 union { 247 __u32 value32; 248 __u64 value64; 249 struct { 250 __u32 size; 251 union { 252 __u64 phys_addr; 253 __u64 linear_addr; 254 } u; 255 } __packed pointer; 256 struct { 257 /** Size of the buffer described by the page list. */ 258 __u32 size; 259 /** Relative to the request header. */ 260 __u32 offset; 261 } page_list; 262 } __packed u; 263 } __packed; 264 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_function_parameter64, 4 + 12); 265 266 #if __BITS_PER_LONG == 64 267 #define vmmdev_hgcm_function_parameter vmmdev_hgcm_function_parameter64 268 #else 269 #define vmmdev_hgcm_function_parameter vmmdev_hgcm_function_parameter32 270 #endif 271 272 #define VMMDEV_HGCM_F_PARM_DIRECTION_NONE 0x00000000U 273 #define VMMDEV_HGCM_F_PARM_DIRECTION_TO_HOST 0x00000001U 274 #define VMMDEV_HGCM_F_PARM_DIRECTION_FROM_HOST 0x00000002U 275 #define VMMDEV_HGCM_F_PARM_DIRECTION_BOTH 0x00000003U 276 277 /** 278 * struct vmmdev_hgcm_pagelist - VMMDEV_HGCM_PARM_TYPE_PAGELIST parameters 279 * point to this structure to actually describe the buffer. 280 */ 281 struct vmmdev_hgcm_pagelist { 282 __u32 flags; /** VMMDEV_HGCM_F_PARM_*. */ 283 __u16 offset_first_page; /** Data offset in the first page. */ 284 __u16 page_count; /** Number of pages. */ 285 union { 286 __u64 unused; /** Deprecated place-holder for first "pages" entry. */ 287 __DECLARE_FLEX_ARRAY(__u64, pages); /** Page addresses. */ 288 }; 289 }; 290 VMMDEV_ASSERT_SIZE(vmmdev_hgcm_pagelist, 4 + 2 + 2 + 8); 291 292 #endif 293