isgx_user.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (C) 2011-2017 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef _UAPI_ASM_X86_SGX_H
  32. #define _UAPI_ASM_X86_SGX_H
  33. #include <linux/types.h>
  34. #include <linux/ioctl.h>
  35. #define SGX_MAGIC 0xA4
  36. #define SGX_IOC_ENCLAVE_CREATE \
  37. _IOW(SGX_MAGIC, 0x00, struct sgx_enclave_create)
  38. #define SGX_IOC_ENCLAVE_ADD_PAGE \
  39. _IOW(SGX_MAGIC, 0x01, struct sgx_enclave_add_page)
  40. #define SGX_IOC_ENCLAVE_INIT \
  41. _IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
  42. #define SGX_IOC_ENCLAVE_EMODPR \
  43. _IOW(SGX_MAGIC, 0x09, struct sgx_modification_param)
  44. #define SGX_IOC_ENCLAVE_MKTCS \
  45. _IOW(SGX_MAGIC, 0x0a, struct sgx_range)
  46. #define SGX_IOC_ENCLAVE_TRIM \
  47. _IOW(SGX_MAGIC, 0x0b, struct sgx_range)
  48. #define SGX_IOC_ENCLAVE_NOTIFY_ACCEPT \
  49. _IOW(SGX_MAGIC, 0x0c, struct sgx_range)
  50. #define SGX_IOC_ENCLAVE_PAGE_REMOVE \
  51. _IOW(SGX_MAGIC, 0x0d, unsigned long)
  52. /* SGX leaf instruction return values */
  53. #define SGX_INVALID_SIG_STRUCT 1
  54. #define SGX_INVALID_ATTRIBUTE 2
  55. #define SGX_BLKSTATE 3
  56. #define SGX_INVALID_MEASUREMENT 4
  57. #define SGX_NOTBLOCKABLE 5
  58. #define SGX_PG_INVLD 6
  59. #define SGX_LOCKFAIL 7
  60. #define SGX_INVALID_SIGNATURE 8
  61. #define SGX_MAC_COMPARE_FAIL 9
  62. #define SGX_PAGE_NOT_BLOCKED 10
  63. #define SGX_NOT_TRACKED 11
  64. #define SGX_VA_SLOT_OCCUPIED 12
  65. #define SGX_CHILD_PRESENT 13
  66. #define SGX_ENCLAVE_ACT 14
  67. #define SGX_ENTRYEPOCH_LOCKED 15
  68. #define SGX_INVALID_LICENSE 16
  69. #define SGX_PREV_TRK_INCMPL 17
  70. #define SGX_PG_IS_SECS 18
  71. #define SGX_PAGE_NOT_MODIFIABLE 20
  72. #define SGX_INVALID_CPUSVN 32
  73. #define SGX_INVALID_ISVSVN 64
  74. #define SGX_UNMASKED_EVENT 128
  75. #define SGX_INVALID_KEYNAME 256
  76. /* IOCTL return values */
  77. #define SGX_POWER_LOST_ENCLAVE 0x40000000
  78. #define SGX_LE_ROLLBACK 0x40000001
  79. /**
  80. * struct sgx_enclave_create - parameter structure for the
  81. * %SGX_IOC_ENCLAVE_CREATE ioctl
  82. * @src: address for the SECS page data
  83. */
  84. struct sgx_enclave_create {
  85. __u64 src;
  86. } __attribute__((packed));
  87. /**
  88. * struct sgx_enclave_add_page - parameter structure for the
  89. * %SGX_IOC_ENCLAVE_ADD_PAGE ioctl
  90. * @addr: address in the ELRANGE
  91. * @src: address for the page data
  92. * @secinfo: address for the SECINFO data
  93. * @mrmask: bitmask for the 256 byte chunks that are to be measured
  94. */
  95. struct sgx_enclave_add_page {
  96. __u64 addr;
  97. __u64 src;
  98. __u64 secinfo;
  99. __u16 mrmask;
  100. } __attribute__((packed));
  101. /**
  102. * struct sgx_enclave_init - parameter structure for the
  103. * %SGX_IOC_ENCLAVE_INIT ioctl
  104. * @addr: address in the ELRANGE
  105. * @sigstruct: address for the page data
  106. * @einittoken: address for the SECINFO data
  107. */
  108. struct sgx_enclave_init {
  109. __u64 addr;
  110. __u64 sigstruct;
  111. __u64 einittoken;
  112. } __attribute__((packed));
  113. struct sgx_enclave_destroy {
  114. __u64 addr;
  115. } __attribute__((packed));
  116. /*
  117. * SGX2.0 definitions
  118. */
  119. #define SGX_GROW_UP_FLAG 1
  120. #define SGX_GROW_DOWN_FLAG 2
  121. struct sgx_range {
  122. unsigned long start_addr;
  123. unsigned int nr_pages;
  124. };
  125. struct sgx_modification_param {
  126. struct sgx_range range;
  127. unsigned long flags;
  128. };
  129. #endif /* _UAPI_ASM_X86_SGX_H */