[PATCH 09/16] block: sed-opal: split generation of bytestring header and content

2019-01-16 Thread Jonas Rabenstein
Split the header generation from the (normal) memcpy part if a bytestring is copied into the command buffer. This allows in-place generation of the bytestring content. For example, copy_from_user may be used without an intermediate buffer. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c

[PATCH 08/16] block: sed-opal: print failed function address

2019-01-16 Thread Jonas Rabenstein
Add function address (and if available its symbol) to the message if a step function fails. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 1332547e5a99..4225f23b2165 100644

[PATCH 12/16] block: sed-opal: unify retrieval of table columns

2019-01-16 Thread Jonas Rabenstein
Instead of having multiple places defining the same argument list to get a specific column of a sed-opal table, provide a generic version and call it from those functions. Signed-off-by: Jonas Rabenstein --- block/opal_proto.h | 2 + block/sed-opal.c | 132

[PATCH 02/16] block: sed-opal: use correct macro for method length

2019-01-16 Thread Jonas Rabenstein
Also the values of OPAL_UID_LENGTH and OPAL_METHOD_LENGTH are the same, it is weird to use OPAL_UID_LENGTH for the definition of the methods. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/sed-opal.c b/block/sed

[PATCH 10/16] block: sed-opal: add ioctl for done-mark of shadow mbr

2019-01-16 Thread Jonas Rabenstein
enable the feature if it is already enabled and one only wants to mark the shadow mbr as done. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 33 +++-- include/linux/sed-opal.h | 1 + include/uapi/linux/sed-opal.h | 1 + 3 files changed, 33

[PATCH 11/16] block: sed-opal: ioctl for writing to shadow mbr

2019-01-16 Thread Jonas Rabenstein
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 Signed-off-by: Jonas

[PATCH 13/16] block: sed-opal: check size of shadow mbr

2019-01-16 Thread Jonas Rabenstein
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 --- block/opal_proto.h | 16 block/sed

[PATCH 03/16] block: sed-opal: unify space check in add_token_*

2019-01-16 Thread Jonas Rabenstein
All add_token_* functions have a common set of conditions that have to be checked. Use a common function for those checks in order to avoid different behaviour as well as code duplication. Co-authored-by: David Kozub Signed-off-by: Jonas Rabenstein Signed-off-by: David Kozub --- block/sed

Re: [PATCH v2 08/11] block: sed-opal: ioctl for writing to shadow mbr

2018-03-29 Thread Jonas Rabenstein
Hi, On Wed, Mar 21, 2018 at 02:43:21AM +0100, Jonas Rabenstein wrote: > On Tue, Mar 20, 2018 at 04:09:08PM -0600, Scott Bauer wrote: > > On Tue, Mar 20, 2018 at 10:36:04AM +0100, Jonas Rabenstein wrote: > > > On Mon, Mar 19, 2018 at 08:52:24PM +0100, Christoph Hellwig wrote: >

Re: [PATCH v2 08/11] block: sed-opal: ioctl for writing to shadow mbr

2018-03-20 Thread Jonas Rabenstein
On Tue, Mar 20, 2018 at 04:09:08PM -0600, Scott Bauer wrote: > On Tue, Mar 20, 2018 at 10:36:04AM +0100, Jonas Rabenstein wrote: > > On Mon, Mar 19, 2018 at 08:52:24PM +0100, Christoph Hellwig wrote: > > > On Mon, Mar 19, 2018 at 07:36:50PM +0100, Jonas Rabenstein wrote: > >

Re: [PATCH v2 11/11] block: sed-opal: check size of shadow mbr

2018-03-20 Thread Jonas Rabenstein
On Mon, Mar 19, 2018 at 09:01:51PM +0100, Christoph Hellwig wrote: > On Mon, Mar 19, 2018 at 07:36:53PM +0100, Jonas Rabenstein wrote: > > 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 &

Re: [PATCH v2 08/11] block: sed-opal: ioctl for writing to shadow mbr

2018-03-20 Thread Jonas Rabenstein
On Mon, Mar 19, 2018 at 08:52:24PM +0100, Christoph Hellwig wrote: > On Mon, Mar 19, 2018 at 07:36:50PM +0100, Jonas Rabenstein wrote: > > 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.

[PATCH v2 02/11] block: sed-opal: unify space check in add_token_*

2018-03-19 Thread Jonas Rabenstein
All add_token_* functions have a common set of conditions that have to be checked. Use a common function for those checks in order to avoid different behaviour as well as code duplication. Signed-off-by: Jonas Rabenstein diff --git a/block/sed-opal.c b/block/sed-opal.c index 5aa41744b8f1

[PATCH v2 01/11] block: sed-opal: use correct macro for method length

2018-03-19 Thread Jonas Rabenstein
Also the values of OPAL_UID_LENGTH and OPAL_METHOD_LENGTH are the same, it is weird to use OPAL_UID_LENGTH for the definition of the methods. Signed-off-by: Jonas Rabenstein diff --git a/block/sed-opal.c b/block/sed-opal.c index 945f4b8610e0..5aa41744b8f1 100644 --- a/block/sed-opal.c +++ b

[PATCH v2 00/11] block: sed-opal support write to shadow mbr

2018-03-19 Thread Jonas Rabenstein
-- Jonas Rabenstein (11): block: sed-opal: use correct macro for method length block: sed-opal: unify space check in add_token_* block: sed-opal: unify cmd start and finalize block: sed-opal: unify error handling of responses block: sed-opal: print failed function address block: sed-opal

[PATCH v2 03/11] block: sed-opal: unify cmd start and finalize

2018-03-19 Thread Jonas Rabenstein
functions and thus must not be additionally added. Signed-off-by: Jonas Rabenstein diff --git a/block/sed-opal.c b/block/sed-opal.c index 771b4cfff95c..efe5d2a7f3dc 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -656,6 +656,9 @@ static int cmd_finalize(struct opal_dev *cmd, u32 hsn, u32

[PATCH v2 04/11] block: sed-opal: unify error handling of responses

2018-03-19 Thread Jonas Rabenstein
Also response_get_token had already been in place, its functionality had been duplicated within response_get_{u64,bytestring} with the same error handling. Unify the handling by reusing response_get_token within the other functions. Signed-off-by: Jonas Rabenstein diff --git a/block/sed-opal.c

[PATCH v2 07/11] block: sed-opal: add ioctl for done-mark of shadow mbr

2018-03-19 Thread Jonas Rabenstein
enable the feature if it is already enabled and one only wants to mark the shadow mbr as done. Signed-off-by: Jonas Rabenstein diff --git a/block/sed-opal.c b/block/sed-opal.c index fc10f81d4892..2c8baff8bf67 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -1988,13 +1988,39 @@ static int

[PATCH v2 08/11] block: sed-opal: ioctl for writing to shadow mbr

2018-03-19 Thread Jonas Rabenstein
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. Signed-off-by: Jonas Rabenstein diff --git a

[PATCH v2 11/11] block: sed-opal: check size of shadow mbr

2018-03-19 Thread Jonas Rabenstein
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 diff --git a/block/sed-opal.c b/block/sed-opal.c index

[PATCH v2 10/11] block: sed-opal: get metadata about opal-sed tables

2018-03-19 Thread Jonas Rabenstein
Every opal-sed table is described in the OPAL_TABLE_TABLE. Provide a function to get desired metadata information out of that table. Signed-off-by: Jonas Rabenstein diff --git a/block/opal_proto.h b/block/opal_proto.h index b6e352cfe982..5e8df3245eb0 100644 --- a/block/opal_proto.h +++ b/block

[PATCH v2 09/11] block: sed-opal: unify retrieval of table columns

2018-03-19 Thread Jonas Rabenstein
Instead of having multiple places defining the same argument list to get a specific column of a sed-opal table, provide a generic version and call it from those functions. Signed-off-by: Jonas Rabenstein diff --git a/block/opal_proto.h b/block/opal_proto.h index e20be8258854..b6e352cfe982

[PATCH v2 05/11] block: sed-opal: print failed function address

2018-03-19 Thread Jonas Rabenstein
Add function address (and if available its symbol) to the message if a step function fails. Signed-off-by: Jonas Rabenstein diff --git a/block/sed-opal.c b/block/sed-opal.c index 30f6e46518a6..9b6f14e7aeb1 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -394,8 +394,8 @@ static int next

[PATCH v2 06/11] block: sed-opal: split generation of bytestring header and content

2018-03-19 Thread Jonas Rabenstein
Split the header generation from the (normal) memcpy part if a bytestring is copied into the command buffer. This allows in-place generation of the bytestring content. For example, copy_from_user may be used without an intermediate buffer. Signed-off-by: Jonas Rabenstein diff --git a/block/sed

[PATCH v2 3/8] block: sed-opal: unify cmd start and finalize

2018-03-13 Thread Jonas Rabenstein
Every step starts with resetting the cmd buffer as well as the comid and constructs the appropriate OPAL_CALL command. Consequently, those actions may be combined into one generic function. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 250

[PATCH v2 8.1/8.4] block: sed-opal: ioctl for writing to shadow mbr

2018-03-13 Thread Jonas Rabenstein
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. Signed-off-by: Jonas Rabenstein --- block/sed

[PATCH v2 8.3/8.4] block: sed-opal: get metadata about opal-sed tables

2018-03-13 Thread Jonas Rabenstein
Every opal-sed table is described in the OPAL_TABLE_TABLE. Provide a function to get desired information out of that table. Signed-off-by: Jonas Rabenstein --- block/opal_proto.h | 16 block/sed-opal.c | 25 + 2 files changed, 41 insertions(+) diff

[PATCH v2 8.2/8.4] block: sed-opal: unify retrieval of table columns

2018-03-13 Thread Jonas Rabenstein
instead of having multiple places defining the same argument list to get a specific column of a sed-opal table, provide a generic version and call it from those functions. Signed-off-by: Jonas Rabenstein --- block/opal_proto.h | 2 + block/sed-opal.c | 130

[PATCH v2 8.4/8.4] block: sed-opal: check size of shadow mbr

2018-03-13 Thread Jonas Rabenstein
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 problem with crappy firmwares. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 14 ++ 1 file changed, 14 insertions

[PATCH v2 8.0/8.4] block: sed-opal: check size of shadow mbr

2018-03-13 Thread Jonas Rabenstein
practice for such an situation but hope it is okay like this. Also the userspace exported pointer is replaced with an u64 value. Jonas Rabenstein (4): block: sed-opal: ioctl for writing to shadow mbr block: sed-opal: unify retrieval of table columns block: sed-opal: get metadata about opal-sed

[PATCH 3/8] block: sed-opal: unify cmd start and finalize

2018-03-13 Thread Jonas Rabenstein
Every step starts with resetting the cmd buffer as well as the comid and constructs the appropriate OPAL_CALL command. Consequently, those actions may be combined into one generic function. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 243

[PATCH 2/8] block: sed-opal: unify space check in add_token_*

2018-03-13 Thread Jonas Rabenstein
All add_token_* functions have a common set of conditions that have to be checked. Use a common function for those checks in order to avoid different behaviour. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 25 - 1 file changed, 16 insertions(+), 9 deletions

[PATCH 5/8] block: sed-opal: print failed function address

2018-03-13 Thread Jonas Rabenstein
add function address (and if available its symbol) to the message if a step function fails. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 5a448a3ba1df..f7925e6f607c 100644

[PATCH 4/8] block: sed-opal: unify error handling of responses

2018-03-13 Thread Jonas Rabenstein
Also response_get_token had already been in place, its functionality had been duplicated within response_get_{u64,bytestring} with the same error handling. Unify the handling by reusing response_get_token within the other functions. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 28

[PATCH 7/8] block: sed-opal: add ioctl for done-mark of shadow mbr

2018-03-13 Thread Jonas Rabenstein
enable the feature if it is already enabled and one only wants to mark the shadow mbr as done. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 33 +++-- include/linux/sed-opal.h | 1 + include/uapi/linux/sed-opal.h | 1 + 3 files changed, 33

[PATCH 8/8] block: sed-opal: ioctl for writing to shadow mbr

2018-03-13 Thread Jonas Rabenstein
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. Signed-off-by: Jonas Rabenstein --- block/sed

[PATCH 6/8] block: sed-opal: split generation of bytestring header and content

2018-03-13 Thread Jonas Rabenstein
Split the header generation from the (normal) memcpy part if a bytestring is copied into the command buffer. This allows in-place generation of the bytestring content. For example, copy_from_user may be used without an intermediate buffer. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c

[PATCH 1/8] block: sed-opal: use correct macro for method length

2018-03-13 Thread Jonas Rabenstein
also the values of OPAL_UID_LENGTH and OPAL_METHOD_LENGTH are the same, it is weird to use OPAL_UID_LENGTH for the definition of the methods. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/sed-opal.c b/block/sed

[PATCH 0/8] block: sed-opal: support write to shadow mbr

2018-03-13 Thread Jonas Rabenstein
, Jonas [0] https://lkml.org/lkml/2018/3/7/534 [1] https://github.com/ghostav/sed-opal-temp Jonas Rabenstein (8): block: sed-opal: use correct macro for method length block: sed-opal: unify space check in add_token_* block: sed-opal: unify cmd start and finalize block: sed-opal: unify error

Re: [PATCH v2] block: sed-opal: fix u64 short atom length

2018-03-07 Thread Jonas Rabenstein
On Wed, Mar 07, 2018 at 04:24:29PM -0700, Scott Bauer wrote: > On Wed, Mar 07, 2018 at 05:55:56PM +0100, Jonas Rabenstein wrote: > > The length must be given as bytes and not as 4 bit tuples. > > > > Signed-off-by: Jonas Rabenstein > > --- > > v2: > >

[PATCH v2] block: sed-opal: fix u64 short atom length

2018-03-07 Thread Jonas Rabenstein
The length must be given as bytes and not as 4 bit tuples. Signed-off-by: Jonas Rabenstein --- v2: - use fls64 - shorten loop body --- block/sed-opal.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 36842bfa572e

[PATCH][RESEND] block: sed-opal: fix u64 short atom length

2018-03-01 Thread Jonas Rabenstein
The length must be given as bytes and not as 4 bit tuples. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 36842bfa572e..d5f565e1557a 100644 --- a/block/sed-opal.c +++ b/block/sed

[PATCH][RESEND] block: sed-opal: fix response string extraction

2018-03-01 Thread Jonas Rabenstein
Tokens are prefixed by a variable length of bytes. If a bytestring is not stored in an tiny or short atom, we have to skip more than one byte in order to have the actual bytes not prefixed by the bytes describing the actual length of the string. Signed-off-by: Jonas Rabenstein --- block/sed

[PATCH] block: sed-opal: fix u64 short atom length

2018-02-20 Thread Jonas Rabenstein
The length must be given as bytes and not as 4 bit tuples. Signed-off-by: Jonas Rabenstein --- block/sed-opal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 36842bfa572e..d5f565e1557a 100644 --- a/block/sed-opal.c +++ b/block/sed

[PATCH] block: sed-opal: fix response string extraction

2018-02-20 Thread Jonas Rabenstein
Tokens are prefixed by a variable length of bytes. If a bytestring is not stored in an tiny or short atom, we have to skip more than one byte in order to have the actual bytes not prefixed by the bytes describing the actual length of the string. Signed-off-by: Jonas Rabenstein --- block/sed