/ duct-tape / xnu / osfmk / kern / hvg_hypercall.h
hvg_hypercall.h
  1  /*
  2   * Copyright (c) 2020 Apple Inc. All rights reserved.
  3   *
  4   * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  5   *
  6   * This file contains Original Code and/or Modifications of Original Code
  7   * as defined in and that are subject to the Apple Public Source License
  8   * Version 2.0 (the 'License'). You may not use this file except in
  9   * compliance with the License. The rights granted to you under the License
 10   * may not be used to create, or enable the creation or redistribution of,
 11   * unlawful or unlicensed copies of an Apple operating system, or to
 12   * circumvent, violate, or enable the circumvention or violation of, any
 13   * terms of an Apple operating system software license agreement.
 14   *
 15   * Please obtain a copy of the License at
 16   * http://www.opensource.apple.com/apsl/ and read it before using this file.
 17   *
 18   * The Original Code and all software distributed under the License are
 19   * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 20   * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 21   * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 22   * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 23   * Please see the License for the specific language governing rights and
 24   * limitations under the License.
 25   *
 26   * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
 27   */
 28  
 29  #ifndef _KERN_HVG_HYPERCALL_H_
 30  #define _KERN_HVG_HYPERCALL_H_
 31  
 32  #include <os/base.h>
 33  #include <stdint.h>
 34  
 35  /* Architecture-independent definitions (exported to userland) */
 36  
 37  /*
 38   * Apple Hypercall arguments
 39   */
 40  typedef struct hvg_hcall_args {
 41  	uint64_t args[6];
 42  } hvg_hcall_args_t;
 43  
 44  
 45  /*
 46   * Apple Hypercall return output
 47   */
 48  typedef struct hvg_hcall_output {
 49  	uint64_t regs[7];
 50  } hvg_hcall_output_t;
 51  
 52  
 53  /*
 54   * Apple Hypercall return code
 55   */
 56  
 57  OS_CLOSED_ENUM(hvg_hcall_return, uint32_t,
 58      HVG_HCALL_SUCCESS             = 0x0000,       /* The call succeeded */
 59      HVG_HCALL_ACCESS_DENIED       = 0x0001,       /* Invalid access right */
 60      HVG_HCALL_INVALID_CODE        = 0x0002,       /* Hypercall code not recognized */
 61      HVG_HCALL_INVALID_PARAMETER   = 0x0003,       /* Specified register value not valid */
 62      HVG_HCALL_IO_FAILED           = 0x0004,       /* Input/output error */
 63      HVG_HCALL_FEAT_DISABLED       = 0x0005,       /* Feature not available */
 64      HVG_HCALL_UNSUPPORTED         = 0x0006,       /* Hypercall not supported */
 65      );
 66  
 67  
 68  /*
 69   * Apple Hypercall call code
 70   */
 71  
 72  OS_CLOSED_ENUM(hvg_hcall_code, uint32_t,
 73      HVG_HCALL_TRIGGER_DUMP        = 0x0001,       /* Collect guest dump */
 74      );
 75  
 76  /*
 77   * Options for collecting kernel vmcore
 78   */
 79  
 80  OS_CLOSED_OPTIONS(hvg_hcall_dump_option, uint32_t,
 81      HVG_HCALL_DUMP_OPTION_REGULAR   =  0x0001     /* Regular dump-guest-memory */
 82      );
 83  
 84  typedef struct hvg_hcall_vmcore_file {
 85  	char tag[57];   /* 7 64-bit registers plus 1 byte for '\0' */
 86  } hvg_hcall_vmcore_file_t;
 87  
 88  extern hvg_hcall_return_t
 89  hvg_hcall_trigger_dump(hvg_hcall_vmcore_file_t *vmcore,
 90      const hvg_hcall_dump_option_t dump_option);
 91  
 92  
 93  #ifdef XNU_KERNEL_PRIVATE
 94  
 95  /*
 96   * For XNU kernel use only (omitted from userland headers)
 97   */
 98  
 99  #if defined (__x86_64__)
100  #include <i386/cpuid.h>
101  #include <i386/x86_hypercall.h>
102  #endif
103  
104  #endif /* XNU_KERNEL_PRIVATE */
105  
106  #endif /* _KERN_HV_HYPERCALL_H_ */