sed-opal.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright © 2016 Intel Corporation
  4. *
  5. * Authors:
  6. * Rafael Antognolli <rafael.antognolli@intel.com>
  7. * Scott Bauer <scott.bauer@intel.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms and conditions of the GNU General Public License,
  11. * version 2, as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. */
  18. #ifndef _UAPI_SED_OPAL_H
  19. #define _UAPI_SED_OPAL_H
  20. #include <linux/types.h>
  21. #define OPAL_KEY_MAX 256
  22. #define OPAL_MAX_LRS 9
  23. enum opal_mbr {
  24. OPAL_MBR_ENABLE = 0x0,
  25. OPAL_MBR_DISABLE = 0x01,
  26. };
  27. enum opal_user {
  28. OPAL_ADMIN1 = 0x0,
  29. OPAL_USER1 = 0x01,
  30. OPAL_USER2 = 0x02,
  31. OPAL_USER3 = 0x03,
  32. OPAL_USER4 = 0x04,
  33. OPAL_USER5 = 0x05,
  34. OPAL_USER6 = 0x06,
  35. OPAL_USER7 = 0x07,
  36. OPAL_USER8 = 0x08,
  37. OPAL_USER9 = 0x09,
  38. };
  39. enum opal_lock_state {
  40. OPAL_RO = 0x01, /* 0001 */
  41. OPAL_RW = 0x02, /* 0010 */
  42. OPAL_LK = 0x04, /* 0100 */
  43. };
  44. struct opal_key {
  45. __u8 lr;
  46. __u8 key_len;
  47. __u8 __align[6];
  48. __u8 key[OPAL_KEY_MAX];
  49. };
  50. struct opal_lr_act {
  51. struct opal_key key;
  52. __u32 sum;
  53. __u8 num_lrs;
  54. __u8 lr[OPAL_MAX_LRS];
  55. __u8 align[2]; /* Align to 8 byte boundary */
  56. };
  57. struct opal_session_info {
  58. __u32 sum;
  59. __u32 who;
  60. struct opal_key opal_key;
  61. };
  62. struct opal_user_lr_setup {
  63. __u64 range_start;
  64. __u64 range_length;
  65. __u32 RLE; /* Read Lock enabled */
  66. __u32 WLE; /* Write Lock Enabled */
  67. struct opal_session_info session;
  68. };
  69. struct opal_lock_unlock {
  70. struct opal_session_info session;
  71. __u32 l_state;
  72. __u8 __align[4];
  73. };
  74. struct opal_new_pw {
  75. struct opal_session_info session;
  76. /* When we're not operating in sum, and we first set
  77. * passwords we need to set them via ADMIN authority.
  78. * After passwords are changed, we can set them via,
  79. * User authorities.
  80. * Because of this restriction we need to know about
  81. * Two different users. One in 'session' which we will use
  82. * to start the session and new_userr_pw as the user we're
  83. * chaning the pw for.
  84. */
  85. struct opal_session_info new_user_pw;
  86. };
  87. struct opal_mbr_data {
  88. struct opal_key key;
  89. __u8 enable_disable;
  90. __u8 __align[7];
  91. };
  92. #define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock)
  93. #define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock)
  94. #define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key)
  95. #define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_lr_act)
  96. #define IOC_OPAL_SET_PW _IOW('p', 224, struct opal_new_pw)
  97. #define IOC_OPAL_ACTIVATE_USR _IOW('p', 225, struct opal_session_info)
  98. #define IOC_OPAL_REVERT_TPR _IOW('p', 226, struct opal_key)
  99. #define IOC_OPAL_LR_SETUP _IOW('p', 227, struct opal_user_lr_setup)
  100. #define IOC_OPAL_ADD_USR_TO_LR _IOW('p', 228, struct opal_lock_unlock)
  101. #define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data)
  102. #define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info)
  103. #define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info)
  104. #endif /* _UAPI_SED_OPAL_H */