uvdevice.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright IBM Corp. 2022
  4. * Author(s): Steffen Eiden <seiden@linux.ibm.com>
  5. */
  6. #ifndef __S390_ASM_UVDEVICE_H
  7. #define __S390_ASM_UVDEVICE_H
  8. #include <linux/types.h>
  9. struct uvio_ioctl_cb {
  10. __u32 flags;
  11. __u16 uv_rc; /* UV header rc value */
  12. __u16 uv_rrc; /* UV header rrc value */
  13. __u64 argument_addr; /* Userspace address of uvio argument */
  14. __u32 argument_len;
  15. __u8 reserved14[0x40 - 0x14]; /* must be zero */
  16. };
  17. #define UVIO_ATT_USER_DATA_LEN 0x100
  18. #define UVIO_ATT_UID_LEN 0x10
  19. struct uvio_attest {
  20. __u64 arcb_addr; /* 0x0000 */
  21. __u64 meas_addr; /* 0x0008 */
  22. __u64 add_data_addr; /* 0x0010 */
  23. __u8 user_data[UVIO_ATT_USER_DATA_LEN]; /* 0x0018 */
  24. __u8 config_uid[UVIO_ATT_UID_LEN]; /* 0x0118 */
  25. __u32 arcb_len; /* 0x0128 */
  26. __u32 meas_len; /* 0x012c */
  27. __u32 add_data_len; /* 0x0130 */
  28. __u16 user_data_len; /* 0x0134 */
  29. __u16 reserved136; /* 0x0136 */
  30. };
  31. /**
  32. * uvio_uvdev_info - Information of supported functions
  33. * @supp_uvio_cmds - supported IOCTLs by this device
  34. * @supp_uv_cmds - supported UVCs corresponding to the IOCTL
  35. *
  36. * UVIO request to get information about supported request types by this
  37. * uvdevice and the Ultravisor. Everything is output. Bits are in LSB0
  38. * ordering. If the bit is set in both, @supp_uvio_cmds and @supp_uv_cmds, the
  39. * uvdevice and the Ultravisor support that call.
  40. *
  41. * Note that bit 0 (UVIO_IOCTL_UVDEV_INFO_NR) is always zero for `supp_uv_cmds`
  42. * as there is no corresponding UV-call.
  43. */
  44. struct uvio_uvdev_info {
  45. /*
  46. * If bit `n` is set, this device supports the IOCTL with nr `n`.
  47. */
  48. __u64 supp_uvio_cmds;
  49. /*
  50. * If bit `n` is set, the Ultravisor(UV) supports the UV-call
  51. * corresponding to the IOCTL with nr `n` in the calling contextx (host
  52. * or guest). The value is only valid if the corresponding bit in
  53. * @supp_uvio_cmds is set as well.
  54. */
  55. __u64 supp_uv_cmds;
  56. };
  57. /*
  58. * The following max values define an upper length for the IOCTL in/out buffers.
  59. * However, they do not represent the maximum the Ultravisor allows which is
  60. * often way smaller. By allowing larger buffer sizes we hopefully do not need
  61. * to update the code with every machine update. It is therefore possible for
  62. * userspace to request more memory than actually used by kernel/UV.
  63. */
  64. #define UVIO_ATT_ARCB_MAX_LEN 0x100000
  65. #define UVIO_ATT_MEASUREMENT_MAX_LEN 0x8000
  66. #define UVIO_ATT_ADDITIONAL_MAX_LEN 0x8000
  67. #define UVIO_ADD_SECRET_MAX_LEN 0x100000
  68. #define UVIO_LIST_SECRETS_LEN 0x1000
  69. #define UVIO_DEVICE_NAME "uv"
  70. #define UVIO_TYPE_UVC 'u'
  71. enum UVIO_IOCTL_NR {
  72. UVIO_IOCTL_UVDEV_INFO_NR = 0x00,
  73. UVIO_IOCTL_ATT_NR,
  74. UVIO_IOCTL_ADD_SECRET_NR,
  75. UVIO_IOCTL_LIST_SECRETS_NR,
  76. UVIO_IOCTL_LOCK_SECRETS_NR,
  77. /* must be the last entry */
  78. UVIO_IOCTL_NUM_IOCTLS
  79. };
  80. #define UVIO_IOCTL(nr) _IOWR(UVIO_TYPE_UVC, nr, struct uvio_ioctl_cb)
  81. #define UVIO_IOCTL_UVDEV_INFO UVIO_IOCTL(UVIO_IOCTL_UVDEV_INFO_NR)
  82. #define UVIO_IOCTL_ATT UVIO_IOCTL(UVIO_IOCTL_ATT_NR)
  83. #define UVIO_IOCTL_ADD_SECRET UVIO_IOCTL(UVIO_IOCTL_ADD_SECRET_NR)
  84. #define UVIO_IOCTL_LIST_SECRETS UVIO_IOCTL(UVIO_IOCTL_LIST_SECRETS_NR)
  85. #define UVIO_IOCTL_LOCK_SECRETS UVIO_IOCTL(UVIO_IOCTL_LOCK_SECRETS_NR)
  86. #define UVIO_SUPP_CALL(nr) (1ULL << (nr))
  87. #define UVIO_SUPP_UDEV_INFO UVIO_SUPP_CALL(UVIO_IOCTL_UDEV_INFO_NR)
  88. #define UVIO_SUPP_ATT UVIO_SUPP_CALL(UVIO_IOCTL_ATT_NR)
  89. #define UVIO_SUPP_ADD_SECRET UVIO_SUPP_CALL(UVIO_IOCTL_ADD_SECRET_NR)
  90. #define UVIO_SUPP_LIST_SECRETS UVIO_SUPP_CALL(UVIO_IOCTL_LIST_SECRETS_NR)
  91. #define UVIO_SUPP_LOCK_SECRETS UVIO_SUPP_CALL(UVIO_IOCTL_LOCK_SECRETS_NR)
  92. #endif /* __S390_ASM_UVDEVICE_H */