graphene-sgx.h 2.4 KB

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