isgx_user.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. /* SGX leaf instruction return values */
  43. #define SGX_SUCCESS 0
  44. #define SGX_INVALID_SIG_STRUCT 1
  45. #define SGX_INVALID_ATTRIBUTE 2
  46. #define SGX_BLKSTATE 3
  47. #define SGX_INVALID_MEASUREMENT 4
  48. #define SGX_NOTBLOCKABLE 5
  49. #define SGX_PG_INVLD 6
  50. #define SGX_LOCKFAIL 7
  51. #define SGX_INVALID_SIGNATURE 8
  52. #define SGX_MAC_COMPARE_FAIL 9
  53. #define SGX_PAGE_NOT_BLOCKED 10
  54. #define SGX_NOT_TRACKED 11
  55. #define SGX_VA_SLOT_OCCUPIED 12
  56. #define SGX_CHILD_PRESENT 13
  57. #define SGX_ENCLAVE_ACT 14
  58. #define SGX_ENTRYEPOCH_LOCKED 15
  59. #define SGX_INVALID_LICENSE 16
  60. #define SGX_PREV_TRK_INCMPL 17
  61. #define SGX_PG_IS_SECS 18
  62. #define SGX_INVALID_CPUSVN 32
  63. #define SGX_INVALID_ISVSVN 64
  64. #define SGX_UNMASKED_EVENT 128
  65. #define SGX_INVALID_KEYNAME 256
  66. /* IOCTL return values */
  67. #define SGX_POWER_LOST_ENCLAVE 0x40000000
  68. #define SGX_LE_ROLLBACK 0x40000001
  69. struct sgx_enclave_create {
  70. __u64 src;
  71. } __attribute__((packed));
  72. struct sgx_enclave_add_page {
  73. __u64 addr;
  74. __u64 src;
  75. __u64 secinfo;
  76. __u16 mrmask;
  77. } __attribute__((packed));
  78. struct sgx_enclave_init {
  79. __u64 addr;
  80. __u64 sigstruct;
  81. __u64 einittoken;
  82. } __attribute__((packed));
  83. #endif /* _UAPI_ASM_X86_SGX_H */