isgx_user.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2011-2016 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 _X86_ISGX_USER_H
  32. #define _X86_ISGX_USER_H
  33. #include <linux/ioctl.h>
  34. #include <linux/stddef.h>
  35. #include <linux/types.h>
  36. #define ISGX_IOCTL_ENCLAVE_CREATE _IOWR('p', 0x02, struct isgx_create_param)
  37. #define ISGX_IOCTL_ENCLAVE_ADD_PAGE _IOW('p', 0x03, struct isgx_add_param)
  38. #define ISGX_IOCTL_ENCLAVE_INIT _IOW('p', 0x04, struct isgx_init_param)
  39. #define ISGX_IOCTL_ENCLAVE_DESTROY _IOW('p', 0x06, struct isgx_destroy_param)
  40. #define SECS_SIZE_OFFSET 0
  41. #define SECS_BASE_OFFSET (SECS_SIZE_OFFSET + 8)
  42. #define SECS_FLAGS_OFFSET (SECS_BASE_OFFSET + 8)
  43. #define SECS_SSAFRAMESIZE_OFFSET (SECS_SIZE_OFFSET + 164)
  44. /* SGX leaf instruction return values */
  45. #define ISGX_SUCCESS 0
  46. #define ISGX_ERROR -1
  47. #define ISGX_INVALID_SIG_STRUCT 0x1
  48. #define ISGX_INVALID_ATTRIBUTE 0x2
  49. #define ISGX_INVALID_MEASUREMENT 0x4
  50. #define ISGX_INVALID_SIGNATIRE 0x8
  51. #define ISGX_INVALID_LAUNCH_TOKEN 0x10
  52. #define ISGX_INVALID_CPUSVN 0x20
  53. #define ISGX_INVALID_ISVSVN 0x40
  54. #define ISGX_UNMASKED_EVENT 0x80
  55. #define ISGX_INVALID_KEYNAME 0x100
  56. /* IOCTL return values */
  57. #define ISGX_OUT_OF_EPC_PAGES 0xc0000001
  58. #define ISGX_POWER_LOST_ENCLAVE 0xc0000002
  59. /* SECINFO flags */
  60. #define ISGX_SECINFO_R 0x1 /* Read Access */
  61. #define ISGX_SECINFO_W 0x2 /* Write Access */
  62. #define ISGX_SECINFO_X 0x4 /* Execute Access */
  63. #define ISGX_SECINFO_SECS 0x000 /* SECS */
  64. #define ISGX_SECINFO_TCS 0x100 /* TCS */
  65. #define ISGX_SECINFO_REG 0x200 /* Regular Page */
  66. struct isgx_secinfo {
  67. __u64 flags;
  68. __u64 reserved[7];
  69. };
  70. struct isgx_create_param {
  71. void *secs;
  72. unsigned long addr;
  73. };
  74. #define ISGX_ADD_SKIP_EEXTEND 0x1
  75. struct isgx_add_param {
  76. unsigned long addr;
  77. unsigned long user_addr;
  78. void *secinfo;
  79. unsigned int flags;
  80. };
  81. struct isgx_init_param {
  82. unsigned long addr;
  83. void *sigstruct;
  84. void *einittoken;
  85. };
  86. struct isgx_destroy_param {
  87. unsigned long addr;
  88. };
  89. #endif /* _X86_ISGX_USER_H */