Skip to content

Commit 73fe6ad

Browse files
hreineckeigaw
authored andcommitted
sed: add '--read-only' to 'sed initialize'
By default 'sed initialize' will set the entire disk to read/write locked, ie no access is possible. That is all fine if the BIOS supports TCG Opal, as then the BIOS can unlock the drive before access. But for BIOS _not_ supporting TCG Opal this results in an inaccessible drive, and requires the user to use a different drive to boot and unlock the SED device. This patch adds a flag '--read-only' to 'nvme sed initlialize' such that the 'read-lock enable' flag is not set for the locking range, and the device continues to be readable by the BIOS for booting. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent ecd7d99 commit 73fe6ad

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

plugins/sed/sed.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ OPT_ARGS(no_opts) = {
2323
OPT_END()
2424
};
2525

26+
OPT_ARGS(init_opts) = {
27+
OPT_FLAG("read-only", 'r', &sedopal_lock_ro,
28+
"Set locking range to read-only"),
29+
OPT_END()
30+
};
31+
2632
OPT_ARGS(key_opts) = {
2733
OPT_FLAG("ask-key", 'k', &sedopal_ask_key,
2834
"prompt for SED authentication key"),
@@ -84,7 +90,7 @@ static int sed_opal_initialize(int argc, char **argv, struct command *cmd,
8490
const char *desc = "Initialize a SED device for locking";
8591
struct nvme_dev *dev;
8692

87-
err = sed_opal_open_device(&dev, argc, argv, desc, no_opts);
93+
err = sed_opal_open_device(&dev, argc, argv, desc, init_opts);
8894
if (err)
8995
return err;
9096

plugins/sed/sedopal_cmd.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ bool sedopal_destructive_revert;
3434
*/
3535
bool sedopal_psid_revert;
3636

37+
/*
38+
* Lock read-only
39+
*/
40+
bool sedopal_lock_ro;
41+
3742
/*
3843
* Map method status codes to error text
3944
*/
@@ -206,7 +211,8 @@ int sedopal_cmd_initialize(int fd)
206211
lr_setup.range_start = 0;
207212
lr_setup.range_length = 0;
208213
lr_setup.RLE = true;
209-
lr_setup.WLE = true;
214+
if (!sedopal_lock_ro)
215+
lr_setup.WLE = true;
210216

211217
lr_setup.session.opal_key = key;
212218
lr_setup.session.sum = 0;

plugins/sed/sedopal_cmd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern bool sedopal_ask_key;
1717
extern bool sedopal_ask_new_key;
1818
extern bool sedopal_destructive_revert;
1919
extern bool sedopal_psid_revert;
20+
extern bool sedopal_lock_ro;
2021

2122
/*
2223
* Sub-commands supported by the sedopal command

0 commit comments

Comments
 (0)