isgx_user.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * This file is provided under a dual BSD/GPLv2 license. When using or
  3. * redistributing this file, you may do so under either license.
  4. *
  5. * GPL LICENSE SUMMARY
  6. *
  7. * Copyright(c) 2016 Intel Corporation.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * Contact Information:
  19. * Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
  20. * Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo
  21. *
  22. * BSD LICENSE
  23. *
  24. * Copyright(c) 2016 Intel Corporation.
  25. *
  26. * Redistribution and use in source and binary forms, with or without
  27. * modification, are permitted provided that the following conditions
  28. * are met:
  29. *
  30. * * Redistributions of source code must retain the above copyright
  31. * notice, this list of conditions and the following disclaimer.
  32. * * Redistributions in binary form must reproduce the above copyright
  33. * notice, this list of conditions and the following disclaimer in
  34. * the documentation and/or other materials provided with the
  35. * distribution.
  36. * * Neither the name of Intel Corporation nor the names of its
  37. * contributors may be used to endorse or promote products derived
  38. * from this software without specific prior written permission.
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  41. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  42. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  43. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  44. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  45. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  46. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  47. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  48. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  49. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  50. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  51. *
  52. * Authors:
  53. *
  54. * Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
  55. * Suresh Siddha <suresh.b.siddha@intel.com>
  56. * Serge Ayoun <serge.ayoun@intel.com>
  57. * Shay Katz-zamir <shay.katz-zamir@intel.com>
  58. */
  59. #ifndef _UAPI_ASM_X86_SGX_H
  60. #define _UAPI_ASM_X86_SGX_H
  61. #include <linux/types.h>
  62. #include <linux/ioctl.h>
  63. #define SGX_MAGIC 0xA4
  64. #define SGX_IOC_ENCLAVE_CREATE \
  65. _IOW(SGX_MAGIC, 0x00, struct sgx_enclave_create)
  66. #define SGX_IOC_ENCLAVE_ADD_PAGE \
  67. _IOW(SGX_MAGIC, 0x01, struct sgx_enclave_add_page)
  68. #define SGX_IOC_ENCLAVE_INIT \
  69. _IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
  70. #define SGX_IOC_ENCLAVE_INIT_IN_KERNEL \
  71. _IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init_in_kernel)
  72. #define SGX_IOC_ENCLAVE_EMODPR \
  73. _IOW(SGX_MAGIC, 0x09, struct sgx_modification_param)
  74. #define SGX_IOC_ENCLAVE_MKTCS \
  75. _IOW(SGX_MAGIC, 0x0a, struct sgx_range)
  76. #define SGX_IOC_ENCLAVE_TRIM \
  77. _IOW(SGX_MAGIC, 0x0b, struct sgx_range)
  78. #define SGX_IOC_ENCLAVE_NOTIFY_ACCEPT \
  79. _IOW(SGX_MAGIC, 0x0c, struct sgx_range)
  80. #define SGX_IOC_ENCLAVE_PAGE_REMOVE \
  81. _IOW(SGX_MAGIC, 0x0d, unsigned long)
  82. /* SGX leaf instruction return values */
  83. #define SGX_INVALID_SIG_STRUCT 1
  84. #define SGX_INVALID_ATTRIBUTE 2
  85. #define SGX_BLKSTATE 3
  86. #define SGX_INVALID_MEASUREMENT 4
  87. #define SGX_NOTBLOCKABLE 5
  88. #define SGX_PG_INVLD 6
  89. #define SGX_LOCKFAIL 7
  90. #define SGX_INVALID_SIGNATURE 8
  91. #define SGX_MAC_COMPARE_FAIL 9
  92. #define SGX_PAGE_NOT_BLOCKED 10
  93. #define SGX_NOT_TRACKED 11
  94. #define SGX_VA_SLOT_OCCUPIED 12
  95. #define SGX_CHILD_PRESENT 13
  96. #define SGX_ENCLAVE_ACT 14
  97. #define SGX_ENTRYEPOCH_LOCKED 15
  98. #define SGX_INVALID_LICENSE 16
  99. #define SGX_PREV_TRK_INCMPL 17
  100. #define SGX_PG_IS_SECS 18
  101. #define SGX_PAGE_NOT_MODIFIABLE 20
  102. #define SGX_INVALID_CPUSVN 32
  103. #define SGX_INVALID_ISVSVN 64
  104. #define SGX_UNMASKED_EVENT 128
  105. #define SGX_INVALID_KEYNAME 256
  106. /* IOCTL return values */
  107. #define SGX_POWER_LOST_ENCLAVE 0x40000000
  108. #define SGX_LE_ROLLBACK 0x40000001
  109. /**
  110. * struct sgx_enclave_create - parameter structure for the
  111. * %SGX_IOC_ENCLAVE_CREATE ioctl
  112. * @src: address for the SECS page data
  113. */
  114. struct sgx_enclave_create {
  115. __u64 src;
  116. } __attribute__((packed));
  117. /**
  118. * struct sgx_enclave_add_page - parameter structure for the
  119. * %SGX_IOC_ENCLAVE_ADD_PAGE ioctl
  120. * @addr: address in the ELRANGE
  121. * @src: address for the page data
  122. * @secinfo: address for the SECINFO data
  123. * @mrmask: bitmask for the 256 byte chunks that are to be measured
  124. */
  125. struct sgx_enclave_add_page {
  126. __u64 addr;
  127. __u64 src;
  128. __u64 secinfo;
  129. __u16 mrmask;
  130. } __attribute__((packed));
  131. /**
  132. * struct sgx_enclave_init - parameter structure for the
  133. * %SGX_IOC_ENCLAVE_INIT ioctl
  134. * @addr: address in the ELRANGE
  135. * @sigstruct: address for the page data
  136. * @einittoken: address for the SECINFO data
  137. */
  138. struct sgx_enclave_init {
  139. __u64 addr;
  140. __u64 sigstruct;
  141. __u64 einittoken;
  142. } __attribute__((packed));
  143. /**
  144. * struct sgx_enclave_init_in_kernel - parameter structure for the in-kernel
  145. * %SGX_IOC_ENCLAVE_INIT ioctl
  146. * @addr: address in the ELRANGE
  147. * @sigstruct: address for the page data
  148. */
  149. struct sgx_enclave_init_in_kernel {
  150. __u64 addr;
  151. __u64 sigstruct;
  152. };
  153. struct sgx_enclave_destroy {
  154. __u64 addr;
  155. } __attribute__((packed));
  156. /*
  157. * SGX2.0 definitions
  158. */
  159. #define SGX_GROW_UP_FLAG 1
  160. #define SGX_GROW_DOWN_FLAG 2
  161. struct sgx_range {
  162. unsigned long start_addr;
  163. unsigned int nr_pages;
  164. };
  165. struct sgx_modification_param {
  166. struct sgx_range range;
  167. unsigned long flags;
  168. };
  169. #endif /* _UAPI_ASM_X86_SGX_H */