2017-11-01 14:09:13 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
2017-02-03 19:50:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Rafael Antognolli <rafael.antognolli@intel.com>
|
|
|
|
* Scott Bauer <scott.bauer@intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UAPI_SED_OPAL_H
|
|
|
|
#define _UAPI_SED_OPAL_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#define OPAL_KEY_MAX 256
|
|
|
|
#define OPAL_MAX_LRS 9
|
|
|
|
|
|
|
|
enum opal_mbr {
|
|
|
|
OPAL_MBR_ENABLE = 0x0,
|
|
|
|
OPAL_MBR_DISABLE = 0x01,
|
|
|
|
};
|
|
|
|
|
2019-05-21 20:46:44 +00:00
|
|
|
enum opal_mbr_done_flag {
|
|
|
|
OPAL_MBR_NOT_DONE = 0x0,
|
|
|
|
OPAL_MBR_DONE = 0x01
|
|
|
|
};
|
|
|
|
|
2017-02-03 19:50:30 +00:00
|
|
|
enum opal_user {
|
|
|
|
OPAL_ADMIN1 = 0x0,
|
|
|
|
OPAL_USER1 = 0x01,
|
|
|
|
OPAL_USER2 = 0x02,
|
|
|
|
OPAL_USER3 = 0x03,
|
|
|
|
OPAL_USER4 = 0x04,
|
|
|
|
OPAL_USER5 = 0x05,
|
|
|
|
OPAL_USER6 = 0x06,
|
|
|
|
OPAL_USER7 = 0x07,
|
|
|
|
OPAL_USER8 = 0x08,
|
|
|
|
OPAL_USER9 = 0x09,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum opal_lock_state {
|
|
|
|
OPAL_RO = 0x01, /* 0001 */
|
|
|
|
OPAL_RW = 0x02, /* 0010 */
|
|
|
|
OPAL_LK = 0x04, /* 0100 */
|
|
|
|
};
|
|
|
|
|
2022-12-06 09:29:13 +00:00
|
|
|
enum opal_lock_flags {
|
|
|
|
/* IOC_OPAL_SAVE will also store the provided key for locking */
|
|
|
|
OPAL_SAVE_FOR_LOCK = 0x01,
|
|
|
|
};
|
|
|
|
|
2017-02-03 19:50:30 +00:00
|
|
|
struct opal_key {
|
2017-02-07 00:22:49 +00:00
|
|
|
__u8 lr;
|
|
|
|
__u8 key_len;
|
|
|
|
__u8 __align[6];
|
|
|
|
__u8 key[OPAL_KEY_MAX];
|
2017-02-03 19:50:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct opal_lr_act {
|
|
|
|
struct opal_key key;
|
2017-02-07 00:22:49 +00:00
|
|
|
__u32 sum;
|
2019-02-14 00:15:54 +00:00
|
|
|
__u8 num_lrs;
|
2017-02-07 00:22:49 +00:00
|
|
|
__u8 lr[OPAL_MAX_LRS];
|
|
|
|
__u8 align[2]; /* Align to 8 byte boundary */
|
2017-02-03 19:50:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct opal_session_info {
|
2017-02-07 00:22:49 +00:00
|
|
|
__u32 sum;
|
|
|
|
__u32 who;
|
2017-02-03 19:50:30 +00:00
|
|
|
struct opal_key opal_key;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct opal_user_lr_setup {
|
2017-02-07 00:22:49 +00:00
|
|
|
__u64 range_start;
|
|
|
|
__u64 range_length;
|
|
|
|
__u32 RLE; /* Read Lock enabled */
|
|
|
|
__u32 WLE; /* Write Lock Enabled */
|
2017-02-03 19:50:30 +00:00
|
|
|
struct opal_session_info session;
|
|
|
|
};
|
|
|
|
|
2023-04-05 11:12:23 +00:00
|
|
|
struct opal_lr_status {
|
|
|
|
struct opal_session_info session;
|
|
|
|
__u64 range_start;
|
|
|
|
__u64 range_length;
|
|
|
|
__u32 RLE; /* Read Lock enabled */
|
|
|
|
__u32 WLE; /* Write Lock Enabled */
|
|
|
|
__u32 l_state;
|
|
|
|
__u8 align[4];
|
|
|
|
};
|
|
|
|
|
2017-02-03 19:50:30 +00:00
|
|
|
struct opal_lock_unlock {
|
|
|
|
struct opal_session_info session;
|
2017-02-07 00:22:49 +00:00
|
|
|
__u32 l_state;
|
2022-12-06 09:29:13 +00:00
|
|
|
__u16 flags;
|
|
|
|
__u8 __align[2];
|
2017-02-03 19:50:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct opal_new_pw {
|
|
|
|
struct opal_session_info session;
|
|
|
|
|
|
|
|
/* When we're not operating in sum, and we first set
|
|
|
|
* passwords we need to set them via ADMIN authority.
|
|
|
|
* After passwords are changed, we can set them via,
|
|
|
|
* User authorities.
|
|
|
|
* Because of this restriction we need to know about
|
|
|
|
* Two different users. One in 'session' which we will use
|
|
|
|
* to start the session and new_userr_pw as the user we're
|
|
|
|
* chaning the pw for.
|
|
|
|
*/
|
|
|
|
struct opal_session_info new_user_pw;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct opal_mbr_data {
|
|
|
|
struct opal_key key;
|
2017-02-07 00:22:49 +00:00
|
|
|
__u8 enable_disable;
|
|
|
|
__u8 __align[7];
|
2017-02-03 19:50:30 +00:00
|
|
|
};
|
|
|
|
|
2019-05-21 20:46:44 +00:00
|
|
|
struct opal_mbr_done {
|
|
|
|
struct opal_key key;
|
|
|
|
__u8 done_flag;
|
|
|
|
__u8 __align[7];
|
|
|
|
};
|
|
|
|
|
2019-05-21 20:46:45 +00:00
|
|
|
struct opal_shadow_mbr {
|
|
|
|
struct opal_key key;
|
|
|
|
const __u64 data;
|
|
|
|
__u64 offset;
|
|
|
|
__u64 size;
|
|
|
|
};
|
|
|
|
|
2019-10-31 16:13:21 +00:00
|
|
|
/* Opal table operations */
|
|
|
|
enum opal_table_ops {
|
|
|
|
OPAL_READ_TABLE,
|
|
|
|
OPAL_WRITE_TABLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define OPAL_UID_LENGTH 8
|
|
|
|
struct opal_read_write_table {
|
|
|
|
struct opal_key key;
|
|
|
|
const __u64 data;
|
|
|
|
const __u8 table_uid[OPAL_UID_LENGTH];
|
|
|
|
__u64 offset;
|
|
|
|
__u64 size;
|
|
|
|
#define OPAL_TABLE_READ (1 << OPAL_READ_TABLE)
|
|
|
|
#define OPAL_TABLE_WRITE (1 << OPAL_WRITE_TABLE)
|
|
|
|
__u64 flags;
|
|
|
|
__u64 priv;
|
|
|
|
};
|
|
|
|
|
2022-08-16 14:07:13 +00:00
|
|
|
#define OPAL_FL_SUPPORTED 0x00000001
|
|
|
|
#define OPAL_FL_LOCKING_SUPPORTED 0x00000002
|
|
|
|
#define OPAL_FL_LOCKING_ENABLED 0x00000004
|
|
|
|
#define OPAL_FL_LOCKED 0x00000008
|
|
|
|
#define OPAL_FL_MBR_ENABLED 0x00000010
|
|
|
|
#define OPAL_FL_MBR_DONE 0x00000020
|
2023-02-10 01:06:12 +00:00
|
|
|
#define OPAL_FL_SUM_SUPPORTED 0x00000040
|
2022-08-16 14:07:13 +00:00
|
|
|
|
|
|
|
struct opal_status {
|
|
|
|
__u32 flags;
|
|
|
|
__u32 reserved;
|
|
|
|
};
|
|
|
|
|
sed-opal: geometry feature reporting command
Locking range start and locking range length
attributes may be require to satisfy restrictions
exposed by OPAL2 geometry feature reporting.
Geometry reporting feature is described in TCG OPAL SSC,
section 3.1.1.4 (ALIGN, LogicalBlockSize, AlignmentGranularity
and LowestAlignedLBA).
4.3.5.2.1.1 RangeStart Behavior:
[ StartAlignment = (RangeStart modulo AlignmentGranularity) - LowestAlignedLBA ]
When processing a Set method or CreateRow method on the Locking
table for a non-Global Range row, if:
a) the AlignmentRequired (ALIGN above) column in the LockingInfo
table is TRUE;
b) RangeStart is non-zero; and
c) StartAlignment is non-zero, then the method SHALL fail and
return an error status code INVALID_PARAMETER.
4.3.5.2.1.2 RangeLength Behavior:
If RangeStart is zero, then
[ LengthAlignment = (RangeLength modulo AlignmentGranularity) - LowestAlignedLBA ]
If RangeStart is non-zero, then
[ LengthAlignment = (RangeLength modulo AlignmentGranularity) ]
When processing a Set method or CreateRow method on the Locking
table for a non-Global Range row, if:
a) the AlignmentRequired (ALIGN above) column in the LockingInfo
table is TRUE;
b) RangeLength is non-zero; and
c) LengthAlignment is non-zero, then the method SHALL fail and
return an error status code INVALID_PARAMETER
In userspace we stuck to logical block size reported by general
block device (via sysfs or ioctl), but we can not read
'AlignmentGranularity' or 'LowestAlignedLBA' anywhere else and
we need to get those values from sed-opal interface otherwise
we will not be able to report or avoid locking range setup
INVALID_PARAMETER errors above.
Signed-off-by: Ondrej Kozina <okozina@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Tested-by: Milan Broz <gmazyland@gmail.com>
Link: https://lore.kernel.org/r/20230411090931.9193-2-okozina@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-04-11 09:09:31 +00:00
|
|
|
/*
|
|
|
|
* Geometry Reporting per TCG Storage OPAL SSC
|
|
|
|
* section 3.1.1.4
|
|
|
|
*/
|
|
|
|
struct opal_geometry {
|
|
|
|
__u8 align;
|
|
|
|
__u32 logical_block_size;
|
|
|
|
__u64 alignment_granularity;
|
|
|
|
__u64 lowest_aligned_lba;
|
|
|
|
__u8 __align[3];
|
|
|
|
};
|
|
|
|
|
2017-02-03 19:50:30 +00:00
|
|
|
#define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock)
|
|
|
|
#define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock)
|
|
|
|
#define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key)
|
2017-02-15 00:29:35 +00:00
|
|
|
#define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_lr_act)
|
2017-02-03 19:50:30 +00:00
|
|
|
#define IOC_OPAL_SET_PW _IOW('p', 224, struct opal_new_pw)
|
|
|
|
#define IOC_OPAL_ACTIVATE_USR _IOW('p', 225, struct opal_session_info)
|
|
|
|
#define IOC_OPAL_REVERT_TPR _IOW('p', 226, struct opal_key)
|
|
|
|
#define IOC_OPAL_LR_SETUP _IOW('p', 227, struct opal_user_lr_setup)
|
|
|
|
#define IOC_OPAL_ADD_USR_TO_LR _IOW('p', 228, struct opal_lock_unlock)
|
|
|
|
#define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data)
|
|
|
|
#define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info)
|
|
|
|
#define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info)
|
2019-06-27 22:30:02 +00:00
|
|
|
#define IOC_OPAL_PSID_REVERT_TPR _IOW('p', 232, struct opal_key)
|
2019-05-21 20:46:44 +00:00
|
|
|
#define IOC_OPAL_MBR_DONE _IOW('p', 233, struct opal_mbr_done)
|
2019-05-21 20:46:45 +00:00
|
|
|
#define IOC_OPAL_WRITE_SHADOW_MBR _IOW('p', 234, struct opal_shadow_mbr)
|
2019-10-31 16:13:21 +00:00
|
|
|
#define IOC_OPAL_GENERIC_TABLE_RW _IOW('p', 235, struct opal_read_write_table)
|
2022-08-16 14:07:13 +00:00
|
|
|
#define IOC_OPAL_GET_STATUS _IOR('p', 236, struct opal_status)
|
2023-04-05 11:12:23 +00:00
|
|
|
#define IOC_OPAL_GET_LR_STATUS _IOW('p', 237, struct opal_lr_status)
|
sed-opal: geometry feature reporting command
Locking range start and locking range length
attributes may be require to satisfy restrictions
exposed by OPAL2 geometry feature reporting.
Geometry reporting feature is described in TCG OPAL SSC,
section 3.1.1.4 (ALIGN, LogicalBlockSize, AlignmentGranularity
and LowestAlignedLBA).
4.3.5.2.1.1 RangeStart Behavior:
[ StartAlignment = (RangeStart modulo AlignmentGranularity) - LowestAlignedLBA ]
When processing a Set method or CreateRow method on the Locking
table for a non-Global Range row, if:
a) the AlignmentRequired (ALIGN above) column in the LockingInfo
table is TRUE;
b) RangeStart is non-zero; and
c) StartAlignment is non-zero, then the method SHALL fail and
return an error status code INVALID_PARAMETER.
4.3.5.2.1.2 RangeLength Behavior:
If RangeStart is zero, then
[ LengthAlignment = (RangeLength modulo AlignmentGranularity) - LowestAlignedLBA ]
If RangeStart is non-zero, then
[ LengthAlignment = (RangeLength modulo AlignmentGranularity) ]
When processing a Set method or CreateRow method on the Locking
table for a non-Global Range row, if:
a) the AlignmentRequired (ALIGN above) column in the LockingInfo
table is TRUE;
b) RangeLength is non-zero; and
c) LengthAlignment is non-zero, then the method SHALL fail and
return an error status code INVALID_PARAMETER
In userspace we stuck to logical block size reported by general
block device (via sysfs or ioctl), but we can not read
'AlignmentGranularity' or 'LowestAlignedLBA' anywhere else and
we need to get those values from sed-opal interface otherwise
we will not be able to report or avoid locking range setup
INVALID_PARAMETER errors above.
Signed-off-by: Ondrej Kozina <okozina@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Tested-by: Milan Broz <gmazyland@gmail.com>
Link: https://lore.kernel.org/r/20230411090931.9193-2-okozina@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-04-11 09:09:31 +00:00
|
|
|
#define IOC_OPAL_GET_GEOMETRY _IOR('p', 238, struct opal_geometry)
|
2017-02-03 19:50:30 +00:00
|
|
|
|
|
|
|
#endif /* _UAPI_SED_OPAL_H */
|