Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR CDDL-1.0) */
0002 /*
0003  * VBoxGuest - VirtualBox Guest Additions Driver Interface.
0004  *
0005  * Copyright (C) 2006-2016 Oracle Corporation
0006  */
0007 
0008 #ifndef __UAPI_VBOXGUEST_H__
0009 #define __UAPI_VBOXGUEST_H__
0010 
0011 #include <asm/bitsperlong.h>
0012 #include <linux/ioctl.h>
0013 #include <linux/vbox_err.h>
0014 #include <linux/vbox_vmmdev_types.h>
0015 
0016 /* Version of vbg_ioctl_hdr structure. */
0017 #define VBG_IOCTL_HDR_VERSION       0x10001
0018 /* Default request type.  Use this for non-VMMDev requests. */
0019 #define VBG_IOCTL_HDR_TYPE_DEFAULT      0
0020 
0021 /**
0022  * Common ioctl header.
0023  *
0024  * This is a mirror of vmmdev_request_header to prevent duplicating data and
0025  * needing to verify things multiple times.
0026  */
0027 struct vbg_ioctl_hdr {
0028     /** IN: The request input size, and output size if size_out is zero. */
0029     __u32 size_in;
0030     /** IN: Structure version (VBG_IOCTL_HDR_VERSION) */
0031     __u32 version;
0032     /** IN: The VMMDev request type or VBG_IOCTL_HDR_TYPE_DEFAULT. */
0033     __u32 type;
0034     /**
0035      * OUT: The VBox status code of the operation, out direction only.
0036      * This is a VINF_ or VERR_ value as defined in vbox_err.h.
0037      */
0038     __s32 rc;
0039     /** IN: Output size. Set to zero to use size_in as output size. */
0040     __u32 size_out;
0041     /** Reserved, MBZ. */
0042     __u32 reserved;
0043 };
0044 VMMDEV_ASSERT_SIZE(vbg_ioctl_hdr, 24);
0045 
0046 
0047 /*
0048  * The VBoxGuest I/O control version.
0049  *
0050  * As usual, the high word contains the major version and changes to it
0051  * signifies incompatible changes.
0052  *
0053  * The lower word is the minor version number, it is increased when new
0054  * functions are added or existing changed in a backwards compatible manner.
0055  */
0056 #define VBG_IOC_VERSION     0x00010000u
0057 
0058 /**
0059  * VBG_IOCTL_DRIVER_VERSION_INFO data structure
0060  *
0061  * Note VBG_IOCTL_DRIVER_VERSION_INFO may switch the session to a backwards
0062  * compatible interface version if uClientVersion indicates older client code.
0063  */
0064 struct vbg_ioctl_driver_version_info {
0065     /** The header. */
0066     struct vbg_ioctl_hdr hdr;
0067     union {
0068         struct {
0069             /** Requested interface version (VBG_IOC_VERSION). */
0070             __u32 req_version;
0071             /**
0072              * Minimum interface version number (typically the
0073              * major version part of VBG_IOC_VERSION).
0074              */
0075             __u32 min_version;
0076             /** Reserved, MBZ. */
0077             __u32 reserved1;
0078             /** Reserved, MBZ. */
0079             __u32 reserved2;
0080         } in;
0081         struct {
0082             /** Version for this session (typ. VBG_IOC_VERSION). */
0083             __u32 session_version;
0084             /** Version of the IDC interface (VBG_IOC_VERSION). */
0085             __u32 driver_version;
0086             /** The SVN revision of the driver, or 0. */
0087             __u32 driver_revision;
0088             /** Reserved \#1 (zero until defined). */
0089             __u32 reserved1;
0090             /** Reserved \#2 (zero until defined). */
0091             __u32 reserved2;
0092         } out;
0093     } u;
0094 };
0095 VMMDEV_ASSERT_SIZE(vbg_ioctl_driver_version_info, 24 + 20);
0096 
0097 #define VBG_IOCTL_DRIVER_VERSION_INFO \
0098     _IOWR('V', 0, struct vbg_ioctl_driver_version_info)
0099 
0100 
0101 /* IOCTL to perform a VMM Device request less than 1KB in size. */
0102 #define VBG_IOCTL_VMMDEV_REQUEST(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 2, s)
0103 
0104 
0105 /* IOCTL to perform a VMM Device request larger then 1KB. */
0106 #define VBG_IOCTL_VMMDEV_REQUEST_BIG    _IO('V', 3)
0107 
0108 
0109 /** VBG_IOCTL_HGCM_CONNECT data structure. */
0110 struct vbg_ioctl_hgcm_connect {
0111     struct vbg_ioctl_hdr hdr;
0112     union {
0113         struct {
0114             struct vmmdev_hgcm_service_location loc;
0115         } in;
0116         struct {
0117             __u32 client_id;
0118         } out;
0119     } u;
0120 };
0121 VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_connect, 24 + 132);
0122 
0123 #define VBG_IOCTL_HGCM_CONNECT \
0124     _IOWR('V', 4, struct vbg_ioctl_hgcm_connect)
0125 
0126 
0127 /** VBG_IOCTL_HGCM_DISCONNECT data structure. */
0128 struct vbg_ioctl_hgcm_disconnect {
0129     struct vbg_ioctl_hdr hdr;
0130     union {
0131         struct {
0132             __u32 client_id;
0133         } in;
0134     } u;
0135 };
0136 VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_disconnect, 24 + 4);
0137 
0138 #define VBG_IOCTL_HGCM_DISCONNECT \
0139     _IOWR('V', 5, struct vbg_ioctl_hgcm_disconnect)
0140 
0141 
0142 /** VBG_IOCTL_HGCM_CALL data structure. */
0143 struct vbg_ioctl_hgcm_call {
0144     /** The header. */
0145     struct vbg_ioctl_hdr hdr;
0146     /** Input: The id of the caller. */
0147     __u32 client_id;
0148     /** Input: Function number. */
0149     __u32 function;
0150     /**
0151      * Input: How long to wait (milliseconds) for completion before
0152      * cancelling the call. Set to -1 to wait indefinitely.
0153      */
0154     __u32 timeout_ms;
0155     /** Interruptable flag, ignored for userspace calls. */
0156     __u8 interruptible;
0157     /** Explicit padding, MBZ. */
0158     __u8 reserved;
0159     /**
0160      * Input: How many parameters following this structure.
0161      *
0162      * The parameters are either HGCMFunctionParameter64 or 32,
0163      * depending on whether we're receiving a 64-bit or 32-bit request.
0164      *
0165      * The current maximum is 61 parameters (given a 1KB max request size,
0166      * and a 64-bit parameter size of 16 bytes).
0167      */
0168     __u16 parm_count;
0169     /*
0170      * Parameters follow in form:
0171      * struct hgcm_function_parameter<32|64> parms[parm_count]
0172      */
0173 };
0174 VMMDEV_ASSERT_SIZE(vbg_ioctl_hgcm_call, 24 + 16);
0175 
0176 #define VBG_IOCTL_HGCM_CALL_32(s)   _IOC(_IOC_READ | _IOC_WRITE, 'V', 6, s)
0177 #define VBG_IOCTL_HGCM_CALL_64(s)   _IOC(_IOC_READ | _IOC_WRITE, 'V', 7, s)
0178 #if __BITS_PER_LONG == 64
0179 #define VBG_IOCTL_HGCM_CALL(s)      VBG_IOCTL_HGCM_CALL_64(s)
0180 #else
0181 #define VBG_IOCTL_HGCM_CALL(s)      VBG_IOCTL_HGCM_CALL_32(s)
0182 #endif
0183 
0184 
0185 /** VBG_IOCTL_LOG data structure. */
0186 struct vbg_ioctl_log {
0187     /** The header. */
0188     struct vbg_ioctl_hdr hdr;
0189     union {
0190         struct {
0191             /**
0192              * The log message, this may be zero terminated. If it
0193              * is not zero terminated then the length is determined
0194              * from the input size.
0195              */
0196             char msg[1];
0197         } in;
0198     } u;
0199 };
0200 
0201 #define VBG_IOCTL_LOG(s)        _IO('V', 9)
0202 
0203 
0204 /** VBG_IOCTL_WAIT_FOR_EVENTS data structure. */
0205 struct vbg_ioctl_wait_for_events {
0206     /** The header. */
0207     struct vbg_ioctl_hdr hdr;
0208     union {
0209         struct {
0210             /** Timeout in milliseconds. */
0211             __u32 timeout_ms;
0212             /** Events to wait for. */
0213             __u32 events;
0214         } in;
0215         struct {
0216             /** Events that occurred. */
0217             __u32 events;
0218         } out;
0219     } u;
0220 };
0221 VMMDEV_ASSERT_SIZE(vbg_ioctl_wait_for_events, 24 + 8);
0222 
0223 #define VBG_IOCTL_WAIT_FOR_EVENTS \
0224     _IOWR('V', 10, struct vbg_ioctl_wait_for_events)
0225 
0226 
0227 /*
0228  * IOCTL to VBoxGuest to interrupt (cancel) any pending
0229  * VBG_IOCTL_WAIT_FOR_EVENTS and return.
0230  *
0231  * Handled inside the vboxguest driver and not seen by the host at all.
0232  * After calling this, VBG_IOCTL_WAIT_FOR_EVENTS should no longer be called in
0233  * the same session. Any VBOXGUEST_IOCTL_WAITEVENT calls in the same session
0234  * done after calling this will directly exit with -EINTR.
0235  */
0236 #define VBG_IOCTL_INTERRUPT_ALL_WAIT_FOR_EVENTS \
0237     _IOWR('V', 11, struct vbg_ioctl_hdr)
0238 
0239 
0240 /** VBG_IOCTL_CHANGE_FILTER_MASK data structure. */
0241 struct vbg_ioctl_change_filter {
0242     /** The header. */
0243     struct vbg_ioctl_hdr hdr;
0244     union {
0245         struct {
0246             /** Flags to set. */
0247             __u32 or_mask;
0248             /** Flags to remove. */
0249             __u32 not_mask;
0250         } in;
0251     } u;
0252 };
0253 VMMDEV_ASSERT_SIZE(vbg_ioctl_change_filter, 24 + 8);
0254 
0255 /* IOCTL to VBoxGuest to control the event filter mask. */
0256 #define VBG_IOCTL_CHANGE_FILTER_MASK \
0257     _IOWR('V', 12, struct vbg_ioctl_change_filter)
0258 
0259 
0260 /** VBG_IOCTL_ACQUIRE_GUEST_CAPABILITIES data structure. */
0261 struct vbg_ioctl_acquire_guest_caps {
0262     /** The header. */
0263     struct vbg_ioctl_hdr hdr;
0264     union {
0265         struct {
0266             /** Flags (VBGL_IOC_AGC_FLAGS_XXX). */
0267             __u32 flags;
0268             /** Capabilities to set (VMMDEV_GUEST_SUPPORTS_XXX). */
0269             __u32 or_mask;
0270             /** Capabilities to drop (VMMDEV_GUEST_SUPPORTS_XXX). */
0271             __u32 not_mask;
0272         } in;
0273     } u;
0274 };
0275 VMMDEV_ASSERT_SIZE(vbg_ioctl_acquire_guest_caps, 24 + 12);
0276 
0277 #define VBGL_IOC_AGC_FLAGS_CONFIG_ACQUIRE_MODE      0x00000001
0278 #define VBGL_IOC_AGC_FLAGS_VALID_MASK           0x00000001
0279 
0280 #define VBG_IOCTL_ACQUIRE_GUEST_CAPABILITIES \
0281     _IOWR('V', 13, struct vbg_ioctl_acquire_guest_caps)
0282 
0283 
0284 /** VBG_IOCTL_CHANGE_GUEST_CAPABILITIES data structure. */
0285 struct vbg_ioctl_set_guest_caps {
0286     /** The header. */
0287     struct vbg_ioctl_hdr hdr;
0288     union {
0289         struct {
0290             /** Capabilities to set (VMMDEV_GUEST_SUPPORTS_XXX). */
0291             __u32 or_mask;
0292             /** Capabilities to drop (VMMDEV_GUEST_SUPPORTS_XXX). */
0293             __u32 not_mask;
0294         } in;
0295         struct {
0296             /** Capabilities held by the session after the call. */
0297             __u32 session_caps;
0298             /** Capabilities for all the sessions after the call. */
0299             __u32 global_caps;
0300         } out;
0301     } u;
0302 };
0303 VMMDEV_ASSERT_SIZE(vbg_ioctl_set_guest_caps, 24 + 8);
0304 
0305 #define VBG_IOCTL_CHANGE_GUEST_CAPABILITIES \
0306     _IOWR('V', 14, struct vbg_ioctl_set_guest_caps)
0307 
0308 
0309 /** VBG_IOCTL_CHECK_BALLOON data structure. */
0310 struct vbg_ioctl_check_balloon {
0311     /** The header. */
0312     struct vbg_ioctl_hdr hdr;
0313     union {
0314         struct {
0315             /** The size of the balloon in chunks of 1MB. */
0316             __u32 balloon_chunks;
0317             /**
0318              * false = handled in R0, no further action required.
0319              *  true = allocate balloon memory in R3.
0320              */
0321             __u8 handle_in_r3;
0322             /** Explicit padding, MBZ. */
0323             __u8 padding[3];
0324         } out;
0325     } u;
0326 };
0327 VMMDEV_ASSERT_SIZE(vbg_ioctl_check_balloon, 24 + 8);
0328 
0329 /*
0330  * IOCTL to check memory ballooning.
0331  *
0332  * The guest kernel module will ask the host for the current size of the
0333  * balloon and adjust the size. Or it will set handle_in_r3 = true and R3 is
0334  * responsible for allocating memory and calling VBG_IOCTL_CHANGE_BALLOON.
0335  */
0336 #define VBG_IOCTL_CHECK_BALLOON \
0337     _IOWR('V', 17, struct vbg_ioctl_check_balloon)
0338 
0339 
0340 /** VBG_IOCTL_WRITE_CORE_DUMP data structure. */
0341 struct vbg_ioctl_write_coredump {
0342     struct vbg_ioctl_hdr hdr;
0343     union {
0344         struct {
0345             __u32 flags; /** Flags (reserved, MBZ). */
0346         } in;
0347     } u;
0348 };
0349 VMMDEV_ASSERT_SIZE(vbg_ioctl_write_coredump, 24 + 4);
0350 
0351 #define VBG_IOCTL_WRITE_CORE_DUMP \
0352     _IOWR('V', 19, struct vbg_ioctl_write_coredump)
0353 
0354 #endif