linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write
@ 2019-05-21 20:46 David Kozub
  2019-05-21 20:46 ` [PATCH v2 1/3] block: sed-opal: add ioctl for done-mark of shadow mbr David Kozub
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: David Kozub @ 2019-05-21 20:46 UTC (permalink / raw)
  To: Jens Axboe, Jonathan Derrick, Scott Bauer, linux-block, linux-kernel
  Cc: Jonas Rabenstein

This patch series extends SED Opal support: it adds IOCTL for setting the shadow
MBR done flag which can be useful for unlocking an Opal disk on boot and it adds
IOCTL for writing to the shadow MBR.

This applies on current master.

I successfully tested toggling the MBR done flag and writing the shadow MBR
using some tools I hacked together[1] with a Samsung SSD 850 EVO drive.

Changes from v1:
* PATCH 2/3: remove check with access_ok, just rely on copy_from_user as
suggested in [2] (I tested passing data == 0 and I got the expected EFAULT)

[1] https://gitlab.com/zub2/opalctl
[2] https://lore.kernel.org/lkml/20190501134833.GB24132@infradead.org/

Jonas Rabenstein (3):
  block: sed-opal: add ioctl for done-mark of shadow mbr
  block: sed-opal: ioctl for writing to shadow mbr
  block: sed-opal: check size of shadow mbr

 block/opal_proto.h            |  16 ++++
 block/sed-opal.c              | 157 +++++++++++++++++++++++++++++++++-
 include/linux/sed-opal.h      |   2 +
 include/uapi/linux/sed-opal.h |  20 +++++
 4 files changed, 193 insertions(+), 2 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/3] block: sed-opal: add ioctl for done-mark of shadow mbr
  2019-05-21 20:46 [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write David Kozub
@ 2019-05-21 20:46 ` David Kozub
  2019-05-21 20:46 ` [PATCH v2 2/3] block: sed-opal: ioctl for writing to " David Kozub
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: David Kozub @ 2019-05-21 20:46 UTC (permalink / raw)
  To: Jens Axboe, Jonathan Derrick, Scott Bauer, linux-block, linux-kernel
  Cc: Jonas Rabenstein

From: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>

Enable users to mark the shadow mbr as done without completely
deactivating the shadow mbr feature. This may be useful on reboots,
when the power to the disk is not disconnected in between and the shadow
mbr stores the required boot files. Of course, this saves also the
(few) commands required to enable the feature if it is already enabled
and one only wants to mark the shadow mbr as done.

Co-authored-by: David Kozub <zub@linux.fjfi.cvut.cz>
Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed by: Scott Bauer <sbauer@plzdonthack.me>
Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>
---
 block/sed-opal.c              | 27 +++++++++++++++++++++++++++
 include/linux/sed-opal.h      |  1 +
 include/uapi/linux/sed-opal.h | 12 ++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/block/sed-opal.c b/block/sed-opal.c
index a46e8d13e16d..a330fc67f3a3 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -1978,6 +1978,30 @@ static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
 	return ret;
 }
 
+static int opal_set_mbr_done(struct opal_dev *dev,
+			     struct opal_mbr_done *mbr_done)
+{
+	u8 mbr_done_tf = mbr_done->done_flag == OPAL_MBR_DONE ?
+		OPAL_TRUE : OPAL_FALSE;
+
+	const struct opal_step mbr_steps[] = {
+		{ start_admin1LSP_opal_session, &mbr_done->key },
+		{ set_mbr_done, &mbr_done_tf },
+		{ end_opal_session, }
+	};
+	int ret;
+
+	if (mbr_done->done_flag != OPAL_MBR_DONE &&
+	    mbr_done->done_flag != OPAL_MBR_NOT_DONE)
+		return -EINVAL;
+
+	mutex_lock(&dev->dev_lock);
+	setup_opal_dev(dev);
+	ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
+	mutex_unlock(&dev->dev_lock);
+	return ret;
+}
+
 static int opal_save(struct opal_dev *dev, struct opal_lock_unlock *lk_unlk)
 {
 	struct opal_suspend_data *suspend;
@@ -2291,6 +2315,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
 	case IOC_OPAL_ENABLE_DISABLE_MBR:
 		ret = opal_enable_disable_shadow_mbr(dev, p);
 		break;
+	case IOC_OPAL_MBR_DONE:
+		ret = opal_set_mbr_done(dev, p);
+		break;
 	case IOC_OPAL_ERASE_LR:
 		ret = opal_erase_locking_range(dev, p);
 		break;
diff --git a/include/linux/sed-opal.h b/include/linux/sed-opal.h
index 3e76b6d7d97f..111dd893d45a 100644
--- a/include/linux/sed-opal.h
+++ b/include/linux/sed-opal.h
@@ -39,6 +39,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
 	case IOC_OPAL_ENABLE_DISABLE_MBR:
 	case IOC_OPAL_ERASE_LR:
 	case IOC_OPAL_SECURE_ERASE_LR:
+	case IOC_OPAL_MBR_DONE:
 		return true;
 	}
 	return false;
diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h
index 33e53b80cd1f..bd29fab60ef4 100644
--- a/include/uapi/linux/sed-opal.h
+++ b/include/uapi/linux/sed-opal.h
@@ -20,6 +20,11 @@ enum opal_mbr {
 	OPAL_MBR_DISABLE = 0x01,
 };
 
+enum opal_mbr_done_flag {
+	OPAL_MBR_NOT_DONE = 0x0,
+	OPAL_MBR_DONE = 0x01
+};
+
 enum opal_user {
 	OPAL_ADMIN1 = 0x0,
 	OPAL_USER1 = 0x01,
@@ -95,6 +100,12 @@ struct opal_mbr_data {
 	__u8 __align[7];
 };
 
+struct opal_mbr_done {
+	struct opal_key key;
+	__u8 done_flag;
+	__u8 __align[7];
+};
+
 #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)
@@ -107,5 +118,6 @@ struct opal_mbr_data {
 #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)
+#define IOC_OPAL_MBR_DONE           _IOW('p', 232, struct opal_mbr_done)
 
 #endif /* _UAPI_SED_OPAL_H */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/3] block: sed-opal: ioctl for writing to shadow mbr
  2019-05-21 20:46 [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write David Kozub
  2019-05-21 20:46 ` [PATCH v2 1/3] block: sed-opal: add ioctl for done-mark of shadow mbr David Kozub
@ 2019-05-21 20:46 ` David Kozub
  2019-05-21 20:46 ` [PATCH v2 3/3] block: sed-opal: check size of " David Kozub
  2019-06-25 20:47 ` [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write Derrick, Jonathan
  3 siblings, 0 replies; 10+ messages in thread
From: David Kozub @ 2019-05-21 20:46 UTC (permalink / raw)
  To: Jens Axboe, Jonathan Derrick, Scott Bauer, linux-block, linux-kernel
  Cc: Jonas Rabenstein

From: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>

Allow modification of the shadow mbr. If the shadow mbr is not marked as
done, this data will be presented read only as the device content. Only
after marking the shadow mbr as done and unlocking a locking range the
actual content is accessible.

Co-authored-by: David Kozub <zub@linux.fjfi.cvut.cz>
Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>
Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>
---
 block/sed-opal.c              | 91 ++++++++++++++++++++++++++++++++++-
 include/linux/sed-opal.h      |  1 +
 include/uapi/linux/sed-opal.h |  8 +++
 3 files changed, 98 insertions(+), 2 deletions(-)

diff --git a/block/sed-opal.c b/block/sed-opal.c
index a330fc67f3a3..c13ac0ebd5e0 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -26,6 +26,9 @@
 #define IO_BUFFER_LENGTH 2048
 #define MAX_TOKS 64
 
+/* Number of bytes needed by cmd_finalize. */
+#define CMD_FINALIZE_BYTES_NEEDED 7
+
 struct opal_step {
 	int (*fn)(struct opal_dev *dev, void *data);
 	void *data;
@@ -523,12 +526,17 @@ static int opal_discovery0_step(struct opal_dev *dev)
 	return execute_step(dev, &discovery0_step, 0);
 }
 
+static size_t remaining_size(struct opal_dev *cmd)
+{
+	return IO_BUFFER_LENGTH - cmd->pos;
+}
+
 static bool can_add(int *err, struct opal_dev *cmd, size_t len)
 {
 	if (*err)
 		return false;
 
-	if (len > IO_BUFFER_LENGTH || cmd->pos > IO_BUFFER_LENGTH - len) {
+	if (remaining_size(cmd) < len) {
 		pr_debug("Error adding %zu bytes: end of buffer.\n", len);
 		*err = -ERANGE;
 		return false;
@@ -674,7 +682,11 @@ static int cmd_finalize(struct opal_dev *cmd, u32 hsn, u32 tsn)
 	struct opal_header *hdr;
 	int err = 0;
 
-	/* close the parameter list opened from cmd_start */
+	/*
+	 * Close the parameter list opened from cmd_start.
+	 * The number of bytes added must be equal to
+	 * CMD_FINALIZE_BYTES_NEEDED.
+	 */
 	add_token_u8(&err, cmd, OPAL_ENDLIST);
 
 	add_token_u8(&err, cmd, OPAL_ENDOFDATA);
@@ -1525,6 +1537,58 @@ static int set_mbr_enable_disable(struct opal_dev *dev, void *data)
 	return finalize_and_send(dev, parse_and_check_status);
 }
 
+static int write_shadow_mbr(struct opal_dev *dev, void *data)
+{
+	struct opal_shadow_mbr *shadow = data;
+	const u8 __user *src;
+	u8 *dst;
+	size_t off = 0;
+	u64 len;
+	int err = 0;
+
+	/* do the actual transmission(s) */
+	src = (u8 __user *)(uintptr_t)shadow->data;
+	while (off < shadow->size) {
+		err = cmd_start(dev, opaluid[OPAL_MBR], opalmethod[OPAL_SET]);
+		add_token_u8(&err, dev, OPAL_STARTNAME);
+		add_token_u8(&err, dev, OPAL_WHERE);
+		add_token_u64(&err, dev, shadow->offset + off);
+		add_token_u8(&err, dev, OPAL_ENDNAME);
+
+		add_token_u8(&err, dev, OPAL_STARTNAME);
+		add_token_u8(&err, dev, OPAL_VALUES);
+
+		/*
+		 * The bytestring header is either 1 or 2 bytes, so assume 2.
+		 * There also needs to be enough space to accommodate the
+		 * trailing OPAL_ENDNAME (1 byte) and tokens added by
+		 * cmd_finalize.
+		 */
+		len = min(remaining_size(dev) - (2+1+CMD_FINALIZE_BYTES_NEEDED),
+			  (size_t)(shadow->size - off));
+		pr_debug("MBR: write bytes %zu+%llu/%llu\n",
+			 off, len, shadow->size);
+
+		dst = add_bytestring_header(&err, dev, len);
+		if (!dst)
+			break;
+		if (copy_from_user(dst, src + off, len))
+			err = -EFAULT;
+		dev->pos += len;
+
+		add_token_u8(&err, dev, OPAL_ENDNAME);
+		if (err)
+			break;
+
+		err = finalize_and_send(dev, parse_and_check_status);
+		if (err)
+			break;
+
+		off += len;
+	}
+	return err;
+}
+
 static int generic_pw_cmd(u8 *key, size_t key_len, u8 *cpin_uid,
 			  struct opal_dev *dev)
 {
@@ -2002,6 +2066,26 @@ static int opal_set_mbr_done(struct opal_dev *dev,
 	return ret;
 }
 
+static int opal_write_shadow_mbr(struct opal_dev *dev,
+				 struct opal_shadow_mbr *info)
+{
+	const struct opal_step mbr_steps[] = {
+		{ start_admin1LSP_opal_session, &info->key },
+		{ write_shadow_mbr, info },
+		{ end_opal_session, }
+	};
+	int ret;
+
+	if (info->size == 0)
+		return 0;
+
+	mutex_lock(&dev->dev_lock);
+	setup_opal_dev(dev);
+	ret = execute_steps(dev, mbr_steps, ARRAY_SIZE(mbr_steps));
+	mutex_unlock(&dev->dev_lock);
+	return ret;
+}
+
 static int opal_save(struct opal_dev *dev, struct opal_lock_unlock *lk_unlk)
 {
 	struct opal_suspend_data *suspend;
@@ -2318,6 +2402,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
 	case IOC_OPAL_MBR_DONE:
 		ret = opal_set_mbr_done(dev, p);
 		break;
+	case IOC_OPAL_WRITE_SHADOW_MBR:
+		ret = opal_write_shadow_mbr(dev, p);
+		break;
 	case IOC_OPAL_ERASE_LR:
 		ret = opal_erase_locking_range(dev, p);
 		break;
diff --git a/include/linux/sed-opal.h b/include/linux/sed-opal.h
index 111dd893d45a..d7993be280db 100644
--- a/include/linux/sed-opal.h
+++ b/include/linux/sed-opal.h
@@ -40,6 +40,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
 	case IOC_OPAL_ERASE_LR:
 	case IOC_OPAL_SECURE_ERASE_LR:
 	case IOC_OPAL_MBR_DONE:
+	case IOC_OPAL_WRITE_SHADOW_MBR:
 		return true;
 	}
 	return false;
diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h
index bd29fab60ef4..e204b1f8e8b8 100644
--- a/include/uapi/linux/sed-opal.h
+++ b/include/uapi/linux/sed-opal.h
@@ -106,6 +106,13 @@ struct opal_mbr_done {
 	__u8 __align[7];
 };
 
+struct opal_shadow_mbr {
+	struct opal_key key;
+	const __u64 data;
+	__u64 offset;
+	__u64 size;
+};
+
 #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)
@@ -119,5 +126,6 @@ struct opal_mbr_done {
 #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)
 #define IOC_OPAL_MBR_DONE           _IOW('p', 232, struct opal_mbr_done)
+#define IOC_OPAL_WRITE_SHADOW_MBR   _IOW('p', 233, struct opal_shadow_mbr)
 
 #endif /* _UAPI_SED_OPAL_H */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/3] block: sed-opal: check size of shadow mbr
  2019-05-21 20:46 [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write David Kozub
  2019-05-21 20:46 ` [PATCH v2 1/3] block: sed-opal: add ioctl for done-mark of shadow mbr David Kozub
  2019-05-21 20:46 ` [PATCH v2 2/3] block: sed-opal: ioctl for writing to " David Kozub
@ 2019-05-21 20:46 ` David Kozub
  2019-06-25 20:47 ` [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write Derrick, Jonathan
  3 siblings, 0 replies; 10+ messages in thread
From: David Kozub @ 2019-05-21 20:46 UTC (permalink / raw)
  To: Jens Axboe, Jonathan Derrick, Scott Bauer, linux-block, linux-kernel
  Cc: Jonas Rabenstein

From: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>

Check whether the shadow mbr does fit in the provided space on the
target. Also a proper firmware should handle this case and return an
error we may prevent problems or even damage with crappy firmwares.

Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Reviewed-by: Scott Bauer <sbauer@plzdonthack.me>
Reviewed-by: Jon Derrick <jonathan.derrick@intel.com>
---
 block/opal_proto.h | 16 ++++++++++++++++
 block/sed-opal.c   | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/block/opal_proto.h b/block/opal_proto.h
index d9a05ad02eb5..466ec7be16ef 100644
--- a/block/opal_proto.h
+++ b/block/opal_proto.h
@@ -98,6 +98,7 @@ enum opal_uid {
 	OPAL_ENTERPRISE_BANDMASTER0_UID,
 	OPAL_ENTERPRISE_ERASEMASTER_UID,
 	/* tables */
+	OPAL_TABLE_TABLE,
 	OPAL_LOCKINGRANGE_GLOBAL,
 	OPAL_LOCKINGRANGE_ACE_RDLOCKED,
 	OPAL_LOCKINGRANGE_ACE_WRLOCKED,
@@ -152,6 +153,21 @@ enum opal_token {
 	OPAL_STARTCOLUMN = 0x03,
 	OPAL_ENDCOLUMN = 0x04,
 	OPAL_VALUES = 0x01,
+	/* table table */
+	OPAL_TABLE_UID = 0x00,
+	OPAL_TABLE_NAME = 0x01,
+	OPAL_TABLE_COMMON = 0x02,
+	OPAL_TABLE_TEMPLATE = 0x03,
+	OPAL_TABLE_KIND = 0x04,
+	OPAL_TABLE_COLUMN = 0x05,
+	OPAL_TABLE_COLUMNS = 0x06,
+	OPAL_TABLE_ROWS = 0x07,
+	OPAL_TABLE_ROWS_FREE = 0x08,
+	OPAL_TABLE_ROW_BYTES = 0x09,
+	OPAL_TABLE_LASTID = 0x0A,
+	OPAL_TABLE_MIN = 0x0B,
+	OPAL_TABLE_MAX = 0x0C,
+
 	/* authority table */
 	OPAL_PIN = 0x03,
 	/* locking tokens */
diff --git a/block/sed-opal.c b/block/sed-opal.c
index c13ac0ebd5e0..87300918eae2 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -130,6 +130,8 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = {
 
 	/* tables */
 
+	[OPAL_TABLE_TABLE]
+		{ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01 },
 	[OPAL_LOCKINGRANGE_GLOBAL] =
 		{ 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x01 },
 	[OPAL_LOCKINGRANGE_ACE_RDLOCKED] =
@@ -1131,6 +1133,29 @@ static int generic_get_column(struct opal_dev *dev, const u8 *table,
 	return finalize_and_send(dev, parse_and_check_status);
 }
 
+/*
+ * see TCG SAS 5.3.2.3 for a description of the available columns
+ *
+ * the result is provided in dev->resp->tok[4]
+ */
+static int generic_get_table_info(struct opal_dev *dev, enum opal_uid table,
+				  u64 column)
+{
+	u8 uid[OPAL_UID_LENGTH];
+	const unsigned int half = OPAL_UID_LENGTH/2;
+
+	/* sed-opal UIDs can be split in two halves:
+	 *  first:  actual table index
+	 *  second: relative index in the table
+	 * so we have to get the first half of the OPAL_TABLE_TABLE and use the
+	 * first part of the target table as relative index into that table
+	 */
+	memcpy(uid, opaluid[OPAL_TABLE_TABLE], half);
+	memcpy(uid+half, opaluid[table], half);
+
+	return generic_get_column(dev, uid, column);
+}
+
 static int gen_key(struct opal_dev *dev, void *data)
 {
 	u8 uid[OPAL_UID_LENGTH];
@@ -1546,6 +1571,20 @@ static int write_shadow_mbr(struct opal_dev *dev, void *data)
 	u64 len;
 	int err = 0;
 
+	/* do we fit in the available shadow mbr space? */
+	err = generic_get_table_info(dev, OPAL_MBR, OPAL_TABLE_ROWS);
+	if (err) {
+		pr_debug("MBR: could not get shadow size\n");
+		return err;
+	}
+
+	len = response_get_u64(&dev->parsed, 4);
+	if (shadow->size > len || shadow->offset > len - shadow->size) {
+		pr_debug("MBR: does not fit in shadow (%llu vs. %llu)\n",
+			 shadow->offset + shadow->size, len);
+		return -ENOSPC;
+	}
+
 	/* do the actual transmission(s) */
 	src = (u8 __user *)(uintptr_t)shadow->data;
 	while (off < shadow->size) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write
  2019-05-21 20:46 [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write David Kozub
                   ` (2 preceding siblings ...)
  2019-05-21 20:46 ` [PATCH v2 3/3] block: sed-opal: check size of " David Kozub
@ 2019-06-25 20:47 ` Derrick, Jonathan
  2019-06-29 16:19   ` Scott Bauer
  3 siblings, 1 reply; 10+ messages in thread
From: Derrick, Jonathan @ 2019-06-25 20:47 UTC (permalink / raw)
  To: linux-kernel, zub, linux-block, sbauer, axboe; +Cc: jonas.rabenstein

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

These are still good with me and we'll likely have a similar future use
for passing data through the ioctl.

Could we get this staged for 5.3?

On Tue, 2019-05-21 at 22:46 +0200, David Kozub wrote:
> This patch series extends SED Opal support: it adds IOCTL for setting the shadow
> MBR done flag which can be useful for unlocking an Opal disk on boot and it adds
> IOCTL for writing to the shadow MBR.
> 
> This applies on current master.
> 
> I successfully tested toggling the MBR done flag and writing the shadow MBR
> using some tools I hacked together[1] with a Samsung SSD 850 EVO drive.
> 
> Changes from v1:
> * PATCH 2/3: remove check with access_ok, just rely on copy_from_user as
> suggested in [2] (I tested passing data == 0 and I got the expected EFAULT)
> 
> [1] https://gitlab.com/zub2/opalctl
> [2] https://lore.kernel.org/lkml/20190501134833.GB24132@infradead.org/
> 
> Jonas Rabenstein (3):
>   block: sed-opal: add ioctl for done-mark of shadow mbr
>   block: sed-opal: ioctl for writing to shadow mbr
>   block: sed-opal: check size of shadow mbr
> 
>  block/opal_proto.h            |  16 ++++
>  block/sed-opal.c              | 157 +++++++++++++++++++++++++++++++++-
>  include/linux/sed-opal.h      |   2 +
>  include/uapi/linux/sed-opal.h |  20 +++++
>  4 files changed, 193 insertions(+), 2 deletions(-)
> 

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3278 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write
  2019-06-25 20:47 ` [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write Derrick, Jonathan
@ 2019-06-29 16:19   ` Scott Bauer
  2019-06-29 16:26     ` Jens Axboe
  0 siblings, 1 reply; 10+ messages in thread
From: Scott Bauer @ 2019-06-29 16:19 UTC (permalink / raw)
  To: axboe; +Cc: jonathan.derrick, linux-kernel, zub, linux-block, jonas.rabenstein


Hey Jens,

Can you please stage these for 5.3 aswell?


On Tue, Jun 25, 2019 at 08:47:26PM +0000, Derrick, Jonathan wrote:
> These are still good with me and we'll likely have a similar future use
> for passing data through the ioctl.
> 
> Could we get this staged for 5.3?
> 
> On Tue, 2019-05-21 at 22:46 +0200, David Kozub wrote:
> > This patch series extends SED Opal support: it adds IOCTL for setting the shadow
> > MBR done flag which can be useful for unlocking an Opal disk on boot and it adds
> > IOCTL for writing to the shadow MBR.
> > 
> > This applies on current master.
> > 
> > I successfully tested toggling the MBR done flag and writing the shadow MBR
> > using some tools I hacked together[1] with a Samsung SSD 850 EVO drive.
> > 
> > Changes from v1:
> > * PATCH 2/3: remove check with access_ok, just rely on copy_from_user as
> > suggested in [2] (I tested passing data == 0 and I got the expected EFAULT)
> > 
> > [1] https://gitlab.com/zub2/opalctl
> > [2] https://lore.kernel.org/lkml/20190501134833.GB24132@infradead.org/
> > 
> > Jonas Rabenstein (3):
> >   block: sed-opal: add ioctl for done-mark of shadow mbr
> >   block: sed-opal: ioctl for writing to shadow mbr
> >   block: sed-opal: check size of shadow mbr
> > 
> >  block/opal_proto.h            |  16 ++++
> >  block/sed-opal.c              | 157 +++++++++++++++++++++++++++++++++-
> >  include/linux/sed-opal.h      |   2 +
> >  include/uapi/linux/sed-opal.h |  20 +++++
> >  4 files changed, 193 insertions(+), 2 deletions(-)
> > 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write
  2019-06-29 16:19   ` Scott Bauer
@ 2019-06-29 16:26     ` Jens Axboe
  2019-06-29 16:28       ` Scott Bauer
  0 siblings, 1 reply; 10+ messages in thread
From: Jens Axboe @ 2019-06-29 16:26 UTC (permalink / raw)
  To: Scott Bauer
  Cc: jonathan.derrick, linux-kernel, zub, linux-block, jonas.rabenstein

On 6/29/19 10:19 AM, Scott Bauer wrote:
> 
> Hey Jens,
> 
> Can you please stage these for 5.3 aswell?

Yes, looks fine to me. But it conflicts with the psid revert in terms
of ioctl numbering. You fine with me renumbering IOC_OPAL_MBR_DONE to:

#define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write
  2019-06-29 16:26     ` Jens Axboe
@ 2019-06-29 16:28       ` Scott Bauer
  2019-06-29 16:35         ` Jens Axboe
  0 siblings, 1 reply; 10+ messages in thread
From: Scott Bauer @ 2019-06-29 16:28 UTC (permalink / raw)
  To: Jens Axboe
  Cc: jonathan.derrick, linux-kernel, zub, linux-block, jonas.rabenstein

On Sat, Jun 29, 2019 at 10:26:52AM -0600, Jens Axboe wrote:
> On 6/29/19 10:19 AM, Scott Bauer wrote:
> > 
> > Hey Jens,
> > 
> > Can you please stage these for 5.3 aswell?
> 
> Yes, looks fine to me. But it conflicts with the psid revert in terms
> of ioctl numbering. You fine with me renumbering IOC_OPAL_MBR_DONE to:
> 
> #define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)

Sorry for the conflict. That's fine. I'll fix up userland tooling.



> 
> -- 
> Jens Axboe
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write
  2019-06-29 16:28       ` Scott Bauer
@ 2019-06-29 16:35         ` Jens Axboe
  2019-06-29 16:37           ` Scott Bauer
  0 siblings, 1 reply; 10+ messages in thread
From: Jens Axboe @ 2019-06-29 16:35 UTC (permalink / raw)
  To: Scott Bauer
  Cc: jonathan.derrick, linux-kernel, zub, linux-block, jonas.rabenstein

On 6/29/19 10:28 AM, Scott Bauer wrote:
> On Sat, Jun 29, 2019 at 10:26:52AM -0600, Jens Axboe wrote:
>> On 6/29/19 10:19 AM, Scott Bauer wrote:
>>>
>>> Hey Jens,
>>>
>>> Can you please stage these for 5.3 aswell?
>>
>> Yes, looks fine to me. But it conflicts with the psid revert in terms
>> of ioctl numbering. You fine with me renumbering IOC_OPAL_MBR_DONE to:
>>
>> #define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)
> 
> Sorry for the conflict. That's fine. I'll fix up userland tooling.

Renamed 232 -> 233, and 233 -> 234, for the two conflicts. So now we have:

#define IOC_OPAL_PSID_REVERT_TPR    _IOW('p', 232, struct opal_key)
#define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)
#define IOC_OPAL_WRITE_SHADOW_MBR   _IOW('p', 234, struct opal_shadow_mbr)

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write
  2019-06-29 16:35         ` Jens Axboe
@ 2019-06-29 16:37           ` Scott Bauer
  0 siblings, 0 replies; 10+ messages in thread
From: Scott Bauer @ 2019-06-29 16:37 UTC (permalink / raw)
  To: Jens Axboe
  Cc: jonathan.derrick, linux-kernel, zub, linux-block, jonas.rabenstein

e1;5202;0csOn Sat, Jun 29, 2019 at 10:35:30AM -0600, Jens Axboe wrote:
> On 6/29/19 10:28 AM, Scott Bauer wrote:
> > On Sat, Jun 29, 2019 at 10:26:52AM -0600, Jens Axboe wrote:
> >> On 6/29/19 10:19 AM, Scott Bauer wrote:
> >>>
> >>> Hey Jens,
> >>>
> >>> Can you please stage these for 5.3 aswell?
> >>
> >> Yes, looks fine to me. But it conflicts with the psid revert in terms
> >> of ioctl numbering. You fine with me renumbering IOC_OPAL_MBR_DONE to:
> >>
> >> #define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)
> > 
> > Sorry for the conflict. That's fine. I'll fix up userland tooling.
> 
> Renamed 232 -> 233, and 233 -> 234, for the two conflicts. So now we have:
> 
> #define IOC_OPAL_PSID_REVERT_TPR    _IOW('p', 232, struct opal_key)
> #define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)
> #define IOC_OPAL_WRITE_SHADOW_MBR   _IOW('p', 234, struct opal_shadow_mbr)

Looks good, thank you for handling this.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-06-29 16:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 20:46 [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write David Kozub
2019-05-21 20:46 ` [PATCH v2 1/3] block: sed-opal: add ioctl for done-mark of shadow mbr David Kozub
2019-05-21 20:46 ` [PATCH v2 2/3] block: sed-opal: ioctl for writing to " David Kozub
2019-05-21 20:46 ` [PATCH v2 3/3] block: sed-opal: check size of " David Kozub
2019-06-25 20:47 ` [PATCH v2 0/3] block: sed-opal: add support for shadow MBR done flag and write Derrick, Jonathan
2019-06-29 16:19   ` Scott Bauer
2019-06-29 16:26     ` Jens Axboe
2019-06-29 16:28       ` Scott Bauer
2019-06-29 16:35         ` Jens Axboe
2019-06-29 16:37           ` Scott Bauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).