graphene-sgx.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef _X86_GSGX_USER_H
  2. #define _X86_GSGX_USER_H
  3. #include <linux/ioctl.h>
  4. #include <linux/stddef.h>
  5. #include <linux/types.h>
  6. #include "isgx_version.h"
  7. #define GSGX_FILE "/dev/gsgx"
  8. #define GSGX_MINOR MISC_DYNAMIC_MINOR
  9. #if SDK_DRIVER_VERSION >= KERNEL_VERSION(1, 8, 0)
  10. #ifndef __packed
  11. #define __packed __attribute__((packed))
  12. #endif
  13. #if SDK_DRIVER_VERSION > KERNEL_VERSION(1, 8, 0)
  14. #include "linux-sgx-driver/sgx_user.h"
  15. #else // 1.8
  16. #include "linux-sgx-driver/isgx_user.h"
  17. #endif
  18. #else // SDK_DRIVER_VERSION < KERNEL_VERSION(1, 8, 0)
  19. #include "linux-sgx-driver/isgx_user.h"
  20. #define GSGX_IOCTL_ENCLAVE_CREATE _IOWR('p', 0x01, struct gsgx_enclave_create)
  21. #define GSGX_IOCTL_ENCLAVE_ADD_PAGES _IOW('p', 0x02, struct gsgx_enclave_add_pages)
  22. #define GSGX_IOCTL_ENCLAVE_INIT _IOW('p', 0x03, struct gsgx_enclave_init)
  23. #define GSGX_ENCLAVE_CREATE_NO_ADDR ((unsigned long) -1)
  24. struct gsgx_enclave_create {
  25. uint64_t src;
  26. };
  27. #define GSGX_ENCLAVE_ADD_PAGES_SKIP_EEXTEND 0x1
  28. #define GSGX_ENCLAVE_ADD_PAGES_REPEAT_SRC 0x2
  29. struct gsgx_enclave_add_pages {
  30. uint64_t flags;
  31. uint64_t addr;
  32. uint64_t user_addr;
  33. uint64_t size;
  34. uint64_t secinfo;
  35. };
  36. struct gsgx_enclave_init {
  37. uint64_t addr;
  38. uint64_t sigstruct;
  39. uint64_t einittoken;
  40. };
  41. #endif /* SDK_DRIVER_VERSION < KERNEL_VERSION(1, 8, 0) */
  42. #if SDK_DRIVER_VERSION == KERNEL_VERSION(1, 6, 0)
  43. #define SGX_SUCCESS ISGX_SUCCESS
  44. #define SGX_INVALID_SIG_STRUCT ISGX_INVALID_SIG_STRUCT
  45. #define SGX_INVALID_ATTRIBUTE ISGX_INVALID_ATTRIBUTE
  46. #define SGX_BLKSTATE ISGX_BLKSTATE
  47. #define SGX_INVALID_MEASUREMENT ISGX_INVALID_MEASUREMENT
  48. #define SGX_NOTBLOCKABLE ISGX_NOTBLOCKABLE
  49. #define SGX_PG_INVLD ISGX_PG_INVLD
  50. #define SGX_LOCKFAIL ISGX_LOCKFAIL
  51. #define SGX_INVALID_SIGNATURE ISGX_INVALID_SIGNATURE
  52. #define SGX_MAC_COMPARE_FAIL ISGX_MAC_COMPARE_FAIL
  53. #define SGX_PAGE_NOT_BLOCKED ISGX_PAGE_NOT_BLOCKED
  54. #define SGX_NOT_TRACKED ISGX_NOT_TRACKED
  55. #define SGX_VA_SLOT_OCCUPIED ISGX_VA_SLOT_OCCUPIED
  56. #define SGX_CHILD_PRESENT ISGX_CHILD_PRESENT
  57. #define SGX_ENCLAVE_ACT ISGX_ENCLAVE_ACT
  58. #define SGX_ENTRYEPOCH_LOCKED ISGX_ENTRYEPOCH_LOCKED
  59. #define SGX_INVALID_LICENSE ISGX_INVALID_LICENSE
  60. #define SGX_PREV_TRK_INCMPL ISGX_PREV_TRK_INCMPL
  61. #define SGX_PG_IS_SECS ISGX_PG_IS_SECS
  62. #define SGX_INVALID_CPUSVN ISGX_INVALID_CPUSVN
  63. #define SGX_INVALID_ISVSVN ISGX_INVALID_ISVSVN
  64. #define SGX_UNMASKED_EVENT ISGX_UNMASKED_EVENT
  65. #define SGX_INVALID_KEYNAME ISGX_INVALID_KEYNAME
  66. #define SGX_POWER_LOST_ENCLAVE ISGX_POWER_LOST_ENCLAVE
  67. #define SGX_LE_ROLLBACK ISGX_LE_ROLLBACK
  68. #endif
  69. #endif /* _X86_GSGX_USER_H */